Eclipse SUMO - Simulation of Urban MObility
MSTransportableControl.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Stores all persons or containers in the net and handles their waiting for cars.
19 /****************************************************************************/
20 #ifndef MSTransportableControl_h
21 #define MSTransportableControl_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <vector>
30 #include <map>
31 #include "MSTransportable.h"
32 #include "MSVehicle.h"
33 
34 
35 // ===========================================================================
36 // class declarations
37 // ===========================================================================
38 class MSNet;
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
53 public:
55  typedef std::vector<MSTransportable*> TransportableVector;
56 
58  typedef std::map<std::string, MSTransportable*>::const_iterator constVehIt;
59 
60 
61 public:
64 
65 
67  virtual ~MSTransportableControl();
68 
69 
74  bool add(MSTransportable* transportable);
75 
76 
81  MSTransportable* get(const std::string& id) const;
82 
83 
85  virtual void erase(MSTransportable* transportable);
86 
88  void setWaitEnd(SUMOTime time, MSTransportable* transportable);
89 
91  void checkWaiting(MSNet* net, const SUMOTime time);
92 
94  void addWaiting(const MSEdge* edge, MSTransportable* person);
95 
103  bool boardAnyWaiting(MSEdge* edge, SUMOVehicle* vehicle, const SUMOVehicleParameter::Stop& stop, SUMOTime& timeToBoardNextPerson, SUMOTime& stopDuration);
104 
111  bool loadAnyWaiting(MSEdge* edge, SUMOVehicle* vehicle, const SUMOVehicleParameter::Stop& stop, SUMOTime& timeToLoadNextContainer, SUMOTime& stopDuration);
112 
114  bool hasTransportables() const;
115 
117  bool hasNonWaiting() const;
118 
120  int getActiveCount();
121 
124 
127 
129  void abortWaiting(MSTransportable* t);
130 
138  std::mt19937* rng) const;
139 
146 
151  return myTransportables.begin();
152  }
153 
154 
159  return myTransportables.end();
160  }
161 
162 
166  int size() const {
167  return (int)myTransportables.size();
168  }
169 
171  void registerJammed() {
172  myJammedNumber++;
173  }
174 
177 
181  int getLoadedNumber() const {
182  return myLoadedNumber;
183  }
184 
185 
189  int getRunningNumber() const {
190  return myRunningNumber;
191  }
192 
196  int getJammedNumber() const {
197  return myJammedNumber;
198  }
199 
204  }
205 
207 
208 protected:
210  std::map<std::string, MSTransportable*> myTransportables;
211 
213  std::map<SUMOTime, TransportableVector> myWaiting4Departure;
214 
216  std::map<SUMOTime, TransportableVector> myWaitingUntil;
217 
219  std::map<const MSEdge*, TransportableVector> myWaiting4Vehicle;
220 
223 
226 
229 
232 
235 
236 };
237 
238 
239 #endif
240 
241 /****************************************************************************/
MSTransportableControl::constVehIt
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal transportables map iterator.
Definition: MSTransportableControl.h:58
MSVehicleType
The car-following model and parameter.
Definition: MSVehicleType.h:66
MSTransportableControl::abortWaitingForVehicle
void abortWaitingForVehicle(MSTransportable *t)
let the given transportable abort waiting for a vehicle (when removing stage via TraCI)
Definition: MSTransportableControl.cpp:279
MSTransportableControl::boardAnyWaiting
bool boardAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToBoardNextPerson, SUMOTime &stopDuration)
board any applicable persons Boards any people who wait on that edge for the given vehicle and remove...
Definition: MSTransportableControl.cpp:154
MSTransportableControl::getActiveCount
int getActiveCount()
return the number of active transportable objects
Definition: MSTransportableControl.cpp:250
MSTransportableControl::erase
virtual void erase(MSTransportable *transportable)
removes a single transportable
Definition: MSTransportableControl.cpp:86
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:92
MSTransportableControl::~MSTransportableControl
virtual ~MSTransportableControl()
Destructor.
Definition: MSTransportableControl.cpp:52
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:61
MSTransportableControl::getWaitingForVehicleNumber
int getWaitingForVehicleNumber() const
Returns the number of vehicles waiting for a ride.
Definition: MSTransportableControl.h:202
MSTransportableControl::myWaiting4Vehicle
std::map< const MSEdge *, TransportableVector > myWaiting4Vehicle
the lists of waiting transportables
Definition: MSTransportableControl.h:219
MSTransportableControl::size
int size() const
Returns the number of known transportables.
Definition: MSTransportableControl.h:166
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:291
MSTransportableControl::myJammedNumber
int myJammedNumber
The number of jammed transportables.
Definition: MSTransportableControl.h:228
MSTransportable
Definition: MSTransportable.h:59
MSTransportableControl::add
bool add(MSTransportable *transportable)
Adds a single transportable, returns false if an id clash occurred.
Definition: MSTransportableControl.cpp:62
MSTransportableControl::setWaitEnd
void setWaitEnd(SUMOTime time, MSTransportable *transportable)
sets the arrival time for a waiting transportable
Definition: MSTransportableControl.cpp:107
MSTransportableControl::registerJammed
void registerJammed()
register a jammed transportable
Definition: MSTransportableControl.h:171
MSTransportableControl::loadAnyWaiting
bool loadAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToLoadNextContainer, SUMOTime &stopDuration)
load any applicable containers Loads any container that is waiting on that edge for the given vehicle...
Definition: MSTransportableControl.cpp:199
MSVehicle.h
MSTransportableControl::hasNonWaiting
bool hasNonWaiting() const
checks whether any transportable is still engaged in walking / stopping
Definition: MSTransportableControl.cpp:244
MSTransportableControl
Definition: MSTransportableControl.h:52
MSTransportableControl::get
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
Definition: MSTransportableControl.cpp:76
MSTransportableControl::myWaiting4Departure
std::map< SUMOTime, TransportableVector > myWaiting4Departure
Transportables waiting for departure.
Definition: MSTransportableControl.h:213
MSTransportableControl::myRunningNumber
int myRunningNumber
The number of transportables within the network (build and inserted but not removed)
Definition: MSTransportableControl.h:225
MSTransportableControl::buildPerson
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
Definition: MSTransportableControl.cpp:311
MSTransportableControl::hasTransportables
bool hasTransportables() const
checks whether any transportable waits to finish her plan
Definition: MSTransportableControl.cpp:238
MSTransportableControl::loadedBegin
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
Definition: MSTransportableControl.h:150
MSTransportableControl::abortAnyWaitingForVehicle
void abortAnyWaitingForVehicle()
aborts the plan for any transportable that is still waiting for a ride
Definition: MSTransportableControl.cpp:256
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
MSTransportableControl::myLoadedNumber
int myLoadedNumber
The number of build transportables.
Definition: MSTransportableControl.h:222
MSTransportableControl::myWaitingUntil
std::map< SUMOTime, TransportableVector > myWaitingUntil
the lists of walking / stopping transportables
Definition: MSTransportableControl.h:216
MSTransportableControl::getJammedNumber
int getJammedNumber() const
Returns the number of times a transportables was jammed.
Definition: MSTransportableControl.h:196
MSTransportableControl::myHaveNewWaiting
bool myHaveNewWaiting
whether a new transportable waiting for a vehicle has been added in the last step
Definition: MSTransportableControl.h:234
MSTransportableControl::TransportableVector
std::vector< MSTransportable * > TransportableVector
Definition of a list of transportables.
Definition: MSTransportableControl.h:55
MSTransportableControl::myWaitingForVehicleNumber
int myWaitingForVehicleNumber
The number of transportables waiting for vehicles.
Definition: MSTransportableControl.h:231
MSTransportable::MSTransportablePlan
std::vector< MSTransportable::Stage * > MSTransportablePlan
the structure holding the plan of a transportable
Definition: MSTransportable.h:588
MSTransportableControl::loadedEnd
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
Definition: MSTransportableControl.h:158
MSTransportableControl::MSTransportableControl
MSTransportableControl()
Constructor.
Definition: MSTransportableControl.cpp:43
MSTransportableControl::addWaiting
void addWaiting(const MSEdge *edge, MSTransportable *person)
adds a transportable to the list of transportables waiting for a vehicle on the specified edge
Definition: MSTransportableControl.cpp:146
MSTransportable.h
MSTransportableControl::checkWaiting
void checkWaiting(MSNet *net, const SUMOTime time)
checks whether any transportables waiting time is over
Definition: MSTransportableControl.cpp:118
MSTransportableControl::getRunningNumber
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
Definition: MSTransportableControl.h:189
config.h
MSTransportableControl::getLoadedNumber
int getLoadedNumber() const
Returns the number of build transportables.
Definition: MSTransportableControl.h:181
MSTransportableControl::myTransportables
std::map< std::string, MSTransportable * > myTransportables
all currently created transportables by id
Definition: MSTransportableControl.h:210
MSTransportableControl::abortWaiting
void abortWaiting(MSTransportable *t)
aborts waiting stage of transportable
Definition: MSTransportableControl.cpp:292
MSTransportableControl::buildContainer
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
Definition: MSTransportableControl.cpp:319
SUMOVehicleParameter::Stop
Definition of vehicle stop (position and duration)
Definition: SUMOVehicleParameter.h:566