SUMO - Simulation of Urban MObility
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* toStop,
83  const SUMOReal arrivalPos, const std::vector<std::string>& lines);
84 
87 
89  virtual void proceed(MSNet* net, MSTransportable* container, SUMOTime now, Stage* previous);
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 
110  return myVehicle;
111  }
112 
114  bool isWaiting4Vehicle() const;
115 
117  SUMOTime getWaitingTime(SUMOTime now) const;
118 
125  SUMOReal getSpeed() const;
126 
129 
132  myVehicle = v;
133  }
134 
140  virtual void tripInfoOutput(OutputDevice& os) const;
141 
147  virtual void routeOutput(OutputDevice& os) const;
148 
153  virtual void beginEventOutput(const MSTransportable& container, SUMOTime t, OutputDevice& os) const;
154 
159  virtual void endEventOutput(const MSTransportable& container, SUMOTime t, OutputDevice& os) const;
160 
161  private:
163  const std::set<std::string> myLines;
164 
167 
170 
172 
175 
177 
178  private:
181 
184 
185  };
186 
193  public:
195  MSContainerStage_Waiting(const MSEdge& destination,
196  SUMOTime duration, SUMOTime until, SUMOReal pos, const std::string& actType);
197 
200 
202  const MSEdge* getEdge() const;
203 
205  const MSEdge* getFromEdge() const;
206 
207  SUMOReal getEdgePos(SUMOTime now) const;
208 
210  SUMOTime getUntil() const;
211 
212  Position getPosition(SUMOTime now) const;
213 
215  SUMOReal getAngle(SUMOTime now) const;
216 
217  SUMOTime getWaitingTime(SUMOTime now) const;
218 
220  SUMOReal getSpeed() const;
221 
223  std::string getStageDescription() const {
224  return "waiting (" + myActType + ")";
225  }
226 
227  /* @brief returns the container stop at which the container is waiting
228  *
229  * this method was added to have a method 'getDepartContainerStop'
230  * for MSContainer.
231  */
233 
235  virtual void proceed(MSNet* net, MSTransportable* container, SUMOTime now, Stage* previous);
236 
242  virtual void tripInfoOutput(OutputDevice& os) const;
243 
249  virtual void routeOutput(OutputDevice& os) const;
250 
255  virtual void beginEventOutput(const MSTransportable& container, SUMOTime t, OutputDevice& os) const;
256 
261  virtual void endEventOutput(const MSTransportable& container, SUMOTime t, OutputDevice& os) const;
262 
263  private:
266 
269 
272 
274  std::string myActType;
275 
278 
279 
280  private:
283 
286 
287  };
288 
296 
297  public:
299  MSContainerStage_Tranship(const std::vector<const MSEdge*>& route, MSStoppingPlace* toStop, SUMOReal speed, SUMOReal departPos, SUMOReal arrivalPos);
300 
303 
305  virtual void proceed(MSNet* net, MSTransportable* container, SUMOTime now, Stage* previous);
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 
410  private:
413 
416 
417  };
418 
419 public:
421  MSContainer(const SUMOVehicleParameter* pars, const MSVehicleType* vtype, MSTransportablePlan* plan);
422 
424  virtual ~MSContainer();
425 
426  /* @brief proceeds to the next step of the route,
427  * @return Whether the persons plan continues */
428  bool proceed(MSNet* net, SUMOTime time);
429 
435  void routeOutput(OutputDevice& os) const;
436 
437 private:
439  MSContainer(const MSContainer&);
440 
443 
444 };
445 
446 
447 #endif
448 
449 /****************************************************************************/
virtual ~MSContainer()
destructor
const std::set< std::string > myLines
the lines to choose from
Definition: MSContainer.h:163
SUMOReal myDepartPos
the depart position
Definition: MSContainer.h:396
long long int SUMOTime
Definition: SUMOTime.h:43
std::string getStageDescription() const
Returns the current stage description as a string.
Definition: MSContainer.h:223
MSStoppingPlace * myDepartContainerStop
The container stop from which the container departs.
Definition: MSContainer.h:399
SUMOTime myWaitingDuration
the time the container is waiting
Definition: MSContainer.h:265
A lane area vehicles can halt at.
std::vector< const MSEdge * >::iterator myRouteStep
current step
Definition: MSContainer.h:393
virtual void proceed(MSNet *net, MSTransportable *container, SUMOTime now, Stage *previous)
proceeds to the next step
Definition: MSContainer.cpp:72
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:169
SUMOTime getWaitingTime(SUMOTime now) const
time spent waiting for a ride
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
MSContainerStage_Driving(const MSEdge &destination, MSStoppingPlace *toStop, const SUMOReal arrivalPos, const std::vector< std::string > &lines)
constructor
Definition: MSContainer.cpp:63
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
SUMOTime myWaitingUntil
the time until the container is waiting
Definition: MSContainer.h:268
virtual void beginEventOutput(const MSTransportable &container, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
The simulated network and simulation perfomer.
Definition: MSNet.h:94
The car-following model and parameter.
Definition: MSVehicleType.h:74
std::vector< const MSEdge * > myRoute
The route of the container.
Definition: MSContainer.h:390
A road/street connecting two junctions.
Definition: MSEdge.h:81
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSContainer.cpp:96
SUMOTime myWaitingSince
The time since which this container is waiting for a ride.
Definition: MSContainer.h:174
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:402
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:274
SUMOReal myArrivalPos
the position at which we want to arrive
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
CState * myContainerState
state that is to be manipulated by MSCModel
Definition: MSContainer.h:405
const MSEdge * getNextRouteEdge() const
Definition: MSContainer.h:380
std::string getStageDescription() const
returns the stage description as a string
Structure representing possible vehicle parameter.
SUMOVehicle * getVehicle() const
The vehicle the person is riding or 0.
Definition: MSContainer.h:109
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:131
MSStoppingPlace * myCurrentContainerStop
the container stop at which the container is waiting
Definition: MSContainer.h:277
const MSEdge * getFromEdge() const
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:214
MSContainer(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportablePlan *plan)
constructor
The container following model for tranship.
SUMOTime myWaitingStart
the time the container started waiting
Definition: MSContainer.h:271
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:166
virtual void endEventOutput(const MSTransportable &container, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
SUMOReal getEdgePos(SUMOTime now) const
MSEdge * myCurrentInternalEdge
The current internal edge this container is on or 0.
Definition: MSContainer.h:408