Eclipse SUMO - Simulation of Urban MObility
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-2024 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 
34 class MSStageMoving : public MSStage {
35 public:
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 
53  inline void setPState(MSTransportableStateAdapter* pstate) {
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 
82  SUMOTime getWaitingTime(SUMOTime now) const;
83 
85  double getSpeed() const;
86 
88  double getConfiguredSpeed() const {
89  return mySpeed;
90  }
91 
93  virtual double getMaxSpeed(const MSTransportable* const transportable = nullptr) const = 0;
94 
96  virtual bool moveToNextEdge(MSTransportable* transportable, SUMOTime currentTime, int prevDir, MSEdge* nextInternal = 0) = 0;
97 
99  virtual void activateEntryReminders(MSTransportable* person, const bool isDepart = false) {
100  UNUSED_PARAMETER(person);
101  UNUSED_PARAMETER(isDepart);
102  }
103 
105  virtual void setRouteIndex(MSTransportable* const transportable, int routeOffset);
106 
107  virtual void replaceRoute(MSTransportable* const transportable, const ConstMSEdgeVector& edges, int routeOffset);
108 
109  inline const std::vector<const MSEdge*>& getRoute() const {
110  return myRoute;
111  }
112 
113  inline const std::vector<const MSEdge*>::iterator getRouteStep() const {
114  return myRouteStep;
115  }
116 
117  inline double getDepartPos() const {
118  return myDepartPos;
119  }
120 
121  inline void setDepartPos(const double pos) {
122  myDepartPos = pos;
123  }
124 
125  inline double getDepartPosLat() const {
126  return myDepartPosLat;
127  }
128 
129  inline int getDepartLane() const {
130  return myDepartLane;
131  }
132 
134  static const MSLane* checkDepartLane(const MSEdge* edge, SUMOVehicleClass svc, int laneIndex, const std::string& id);
135 
136 protected:
139 
141  std::vector<const MSEdge*> myRoute;
142 
144  std::string myRouteID;
145 
147  std::vector<const MSEdge*>::iterator myRouteStep;
148 
151 
153  double mySpeed;
154 
156  double myDepartPos;
157 
160 
163 };
long long int SUMOTime
Definition: GUI.h:35
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
MSStageType
Definition: MSStage.h:54
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
#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
virtual SUMOTime getWaitingTime() const
Definition: MSStage.cpp:150
double getAngle(SUMOTime now) const
Returns the angle of the container.
std::string myRouteID
The original route id.
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
virtual bool moveToNextEdge(MSTransportable *transportable, SUMOTime currentTime, int prevDir, MSEdge *nextInternal=0)=0
move forward and return whether the transportable arrived
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.
virtual void activateEntryReminders(MSTransportable *person, const bool isDepart=false)
add the move reminders for the current lane on entry
Definition: MSStageMoving.h:99
ConstMSEdgeVector getEdges() const
the edges of the current stage
void setPState(MSTransportableStateAdapter *pstate)
Definition: MSStageMoving.h:53
double myDepartPosLat
the lateral depart position
double getSpeed() const
Returns the speed of the container.
const std::vector< const MSEdge * >::iterator getRouteStep() const
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.
Definition: MSStageMoving.h:88
MSTransportableStateAdapter * myPState
state that is to be manipulated by MSPModel
virtual const MSEdge * getNextRouteEdge() const =0
const std::vector< const MSEdge * > & getRoute() const
virtual void setRouteIndex(MSTransportable *const transportable, int routeOffset)
place transportable on a previously passed edge
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
Definition: MSStageMoving.h:37
std::vector< const MSEdge * > myRoute
The route of the container.
double getDepartPos() const
MSTransportableStateAdapter * getPState() const
Definition: MSStageMoving.h:49
double myDepartPos
the depart position
const MSEdge * getFromEdge() const
Returns first edge of the containers route.
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
std::vector< const MSEdge * >::iterator myRouteStep
current step
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:156
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37