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-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// 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 void setEnded(SUMOTime t);
182
184 virtual bool isWaitingFor(const SUMOVehicle* vehicle) const;
185
187 virtual bool isWaiting4Vehicle() const {
188 return false;
189 }
190
192 virtual bool isWalk() const {
193 return false;
194 }
195
197 virtual SUMOVehicle* getVehicle() const {
198 return nullptr;
199 }
200
202 virtual double getSpeed() const;
203
205 virtual ConstMSEdgeVector getEdges() const;
206
208 virtual int getRoutePosition() const {
209 return 0;
210 }
211
213 Position getEdgePosition(const MSEdge* e, double at, double offset) const;
214
216 Position getLanePosition(const MSLane* lane, double at, double offset) const;
217
219 double getEdgeAngle(const MSEdge* e, double at) const;
220
221 void setDestination(const MSEdge* newDestination, MSStoppingPlace* newDestStop);
222
223 virtual void setOrigin(const MSEdge* origin, MSStoppingPlace* originStop, double departPos) {
224 UNUSED_PARAMETER(origin);
225 UNUSED_PARAMETER(originStop);
226 UNUSED_PARAMETER(departPos);
227 }
228
230 virtual double getDistance() const = 0;
231
236 virtual void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const = 0;
237
245 virtual void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous, const bool withTiming, const bool saveState = false) const = 0;
246
247 virtual MSStage* clone() const = 0;
248
251 virtual void saveState(std::ostringstream& out, MSTransportable* transportable) {
252 UNUSED_PARAMETER(out);
253 UNUSED_PARAMETER(transportable);
254 }
255
258 virtual void loadState(MSTransportable* transportable, std::istringstream& state) {
259 UNUSED_PARAMETER(transportable);
260 UNUSED_PARAMETER(state);
261 }
262
263 bool wasSet(int what) const {
264 return (myParametersSet & what) != 0;
265 }
266
267 void markSet(int what) {
268 myParametersSet |= what;
269 }
270
275 double getCosts() const {
276 return myCosts;
277 }
278
283 void setCosts(double costs) {
284 myCosts = costs;
285 }
286
288 return myTrip;
289 }
290
291 void setTrip(MSStageTrip* trip) {
292 myTrip = trip;
293 }
294
295 virtual bool equals(const MSStage& s) const {
296 return myDestination == s.myDestination &&
300 myType == s.myType &&
301 myGroup == s.myGroup;
302 }
303
304protected:
307
310
313
316
319
322
325
327 const std::string myGroup;
328
330 double myCosts;
331
334
335 MSStageTrip* myTrip = nullptr;
336
338 static const double ROADSIDE_OFFSET;
339
340private:
343
345 MSStage& operator=(const MSStage&) = delete;
346
347};
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:156
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:315
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:192
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:287
virtual void saveState(std::ostringstream &out, MSTransportable *transportable)
Saves the current state into the given stream, standard implementation does nothing.
Definition MSStage.h:251
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:333
virtual SUMOTime getTimeLoss(const MSTransportable *transportable) const
Definition MSStage.cpp:161
virtual void setSpeed(double)
sets the walking speed (ignored in other stages)
Definition MSStage.h:160
void setTrip(MSStageTrip *trip)
Definition MSStage.h:291
virtual void init(MSTransportable *)
initialization, e.g. for param-related events
Definition MSStage.h:82
virtual SUMOTime getTravelTime() const
Definition MSStage.cpp:146
SUMOTime getDeparted() const
get departure time of stage
Definition MSStage.cpp:129
void setDeparted(SUMOTime now)
logs beginning of stage
Definition MSStage.cpp:115
virtual bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle.
Definition MSStage.cpp:173
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition MSStage.h:309
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:335
const std::string myGroup
The id of the group of transportables traveling together.
Definition MSStage.h:327
virtual const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition MSStage.cpp:167
SUMOTime getArrived() const
get arrival time of stage
Definition MSStage.cpp:134
double getCosts() const
Returns the costs of the stage.
Definition MSStage.h:275
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:258
virtual void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous, const bool withTiming, const bool saveState=false) const =0
Called on writing vehroute output.
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:263
bool unspecifiedArrivalPos() const
Definition MSStage.cpp:204
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:197
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:283
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:330
virtual bool isWaiting4Vehicle() const
Whether the transportable waits for a vehicle.
Definition MSStage.h:187
virtual SUMOTime getWaitingTime() const
Definition MSStage.cpp:151
virtual SUMOTime getDuration() const
Definition MSStage.cpp:140
SUMOTime myArrived
the time at which this stage ended
Definition MSStage.h:321
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
Definition MSStage.cpp:195
Position getLanePosition(const MSLane *lane, double at, double offset) const
get position on lane at length at with orthogonal offset
Definition MSStage.cpp:183
virtual double getArrivalPosLat() const
Definition MSStage.h:104
void markSet(int what)
Definition MSStage.h:267
MSStageType myType
The type of this stage.
Definition MSStage.h:324
virtual bool equals(const MSStage &s) const
Definition MSStage.h:295
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
Definition MSStage.cpp:189
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:208
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
Definition MSStage.h:338
double myArrivalPos
the longitudinal position at which we want to arrive
Definition MSStage.h:312
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:178
const MSEdge * myDestination
the next edge to reach by getting transported
Definition MSStage.h:306
virtual void setOrigin(const MSEdge *origin, MSStoppingPlace *originStop, double departPos)
Definition MSStage.h:223
SUMOTime myDeparted
the time at which this stage started
Definition MSStage.h:318
void setEnded(SUMOTime t)
sets end of stage
Definition MSStage.cpp:123
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:63
Structure representing possible vehicle parameter.
#define UNUSED_PARAMETER(x)