SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSTransportable.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // The common superclass for modelling transportable objects like persons and containers
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef MSTransportable_h
21 #define MSTransportable_h
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class MSEdge;
37 class MSLane;
38 class MSNet;
39 class MSVehicleType;
40 class OutputDevice;
41 class Position;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
54 public:
55  enum StageType {
56  DRIVING = 0,
57  WAITING = 1,
58  MOVING_WITHOUT_VEHICLE = 2 // walking for persons, tranship for containers
59  };
60 
65  class Stage {
66  public:
68  Stage(const MSEdge& destination, StageType type);
69 
71  virtual ~Stage();
72 
74  const MSEdge& getDestination() const;
75 
77  virtual const MSEdge* getEdge() const = 0;
78  virtual const MSEdge* getFromEdge() const = 0;
79  virtual SUMOReal getEdgePos(SUMOTime now) const = 0;
80 
82  virtual Position getPosition(SUMOTime now) const = 0;
83 
85  virtual SUMOReal getAngle(SUMOTime now) const = 0;
86 
89  return myType;
90  }
91 
93  virtual std::string getStageDescription() const = 0;
94 
96  virtual void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, MSEdge* previousEdge, const SUMOReal at) = 0;
97 
99  void setDeparted(SUMOTime now);
100 
102  void setArrived(SUMOTime now);
103 
105  virtual bool isWaitingFor(const std::string& line) const;
106 
108  virtual bool isWaiting4Vehicle() const {
109  return false;
110  }
111 
113  virtual SUMOTime getWaitingTime(SUMOTime now) const = 0;
114 
116  virtual SUMOReal getSpeed() const = 0;
117 
119  Position getEdgePosition(const MSEdge* e, SUMOReal at, SUMOReal offset) const;
120 
122  Position getLanePosition(const MSLane* lane, SUMOReal at, SUMOReal offset) const;
123 
125  SUMOReal getEdgeAngle(const MSEdge* e, SUMOReal at) const;
126 
131  virtual void tripInfoOutput(OutputDevice& os) const = 0;
132 
137  virtual void routeOutput(OutputDevice& os) const = 0;
138 
143  virtual void beginEventOutput(const MSTransportable& container, SUMOTime t, OutputDevice& os) const = 0;
144 
149  virtual void endEventOutput(const MSTransportable& container, SUMOTime t, OutputDevice& os) const = 0;
150 
151  protected:
154 
157 
160 
163 
164  private:
166  Stage(const Stage&);
167 
169  Stage& operator=(const Stage&);
170 
171  };
172 
174  typedef std::vector<MSTransportable::Stage*> MSTransportablePlan;
175 
177  MSTransportable(const SUMOVehicleParameter* pars, const MSVehicleType* vtype, MSTransportablePlan* plan);
178 
180  virtual ~MSTransportable();
181 
182  /* @brief proceeds to the next step of the route,
183  * @return Whether the containers plan continues */
184  virtual bool proceed(MSNet* net, SUMOTime time) = 0;
185 
187  const std::string& getID() const;
188 
189  inline const SUMOVehicleParameter& getParameter() const {
190  return *myParameter;
191  }
192 
193  inline const MSVehicleType& getVehicleType() const {
194  return *myVType;
195  }
196 
198  SUMOTime getDesiredDepart() const;
199 
201  void setDeparted(SUMOTime now);
202 
204  const MSEdge& getDestination() const {
205  return (*myStep)->getDestination();
206  }
207 
209  const MSEdge& getNextDestination() const {
210  return (*(myStep + 1))->getDestination();
211  }
212 
214  const MSEdge* getEdge() const {
215  return (*myStep)->getEdge();
216  }
217 
219  const MSEdge* getFromEdge() const {
220  return (*myStep)->getFromEdge();
221  }
222 
224  virtual SUMOReal getEdgePos() const;
225 
227  virtual Position getPosition() const;
228 
230  virtual SUMOReal getAngle() const;
231 
233  virtual SUMOReal getWaitingSeconds() const;
234 
236  virtual SUMOReal getSpeed() const;
237 
240  return (*myStep)->getStageType();
241  }
242 
244  std::string getCurrentStageDescription() const {
245  return (*myStep)->getStageDescription();
246  }
247 
250  return *myStep;
251  }
252 
258  void tripInfoOutput(OutputDevice& os) const;
259 
265  virtual void routeOutput(OutputDevice& os) const = 0;
266 
268  bool isWaitingFor(const std::string& line) const {
269  return (*myStep)->isWaitingFor(line);
270  }
271 
273  bool isWaiting4Vehicle() const {
274  return (*myStep)->isWaiting4Vehicle();
275  }
276 
277 protected:
280 
284 
287 
290 
292  MSTransportablePlan::iterator myStep;
293 
294 private:
297 
300 
301 };
302 
303 
304 #endif
305 
306 /****************************************************************************/
void setArrived(SUMOTime now)
logs end of the step
long long int SUMOTime
Definition: SUMOTime.h:43
void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
StageType getStageType() const
bool isWaiting4Vehicle() const
Whether the container waits for a vehicle.
const SUMOVehicleParameter & getParameter() const
virtual SUMOReal getWaitingSeconds() const
the time this container spent waiting in seconds
virtual const MSEdge * getEdge() const =0
Returns the current edge.
virtual SUMOReal getEdgePos(SUMOTime now) const =0
Stage & operator=(const Stage &)
Invalidated assignment operator.
const std::string & getID() const
returns the id of the transportable
MSTransportable & operator=(const MSTransportable &)
Invalidated assignment operator.
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
virtual bool proceed(MSNet *net, SUMOTime time)=0
virtual bool isWaiting4Vehicle() const
Whether the transportable waits for a vehicle.
virtual SUMOReal getEdgePos() const
Return the position on the edge.
MSTransportablePlan::iterator myStep
the iterator over the route
virtual SUMOReal getAngle() const
return the current angle of the container
MSTransportable(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportablePlan *plan)
constructor
virtual SUMOReal getAngle(SUMOTime now) const =0
returns the angle of the transportable
SUMOReal getEdgeAngle(const MSEdge *e, SUMOReal at) const
get angle of the edge at a certain position
The simulated network and simulation perfomer.
Definition: MSNet.h:94
The car-following model and parameter.
Definition: MSVehicleType.h:74
SUMOTime getDesiredDepart() const
Returns the desired departure time.
const SUMOVehicleParameter * myParameter
the plan of the container
bool myWriteEvents
Whether events shall be written.
const MSEdge & getDestination() const
returns the destination edge
A road/street connecting two junctions.
Definition: MSEdge.h:81
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a container
Position getLanePosition(const MSLane *lane, SUMOReal at, SUMOReal offset) const
get position on lane at length at with orthogonal offset
virtual Position getPosition(SUMOTime now) const =0
returns the position of the transportable
Position getEdgePosition(const MSEdge *e, SUMOReal at, SUMOReal offset) const
get position on edge e at length at with orthogonal offset
const MSVehicleType & getVehicleType() const
Stage(const MSEdge &destination, StageType type)
constructor
virtual SUMOReal getSpeed() const =0
the speed of the transportable
SUMOTime myArrived
the time at which this stage ended
const MSEdge * getEdge() const
Returns the current edge.
SUMOTime myDeparted
the time at which this stage started
void setDeparted(SUMOTime now)
logs depart time of the current stage
virtual void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)=0
proceeds to the next step
virtual bool isWaitingFor(const std::string &line) const
Whether the transportable waits for a vehicle of the line specified.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
const MSVehicleType * myVType
This container&#39;s type. (mainly used for drawing related information Note sure if it is really necessa...
StageType getCurrentStageType() const
the current stage type of the container
virtual ~MSTransportable()
destructor
virtual void routeOutput(OutputDevice &os) const =0
Called on writing vehroute output.
virtual std::string getStageDescription() const =0
return string representation of the current stage
const MSEdge & getDestination() const
Returns the current destination.
const MSEdge * getFromEdge() const
Returns the departure edge.
virtual SUMOReal getSpeed() const
the current speed of the container
StageType myType
The type of this stage.
Structure representing possible vehicle parameter.
virtual SUMOTime getWaitingTime(SUMOTime now) const =0
the time this transportable spent waiting
virtual void endEventOutput(const MSTransportable &container, SUMOTime t, OutputDevice &os) const =0
Called for writing the events output (end of an action)
bool isWaitingFor(const std::string &line) const
Whether the container waits for a vehicle of the line specified.
const MSEdge & getNextDestination() const
Returns the destination after the current destination.
virtual Position getPosition() const
Return the Network coordinate of the container.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
void setDeparted(SUMOTime now)
logs end of the step
#define SUMOReal
Definition: config.h:215
MSTransportablePlan * myPlan
the plan of the container
virtual void beginEventOutput(const MSTransportable &container, SUMOTime t, OutputDevice &os) const =0
Called for writing the events output (begin of an action)
virtual void tripInfoOutput(OutputDevice &os) const =0
Called on writing tripinfo output.
std::string getCurrentStageDescription() const
Returns the current stage description as a string.
virtual ~Stage()
destructor
virtual void routeOutput(OutputDevice &os) const =0
Called on writing vehroute output.
const MSEdge & myDestination
the next edge to reach by getting transported
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
virtual const MSEdge * getFromEdge() const =0