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.dev/sumo
3 // Copyright (C) 2001-2024 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 // A stage performing the travelling by a transport system (cars, public transport)
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <set>
24 #include <cassert>
25 #include <utils/common/Command.h>
26 #include <utils/common/SUMOTime.h>
28 #include <utils/geom/Position.h>
30 #include <utils/geom/Boundary.h>
33 #include "MSStage.h"
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class MSEdge;
40 class MSLane;
41 class MSNet;
42 class MSStop;
43 class MSStoppingPlace;
44 class MSVehicleType;
45 class OutputDevice;
47 class SUMOVehicle;
49 class MSTransportable;
50 
51 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
60 class MSStageDriving : public MSStage {
61 public:
63  MSStageDriving(const MSEdge* origin, const MSEdge* destination, MSStoppingPlace* toStop,
64  const double arrivalPos, const double arrivalPosLat, const std::vector<std::string>& lines,
65  const std::string& group = "",
66  const std::string& intendedVeh = "", SUMOTime intendedDepart = -1);
67 
69  virtual ~MSStageDriving();
70 
71  MSStage* clone() const;
72 
74  double getArrivalPos() const;
75 
76  bool unspecifiedArrivalPos() const;
77 
79  void abort(MSTransportable* t);
80 
82  void init(MSTransportable* transportable);
83 
85  const MSEdge* getEdge() const;
86  const MSEdge* getFromEdge() const;
87  double getEdgePos(SUMOTime now) const;
88 
90  int getDirection() const;
91 
92  const MSLane* getLane() const;
93 
95  return myOriginStop;
96  }
97 
99  Position getPosition(SUMOTime now) const;
100 
101  double getAngle(SUMOTime now) const;
102 
104  double getDistance() const;
105 
107  std::string getStageDescription(const bool isPerson) const;
108 
110  std::string getStageSummary(const bool isPerson) const;
111 
113  void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* previous);
114 
119  void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
120 
128  void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous) const;
129 
131  bool isWaitingFor(const SUMOVehicle* vehicle) const;
132 
134  bool isWaiting4Vehicle() const;
135 
137  std::string getWaitingDescription() const;
138 
140  return myVehicle;
141  }
142 
144  SUMOTime getWaitingTime(SUMOTime now) const;
145 
146  double getSpeed() const;
147 
148  ConstMSEdgeVector getEdges() const;
149 
150  void setVehicle(SUMOVehicle* v);
151 
153  const std::string setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived);
154 
155  const std::set<std::string>& getLines() const {
156  return myLines;
157  }
158 
159  std::string getIntendedVehicleID() const {
160  return myIntendedVehicleID;
161  }
162 
164  return myIntendedDepart;
165  }
166 
167  std::string getVehicleType() const {
168  return myVehicleType;
169  }
170 
172  void setOrigin(const MSEdge* origin) {
173  myOrigin = origin;
174  }
175 
177  bool canLeaveVehicle(const MSTransportable* t, const SUMOVehicle& veh, const MSStop& stop);
178 
179  SUMOTime getTimeLoss(const MSTransportable* transportable) const;
180  SUMOTime getWaitingTime() const;
181 
184  void saveState(std::ostringstream& out);
185 
188  void loadState(MSTransportable* transportable, std::istringstream& state);
189 
190 protected:
192  const MSEdge* myOrigin;
193 
195  const std::set<std::string> myLines;
196 
200  std::string myVehicleID;
201  std::string myVehicleLine;
202  std::string myVehicleType;
203 
208 
209  double myWaitingPos;
216 
217  std::string myIntendedVehicleID;
219 
220 
221 private:
223  void registerWaiting(MSTransportable* transportable, SUMOTime now);
224 
225 private:
228 
231 
232 private:
233  class BookReservation : public Command {
234  public:
235  BookReservation(MSTransportable* transportable, SUMOTime earliestPickupTime, MSStageDriving* stage) :
236  myTransportable(transportable), myEarliestPickupTime(earliestPickupTime), myStage(stage), myWaitingPos(stage->myWaitingPos) {}
237  SUMOTime execute(SUMOTime currentTime);
238 
239  public:
243  double myWaitingPos;
244  };
245 
246 protected:
248 
249 };
long long int SUMOTime
Definition: GUI.h:35
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
std::vector< const MSEdge * > ConstMSEdgeVector
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
Base (microsim) event class.
Definition: Command.h:50
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
The simulated network and simulation perfomer.
Definition: MSNet.h:89
SUMOTime execute(SUMOTime currentTime)
Executes the command.
BookReservation(MSTransportable *transportable, SUMOTime earliestPickupTime, MSStageDriving *stage)
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.
SUMOTime getWaitingTime() const
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
void registerWaiting(MSTransportable *transportable, SUMOTime now)
brief register waiting person (on proceed or loadState)
void init(MSTransportable *transportable)
initialization, e.g. for param-related events
const std::set< std::string > & getLines() const
MSStoppingPlace * getOriginStop() const
returns the origin stop (if any). only needed for MSStageTrip
MSStageDriving(const MSEdge *origin, const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double arrivalPosLat, const std::vector< std::string > &lines, const std::string &group="", const std::string &intendedVeh="", SUMOTime intendedDepart=-1)
constructor
bool unspecifiedArrivalPos() const
SUMOTime getTimeLoss(const MSTransportable *transportable) const
SUMOTime getIntendedDepart() const
double getSpeed() const
the speed of the transportable
bool canLeaveVehicle(const MSTransportable *t, const SUMOVehicle &veh, const MSStop &stop)
checks whether the person may exit at the current vehicle position
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.
BookReservation * myReservationCommand
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 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
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
Definition: MSStop.h:44
A lane area vehicles can halt at.
Abstract in-person device.
The car-following model and parameter.
Definition: MSVehicleType.h:63
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.