Eclipse SUMO - Simulation of Urban MObility
MSStageDriving.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-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#include "MSStage.h"
33
34
35// ===========================================================================
36// class declarations
37// ===========================================================================
38class MSEdge;
39class MSLane;
40class MSNet;
41class MSStop;
42class MSStoppingPlace;
43class MSVehicleType;
44class OutputDevice;
46class SUMOVehicle;
48class MSTransportable;
49
50typedef std::vector<const MSEdge*> ConstMSEdgeVector;
51
52// ===========================================================================
53// class definitions
54// ===========================================================================
59class MSStageDriving : public MSStage {
60public:
62 MSStageDriving(const MSEdge* origin, const MSEdge* destination, MSStoppingPlace* toStop,
63 const double arrivalPos, const std::vector<std::string>& lines,
64 const std::string& group = "",
65 const std::string& intendedVeh = "", SUMOTime intendedDepart = -1);
66
68 virtual ~MSStageDriving();
69
70 MSStage* clone() const;
71
73 double getArrivalPos() const;
74
75 bool unspecifiedArrivalPos() const;
76
78 void abort(MSTransportable* t);
79
81 const MSEdge* getEdge() const;
82 const MSEdge* getFromEdge() const;
83 double getEdgePos(SUMOTime now) const;
84
86 int getDirection() const;
87
88 const MSLane* getLane() const;
89
91 return myOriginStop;
92 }
93
95 Position getPosition(SUMOTime now) const;
96
97 double getAngle(SUMOTime now) const;
98
100 double getDistance() const;
101
103 std::string getStageDescription(const bool isPerson) const;
104
106 std::string getStageSummary(const bool isPerson) const;
107
109 void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* previous);
110
115 void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
116
124 void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous) const;
125
127 bool isWaitingFor(const SUMOVehicle* vehicle) const;
128
130 bool isWaiting4Vehicle() const;
131
133 std::string getWaitingDescription() const;
134
136 return myVehicle;
137 }
138
141
142 double getSpeed() const;
143
145
146 void setVehicle(SUMOVehicle* v);
147
149 const std::string setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived);
150
151 const std::set<std::string>& getLines() const {
152 return myLines;
153 }
154
155 std::string getIntendedVehicleID() const {
156 return myIntendedVehicleID;
157 }
158
160 return myIntendedDepart;
161 }
162
163 std::string getVehicleType() const {
164 return myVehicleType;
165 }
166
168 void setOrigin(const MSEdge* origin) {
169 myOrigin = origin;
170 }
171
173 bool canLeaveVehicle(const MSTransportable* t, const SUMOVehicle& veh, const MSStop& stop);
174
177 void saveState(std::ostringstream& out);
178
181 void loadState(MSTransportable* transportable, std::istringstream& state);
182
183protected:
186
188 const std::set<std::string> myLines;
189
193 std::string myVehicleID;
194 std::string myVehicleLine;
195 std::string myVehicleType;
196
201
209
212
213private:
215 void registerWaiting(MSTransportable* transportable, SUMOTime now);
216
217private:
220
223
224};
long long int SUMOTime
Definition: GUI.h:36
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
std::vector< const MSEdge * > ConstMSEdgeVector
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
The simulated network and simulation perfomer.
Definition: MSNet.h:88
bool isWaiting4Vehicle() const
Whether the person waits for a vehicle.
MSStageDriving(const MSStageDriving &)
Invalidated copy constructor.
MSStage * clone() const
MSStoppingPlace * myOriginStop
the stop at which this ride starts (or nullptr)
const MSEdge * getEdge() const
Returns the current edge.
void loadState(MSTransportable *transportable, std::istringstream &state)
Reconstructs the current state.
void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, MSStage *previous)
proceeds to this stage
std::string myVehicleID
cached vehicle data for output after the vehicle has been removed
virtual ~MSStageDriving()
destructor
Position myStopWaitPos
double myVehicleDistance
ConstMSEdgeVector getEdges() const
the edges of the current stage
std::string getWaitingDescription() const
Return where the person waits and for what.
const std::string setArrived(MSNet *net, MSTransportable *transportable, SUMOTime now, const bool vehicleArrived)
marks arrival time and records driven distance
std::string myIntendedVehicleID
double getEdgePos(SUMOTime now) const
double getAngle(SUMOTime now) const
returns the angle of the transportable
void registerWaiting(MSTransportable *transportable, SUMOTime now)
brief register waiting person (on proceed or loadState)
bool unspecifiedArrivalPos() const
SUMOTime getIntendedDepart() const
double getSpeed() const
the speed of the transportable
bool canLeaveVehicle(const MSTransportable *t, const SUMOVehicle &veh, const MSStop &stop)
checks whether the person may exit at the current vehicle position
bool isWaitingFor(const SUMOVehicle *vehicle) const
Whether the person waits for the given vehicle.
Position getPosition(SUMOTime now) const
returns the position of the transportable
void tripInfoOutput(OutputDevice &os, const MSTransportable *const transportable) const
Called on writing tripinfo output.
const MSEdge * myOrigin
the origin edge
const MSLane * getLane() const
Returns the current lane (if applicable)
SUMOVehicleClass myVehicleVClass
std::string getIntendedVehicleID() const
std::string getStageDescription(const bool isPerson) const
return (brief) string representation of the current stage
SUMOVehicle * getVehicle() const
Current vehicle in which the transportable is driving (or nullptr)
void routeOutput(const bool isPerson, OutputDevice &os, const bool withRouteLength, const MSStage *const previous) const
Called on writing vehroute output.
const MSEdge * getFromEdge() const
SUMOTime myWaitingSince
The time since which this person is waiting for a ride.
std::string myVehicleLine
void saveState(std::ostringstream &out)
Saves the current state into the given stream.
const MSEdge * myWaitingEdge
SUMOTime myIntendedDepart
std::string getStageSummary(const bool isPerson) const
return string summary of the current stage
void setVehicle(SUMOVehicle *v)
std::string myVehicleType
double getDistance() const
get travel distance in this stage
const std::set< std::string > myLines
the lines to choose from
SUMOTime getWaitingTime(SUMOTime now) const
time spent waiting for a ride
SUMOTime myTimeLoss
While driving, this is the timeLoss of the vehicle when the ride started, after arrival this is the t...
const std::set< std::string > & getLines() const
MSStoppingPlace * getOriginStop() const
returns the origin stop (if any). only needed for MSStageTrip
double getArrivalPos() const
return default value for undefined arrivalPos
std::string getVehicleType() const
SUMOVehicle * myVehicle
The taken vehicle.
void abort(MSTransportable *t)
abort this stage (TraCI)
int getDirection() const
Return the movement directon on the edge.
void setOrigin(const MSEdge *origin)
change origin for parking area rerouting
MSStageDriving(const MSEdge *origin, const MSEdge *destination, MSStoppingPlace *toStop, const double arrivalPos, const std::vector< std::string > &lines, const std::string &group="", const std::string &intendedVeh="", SUMOTime intendedDepart=-1)
constructor
MSStageDriving & operator=(const MSStageDriving &)=delete
Invalidated assignment operator.
Definition: MSStop.h:44
A lane area vehicles can halt at.
Abstract in-person device.
The car-following model and parameter.
Definition: MSVehicleType.h:63
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
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.