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.org/sumo
3// Copyright (C) 2001-2022 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 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, MSStageType type) :
39 MSStage(route.back(), toStop, arrivalPos, type),
40 myState(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 myState;
51 }
52
54 const MSEdge* getEdge() const;
55
57 const MSLane* getLane() const;
58
60 const MSEdge* getFromEdge() const;
61
64
66 double getEdgePos(SUMOTime now) const;
67
69 int getDirection() const;
70
72 Position getPosition(SUMOTime now) const;
73
75 double getAngle(SUMOTime now) const;
76
79
81 double getSpeed() const;
82
84 double getConfiguredSpeed() const {
85 return mySpeed;
86 }
87
89 virtual double getMaxSpeed(const MSTransportable* const transportable = nullptr) const = 0;
90
92 virtual bool moveToNextEdge(MSTransportable* transportable, SUMOTime currentTime, int prevDir, MSEdge* nextInternal = 0) = 0;
93
94 virtual void activateEntryReminders(MSTransportable* /*person*/) { }
95
97 virtual void setRouteIndex(MSTransportable* const transportable, int routeOffset);
98
99 virtual void replaceRoute(MSTransportable* const transportable, const ConstMSEdgeVector& edges, int routeOffset);
100
101 inline const std::vector<const MSEdge*>& getRoute() const {
102 return myRoute;
103 }
104
105 inline const std::vector<const MSEdge*>::iterator getRouteStep() const {
106 return myRouteStep;
107 }
108
109 inline double getDepartPos() const {
110 return myDepartPos;
111 }
112
113 inline double getDepartPosLat() const {
114 return myDepartPosLat;
115 }
116
117 inline int getDepartLane() const {
118 return myDepartLane;
119 }
120
122 static const MSLane* checkDepartLane(const MSEdge* edge, SUMOVehicleClass svc, int laneIndex, const std::string& id);
123
124protected:
127
129 std::vector<const MSEdge*> myRoute;
130
132 std::string myRouteID;
133
135 std::vector<const MSEdge*>::iterator myRouteStep;
136
139
141 double mySpeed;
142
145
148
151};
long long int SUMOTime
Definition: GUI.h:36
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.
A road/street connecting two junctions.
Definition: MSEdge.h:77
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
double getAngle(SUMOTime now) const
Returns the angle of the container.
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
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.
MSTransportableStateAdapter * myState
state that is to be manipulated by MSPModel
ConstMSEdgeVector getEdges() const
the edges of the current stage
SUMOTime getWaitingTime(SUMOTime now) const
Returns the time the container spent waiting.
const std::vector< const MSEdge * > & getRoute() const
double myDepartPosLat
the lateral depart position
double getSpeed() const
Returns the speed of the container.
virtual void activateEntryReminders(MSTransportable *)
Definition: MSStageMoving.h:94
std::vector< constMSEdge * >::iterator myRouteStep
current step
double getDepartPosLat() const
MSStageMoving(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, MSStageType type)
constructor
Definition: MSStageMoving.h:37
virtual MSTransportableStateAdapter * getState() const
Definition: MSStageMoving.h:49
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:84
virtual void setRouteIndex(MSTransportable *const transportable, int routeOffset)
place transportable on a previously passed edge
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 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
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:148
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37