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-2020 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>
25 #include <utils/common/SUMOTime.h>
27 #include <utils/geom/Position.h>
29 #include <utils/geom/Boundary.h>
32 #include "MSStage.h"
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class MSEdge;
39 class MSLane;
40 class MSNet;
41 class MSStoppingPlace;
42 class MSVehicleType;
43 class OutputDevice;
45 class SUMOVehicle;
47 class MSTransportable;
48 
49 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
50 
51 // ===========================================================================
52 // class definitions
53 // ===========================================================================
58 class MSStageDriving : public MSStage {
59 public:
61  MSStageDriving(const MSEdge* origin, const MSEdge* destination, MSStoppingPlace* toStop,
62  const double arrivalPos, const std::vector<std::string>& lines,
63  const std::string& group = "",
64  const std::string& intendedVeh = "", SUMOTime intendedDepart = -1);
65 
67  virtual ~MSStageDriving();
68 
69  MSStage* clone() const;
70 
72  double getArrivalPos() const;
73 
74  bool unspecifiedArrivalPos() const;
75 
77  void abort(MSTransportable* t);
78 
80  const MSEdge* getEdge() const;
81  const MSEdge* getFromEdge() const;
82  double getEdgePos(SUMOTime now) const;
83 
85  return myOriginStop;
86  }
87 
89  Position getPosition(SUMOTime now) const;
90 
91  double getAngle(SUMOTime now) const;
92 
94  double getDistance() const;
95 
97  std::string getStageDescription(const bool isPerson) const;
98 
100  std::string getStageSummary(const bool isPerson) const;
101 
103  void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSStage* previous);
104 
109  void tripInfoOutput(OutputDevice& os, const MSTransportable* const transportable) const;
110 
118  void routeOutput(const bool isPerson, OutputDevice& os, const bool withRouteLength, const MSStage* const previous) const;
119 
121  bool isWaitingFor(const SUMOVehicle* vehicle) const;
122 
124  bool isWaiting4Vehicle() const;
125 
127  std::string getWaitingDescription() const;
128 
130  return myVehicle;
131  }
132 
134  SUMOTime getWaitingTime(SUMOTime now) const;
135 
136  double getSpeed() const;
137 
138  ConstMSEdgeVector getEdges() const;
139 
140  void setVehicle(SUMOVehicle* v);
141 
143  const std::string setArrived(MSNet* net, MSTransportable* transportable, SUMOTime now, const bool vehicleArrived);
144 
145  const std::set<std::string>& getLines() const {
146  return myLines;
147  }
148 
149  std::string getIntendedVehicleID() const {
150  return myIntendedVehicleID;
151  }
152 
154  return myIntendedDepart;
155  }
156 
157  std::string getVehicleType() const {
158  return myVehicleType;
159  }
160 
162  void setOrigin(const MSEdge* origin) {
163  myOrigin = origin;
164  }
165 
168  void saveState(std::ostringstream& out);
169 
172  void loadState(MSTransportable* transportable, std::istringstream& state);
173 
174 protected:
176  const MSEdge* myOrigin;
177 
179  const std::set<std::string> myLines;
180 
184  std::string myVehicleID;
185  std::string myVehicleLine;
186  std::string myVehicleType;
187 
192 
193  double myWaitingPos;
200 
201  std::string myIntendedVehicleID;
203 
204 private:
207 
210 
211 };
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:74
std::vector< const MSEdge * > ConstMSEdgeVector
long long int SUMOTime
Definition: SUMOTime.h:31
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:82
The simulated network and simulation perfomer.
Definition: MSNet.h:89
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)
MSStageDriving & operator=(const MSStageDriving &)=delete
Invalidated assignment operator.
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
const std::set< std::string > & getLines() const
MSStoppingPlace * getOriginStop() const
returns the origin stop (if any). only needed for MSStageTrip
bool unspecifiedArrivalPos() const
SUMOTime getIntendedDepart() const
double getSpeed() const
the speed of the transportable
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
SUMOVehicleClass myVehicleVClass
std::string getIntendedVehicleID() const
SUMOVehicle * getVehicle() const
Whether the transportable waits for a vehicle.
std::string getStageDescription(const bool isPerson) const
return (brief) string representation of the current stage
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...
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)
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
A lane area vehicles can halt at.
Abstract in-person device.
The car-following model and parameter.
Definition: MSVehicleType.h:62
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
Representation of a vehicle.
Definition: SUMOVehicle.h:58
Structure representing possible vehicle parameter.