Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSStageMoving.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/****************************************************************************/
19// The common superclass for modelling walking and tranship
20/****************************************************************************/
21#pragma once
22#include <config.h>
23
25
26
27// ===========================================================================
28// class declarations
29// ===========================================================================
30
34class MSStageMoving : public MSStage {
35public:
37 MSStageMoving(const MSStageType type, const std::vector<const MSEdge*>& route, const std::string& routeID, MSStoppingPlace* toStop, const double speed,
38 const double departPos, const double arrivalPos, const double departPosLat, const int departLane) :
39 MSStage(type, route.back(), toStop, arrivalPos),
40 myPState(nullptr), myRoute(route), myRouteID(routeID), myRouteStep(myRoute.begin()),
41 mySpeed(speed), myDepartPos(departPos),
42 myDepartPosLat(departPosLat), myDepartLane(departLane),
44 {}
45
47 virtual ~MSStageMoving();
48
49 virtual const MSEdge* getNextRouteEdge() const = 0;
50
52 return myPState;
53 }
54
56 myPState = pstate;
57 }
58
60 const MSEdge* getEdge() const;
61
63 const MSLane* getLane() const;
64
66 const MSEdge* getFromEdge() const;
67
70
72 double getEdgePos(SUMOTime now) const;
73
75 int getDirection() const;
76
78 Position getPosition(SUMOTime now) const;
79
81 double getAngle(SUMOTime now) const;
82
85
88
93
95 double getSpeed() const;
96
98 double getConfiguredSpeed() const {
99 return mySpeed;
100 }
101
103 virtual double getMaxSpeed(const MSTransportable* const transportable = nullptr) const = 0;
104
106 virtual bool moveToNextEdge(MSTransportable* transportable, SUMOTime currentTime, int prevDir, MSEdge* nextInternal = nullptr, const bool isReplay = false) = 0;
107
109 virtual void activateEntryReminders(MSTransportable* person, const bool isDepart = false) {
110 UNUSED_PARAMETER(person);
111 UNUSED_PARAMETER(isDepart);
112 }
113
115 virtual void setRouteIndex(MSTransportable* const transportable, int routeOffset);
116
117 virtual void replaceRoute(MSTransportable* const transportable, const ConstMSEdgeVector& edges, int routeOffset);
118
119 inline const std::vector<const MSEdge*>& getRoute() const {
120 return myRoute;
121 }
122
123 inline const std::vector<const MSEdge*>::iterator getRouteStep() const {
124 return myRouteStep;
125 }
126
127 inline double getDepartPos() const {
128 return myDepartPos;
129 }
130
131 inline void setDepartPos(const double pos) {
132 myDepartPos = pos;
133 }
134
135 inline double getDepartPosLat() const {
136 return myDepartPosLat;
137 }
138
139 inline int getDepartLane() const {
140 return myDepartLane;
141 }
142
144 static const MSLane* checkDepartLane(const MSEdge* edge, SUMOVehicleClass svc, int laneIndex, const std::string& id);
145
146 bool equals(const MSStage& s) const {
147 if (!MSStage::equals(s)) {
148 return false;
149 }
150 // this is safe because MSStage already checked that the type fits
151 const MSStageMoving& sm = static_cast<const MSStageMoving&>(s);
152 return myRoute == sm.myRoute &&
153 myRouteID == sm.myRouteID &&
154 mySpeed == sm.mySpeed &&
155 myDepartPos == sm.myDepartPos &&
158 }
159
160protected:
163
165 std::vector<const MSEdge*> myRoute;
166
168 std::string myRouteID;
169
171 std::vector<const MSEdge*>::iterator myRouteStep;
172
175
177 double mySpeed;
178
181
184
187
189};
long long int SUMOTime
Definition GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition MSEdge.h:74
MSStageType
Definition MSStage.h:55
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
A road/street connecting two junctions.
Definition MSEdge.h:77
Representation of a lane in the micro simulation.
Definition MSLane.h:84
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
double getAngle(SUMOTime now) const
Returns the angle of the transportable.
std::string myRouteID
The original route id.
virtual const MSEdge * getNextRouteEdge() const =0
const MSLane * getLane() const
Returns the current lane.
static const MSLane * checkDepartLane(const MSEdge *edge, SUMOVehicleClass svc, int laneIndex, const std::string &id)
interpret custom depart lane
double getEdgePos(SUMOTime now) const
Returns the offset from the start of the current edge measured in its natural direction.
int getDirection() const
Return the movement directon on the edge.
bool equals(const MSStage &s) const
virtual void activateEntryReminders(MSTransportable *person, const bool isDepart=false)
add the move reminders for the current lane on entry
ConstMSEdgeVector getEdges() const
the edges of the current stage
void setTotalWaitingTime(SUMOTime t)
Restore waiting time when loading state.
const std::vector< const MSEdge * > & getRoute() const
void setPState(MSTransportableStateAdapter *pstate)
double myDepartPosLat
the lateral depart position
double getSpeed() const
Returns the speed of the transportable.
std::vector< constMSEdge * >::iterator myRouteStep
current step
double getDepartPosLat() const
int getDepartLane() const
double mySpeed
the speed of the transportable
int myDepartLane
the depart lane or -1
MSEdge * myCurrentInternalEdge
The current internal edge this transportable is on or nullptr.
Position getPosition(SUMOTime now) const
Returns the position of the container.
const MSEdge * getEdge() const
Returns the current edge.
double getConfiguredSpeed() const
Returns the configured speed in this stage.
MSTransportableStateAdapter * myPState
state that is to be manipulated by MSPModel
SUMOTime getWaitingTime() const
Returns the time the transportable spent waiting.
SUMOTime myLoadedWaitingTime
MSTransportableStateAdapter * getPState() const
virtual void setRouteIndex(MSTransportable *const transportable, int routeOffset)
place transportable on a previously passed edge
SUMOTime getTotalWaitingTime() const
Returns the cumulative time the transportable spent waiting.
MSStageMoving(const MSStageType type, const std::vector< const MSEdge * > &route, const std::string &routeID, MSStoppingPlace *toStop, const double speed, const double departPos, const double arrivalPos, const double departPosLat, const int departLane)
constructor
std::vector< const MSEdge * > myRoute
The route of the container.
double getDepartPos() const
double myDepartPos
the depart position
const MSEdge * getFromEdge() const
Returns first edge of the containers route.
const std::vector< constMSEdge * >::iterator getRouteStep() const
virtual bool moveToNextEdge(MSTransportable *transportable, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=nullptr, const bool isReplay=false)=0
move forward and return whether the transportable arrived
virtual void replaceRoute(MSTransportable *const transportable, const ConstMSEdgeVector &edges, int routeOffset)
virtual double getMaxSpeed(const MSTransportable *const transportable=nullptr) const =0
the maximum speed of the transportable
void setDepartPos(const double pos)
virtual ~MSStageMoving()
destructor
A lane area vehicles can halt at.
abstract base class for managing callbacks to retrieve various state information from the model
Definition MSPModel.h:154
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
#define UNUSED_PARAMETER(x)