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-2016 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 #include <set>
33 #include <utils/common/SUMOTime.h>
34 #include <utils/geom/Position.h>
35 
36 
37 // ===========================================================================
38 // class declarations
39 // ===========================================================================
40 class MSEdge;
41 class MSLane;
42 class MSNet;
43 class MSStoppingPlace;
44 class MSVehicleType;
45 class OutputDevice;
47 class SUMOVehicle;
48 
49 
50 // ===========================================================================
51 // class definitions
52 // ===========================================================================
59 public:
60  enum StageType {
61  DRIVING = 0,
62  WAITING = 1,
63  MOVING_WITHOUT_VEHICLE = 2, // walking for persons, tranship for containers
65  };
66 
71  class Stage {
72  public:
74  Stage(const MSEdge& destination, MSStoppingPlace* toStop, const SUMOReal arrivalPos, StageType type);
75 
77  virtual ~Stage();
78 
80  const MSEdge& getDestination() const;
81 
84  return myDestinationStop;
85  }
86 
88  return myArrivalPos;
89  }
90 
92  virtual const MSEdge* getEdge() const = 0;
93  virtual const MSEdge* getFromEdge() const = 0;
94  virtual SUMOReal getEdgePos(SUMOTime now) const = 0;
95 
97  virtual Position getPosition(SUMOTime now) const = 0;
98 
100  virtual SUMOReal getAngle(SUMOTime now) const = 0;
101 
104  return myType;
105  }
106 
108  virtual std::string getStageDescription() const = 0;
109 
111  virtual void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, Stage* previous) = 0;
112 
114  void setDeparted(SUMOTime now);
115 
117  void setArrived(SUMOTime now);
118 
120  virtual bool isWaitingFor(const std::string& line) const;
121 
123  virtual bool isWaiting4Vehicle() const {
124  return false;
125  }
126 
128  virtual SUMOVehicle* getVehicle() const {
129  return 0;
130  }
131 
133  virtual SUMOTime getWaitingTime(SUMOTime now) const = 0;
134 
136  virtual SUMOReal getSpeed() const = 0;
137 
139  Position getEdgePosition(const MSEdge* e, SUMOReal at, SUMOReal offset) const;
140 
142  Position getLanePosition(const MSLane* lane, SUMOReal at, SUMOReal offset) const;
143 
145  SUMOReal getEdgeAngle(const MSEdge* e, SUMOReal at) const;
146 
151  virtual void tripInfoOutput(OutputDevice& os) const = 0;
152 
157  virtual void routeOutput(OutputDevice& os) const = 0;
158 
163  virtual void beginEventOutput(const MSTransportable& transportable, SUMOTime t, OutputDevice& os) const = 0;
164 
169  virtual void endEventOutput(const MSTransportable& transportable, SUMOTime t, OutputDevice& os) const = 0;
170 
171  protected:
174 
177 
180 
183 
186 
189 
190  private:
192  Stage(const Stage&);
193 
195  Stage& operator=(const Stage&);
196 
197  };
198 
202  class Stage_Waiting : public Stage {
203  public:
205  Stage_Waiting(const MSEdge& destination, SUMOTime duration, SUMOTime until,
206  SUMOReal pos, const std::string& actType, const bool initial);
207 
209  virtual ~Stage_Waiting();
210 
212  const MSEdge* getEdge() const;
213  const MSEdge* getFromEdge() const;
214  SUMOReal getEdgePos(SUMOTime now) const;
215  SUMOTime getUntil() const;
216 
218  Position getPosition(SUMOTime now) const;
219 
220  SUMOReal getAngle(SUMOTime now) const;
221 
222  SUMOTime getWaitingTime(SUMOTime now) const;
223 
224  SUMOReal getSpeed() const;
225 
226  std::string getStageDescription() const {
227  return "waiting (" + myActType + ")";
228  }
229 
231  virtual void proceed(MSNet* net, MSTransportable* transportable, SUMOTime now, Stage* previous);
232 
238  virtual void tripInfoOutput(OutputDevice& os) const;
239 
245  virtual void routeOutput(OutputDevice& os) const;
246 
251  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
252 
257  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
258 
259  private:
262 
265 
268 
270  std::string myActType;
271 
272  private:
275 
278 
279  };
280 
285  class Stage_Driving : public Stage {
286  public:
288  Stage_Driving(const MSEdge& destination, MSStoppingPlace* toStop,
289  const SUMOReal arrivalPos, const std::vector<std::string>& lines);
290 
292  virtual ~Stage_Driving();
293 
295  const MSEdge* getEdge() const;
296  const MSEdge* getFromEdge() const;
297  SUMOReal getEdgePos(SUMOTime now) const;
298 
300  Position getPosition(SUMOTime now) const;
301 
302  SUMOReal getAngle(SUMOTime now) const;
303 
305  bool isWaitingFor(const std::string& line) const;
306 
308  bool isWaiting4Vehicle() const;
309 
312  return myVehicle;
313  }
314 
316  SUMOTime getWaitingTime(SUMOTime now) const;
317 
318  SUMOReal getSpeed() const;
319 
321  myVehicle = v;
322  }
323 
328  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
329 
334  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
335 
336  protected:
338  const std::set<std::string> myLines;
339 
342 
348 
349  private:
352 
355 
356  };
357 
359  typedef std::vector<MSTransportable::Stage*> MSTransportablePlan;
360 
362  MSTransportable(const SUMOVehicleParameter* pars, const MSVehicleType* vtype, MSTransportablePlan* plan);
363 
365  virtual ~MSTransportable();
366 
367  /* @brief proceeds to the next step of the route,
368  * @return Whether the transportables plan continues */
369  virtual bool proceed(MSNet* net, SUMOTime time) = 0;
370 
372  const std::string& getID() const;
373 
374  inline const SUMOVehicleParameter& getParameter() const {
375  return *myParameter;
376  }
377 
378  inline const MSVehicleType& getVehicleType() const {
379  return *myVType;
380  }
381 
383  SUMOTime getDesiredDepart() const;
384 
386  void setDeparted(SUMOTime now);
387 
389  const MSEdge& getDestination() const {
390  return (*myStep)->getDestination();
391  }
392 
394  const MSEdge& getNextDestination() const {
395  return (*(myStep + 1))->getDestination();
396  }
397 
399  const MSEdge* getEdge() const {
400  return (*myStep)->getEdge();
401  }
402 
404  const MSEdge* getFromEdge() const {
405  return (*myStep)->getFromEdge();
406  }
407 
409  virtual SUMOReal getEdgePos() const;
410 
412  virtual Position getPosition() const;
413 
415  virtual SUMOReal getAngle() const;
416 
418  virtual SUMOReal getWaitingSeconds() const;
419 
421  virtual SUMOReal getSpeed() const;
422 
425  return (*myStep)->getStageType();
426  }
427 
429  std::string getCurrentStageDescription() const {
430  return (*myStep)->getStageDescription();
431  }
432 
435  return *myStep;
436  }
437 
443  virtual void tripInfoOutput(OutputDevice& os) const = 0;
444 
450  virtual void routeOutput(OutputDevice& os) const = 0;
451 
453  bool isWaitingFor(const std::string& line) const {
454  return (*myStep)->isWaitingFor(line);
455  }
456 
458  bool isWaiting4Vehicle() const {
459  return (*myStep)->isWaiting4Vehicle();
460  }
461 
464  return (*myStep)->getVehicle();
465  }
466 
467 protected:
469  static const SUMOReal ROADSIDE_OFFSET;
470 
473 
477 
480 
482  MSTransportablePlan* myPlan;
483 
485  MSTransportablePlan::iterator myStep;
486 
487 private:
490 
493 
494 };
495 
496 
497 #endif
498 
499 /****************************************************************************/
void setArrived(SUMOTime now)
logs end of the step
long long int SUMOTime
Definition: SUMOTime.h:43
std::string myActType
The type of activity.
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::set< std::string > myLines
the lines to choose from
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
SUMOVehicle * getVehicle() const
The vehicle the person is riding or 0.
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:93
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
SUMOTime myWaitingSince
The time since which this person is waiting for a ride.
A road/street connecting two junctions.
Definition: MSEdge.h:80
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
static const SUMOReal ROADSIDE_OFFSET
the offset for computing positions when standing at an edge
Representation of a vehicle.
Definition: SUMOVehicle.h:66
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...
void setVehicle(SUMOVehicle *v)
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
SUMOTime myWaitingUntil
the time until the person is waiting
SUMOVehicle * myVehicle
The taken vehicle.
virtual std::string getStageDescription() const =0
return string representation of the current stage
std::string getStageDescription() const
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:213
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:79
SUMOTime myWaitingDuration
the time the person is waiting
SUMOTime myWaitingStart
the time the person is waiting
virtual const MSEdge * getFromEdge() const =0