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-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/****************************************************************************/
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) {}
43
45 virtual ~MSStageMoving();
46
47 virtual const MSEdge* getNextRouteEdge() const = 0;
48
50 return myPState;
51 }
52
54 myPState = pstate;
55 }
56
58 const MSEdge* getEdge() const;
59
61 const MSLane* getLane() const;
62
64 const MSEdge* getFromEdge() const;
65
68
70 double getEdgePos(SUMOTime now) const;
71
73 int getDirection() const;
74
76 Position getPosition(SUMOTime now) const;
77
79 double getAngle(SUMOTime now) const;
80
83
86
88 double getSpeed() const;
89
91 double getConfiguredSpeed() const {
92 return mySpeed;
93 }
94
96 virtual double getMaxSpeed(const MSTransportable* const transportable = nullptr) const = 0;
97
99 virtual bool moveToNextEdge(MSTransportable* transportable, SUMOTime currentTime, int prevDir, MSEdge* nextInternal = nullptr, const bool isReplay = false) = 0;
100
102 virtual void activateEntryReminders(MSTransportable* person, const bool isDepart = false) {
103 UNUSED_PARAMETER(person);
104 UNUSED_PARAMETER(isDepart);
105 }
106
108 virtual void setRouteIndex(MSTransportable* const transportable, int routeOffset);
109
110 virtual void replaceRoute(MSTransportable* const transportable, const ConstMSEdgeVector& edges, int routeOffset);
111
112 inline const std::vector<const MSEdge*>& getRoute() const {
113 return myRoute;
114 }
115
116 inline const std::vector<const MSEdge*>::iterator getRouteStep() const {
117 return myRouteStep;
118 }
119
120 inline double getDepartPos() const {
121 return myDepartPos;
122 }
123
124 inline void setDepartPos(const double pos) {
125 myDepartPos = pos;
126 }
127
128 inline double getDepartPosLat() const {
129 return myDepartPosLat;
130 }
131
132 inline int getDepartLane() const {
133 return myDepartLane;
134 }
135
137 static const MSLane* checkDepartLane(const MSEdge* edge, SUMOVehicleClass svc, int laneIndex, const std::string& id);
138
139 bool equals(const MSStage& s) const {
140 if (!MSStage::equals(s)) {
141 return false;
142 }
143 // this is safe because MSStage already checked that the type fits
144 const MSStageMoving& sm = static_cast<const MSStageMoving&>(s);
145 return myRoute == sm.myRoute &&
146 myRouteID == sm.myRouteID &&
147 mySpeed == sm.mySpeed &&
148 myDepartPos == sm.myDepartPos &&
151 }
152
153protected:
156
158 std::vector<const MSEdge*> myRoute;
159
161 std::string myRouteID;
162
164 std::vector<const MSEdge*>::iterator myRouteStep;
165
168
170 double mySpeed;
171
174
177
180};
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:291
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
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.
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)