Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSStage.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// 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>
27#include <utils/geom/Position.h>
29#include <utils/geom/Boundary.h>
32
33
34// ===========================================================================
35// class declarations
36// ===========================================================================
37class MSEdge;
38class MSLane;
39class MSNet;
40class MSStoppingPlace;
41class MSVehicleType;
42class OutputDevice;
44class SUMOVehicle;
45class MSStageTrip;
47class MSTransportable;
49
50typedef std::vector<const MSEdge*> ConstMSEdgeVector;
51
52// ===========================================================================
53// class definitions
54// ===========================================================================
55enum class MSStageType {
58 WALKING = 2, // only for persons
60 ACCESS = 4,
61 TRIP = 5,
63};
64
69class MSStage : public Parameterised {
70public:
72 static const double ARRIVALPOS_UNSPECIFIED;
73
75 MSStage(const MSStageType type, const MSEdge* destination, MSStoppingPlace* toStop, const double arrivalPos,
76 const double arrivalPosLat = 0.0, const std::string& group = "");
77
79 virtual ~MSStage();
80
82 virtual void init(MSTransportable* /*transportable*/) {};
83
85 const MSEdge* getDestination() const;
86
91
93 virtual MSStoppingPlace* getOriginStop() const {
94 return nullptr;
95 }
96
97 virtual double getArrivalPos() const {
98 return myArrivalPos;
99 }
100
101 bool unspecifiedArrivalPos() const;
102
103
104 virtual double getArrivalPosLat() const {
105 return myArrivalPosLat;
106 }
107
108 void setArrivalPos(double arrivalPos) {
109 myArrivalPos = arrivalPos;
110 }
111
113 virtual const MSEdge* getEdge() const;
114 virtual const MSEdge* getFromEdge() const;
115 virtual double getEdgePos(SUMOTime now) const;
116 virtual double getEdgePosLat(SUMOTime now) const;
117
119 virtual int getDirection() const;
120
122 virtual Position getPosition(SUMOTime now) const = 0;
123
125 virtual double getAngle(SUMOTime now) const = 0;
126
128 virtual const MSLane* getLane() const {
129 return nullptr;
130 }
131
133 virtual SUMOTime getJumpDuration() const {
134 return -1;
135 }
136
139 return myType;
140 }
141
143 const std::string& getGroup() const {
144 return myGroup;
145 }
146
148 virtual std::string getStageDescription(const bool isPerson) const = 0;
149
151 virtual std::string getStageSummary(const bool isPerson) const = 0;
152
154 virtual void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* previous) = 0;
155
157 virtual void abort(MSTransportable*) {};
158
160 virtual void setSpeed(double) {};
161
163 SUMOTime getDeparted() const;
164
166 SUMOTime getArrived() const;
167
168 virtual SUMOTime getTimeLoss(const MSTransportable* transportable) const;
169 virtual SUMOTime getDuration() const;
170 virtual SUMOTime getTravelTime() const;
171 virtual SUMOTime getWaitingTime() const;
172 virtual SUMOTime getTotalWaitingTime() const;
173
175 void setDeparted(SUMOTime now);
176
178 virtual const std::string setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived);
179
181 virtual bool isWaitingFor(const SUMOVehicle* vehicle) const;
182
184 virtual bool isWaiting4Vehicle() const {
185 return false;
186 }
187
189 virtual bool isWalk() const {
190 return false;
191 }
192
194 virtual SUMOVehicle* getVehicle() const {
195 return nullptr;
196 }
197
199 virtual double getSpeed() const;
200
202 virtual ConstMSEdgeVector getEdges() const;
203
205 virtual int getRoutePosition() const {
206 return 0;
207 }
208
210 Position getEdgePosition(const MSEdge* e, double at, double offset) const;
211
213 Position getLanePosition(const MSLane* lane, double at, double offset) const;
214
216 double getEdgeAngle(const MSEdge* e, double at) const;
217
218 void setDestination(const MSEdge* newDestination, MSStoppingPlace* newDestStop);
219
220 virtual void setOrigin(const MSEdge* origin, MSStoppingPlace* originStop, double departPos) {
221 UNUSED_PARAMETER(origin);
222 UNUSED_PARAMETER(originStop);
223 UNUSED_PARAMETER(departPos);
224 }
225
227 virtual double getDistance() const = 0;
228
233 virtual void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const = 0;
234
242 virtual void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous) const = 0;
243
244 virtual MSStage* clone() const = 0;
245
248 virtual void saveState(std::ostringstream& out) {
249 UNUSED_PARAMETER(out);
250 }
251
254 virtual void loadState(MSTransportable* transportable, std::istringstream& state) {
255 UNUSED_PARAMETER(transportable);
256 UNUSED_PARAMETER(state);
257 }
258
259 bool wasSet(int what) const {
260 return (myParametersSet & what) != 0;
261 }
262
263 void markSet(int what) {
264 myParametersSet |= what;
265 }
266
271 double getCosts() const {
272 return myCosts;
273 }
274
279 void setCosts(double costs) {
280 myCosts = costs;
281 }
282
284 return myTrip;
285 }
286
287 void setTrip(MSStageTrip* trip) {
288 myTrip = trip;
289 }
290
291 virtual bool equals(const MSStage& s) const {
292 return myDestination == s.myDestination &&
296 myType == s.myType &&
297 myGroup == s.myGroup;
298 }
299
300protected:
303
306
309
312
315
318
321
323 const std::string myGroup;
324
326 double myCosts;
327
330
331 MSStageTrip* myTrip = nullptr;
332
334 static const double ROADSIDE_OFFSET;
335
336private:
339
341 MSStage& operator=(const MSStage&) = delete;
342
343};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
MSStageType
Definition MSStage.h:55
@ WAITING_FOR_DEPART
Definition MSStage.h:56
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
virtual SUMOTime getTotalWaitingTime() const
Definition MSStage.cpp:149
virtual ~MSStage()
destructor
Definition MSStage.cpp:61
const MSEdge * getDestination() const
returns the destination edge
Definition MSStage.cpp:65
double myArrivalPosLat
the lateral position at which we want to arrive
Definition MSStage.h:311
MSStage(const MSStage &)
Invalidated copy constructor.
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition MSStage.cpp:107
virtual bool isWalk() const
Whether the transportable is walking.
Definition MSStage.h:189
virtual double getEdgePos(SUMOTime now) const
Definition MSStage.cpp:83
virtual int getDirection() const
Return the movement directon on the edge.
Definition MSStage.cpp:95
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const =0
Called on writing tripinfo output.
virtual SUMOTime getJumpDuration() const
Return the current jump duration (if applicable).
Definition MSStage.h:133
virtual const MSEdge * getFromEdge() const
Definition MSStage.cpp:77
virtual double getEdgePosLat(SUMOTime now) const
Definition MSStage.cpp:89
MSStageTrip * getTrip() const
Definition MSStage.h:283
MSStage & operator=(const MSStage &)=delete
Invalidated assignment operator.
virtual double getArrivalPos() const
Definition MSStage.h:97
static const double ARRIVALPOS_UNSPECIFIED
sentinel value
Definition MSStage.h:72
int myParametersSet
Information on which parameter were set (mainly for vehroute output).
Definition MSStage.h:329
virtual SUMOTime getTimeLoss(const MSTransportable *transportable) const
Definition MSStage.cpp:154
virtual void setSpeed(double)
sets the walking speed (ignored in other stages)
Definition MSStage.h:160
void setTrip(MSStageTrip *trip)
Definition MSStage.h:287
virtual void init(MSTransportable *)
initialization, e.g. for param-related events
Definition MSStage.h:82
virtual void saveState(std::ostringstream &out)
Saves the current state into the given stream, standard implementation does nothing.
Definition MSStage.h:248
virtual SUMOTime getTravelTime() const
Definition MSStage.cpp:139
SUMOTime getDeparted() const
get departure time of stage
Definition MSStage.cpp:122
void setDeparted(SUMOTime now)
logs end of the step
Definition MSStage.cpp:115
virtual bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle.
Definition MSStage.cpp:166
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition MSStage.h:305
virtual std::string getStageDescription(const bool isPerson) const =0
return (brief) string representation of the current stage
virtual MSStoppingPlace * getOriginStop() const
returns the origin stop (if any). only needed for MSStageTrip
Definition MSStage.h:93
const std::string & getGroup() const
return the id of the group of transportables traveling together
Definition MSStage.h:143
MSStageTrip * myTrip
Definition MSStage.h:331
const std::string myGroup
The id of the group of transportables traveling together.
Definition MSStage.h:323
virtual const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition MSStage.cpp:160
SUMOTime getArrived() const
get arrival time of stage
Definition MSStage.cpp:127
double getCosts() const
Returns the costs of the stage.
Definition MSStage.h:271
virtual std::string getStageSummary(const bool isPerson) const =0
return string summary of the current stage
virtual void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state, standard implementation does nothing.
Definition MSStage.h:254
virtual Position getPosition(SUMOTime now) const =0
returns the position of the transportable
MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
Definition MSStage.h:88
bool wasSet(int what) const
Definition MSStage.h:259
bool unspecifiedArrivalPos() const
Definition MSStage.cpp:197
MSStageType getStageType() const
Definition MSStage.h:138
void setArrivalPos(double arrivalPos)
Definition MSStage.h:108
virtual double getDistance() const =0
get travel distance in this stage
virtual SUMOVehicle * getVehicle() const
Current vehicle in which the transportable is driving (or nullptr).
Definition MSStage.h:194
virtual const MSLane * getLane() const
Returns the current lane (if applicable).
Definition MSStage.h:128
virtual void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, MSStage *previous)=0
proceeds to this stage
void setCosts(double costs)
Sets the costs of the stage.
Definition MSStage.h:279
virtual void abort(MSTransportable *)
abort this stage (TraCI)
Definition MSStage.h:157
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 double getSpeed() const
the speed of the transportable
Definition MSStage.cpp:101
double myCosts
The assigned or calculated costs.
Definition MSStage.h:326
virtual bool isWaiting4Vehicle() const
Whether the transportable waits for a vehicle.
Definition MSStage.h:184
virtual SUMOTime getWaitingTime() const
Definition MSStage.cpp:144
virtual SUMOTime getDuration() const
Definition MSStage.cpp:133
SUMOTime myArrived
the time at which this stage ended
Definition MSStage.h:317
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
Definition MSStage.cpp:188
virtual void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const =0
Called on writing vehroute output.
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
Definition MSStage.cpp:176
virtual double getArrivalPosLat() const
Definition MSStage.h:104
void markSet(int what)
Definition MSStage.h:263
MSStageType myType
The type of this stage.
Definition MSStage.h:320
virtual bool equals(const MSStage &s) const
Definition MSStage.h:291
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
Definition MSStage.cpp:182
virtual MSStage * clone() const =0
virtual const MSEdge * getEdge() const
Returns the current edge.
Definition MSStage.cpp:71
virtual int getRoutePosition() const
return index of current edge within route
Definition MSStage.h:205
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
Definition MSStage.h:334
double myArrivalPos
the longitudinal position at which we want to arrive
Definition MSStage.h:308
virtual double getAngle(SUMOTime now) const =0
returns the angle of the transportable
Position getEdgePosition(const MSEdge *e, double at, double offset) const
get position on edge e at length at with orthogonal offset
Definition MSStage.cpp:171
const MSEdge * myDestination
the next edge to reach by getting transported
Definition MSStage.h:302
virtual void setOrigin(const MSEdge *origin, MSStoppingPlace *originStop, double departPos)
Definition MSStage.h:220
SUMOTime myDeparted
the time at which this stage started
Definition MSStage.h:314
A lane area vehicles can halt at.
Abstract in-person device.
abstract base class for managing callbacks to retrieve various state information from the model
Definition MSPModel.h:154
The car-following model and parameter.
Static storage of an output device and its base (abstract) implementation.
Parameterised()
Default constructor.
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.
#define UNUSED_PARAMETER(x)