SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSPerson.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // The class for modelling person-movements
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2015 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSPerson_h
24 #define MSPerson_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <vector>
38 #include <set>
39 #include <utils/common/SUMOTime.h>
40 #include <utils/common/Command.h>
41 #include <utils/geom/Position.h>
44 
45 
46 // ===========================================================================
47 // class declarations
48 // ===========================================================================
49 class MSNet;
50 class MSEdge;
51 class MSLane;
52 class OutputDevice;
54 class MSStoppingPlace;
55 class SUMOVehicle;
56 class MSVehicleType;
57 class MSPModel;
59 
60 typedef std::vector<const MSEdge*> ConstMSEdgeVector;
61 
62 // ===========================================================================
63 // class definitions
64 // ===========================================================================
70 class MSPerson : public MSTransportable {
71 public:
78  friend class MSPModel;
79  friend class GUIPerson; // debugging
80 
81  public:
83  MSPersonStage_Walking(const ConstMSEdgeVector& route, MSStoppingPlace* toBS, SUMOTime walkingTime, SUMOReal speed, SUMOReal departPos, SUMOReal arrivalPos);
84 
87 
89  virtual void proceed(MSNet* net, MSTransportable* person, 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 
99  SUMOReal getAngle(SUMOTime now) const;
100 
101  SUMOTime getWaitingTime(SUMOTime now) const;
102 
103  SUMOReal getSpeed() const;
104 
105  std::string getStageDescription() const {
106  return "walking";
107  }
108 
113  virtual void tripInfoOutput(OutputDevice& os) const;
114 
119  virtual void routeOutput(OutputDevice& os) const;
120 
125  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
126 
131  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
132 
134  bool moveToNextEdge(MSPerson* person, SUMOTime currentTime, MSEdge* nextInternal = 0);
135 
136 
138 
139  inline SUMOReal getMaxSpeed() const {
140  return mySpeed;
141  }
142  inline SUMOReal getDepartPos() const {
143  return myDepartPos;
144  }
145  inline SUMOReal getArrivalPos() const {
146  return myArrivalPos;
147  }
148 
149  inline const MSEdge* getRouteEdge() const {
150  return *myRouteStep;
151  }
152  inline const MSEdge* getNextRouteEdge() const {
153  return myRouteStep == myRoute.end() - 1 ? 0 : *(myRouteStep + 1);
154  }
155  inline const ConstMSEdgeVector& getRoute() const {
156  return myRoute;
157  }
158 
160  return myPedestrianState;
161  }
163 
164 
165  private:
166 
167  /* @brief compute average speed if the total walking duration is given
168  * @note Must be callled when the previous stage changes myDepartPos from the default*/
170 
171 
172  private:
175 
178 
179 
180  ConstMSEdgeVector::iterator myRouteStep;
181 
184 
186  //std::vector<SUMOTime> myArrivalTimes;
187 
192 
195 
197  public:
199  explicit arrival_finder(SUMOTime time) : myTime(time) {}
200 
202  bool operator()(SUMOReal t) const {
203  return myTime > t;
204  }
205 
206  private:
209  };
210 
211  private:
214 
217 
218  };
219 
225  public:
227  MSPersonStage_Driving(const MSEdge& destination, MSStoppingPlace* toBS,
228  const std::vector<std::string>& lines);
229 
232 
234  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, MSEdge* previousEdge, const SUMOReal at);
235 
237  const MSEdge* getEdge() const;
238  const MSEdge* getFromEdge() const;
239  SUMOReal getEdgePos(SUMOTime now) const;
240 
242  Position getPosition(SUMOTime now) const;
243 
244  SUMOReal getAngle(SUMOTime now) const;
245 
246  std::string getStageDescription() const;
247 
249  bool isWaitingFor(const std::string& line) const;
250 
252  bool isWaiting4Vehicle() const;
253 
255  SUMOTime getWaitingTime(SUMOTime now) const;
256 
257  SUMOReal getSpeed() const;
258 
260  myVehicle = v;
261  }
262 
268  virtual void tripInfoOutput(OutputDevice& os) const;
269 
275  virtual void routeOutput(OutputDevice& os) const;
276 
281  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
282 
287  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
288 
289  private:
291  const std::set<std::string> myLines;
292 
295 
301 
302  private:
305 
308 
309  };
310 
315  public:
317  MSPersonStage_Waiting(const MSEdge& destination,
318  SUMOTime duration, SUMOTime until, SUMOReal pos, const std::string& actType);
319 
322 
324  const MSEdge* getEdge() const;
325  const MSEdge* getFromEdge() const;
326  SUMOReal getEdgePos(SUMOTime now) const;
327  SUMOTime getUntil() const;
328 
330  Position getPosition(SUMOTime now) const;
331 
332  SUMOReal getAngle(SUMOTime now) const;
333 
334  SUMOTime getWaitingTime(SUMOTime now) const;
335 
336  SUMOReal getSpeed() const;
337 
338  std::string getStageDescription() const {
339  return "waiting (" + myActType + ")";
340  }
341 
343  virtual void proceed(MSNet* net, MSTransportable* person, SUMOTime now, MSEdge* previousEdge, const SUMOReal at);
344 
350  virtual void tripInfoOutput(OutputDevice& os) const;
351 
357  virtual void routeOutput(OutputDevice& os) const;
358 
363  virtual void beginEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
364 
369  virtual void endEventOutput(const MSTransportable& p, SUMOTime t, OutputDevice& os) const;
370 
371  private:
374 
377 
380 
382  std::string myActType;
383 
385 
386 
387  private:
390 
393 
394  };
395 
396 public:
399 
401  virtual ~MSPerson();
402 
403  /* @brief proceeds to the next step of the route,
404  * @return Whether the persons plan continues */
405  bool proceed(MSNet* net, SUMOTime time);
406 
412  void routeOutput(OutputDevice& os) const;
413 
415  const std::string& getNextEdge() const;
416 
417 private:
419  MSPerson(const MSPerson&);
420 
422  MSPerson& operator=(const MSPerson&);
423 
424 };
425 
426 
427 #endif
428 
429 /****************************************************************************/
SUMOTime getUntil() const
Definition: MSPerson.cpp:399
SUMOReal getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:411
const MSEdge * myWaitingEdge
Definition: MSPerson.h:300
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:245
MSStoppingPlace * myDestinationBusStop
Definition: MSPerson.h:296
virtual ~MSPerson()
destructor
Definition: MSPerson.cpp:481
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSPerson.cpp:460
const MSEdge * getNextRouteEdge() const
Definition: MSPerson.h:152
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:446
SUMOReal getSpeed() const
the speed of the transportable
Definition: MSPerson.cpp:466
A lane area vehicles can halt at.
arrival_finder(SUMOTime time)
constructor
Definition: MSPerson.h:199
MSEdge * myCurrentInternalEdge
The current internal edge this person is on or 0.
Definition: MSPerson.h:183
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.cpp:236
MSStoppingPlace * myDestinationBusStop
Definition: MSPerson.h:190
SUMOTime myWaitingSince
The time since which this person is waiting for a ride.
Definition: MSPerson.h:299
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:105
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:427
const std::set< std::string > myLines
the lines to choose from
Definition: MSPerson.h:291
bool isWaiting4Vehicle() const
Whether the person waits for a vehicle.
Definition: MSPerson.cpp:313
SUMOReal getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:251
SUMOTime myWaitingUntil
the time until the person is waiting
Definition: MSPerson.h:376
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:170
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:79
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:182
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:337
The simulated network and simulation perfomer.
Definition: MSNet.h:94
SUMOReal getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:99
The car-following model and parameter.
Definition: MSVehicleType.h:74
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.cpp:83
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
Definition: MSPerson.cpp:417
The pedestrian following model.
Definition: MSPModel.h:54
ConstMSEdgeVector myRoute
The route of the person.
Definition: MSPerson.h:177
A road/street connecting two junctions.
Definition: MSEdge.h:81
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a container
void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:513
bool moveToNextEdge(MSPerson *person, SUMOTime currentTime, MSEdge *nextInternal=0)
move forward and return whether the person arrived
Definition: MSPerson.cpp:196
SUMOReal getEdgePos(SUMOTime now) const
Definition: MSPerson.cpp:393
PedestrianState * getPedestrianState() const
Definition: MSPerson.h:159
Representation of a vehicle.
Definition: SUMOVehicle.h:65
MSPersonStage_Walking & operator=(const MSPersonStage_Walking &)
Invalidated assignment operator.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
SUMOReal getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:271
const ConstMSEdgeVector & getRoute() const
Definition: MSPerson.h:155
SUMOReal getSpeed() const
the speed of the transportable
Definition: MSPerson.cpp:325
SUMOReal computeAverageSpeed() const
Definition: MSPerson.cpp:152
SUMOTime myWaitingDuration
the time the person is waiting
Definition: MSPerson.h:373
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:405
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:343
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
Definition: MSPerson.cpp:286
std::string myActType
The type of activity.
Definition: MSPerson.h:382
MSPerson & operator=(const MSPerson &)
Invalidated assignment operator.
MSPersonStage_Driving & operator=(const MSPersonStage_Driving &)
Invalidated assignment operator.
ConstMSEdgeVector::iterator myRouteStep
Definition: MSPerson.h:180
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:387
const MSEdge * getRouteEdge() const
Definition: MSPerson.h:149
bool operator()(SUMOReal t) const
comparison operator
Definition: MSPerson.h:202
void setVehicle(SUMOVehicle *v)
Definition: MSPerson.h:259
MSPersonStage_Driving(const MSEdge &destination, MSStoppingPlace *toBS, const std::vector< std::string > &lines)
constructor
Definition: MSPerson.cpp:226
SUMOTime getWaitingTime(SUMOTime now) const
the time this transportable spent waiting
Definition: MSPerson.cpp:117
bool isWaitingFor(const std::string &line) const
Whether the person waits for a vehicle of the line specified.
Definition: MSPerson.cpp:307
MSPersonStage_Waiting(const MSEdge &destination, SUMOTime duration, SUMOTime until, SUMOReal pos, const std::string &actType)
constructor
Definition: MSPerson.cpp:365
std::string getStageDescription() const
return string representation of the current stage
Definition: MSPerson.h:105
abstract base class for managing callbacks to retrieve various state information from the model ...
Definition: MSPModel.h:96
SUMOReal getArrivalPos() const
Definition: MSPerson.h:145
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSPerson.cpp:453
SUMOReal getAngle(SUMOTime now) const
returns the angle of the transportable
Definition: MSPerson.cpp:111
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSPerson.cpp:189
const MSEdge * getEdge() const
Returns the current edge.
Definition: MSPerson.cpp:381
Structure representing possible vehicle parameter.
virtual void routeOutput(OutputDevice &os) const
Called on writing vehroute output.
Definition: MSPerson.cpp:433
virtual void beginEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output.
Definition: MSPerson.cpp:350
SUMOTime myTime
the searched arrival time
Definition: MSPerson.h:208
SUMOTime myWaitingStart
the time the person is waiting
Definition: MSPerson.h:379
MSPersonStage_Waiting & operator=(const MSPersonStage_Waiting &)
Invalidated assignment operator.
SUMOTime myWalkingTime
the time the person is walking
Definition: MSPerson.h:174
SUMOReal getDepartPos() const
Definition: MSPerson.h:142
~MSPersonStage_Walking()
destructor
Definition: MSPerson.cpp:78
const std::string & getNextEdge() const
return the list of internal edges if this person is walking and the pedestrian model allows it ...
Definition: MSPerson.cpp:524
Position getPosition(SUMOTime now) const
returns the position of the transportable
Definition: MSPerson.cpp:261
std::string getStageDescription() const
return string representation of the current stage
Definition: MSPerson.cpp:331
PedestrianState * myPedestrianState
state that is to be manipulated by MSPModel
Definition: MSPerson.h:194
bool proceed(MSNet *net, SUMOTime time)
Definition: MSPerson.cpp:486
MSPersonStage_Walking(const ConstMSEdgeVector &route, MSStoppingPlace *toBS, SUMOTime walkingTime, SUMOReal speed, SUMOReal departPos, SUMOReal arrivalPos)
constructor
Definition: MSPerson.cpp:59
SUMOTime getWaitingTime(SUMOTime now) const
time spent waiting for a ride
Definition: MSPerson.cpp:319
const MSEdge * getFromEdge() const
Definition: MSPerson.cpp:93
MSPerson(const SUMOVehicleParameter *pars, const MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan)
constructor
Definition: MSPerson.cpp:476
virtual void endEventOutput(const MSTransportable &p, SUMOTime t, OutputDevice &os) const
Called for writing the events output (end of an action)
Definition: MSPerson.cpp:356
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:215
SUMOReal myDepartPos
A vector of computed times an edge is reached.
Definition: MSPerson.h:188
SUMOVehicle * myVehicle
The taken vehicle.
Definition: MSPerson.h:294
SUMOReal getMaxSpeed() const
accessors to be used by MSPModel
Definition: MSPerson.h:139
SUMOReal getSpeed() const
the speed of the transportable
Definition: MSPerson.cpp:123
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
virtual void proceed(MSNet *net, MSTransportable *person, SUMOTime now, MSEdge *previousEdge, const SUMOReal at)
proceeds to the next step
Definition: MSPerson.cpp:129
std::string getStageDescription() const
return string representation of the current stage
Definition: MSPerson.h:338
virtual void tripInfoOutput(OutputDevice &os) const
Called on writing tripinfo output.
Definition: MSPerson.cpp:164