Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2026 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>
28#include <utils/geom/Position.h>
30#include <utils/geom/Boundary.h>
33#include "MSStage.h"
34
35
36// ===========================================================================
37// class declarations
38// ===========================================================================
39class MSEdge;
40class MSLane;
41class MSNet;
42class MSStop;
43class MSStoppingPlace;
44class MSVehicleType;
45class OutputDevice;
47class SUMOVehicle;
49class MSTransportable;
50
51typedef std::vector<const MSEdge*> ConstMSEdgeVector;
52
53// ===========================================================================
54// class definitions
55// ===========================================================================
60class MSStageDriving : public MSStage {
61public:
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
77 void abort(MSTransportable* t);
78
80 void init(MSTransportable* transportable);
81
83 const MSEdge* getEdge() const;
84 const MSEdge* getFromEdge() const;
85 double getEdgePos(SUMOTime now) const;
86
88 int getDirection() const;
89
90 const MSLane* getLane() const;
91
93 return myOriginStop;
94 }
95
97 Position getPosition(SUMOTime now) const;
98
99 double getAngle(SUMOTime now) const;
100
102 double getDistance() const;
103
105 std::string getStageDescription(const bool isPerson) const;
106
108 std::string getStageSummary(const bool isPerson) const;
109
111 void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* previous);
112
117 void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
118
126 void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous, const bool withTiming, const bool saveState = false) const;
127
129 bool isWaitingFor(const SUMOVehicle* vehicle) const;
130
132 bool isWaiting4Vehicle() const;
133
135 std::string getWaitingDescription() const;
136
138 return myVehicle;
139 }
140
143
144 double getSpeed() const;
145
147
148 void setVehicle(SUMOVehicle* v);
149 void setVehicleID(const std::string vehID) {
150 myVehicleID = vehID;
151 }
152
154 const std::string setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived);
155
156 const std::set<std::string>& getLines() const {
157 return myLines;
158 }
159
160 std::string getIntendedVehicleID() const {
161 return myIntendedVehicleID;
162 }
163
165 return myIntendedDepart;
166 }
167
168 std::string getVehicleType() const {
169 return myVehicleType;
170 }
171
173 void setOrigin(const MSEdge* origin, MSStoppingPlace* originStop, double departPos) {
174 myOrigin = origin;
175 myOriginStop = originStop;
176 myWaitingPos = departPos;
177 }
178
181 myWaitingSince = t;
182 }
183
185 void setVehicleDistance(double dist) {
186 myVehicleDistance = dist;
187 }
188
190 bool canLeaveVehicle(const MSTransportable* t, const SUMOVehicle& veh, const MSStop& stop);
191
192 SUMOTime getTimeLoss(const MSTransportable* transportable) const;
193 SUMOTime getDuration() const;
194 SUMOTime getTravelTime() const;
195 SUMOTime getWaitingTime() const;
196
199 void saveState(std::ostringstream& out, MSTransportable* transportable);
200
203 void loadState(MSTransportable* transportable, std::istringstream& state);
204
205 bool equals(const MSStage& s) const {
206 if (!MSStage::equals(s)) {
207 return false;
208 }
209 // this is safe because MSStage already checked that the type fits
210 const MSStageDriving& sd = static_cast<const MSStageDriving&>(s);
211 return myOrigin == sd.myOrigin &&
212 myLines == sd.myLines &&
213 myIntendedVehicleID == sd.myIntendedVehicleID;
214 }
215
216protected:
219
221 const std::set<std::string> myLines;
222
226 std::string myVehicleID;
227 std::string myVehicleLine;
228 std::string myVehicleType;
229
234
242
246
247private:
249 void registerWaiting(MSTransportable* transportable, SUMOTime now);
250
251private:
254
257
258private:
259 class BookReservation : public Command {
260 public:
261 BookReservation(MSTransportable* transportable, SUMOTime earliestPickupTime, MSStageDriving* stage) :
262 myTransportable(transportable), myEarliestPickupTime(earliestPickupTime), myStage(stage), myWaitingPos(stage->myWaitingPos) {}
263 SUMOTime execute(SUMOTime currentTime);
264
265 public:
270 };
271};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
const double INVALID_DOUBLE
invalid double
Definition StdDefs.h:68
Command()
Constructor.
Definition Command.h:53
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.
void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous, const bool withTiming, const bool saveState=false) const
Called on writing vehroute output.
MSStage * clone() const
MSStoppingPlace * myOriginStop
the stop at which this ride starts (or nullptr)
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
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
void setWaitingSince(SUMOTime t)
restore further state during loading
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
void saveState(std::ostringstream &out, MSTransportable *transportable)
Saves the current state into the given stream.
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
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.
const MSEdge * myOrigin
the origin edge
const MSLane * getLane() const
Returns the current lane (if applicable).
SUMOVehicleClass myVehicleVClass
std::string getIntendedVehicleID() const
double myReservationWaitingPos
std::string getStageDescription(const bool isPerson) const
return (brief) string representation of the current stage
SUMOVehicle * getVehicle() const
Current vehicle in which the transportable is driving (or nullptr).
const MSEdge * getFromEdge() const
SUMOTime myWaitingSince
The time since which this person is waiting for a ride.
std::string myVehicleLine
void setVehicleDistance(double dist)
restore further state during loading
const MSEdge * myWaitingEdge
void setOrigin(const MSEdge *origin, MSStoppingPlace *originStop, double departPos)
change origin for parking area rerouting
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
SUMOTime getDuration() const
void setVehicleID(const std::string vehID)
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...
const std::set< std::string > & getLines() const
bool equals(const MSStage &s) const
MSStoppingPlace * getOriginStop() const
returns the origin stop (if any). only needed for MSStageTrip
double getArrivalPos() const
return default value for undefined arrivalPos
SUMOTime getTravelTime() const
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.
MSStageDriving & operator=(const MSStageDriving &)=delete
Invalidated assignment operator.
MSStage(const MSStageType type, const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const double arrivalPosLat=0.0, const std::string &group="")
constructor
Definition MSStage.cpp:47
virtual bool equals(const MSStage &s) const
Definition MSStage.h:295
A lane area vehicles can halt at.
Abstract in-person device.
The car-following model and parameter.
Static storage of an output device and its base (abstract) implementation.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
Representation of a vehicle.
Definition SUMOVehicle.h:63
Structure representing possible vehicle parameter.
static double sd[6]
Definition odrSpiral.cpp:57