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-2025 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;
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
151 const std::string setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived);
152
153 const std::set<std::string>& getLines() const {
154 return myLines;
155 }
156
157 std::string getIntendedVehicleID() const {
158 return myIntendedVehicleID;
159 }
160
162 return myIntendedDepart;
163 }
164
165 std::string getVehicleType() const {
166 return myVehicleType;
167 }
168
170 void setOrigin(const MSEdge* origin, MSStoppingPlace* originStop, double departPos) {
171 myOrigin = origin;
172 myOriginStop = originStop;
173 myWaitingPos = departPos;
174 }
175
177 bool canLeaveVehicle(const MSTransportable* t, const SUMOVehicle& veh, const MSStop& stop);
178
179 SUMOTime getTimeLoss(const MSTransportable* transportable) const;
180 SUMOTime getDuration() const;
181 SUMOTime getTravelTime() const;
182 SUMOTime getWaitingTime() const;
183
186 void saveState(std::ostringstream& out);
187
190 void loadState(MSTransportable* transportable, std::istringstream& state);
191
192 bool equals(const MSStage& s) const {
193 if (!MSStage::equals(s)) {
194 return false;
195 }
196 // this is safe because MSStage already checked that the type fits
197 const MSStageDriving& sd = static_cast<const MSStageDriving&>(s);
198 return myOrigin == sd.myOrigin &&
199 myLines == sd.myLines &&
200 myIntendedVehicleID == sd.myIntendedVehicleID;
201 }
202
203protected:
206
208 const std::set<std::string> myLines;
209
213 std::string myVehicleID;
214 std::string myVehicleLine;
215 std::string myVehicleType;
216
221
229
232
233
234private:
236 void registerWaiting(MSTransportable* transportable, SUMOTime now);
237
238private:
241
244
245private:
246 class BookReservation : public Command {
247 public:
248 BookReservation(MSTransportable* transportable, SUMOTime earliestPickupTime, MSStageDriving* stage) :
249 myTransportable(transportable), myEarliestPickupTime(earliestPickupTime), myStage(stage), myWaitingPos(stage->myWaitingPos) {}
250 SUMOTime execute(SUMOTime currentTime);
251
252 public:
257 };
258
259protected:
261
262};
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.
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.
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
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
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.
BookReservation * myReservationCommand
const MSEdge * myOrigin
the origin edge
const MSLane * getLane() const
Returns the current lane (if applicable).
SUMOVehicleClass myVehicleVClass
std::string getIntendedVehicleID() const
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).
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
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
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:291
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:62
Structure representing possible vehicle parameter.
static double sd[6]
Definition odrSpiral.cpp:57