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-2023 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;
46class MSTransportable;
48
49typedef std::vector<const MSEdge*> ConstMSEdgeVector;
50
51// ===========================================================================
52// class definitions
53// ===========================================================================
54enum class MSStageType {
56 WAITING = 1,
57 WALKING = 2, // only for persons
58 DRIVING = 3,
59 ACCESS = 4,
60 TRIP = 5,
61 TRANSHIP = 6
62};
63
68class MSStage : public Parameterised {
69public:
71 MSStage(const MSEdge* destination, MSStoppingPlace* toStop, const double arrivalPos, MSStageType type, const std::string& group = "");
72
74 virtual ~MSStage();
75
77 const MSEdge* getDestination() const;
78
83
85 virtual MSStoppingPlace* getOriginStop() const {
86 return nullptr;
87 }
88
89 virtual double getArrivalPos() const {
90 return myArrivalPos;
91 }
92
93 void setArrivalPos(double arrivalPos) {
94 myArrivalPos = arrivalPos;
95 }
96
98 virtual const MSEdge* getEdge() const;
99 virtual const MSEdge* getFromEdge() const;
100 virtual double getEdgePos(SUMOTime now) const;
101
103 virtual int getDirection() const;
104
106 virtual Position getPosition(SUMOTime now) const = 0;
107
109 virtual double getAngle(SUMOTime now) const = 0;
110
112 virtual const MSLane* getLane() const {
113 return nullptr;
114 }
115
118 return myType;
119 }
120
122 const std::string& getGroup() const {
123 return myGroup;
124 }
125
127 virtual std::string getStageDescription(const bool isPerson) const = 0;
128
130 virtual std::string getStageSummary(const bool isPerson) const = 0;
131
133 virtual void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* previous) = 0;
134
136 virtual void abort(MSTransportable*) {};
137
139 virtual void setSpeed(double) {};
140
142 SUMOTime getDeparted() const;
143
145 SUMOTime getArrived() const;
146
148 void setDeparted(SUMOTime now);
149
151 virtual const std::string setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived);
152
154 virtual bool isWaitingFor(const SUMOVehicle* vehicle) const;
155
157 virtual bool isWaiting4Vehicle() const {
158 return false;
159 }
160
162 virtual SUMOVehicle* getVehicle() const {
163 return nullptr;
164 }
165
167 virtual SUMOTime getWaitingTime(SUMOTime now) const;
168
170 virtual double getSpeed() const;
171
173 virtual ConstMSEdgeVector getEdges() const;
174
176 virtual int getRoutePosition() const {
177 return 0;
178 }
179
181 Position getEdgePosition(const MSEdge* e, double at, double offset) const;
182
184 Position getLanePosition(const MSLane* lane, double at, double offset) const;
185
187 double getEdgeAngle(const MSEdge* e, double at) const;
188
189 void setDestination(const MSEdge* newDestination, MSStoppingPlace* newDestStop);
190
192 virtual double getDistance() const = 0;
193
198 virtual void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const = 0;
199
207 virtual void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous) const = 0;
208
209 virtual MSStage* clone() const = 0;
210
213 virtual void saveState(std::ostringstream& out) {
214 UNUSED_PARAMETER(out);
215 }
216
219 virtual void loadState(MSTransportable* transportable, std::istringstream& state) {
220 UNUSED_PARAMETER(transportable);
221 UNUSED_PARAMETER(state);
222 }
223
224 bool wasSet(int what) const {
225 return (myParametersSet & what) != 0;
226 }
227
228 void markSet(int what) {
229 myParametersSet |= what;
230 }
231
232
233protected:
236
239
242
245
248
251
253 const std::string myGroup;
254
257
259 static const double ROADSIDE_OFFSET;
260
261private:
264
266 MSStage& operator=(const MSStage&) = delete;
267
268};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
MSStageType
Definition MSStage.h:54
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSStage.h:49
#define UNUSED_PARAMETER(x)
Definition StdDefs.h:30
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:88
virtual ~MSStage()
destructor
Definition MSStage.cpp:58
const MSEdge * getDestination() const
returns the destination edge
Definition MSStage.cpp:61
MSStage(const MSStage &)
Invalidated copy constructor.
virtual ConstMSEdgeVector getEdges() const
the edges of the current stage
Definition MSStage.cpp:102
virtual double getEdgePos(SUMOTime now) const
Definition MSStage.cpp:79
virtual int getDirection() const
Return the movement directon on the edge.
Definition MSStage.cpp:84
virtual void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const =0
Called on writing tripinfo output.
virtual const MSEdge * getFromEdge() const
Definition MSStage.cpp:73
MSStage & operator=(const MSStage &)=delete
Invalidated assignment operator.
virtual double getArrivalPos() const
Definition MSStage.h:89
int myParametersSet
Information on which parameter were set (mainly for vehroute output)
Definition MSStage.h:256
virtual void setSpeed(double)
sets the walking speed (ignored in other stages)
Definition MSStage.h:139
virtual void saveState(std::ostringstream &out)
Saves the current state into the given stream, standard implementation does nothing.
Definition MSStage.h:213
SUMOTime getDeparted() const
get departure time of stage
Definition MSStage.cpp:117
void setDeparted(SUMOTime now)
logs end of the step
Definition MSStage.cpp:110
virtual bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the transportable waits for the given vehicle.
Definition MSStage.cpp:133
MSStoppingPlace * myDestinationStop
the stop to reach by getting transported (if any)
Definition MSStage.h:238
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:85
const std::string & getGroup() const
return the id of the group of transportables traveling together
Definition MSStage.h:122
const std::string myGroup
The id of the group of transportables traveling together.
Definition MSStage.h:253
virtual const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
logs end of the step
Definition MSStage.cpp:127
SUMOTime getArrived() const
get arrival time of stage
Definition MSStage.cpp:122
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:219
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:80
bool wasSet(int what) const
Definition MSStage.h:224
MSStageType getStageType() const
Definition MSStage.h:117
void setArrivalPos(double arrivalPos)
Definition MSStage.h:93
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:162
virtual const MSLane * getLane() const
Returns the current lane (if applicable)
Definition MSStage.h:112
virtual void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, MSStage *previous)=0
proceeds to this stage
virtual void abort(MSTransportable *)
abort this stage (TraCI)
Definition MSStage.h:136
virtual double getSpeed() const
the speed of the transportable
Definition MSStage.cpp:96
virtual bool isWaiting4Vehicle() const
Whether the transportable waits for a vehicle.
Definition MSStage.h:157
SUMOTime myArrived
the time at which this stage ended
Definition MSStage.h:247
void setDestination(const MSEdge *newDestination, MSStoppingPlace *newDestStop)
Definition MSStage.cpp:155
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:143
void markSet(int what)
Definition MSStage.h:228
MSStageType myType
The type of this stage.
Definition MSStage.h:250
double getEdgeAngle(const MSEdge *e, double at) const
get angle of the edge at a certain position
Definition MSStage.cpp:149
virtual MSStage * clone() const =0
virtual const MSEdge * getEdge() const
Returns the current edge.
Definition MSStage.cpp:67
virtual int getRoutePosition() const
return index of current edge within route
Definition MSStage.h:176
static const double ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
Definition MSStage.h:259
double myArrivalPos
the position at which we want to arrive
Definition MSStage.h:241
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:138
const MSEdge * myDestination
the next edge to reach by getting transported
Definition MSStage.h:235
virtual SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition MSStage.cpp:90
SUMOTime myDeparted
the time at which this stage started
Definition MSStage.h:244
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:150
The car-following model and parameter.
Static storage of an output device and its base (abstract) implementation.
An upper class for objects with additional parameters.
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.