SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSContainer.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // The class for modelling container-movements
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef MSContainer_h
22 #define MSContainer_h
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <vector>
35 #include <set>
36 #include <utils/common/SUMOTime.h>
37 #include <utils/common/Command.h>
38 #include <utils/geom/Position.h>
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class MSNet;
47 class MSEdge;
48 class MSLane;
49 class OutputDevice;
51 class MSStoppingPlace;
52 class SUMOVehicle;
53 class MSVehicleType;
55 class CState;
56 
57 
58 // ===========================================================================
59 // class definitions
60 // ===========================================================================
68 class MSContainer : public MSTransportable {
69 public:
71  static const SUMOReal ROADSIDE_OFFSET;
72 
73 
80  public:
82  MSContainerStage_Driving(const MSEdge& destination, MSStoppingPlace* toCS,
83  const std::vector<std::string>& lines);
84 
87 
89  virtual void proceed(MSNet* net, MSTransportable* container, SUMOTime now, MSEdge* previousEdge, const SUMOReal at);
90 
92  const MSEdge* getEdge() const;
93  const MSEdge* getFromEdge() const;
94  SUMOReal getEdgePos(SUMOTime now) const;
95 
97  Position getPosition(SUMOTime now) const;
98 
100  SUMOReal getAngle(SUMOTime now) const;
101 
103  std::string getStageDescription() const;
104 
106  bool isWaitingFor(const std::string& line) const;
107 
109  bool isWaiting4Vehicle() const;
110 
112  SUMOTime getWaitingTime(SUMOTime now) const;
113 
120  SUMOReal getSpeed() const;
121 
124 
127  myVehicle = v;
128  }
129 
135  virtual void tripInfoOutput(OutputDevice& os) const;
136 
142  virtual void routeOutput(OutputDevice& os) const;
143 
148  virtual void beginEventOutput(const MSTransportable& container, SUMOTime t, OutputDevice& os) const;
149 
154  virtual void endEventOutput(const MSTransportable& container, SUMOTime t, OutputDevice& os) const;
155 
156  private:
158  const std::set<std::string> myLines;
159 
162 
165 
168 
170 
173 
175 
176  private:
179 
182 
183  };
184 
191  public:
193  MSContainerStage_Waiting(const MSEdge& destination,
194  SUMOTime duration, SUMOTime until, SUMOReal pos, const std::string& actType);
195 
198 
200  const MSEdge* getEdge() const;
201 
203  const MSEdge* getFromEdge() const;
204 
205  SUMOReal getEdgePos(SUMOTime now) const;
206 
208  SUMOTime getUntil() const;
209 
210  Position getPosition(SUMOTime now) const;
211 
213  SUMOReal getAngle(SUMOTime now) const;
214 
215  SUMOTime getWaitingTime(SUMOTime now) const;
216 
218  SUMOReal getSpeed() const;
219 
221  std::string getStageDescription() const {
222  return "waiting (" + myActType + ")";
223  }
224 
225  /* @brief returns the container stop at which the container is waiting
226  *
227  * this method was added to have a method 'getDepartContainerStop'
228  * for MSContainer.
229  */
231 
233  virtual void proceed(MSNet* net, MSTransportable* container, SUMOTime now, MSEdge* previousEdge, const SUMOReal at);
234 
240  virtual void tripInfoOutput(OutputDevice& os) const;
241 
247  virtual void routeOutput(OutputDevice& os) const;
248 
253  virtual void beginEventOutput(const MSTransportable& container, SUMOTime t, OutputDevice& os) const;
254 
259  virtual void endEventOutput(const MSTransportable& container, SUMOTime t, OutputDevice& os) const;
260 
261  private:
264 
267 
270 
272  std::string myActType;
273 
275 
278 
279 
280  private:
283 
286 
287  };
288 
296 
297  public:
299  MSContainerStage_Tranship(const std::vector<const MSEdge*>& route, MSStoppingPlace* toCS, SUMOReal speed, SUMOReal departPos, SUMOReal arrivalPos);
300 
303 
305  virtual void proceed(MSNet* net, MSTransportable* container, SUMOTime now, MSEdge* previousEdge, const SUMOReal at);
306 
308  const MSEdge* getEdge() const;
309 
311  const MSEdge* getFromEdge() const;
312 
314  const MSEdge* getToEdge() const;
315 
317  SUMOReal getEdgePos(SUMOTime now) const;
318 
320  Position getPosition(SUMOTime now) const;
321 
323  SUMOReal getAngle(SUMOTime now) const;
324 
326  SUMOTime getWaitingTime(SUMOTime now) const;
327 
329  SUMOReal getSpeed() const;
330 
332  std::string getStageDescription() const {
333  return "tranship";
334  }
335 
338 
343  virtual void tripInfoOutput(OutputDevice& os) const;
344 
349  virtual void routeOutput(OutputDevice& os) const;
350 
355  virtual void beginEventOutput(const MSTransportable& c, SUMOTime t, OutputDevice& os) const;
356 
361  virtual void endEventOutput(const MSTransportable& c, SUMOTime t, OutputDevice& os) const;
362 
364  bool moveToNextEdge(MSTransportable* container, SUMOTime currentTime, MSEdge* nextInternal = 0);
365 
366 
368  inline SUMOReal getMaxSpeed() const {
369  return mySpeed;
370  }
371 
372  inline SUMOReal getDepartPos() const {
373  return myDepartPos;
374  }
375 
376  inline SUMOReal getArrivalPos() const {
377  return myArrivalPos;
378  }
379 
380  inline const MSEdge* getNextRouteEdge() const {
381  return myRouteStep == myRoute.end() - 1 ? 0 : *(myRouteStep + 1);
382  }
383 
385  return myContainerState;
386  }
387 
388  private:
390  std::vector<const MSEdge*> myRoute;
391 
393  std::vector<const MSEdge*>::iterator myRouteStep;
394 
397 
400 
403 
406 
409 
412 
415 
416  private:
419 
422 
423  };
424 
425 public:
427  MSContainer(const SUMOVehicleParameter* pars, const MSVehicleType* vtype, MSTransportablePlan* plan);
428 
430  virtual ~MSContainer();
431 
432  /* @brief proceeds to the next step of the route,
433  * @return Whether the persons plan continues */
434  bool proceed(MSNet* net, SUMOTime time);
435 
441  void routeOutput(OutputDevice& os) const;
442 
443 private:
445  MSContainer(const MSContainer&);
446 
449 
450 };
451 
452 
453 #endif
454 
455 /****************************************************************************/
virtual ~MSContainer()
destructor
SUMOReal getEdgePos(SUMOTime now) const
Returns the offset from the start of the current edge measured in its natural direction.
const std::set< std::string > myLines
the lines to choose from
Definition: MSContainer.h:158
SUMOReal myDepartPos
the depart position
Definition: MSContainer.h:396
virtual void beginEventOutput(const MSTransportable &c, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
MSContainerStage_Tranship & operator=(const MSContainerStage_Tranship &)
Invalidated assignment operator.
std::string getStageDescription() const
Returns the current stage description as a string.
Definition: MSContainer.h:221
SUMOReal getAngle(SUMOTime now) const
the angle of the edge minus 90deg
MSStoppingPlace * myDepartContainerStop
The container stop from which the container departs.
Definition: MSContainer.h:405
SUMOTime myWaitingDuration
the time the container is waiting
Definition: MSContainer.h:263
A lane area vehicles can halt at.
std::vector< const MSEdge * >::iterator myRouteStep
current step
Definition: MSContainer.h:393
MSContainerStage_Waiting & operator=(const MSContainerStage_Waiting &)
Invalidated assignment operator.
MSContainerStage_Tranship(const std::vector< const MSEdge * > &route, MSStoppingPlace *toCS, SUMOReal speed, SUMOReal departPos, SUMOReal arrivalPos)
constructor
bool isWaitingFor(const std::string &line) const
Whether the container waits for a vehicle of the line specified.
MSStoppingPlace * myDepartContainerStop
The container stop from which the container departs.
Definition: MSContainer.h:167
SUMOTime getWaitingTime(SUMOTime now) const
time spent waiting for a ride
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
const MSEdge * getEdge() const
Returns the current edge.
SUMOReal getSpeed() const
Returns the speed of the container which is always zero in that stage.
MSContainerStage_Waiting(const MSEdge &destination, SUMOTime duration, SUMOTime until, SUMOReal pos, const std::string &actType)
constructor
std::string getStageDescription() const
Returns the current stage description as a string.
Definition: MSContainer.h:332
SUMOReal getMaxSpeed() const
accessors to be used by MSCModel_NonInteracting
Definition: MSContainer.h:368
SUMOReal getEdgePos(SUMOTime now) const
virtual void proceed(MSNet *net, MSTransportable *container, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
Definition: MSContainer.cpp:71
virtual void proceed(MSNet *net, MSTransportable *container, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
SUMOTime myWaitingUntil
the time until the container is waiting
Definition: MSContainer.h:266
virtual void beginEventOutput(const MSTransportable &container, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
MSStoppingPlace * myDestinationContainerStop
the destination container stop
Definition: MSContainer.h:402
virtual void proceed(MSNet *net, MSTransportable *container, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
The simulated network and simulation perfomer.
Definition: MSNet.h:94
The car-following model and parameter.
Definition: MSVehicleType.h:74
const MSEdge * getEdge() const
Returns the current edge.
std::vector< const MSEdge * > myRoute
The route of the container.
Definition: MSContainer.h:390
virtual void beginEventOutput(const MSTransportable &container, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
A road/street connecting two junctions.
Definition: MSEdge.h:81
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a container
SUMOReal myArrivalPos
the arrival position
Definition: MSContainer.h:399
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSContainer.cpp:91
SUMOTime myWaitingSince
The time since which this container is waiting for a ride.
Definition: MSContainer.h:172
SUMOTime getUntil() const
Returns time until the container waits.
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Representation of a vehicle.
Definition: SUMOVehicle.h:65
SUMOReal mySpeed
the speed of the container
Definition: MSContainer.h:408
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
SUMOReal getSpeed() const
the speed of the container
std::string myActType
The type of activity.
Definition: MSContainer.h:272
Position getPosition(SUMOTime now) const
Returns the position of the container.
MSStoppingPlace * myDestinationContainerStop
The destination container stop.
Definition: MSContainer.h:164
SUMOReal getSpeed() const
Returns the speed of the container.
static const SUMOReal ROADSIDE_OFFSET
the offset for computing container positions when standing at an edge
Definition: MSContainer.h:71
Position getPosition(SUMOTime now) const
returns the position of the transportable
MSContainerStage_Driving(const MSEdge &destination, MSStoppingPlace *toCS, const std::vector< std::string > &lines)
constructor
Definition: MSContainer.cpp:62
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
virtual void endEventOutput(const MSTransportable &c, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
const MSEdge * getFromEdge() const
Returns first edge of the containers route.
CState * myContainerState
state that is to be manipulated by MSCModel
Definition: MSContainer.h:411
bool moveToNextEdge(MSTransportable *container, SUMOTime currentTime, MSEdge *nextInternal=0)
move forward and return whether the container arrived
const MSEdge * getNextRouteEdge() const
Definition: MSContainer.h:380
Position getPosition(SUMOTime now) const
returns the position of the transportable
const MSEdge * getFromEdge() const
Returns the current edge.
std::string getStageDescription() const
returns the stage description as a string
Structure representing possible vehicle parameter.
bool proceed(MSNet *net, SUMOTime time)
SUMOReal getAngle(SUMOTime now) const
the angle of the vehicle or the angle of the edge + 90deg
void setVehicle(SUMOVehicle *v)
assign a vehicle to the container
Definition: MSContainer.h:126
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
MSStoppingPlace * myCurrentContainerStop
the container stop at which the container is waiting
Definition: MSContainer.h:277
MSStoppingPlace * getDepartContainerStop() const
const MSEdge * getFromEdge() const
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
SUMOTime getWaitingTime(SUMOTime now) const
Returns the time the container spent waiting.
#define SUMOReal
Definition: config.h:215
MSStoppingPlace * getDepartContainerStop() const
returns the container stop from which the container departs
MSContainer(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportablePlan *plan)
constructor
The container following model for tranship.
const MSEdge * getToEdge() const
Returns last edge of the containers route.
SUMOReal getAngle(SUMOTime now) const
Returns the angle of the container.
SUMOTime myWaitingStart
the time the container started waiting
Definition: MSContainer.h:269
bool isWaiting4Vehicle() const
Whether the container waits for a vehicle.
MSStoppingPlace * getDepartContainerStop() const
returns the container stop from which the container departs
MSContainerStage_Driving & operator=(const MSContainerStage_Driving &)
Invalidated assignment operator.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
SUMOVehicle * myVehicle
The taken vehicle.
Definition: MSContainer.h:161
virtual void endEventOutput(const MSTransportable &container, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
virtual void endEventOutput(const MSTransportable &container, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
MSContainer & operator=(const MSContainer &)
Invalidated assignment operator.
void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
SUMOReal getEdgePos(SUMOTime now) const
MSEdge * myCurrentInternalEdge
The current internal edge this container is on or 0.
Definition: MSContainer.h:414