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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // Stores all persons or containers in the net and handles their waiting for cars.
22 /****************************************************************************/
23 #pragma once
24 #include <config.h>
25 
26 #include <vector>
27 #include <map>
29 #include <microsim/MSVehicle.h>
30 
31 
32 // ===========================================================================
33 // class declarations
34 // ===========================================================================
35 class MSNet;
36 class MSPModel;
37 
38 
39 // ===========================================================================
40 // class definitions
41 // ===========================================================================
51 public:
53  typedef std::vector<MSTransportable*> TransportableVector;
54 
56  typedef std::map<std::string, MSTransportable*>::const_iterator constVehIt;
57 
58 
59 public:
61  MSTransportableControl(const bool isPerson);
62 
63 
65  virtual ~MSTransportableControl();
66 
67 
72  bool add(MSTransportable* transportable);
73 
74 
79  MSTransportable* get(const std::string& id) const;
80 
81 
83  virtual void erase(MSTransportable* transportable);
84 
86  void setWaitEnd(SUMOTime time, MSTransportable* transportable);
87 
89  void checkWaiting(MSNet* net, const SUMOTime time);
90 
92  void addWaiting(const MSEdge* edge, MSTransportable* person);
93 
95  void forceDeparture();
96 
104  bool boardAnyWaiting(MSEdge* edge, SUMOVehicle* vehicle, const SUMOVehicleParameter::Stop& stop, SUMOTime& timeToBoardNextPerson, SUMOTime& stopDuration);
105 
112  bool loadAnyWaiting(MSEdge* edge, SUMOVehicle* vehicle, const SUMOVehicleParameter::Stop& stop, SUMOTime& timeToLoadNextContainer, SUMOTime& stopDuration);
113 
115  bool hasTransportables() const;
116 
118  bool hasNonWaiting() const;
119 
121  int getActiveCount();
122 
125 
128 
130  void abortWaiting(MSTransportable* t);
131 
139  std::mt19937* rng) const;
140 
147 
152  return myTransportables.begin();
153  }
154 
155 
160  return myTransportables.end();
161  }
162 
163 
167  int size() const {
168  return (int)myTransportables.size();
169  }
170 
172  void registerJammed() {
173  myJammedNumber++;
174  }
175 
177  void fixLoadCount() {
178  myLoadedNumber--;
179  }
180 
183 
187  int getLoadedNumber() const {
188  return myLoadedNumber;
189  }
190 
191  int getDepartedNumber() const;
192 
196  int getRunningNumber() const {
197  return myRunningNumber;
198  }
199 
203  int getJammedNumber() const {
204  return myJammedNumber;
205  }
206 
211  }
212 
216  int getWaitingUntilNumber() const {
217  return myWaitingUntilNumber;
218  }
219 
222  int getMovingNumber() const;
223 
226  int getRidingNumber() const;
227 
230  int getEndedNumber() const {
231  return myEndedNumber;
232  }
233 
237  int getArrivedNumber() const {
238  return myArrivedNumber;
239  }
240 
242 
247  return myMovementModel;
248  }
249 
254  return myNonInteractingModel;
255  }
256 
257  void addArrived() {
258  myArrivedNumber++;
259  }
260 
261  void addDiscarded() {
262  myLoadedNumber++;
264  }
265 
268  void saveState(OutputDevice& out);
269 
272  void loadState(const std::string& state);
273 
274 protected:
276  std::map<std::string, MSTransportable*> myTransportables;
277 
279  std::map<SUMOTime, TransportableVector> myWaiting4Departure;
280 
282  std::map<SUMOTime, TransportableVector> myWaitingUntil;
283 
285  std::map<const MSEdge*, TransportableVector> myWaiting4Vehicle;
286 
289 
292 
295 
298 
301 
304 
307 
310 
313 
316 
317 private:
319 
321 
322 private:
325 };
long long int SUMOTime
Definition: SUMOTime.h:31
A road/street connecting two junctions.
Definition: MSEdge.h:77
The simulated network and simulation perfomer.
Definition: MSNet.h:89
The pedestrian (and also sometimes container) movement model.
Definition: MSPModel.h:51
void loadState(const std::string &state)
Reconstruct the current state.
MSPModel * getMovementModel()
Returns the default movement model for this kind of transportables.
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
void setWaitEnd(SUMOTime time, MSTransportable *transportable)
sets the arrival time for a waiting transportable
bool hasTransportables() const
checks whether any transportable waits to finish her plan
std::map< std::string, MSTransportable * >::const_iterator constVehIt
Definition of the internal transportables map iterator.
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
int myWaitingForDepartureNumber
The number of transportables waiting for departure.
int getWaitingForVehicleNumber() const
Returns the number of transportables waiting for a ride.
int getEndedNumber() const
Returns the number of transportables that exited the simulation.
void fixLoadCount()
decrement counter to avoid double counting transportables loaded from state
void forceDeparture()
register forced (traci) departure
void checkWaiting(MSNet *net, const SUMOTime time)
checks whether any transportables waiting time is over
int size() const
Returns the number of known transportables.
MSPModel * getNonInteractingModel()
Returns the non interacting movement model (for tranship and "beaming")
int getArrivedNumber() const
Returns the number of transportables that arrived at their destination.
void saveState(OutputDevice &out)
Saves the current state into the given stream.
MSTransportableControl(const bool isPerson)
Constructor.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, std::mt19937 *rng) const
Builds a new person.
int getLoadedNumber() const
Returns the number of build transportables.
int getWaitingUntilNumber() const
Returns the number of transportables waiting for a specified amount of time.
MSTransportableControl & operator=(const MSTransportableControl &src)=delete
invalidated assignment operator
int myLoadedNumber
The number of build transportables.
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
std::map< std::string, MSTransportable * > myTransportables
all currently created transportables by id
void abortWaiting(MSTransportable *t)
aborts waiting stage of transportable
void abortWaitingForVehicle(MSTransportable *t)
let the given transportable abort waiting for a vehicle (when removing stage via TraCI)
void abortAnyWaitingForVehicle()
aborts the plan for any transportable that is still waiting for a ride
bool hasNonWaiting() const
checks whether any transportable is still engaged in walking / stopping
virtual MSTransportable * buildContainer(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan) const
Builds a new container.
int myArrivedNumber
The number of transportables that arrived at their destination.
int getMovingNumber() const
Returns the number of transportables moving by themselvs (i.e. walking)
void addWaiting(const MSEdge *edge, MSTransportable *person)
adds a transportable to the list of transportables waiting for a vehicle on the specified edge
int myEndedNumber
The number of transportables that exited the simulation.
int getJammedNumber() const
Returns the number of times a transportables was jammed.
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...
std::map< const MSEdge *, TransportableVector > myWaiting4Vehicle
the lists of waiting transportables
int myWaitingUntilNumber
The number of transportables waiting for a specified time.
virtual void erase(MSTransportable *transportable)
removes a single transportable
int myDiscardedNumber
The number of discarded transportables.
std::map< SUMOTime, TransportableVector > myWaitingUntil
the lists of walking / stopping transportables
bool add(MSTransportable *transportable)
Adds a single transportable, returns false if an id clash occurred.
bool myHaveNewWaiting
whether a new transportable waiting for a vehicle has been added in the last step
virtual ~MSTransportableControl()
Destructor.
int myJammedNumber
The number of jammed transportables.
std::map< SUMOTime, TransportableVector > myWaiting4Departure
Transportables waiting for departure.
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...
void registerJammed()
register a jammed transportable
std::vector< MSTransportable * > TransportableVector
Definition of a list of transportables.
int myRunningNumber
The number of transportables within the network (build and inserted but not removed)
int myWaitingForVehicleNumber
The number of transportables waiting for vehicles.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
int getActiveCount()
return the number of active transportable objects
int getRidingNumber() const
Returns the number of transportables riding a vehicle.
std::vector< MSStage * > MSTransportablePlan
the structure holding the plan of a transportable
The car-following model and parameter.
Definition: MSVehicleType.h:62
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
Representation of a vehicle.
Definition: SUMOVehicle.h:58
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.