Eclipse SUMO - Simulation of Urban MObility
MSStageDriving.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // The common superclass for modelling transportable objects like persons and containers
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <set>
24 #include <cassert>
25 #include <utils/common/SUMOTime.h>
27 #include <utils/geom/Position.h>
29 #include <utils/geom/Boundary.h>
32 #include "MSStage.h"
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class MSEdge;
39 class MSLane;
40 class MSNet;
41 class MSStoppingPlace;
42 class MSVehicleType;
43 class OutputDevice;
45 class SUMOVehicle;
47 class MSTransportable;
48 
49 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
58 class MSStageDriving : public MSStage {
59 public:
61  MSStageDriving(const MSEdge* origin, const MSEdge* destination, MSStoppingPlace* toStop,
62  const double arrivalPos, const std::vector<std::string>& lines,
63  const std::string& group = "",
64  const std::string& intendedVeh = "", SUMOTime intendedDepart = -1);
65 
67  virtual ~MSStageDriving();
68 
69  MSStage* clone() const;
70 
72  double getArrivalPos() const;
73 
74  bool unspecifiedArrivalPos() const;
75 
77  void abort(MSTransportable* t);
78 
80  const MSEdge* getEdge() const;
81  const MSEdge* getFromEdge() const;
82  double getEdgePos(SUMOTime now) const;
83 
85  int getDirection() const;
86 
87  const MSLane* getLane() const;
88 
90  return myOriginStop;
91  }
92 
94  Position getPosition(SUMOTime now) const;
95 
96  double getAngle(SUMOTime now) const;
97 
99  double getDistance() const;
100 
102  std::string getStageDescription(const bool isPerson) const;
103 
105  std::string getStageSummary(const bool isPerson) const;
106 
108  void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* previous);
109 
114  void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
115 
123  void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous) const;
124 
126  bool isWaitingFor(const SUMOVehicle* vehicle) const;
127 
129  bool isWaiting4Vehicle() const;
130 
132  std::string getWaitingDescription() const;
133 
135  return myVehicle;
136  }
137 
139  SUMOTime getWaitingTime(SUMOTime now) const;
140 
141  double getSpeed() const;
142 
143  ConstMSEdgeVector getEdges() const;
144 
145  void setVehicle(SUMOVehicle* v);
146 
148  const std::string setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived);
149 
150  const std::set<std::string>& getLines() const {
151  return myLines;
152  }
153 
154  std::string getIntendedVehicleID() const {
155  return myIntendedVehicleID;
156  }
157 
159  return myIntendedDepart;
160  }
161 
162  std::string getVehicleType() const {
163  return myVehicleType;
164  }
165 
167  void setOrigin(const MSEdge* origin) {
168  myOrigin = origin;
169  }
170 
172  bool canLeaveVehicle(const MSTransportable* t, const SUMOVehicle& veh);
173 
176  void saveState(std::ostringstream& out);
177 
180  void loadState(MSTransportable* transportable, std::istringstream& state);
181 
182 protected:
184  const MSEdge* myOrigin;
185 
187  const std::set<std::string> myLines;
188 
192  std::string myVehicleID;
193  std::string myVehicleLine;
194  std::string myVehicleType;
195 
200 
201  double myWaitingPos;
208 
209  std::string myIntendedVehicleID;
211 
212 private:
215 
218 
219 };
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
std::vector< const MSEdge * > ConstMSEdgeVector
long long int SUMOTime
Definition: SUMOTime.h:32
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
The simulated network and simulation perfomer.
Definition: MSNet.h:88
bool isWaiting4Vehicle() const
Whether the person waits for a vehicle.
MSStageDriving(const MSStageDriving &)
Invalidated copy constructor.
MSStage * clone() const
MSStoppingPlace * myOriginStop
the stop at which this ride starts (or nullptr)
MSStageDriving & operator=(const MSStageDriving &)=delete
Invalidated assignment operator.
const MSEdge * getEdge() const
Returns the current edge.
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, MSStage *previous)
proceeds to this stage
std::string myVehicleID
cached vehicle data for output after the vehicle has been removed
virtual ~MSStageDriving()
destructor
Position myStopWaitPos
double myVehicleDistance
ConstMSEdgeVector getEdges() const
the edges of the current stage
std::string getWaitingDescription() const
Return where the person waits and for what.
const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
marks arrival time and records driven distance
std::string myIntendedVehicleID
double getEdgePos(SUMOTime now) const
double getAngle(SUMOTime now) const
returns the angle of the transportable
const std::set< std::string > & getLines() const
MSStoppingPlace * getOriginStop() const
returns the origin stop (if any). only needed for MSStageTrip
bool unspecifiedArrivalPos() const
SUMOTime getIntendedDepart() const
double getSpeed() const
the speed of the transportable
bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the person waits for the given vehicle.
Position getPosition(SUMOTime now) const
returns the position of the transportable
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
const MSEdge * myOrigin
the origin edge
const MSLane * getLane() const
Returns the current lane (if applicable)
SUMOVehicleClass myVehicleVClass
std::string getIntendedVehicleID() const
SUMOVehicle * getVehicle() const
Current vehicle in which the transportable is driving (or nullptr)
std::string getStageDescription(const bool isPerson) const
return (brief) string representation of the current stage
void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
const MSEdge * getFromEdge() const
SUMOTime myWaitingSince
The time since which this person is waiting for a ride.
std::string myVehicleLine
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
const MSEdge * myWaitingEdge
SUMOTime myIntendedDepart
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
void setVehicle(SUMOVehicle *v)
std::string myVehicleType
double getDistance() const
get travel distance in this stage
const std::set< std::string > myLines
the lines to choose from
SUMOTime getWaitingTime(SUMOTime now) const
time spent waiting for a ride
SUMOTime myTimeLoss
While driving, this is the timeLoss of the vehicle when the ride started, after arrival this is the t...
double getArrivalPos() const
return default value for undefined arrivalPos
std::string getVehicleType() const
bool canLeaveVehicle(const MSTransportable *t, const SUMOVehicle &veh)
checks whether the person may exit at the current vehicle position
SUMOVehicle * myVehicle
The taken vehicle.
void abort(MSTransportable *t)
abort this stage (TraCI)
int getDirection() const
Return the movement directon on the edge.
void setOrigin(const MSEdge *origin)
change origin for parking area rerouting
MSStageDriving(const MSEdge *origin, const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const std::vector< std::string > &lines, const std::string &group="", const std::string &intendedVeh="", SUMOTime intendedDepart=-1)
constructor
A lane area vehicles can halt at.
Abstract in-person device.
The car-following model and parameter.
Definition: MSVehicleType.h:62
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
Representation of a vehicle.
Definition: SUMOVehicle.h:60
Structure representing possible vehicle parameter.