SUMO - Simulation of Urban MObility
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 MSStoppingPlace;
40 class MSVehicleType;
41 class OutputDevice;
42 class Position;
44 class SUMOVehicle;
45 
46 
47 // ===========================================================================
48 // class definitions
49 // ===========================================================================
56 public:
57  enum StageType {
58  DRIVING = 0,
59  WAITING = 1,
60  MOVING_WITHOUT_VEHICLE = 2 // walking for persons, tranship for containers
61  };
62 
67  class Stage {
68  public:
70  Stage(const MSEdge& destination, MSStoppingPlace* toStop, const SUMOReal arrivalPos, StageType type);
71 
73  virtual ~Stage();
74 
76  const MSEdge& getDestination() const;
77 
80  return myDestinationStop;
81  }
82 
84  return myArrivalPos;
85  }
86 
88  virtual const MSEdge* getEdge() const = 0;
89  virtual const MSEdge* getFromEdge() const = 0;
90  virtual SUMOReal getEdgePos(SUMOTime now) const = 0;
91 
93  virtual Position getPosition(SUMOTime now) const = 0;
94 
96  virtual SUMOReal getAngle(SUMOTime now) const = 0;
97 
100  return myType;
101  }
102 
104  virtual std::string getStageDescription() const = 0;
105 
107  virtual void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, Stage* previous) = 0;
108 
110  void setDeparted(SUMOTime now);
111 
113  void setArrived(SUMOTime now);
114 
116  virtual bool isWaitingFor(const std::string& line) const;
117 
119  virtual bool isWaiting4Vehicle() const {
120  return false;
121  }
122 
124  virtual SUMOVehicle* getVehicle() const {
125  return 0;
126  }
127 
129  virtual SUMOTime getWaitingTime(SUMOTime now) const = 0;
130 
132  virtual SUMOReal getSpeed() const = 0;
133 
135  Position getEdgePosition(const MSEdge* e, SUMOReal at, SUMOReal offset) const;
136 
138  Position getLanePosition(const MSLane* lane, SUMOReal at, SUMOReal offset) const;
139 
141  SUMOReal getEdgeAngle(const MSEdge* e, SUMOReal at) const;
142 
147  virtual void tripInfoOutput(OutputDevice& os) const = 0;
148 
153  virtual void routeOutput(OutputDevice& os) const = 0;
154 
159  virtual void beginEventOutput(const MSTransportable& transportable, SUMOTime t, OutputDevice& os) const = 0;
160 
165  virtual void endEventOutput(const MSTransportable& transportable, SUMOTime t, OutputDevice& os) const = 0;
166 
167  protected:
170 
173 
176 
179 
182 
185 
186  private:
188  Stage(const Stage&);
189 
191  Stage& operator=(const Stage&);
192 
193  };
194 
196  typedef std::vector<MSTransportable::Stage*> MSTransportablePlan;
197 
199  MSTransportable(const SUMOVehicleParameter* pars, const MSVehicleType* vtype, MSTransportablePlan* plan);
200 
202  virtual ~MSTransportable();
203 
204  /* @brief proceeds to the next step of the route,
205  * @return Whether the transportables plan continues */
206  virtual bool proceed(MSNet* net, SUMOTime time) = 0;
207 
209  const std::string& getID() const;
210 
211  inline const SUMOVehicleParameter& getParameter() const {
212  return *myParameter;
213  }
214 
215  inline const MSVehicleType& getVehicleType() const {
216  return *myVType;
217  }
218 
220  SUMOTime getDesiredDepart() const;
221 
223  void setDeparted(SUMOTime now);
224 
226  const MSEdge& getDestination() const {
227  return (*myStep)->getDestination();
228  }
229 
231  const MSEdge& getNextDestination() const {
232  return (*(myStep + 1))->getDestination();
233  }
234 
236  const MSEdge* getEdge() const {
237  return (*myStep)->getEdge();
238  }
239 
241  const MSEdge* getFromEdge() const {
242  return (*myStep)->getFromEdge();
243  }
244 
246  virtual SUMOReal getEdgePos() const;
247 
249  virtual Position getPosition() const;
250 
252  virtual SUMOReal getAngle() const;
253 
255  virtual SUMOReal getWaitingSeconds() const;
256 
258  virtual SUMOReal getSpeed() const;
259 
262  return (*myStep)->getStageType();
263  }
264 
266  std::string getCurrentStageDescription() const {
267  return (*myStep)->getStageDescription();
268  }
269 
272  return *myStep;
273  }
274 
280  void tripInfoOutput(OutputDevice& os) const;
281 
287  virtual void routeOutput(OutputDevice& os) const = 0;
288 
290  bool isWaitingFor(const std::string& line) const {
291  return (*myStep)->isWaitingFor(line);
292  }
293 
295  bool isWaiting4Vehicle() const {
296  return (*myStep)->isWaiting4Vehicle();
297  }
298 
301  return (*myStep)->getVehicle();
302  }
303 
304 protected:
307 
311 
314 
316  MSTransportablePlan* myPlan;
317 
319  MSTransportablePlan::iterator myStep;
320 
321 private:
324 
327 
328 };
329 
330 
331 #endif
332 
333 /****************************************************************************/
void setArrived(SUMOTime now)
logs end of the step
long long int SUMOTime
Definition: SUMOTime.h:43
virtual void beginEventOutput(const MSTransportable &transportable, SUMOTime t, OutputDevice &os) const =0
Called for writing the events output (begin of an action)
StageType getStageType() const
A lane area vehicles can halt at.
bool isWaiting4Vehicle() const
Whether the transportable waits for a vehicle.
Stage(const MSEdge &destination, MSStoppingPlace *toStop, const SUMOReal arrivalPos, StageType type)
constructor
const SUMOVehicleParameter & getParameter() const
virtual SUMOReal getWaitingSeconds() const
the time this transportable spent waiting in seconds
virtual const MSEdge * getEdge() const =0
Returns the current edge.
const MSStoppingPlace * getDestinationStop() const
returns the destination stop (if any)
virtual SUMOReal getEdgePos(SUMOTime now) const =0
SUMOVehicle * getVehicle() const
The vehicle associated with this transportable.
Stage & operator=(const Stage &)
Invalidated assignment operator.
const std::string & getID() const
returns the id of the transportable
MSTransportable::Stage * getCurrentStage() const
Return the current stage.
virtual bool isWaiting4Vehicle() const
Whether the transportable waits for a vehicle.
MSTransportablePlan::iterator myStep
the iterator over the route
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
virtual SUMOVehicle * getVehicle() const
Whether the transportable waits for a vehicle.
SUMOTime getDesiredDepart() const
Returns the desired departure time.
const SUMOVehicleParameter * myParameter
the plan of the transportable
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 transportable
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
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
Representation of a vehicle.
Definition: SUMOVehicle.h:65
virtual bool isWaitingFor(const std::string &line) const
Whether the transportable waits for a vehicle of the line specified.
MSStoppingPlace *const myDestinationStop
the stop to reach by getting transported (if any)
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
const MSVehicleType * myVType
This transportable&#39;s type. (mainly used for drawing related information Note sure if it is really nec...
StageType getCurrentStageType() const
the current stage type of the transportable
virtual void proceed(MSNet *net, MSTransportable *transportable, SUMOTime now, Stage *previous)=0
proceeds to the next step
virtual ~MSTransportable()
destructor
SUMOReal myArrivalPos
the position at which we want to arrive
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.
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 &transportable, SUMOTime t, OutputDevice &os) const =0
Called for writing the events output (end of an action)
SUMOReal getArrivalPos() const
bool isWaitingFor(const std::string &line) const
Whether the transportable waits for a vehicle of the line specified.
const MSEdge & getNextDestination() const
Returns the destination after the current destination.
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:214
MSTransportablePlan * myPlan
the plan of the transportable
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