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.dev/sumo
3 // Copyright (C) 2001-2024 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>
28 #include <microsim/MSVehicle.h>
31 
32 
33 // ===========================================================================
34 // class declarations
35 // ===========================================================================
36 class MSNet;
37 class MSPModel;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
52 public:
54  typedef std::vector<MSTransportable*> TransportableVector;
55 
57  typedef std::map<std::string, MSTransportable*>::const_iterator constVehIt;
58 
59 
60 public:
62  MSTransportableControl(const bool isPerson);
63 
64 
66  virtual ~MSTransportableControl();
67 
68 
73  bool add(MSTransportable* transportable);
74 
75 
80  MSTransportable* get(const std::string& id) const;
81 
82 
84  virtual void erase(MSTransportable* transportable);
85 
87  void setWaitEnd(SUMOTime time, MSTransportable* transportable);
88 
90  void checkWaiting(MSNet* net, const SUMOTime time);
91 
93  void addWaiting(const MSEdge* edge, MSTransportable* person);
94 
96  void forceDeparture();
97 
99  bool hasAnyWaiting(const MSEdge* edge, SUMOVehicle* vehicle) const;
100 
109  bool loadAnyWaiting(const MSEdge* edge, SUMOVehicle* vehicle, SUMOTime& timeToLoadNext, SUMOTime& stopDuration);
110 
112  bool hasTransportables() const;
113 
115  bool hasNonWaiting() const;
116 
118  int getActiveCount();
119 
122 
125 
127  void abortWaiting(MSTransportable* t);
128 
136  SumoRNG* rng) const;
137 
144 
149  return myTransportables.begin();
150  }
151 
152 
157  return myTransportables.end();
158  }
159 
160 
164  int size() const {
165  return (int)myTransportables.size();
166  }
167 
169  void registerJammed() {
170  myJammedNumber++;
171  }
172 
176  }
177 
181  }
182 
184  void fixLoadCount(const MSTransportable* transportable);
185 
188 
192  int getLoadedNumber() const {
193  return myLoadedNumber;
194  }
195 
196  int getDepartedNumber() const;
197 
201  int getRunningNumber() const {
202  return myRunningNumber;
203  }
204 
208  int getJammedNumber() const {
209  return myJammedNumber;
210  }
211 
216  }
217 
221  int getWaitingUntilNumber() const {
222  return myWaitingUntilNumber;
223  }
224 
227  int getMovingNumber() const;
228 
231  int getRidingNumber() const;
232 
235  int getEndedNumber() const {
236  return myEndedNumber;
237  }
238 
242  int getArrivedNumber() const {
243  return myArrivedNumber;
244  }
245 
247  int getTeleportsAbortWait() const {
248  return myTeleportsAbortWait;
249  }
250 
252  int getTeleportsWrongDest() const {
253  return myTeleportsWrongDest;
254  }
255 
257  int getTeleportCount() const {
259  }
260 
262 
267  return myMovementModel;
268  }
269 
274  return myNonInteractingModel;
275  }
276 
277  void addArrived() {
278  myArrivedNumber++;
279  }
280 
281  void addDiscarded() {
282  myLoadedNumber++;
284  }
285 
286  void startedAccess() {
287  myAccessNumber++;
288  }
289 
290  void endedAccess() {
291  myAccessNumber--;
292  }
293 
296  void saveState(OutputDevice& out);
297 
300  void loadState(const std::string& state);
301 
303  void clearState();
304 
306  return myRouteInfos;
307  }
308 
309 protected:
311  std::map<std::string, MSTransportable*> myTransportables;
312 
314  std::map<SUMOTime, TransportableVector> myWaiting4Departure;
315 
317  std::map<SUMOTime, TransportableVector> myWaitingUntil;
318 
320  std::map<const MSEdge*, TransportableVector, ComparatorNumericalIdLess> myWaiting4Vehicle;
321 
324 
327 
330 
333 
336 
339 
342 
345 
348 
351 
354 
357 
360 
361 private:
363 
365 
368 
371 
372 private:
375 };
long long int SUMOTime
Definition: GUI.h:35
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
int myAccessNumber
The number of transportables currently in an access stage.
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 forceDeparture()
register forced (traci) departure
void fixLoadCount(const MSTransportable *transportable)
decrement counter to avoid double counting transportables loaded from state
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 registerTeleportAbortWait()
register a teleport after aborting a long wait
void saveState(OutputDevice &out)
Saves the current state into the given stream.
MSTransportableControl(const bool isPerson)
Constructor.
int getTeleportCount() const
Returns the number of teleports transportables did.
int getLoadedNumber() const
Returns the number of build transportables.
bool hasAnyWaiting(const MSEdge *edge, SUMOVehicle *vehicle) const
check whether any transportables are waiting for the given vehicle
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.
int getTeleportsWrongDest() const
return the number of teleports of transportables riding to the wrong destination
int myTeleportsAbortWait
The number of teleports due to long waits for a ride.
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 registerTeleportWrongDest()
register a teleport to the final destination
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.
virtual MSTransportable * buildPerson(const SUMOVehicleParameter *pars, MSVehicleType *vtype, MSTransportable::MSTransportablePlan *plan, SumoRNG *rng) const
Builds a new person.
std::map< const MSEdge *, TransportableVector, ComparatorNumericalIdLess > myWaiting4Vehicle
the lists of waiting transportables
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
SUMOTime myAbortWaitingTimeout
The time until waiting for a ride is aborted.
int myEndedNumber
The number of transportables that exited the simulation.
bool loadAnyWaiting(const MSEdge *edge, SUMOVehicle *vehicle, SUMOTime &timeToLoadNext, SUMOTime &stopDuration)
load any applicable transportables Loads any person / container that is waiting on that edge for the ...
int getJammedNumber() const
Returns the number of times a transportables was jammed.
int myWaitingUntilNumber
The number of transportables waiting for a specified time.
void clearState()
Resets transportables when quick-loading state.
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.
int myTeleportsWrongDest
The number of teleports due to wrong destination.
std::map< SUMOTime, TransportableVector > myWaiting4Departure
Transportables waiting for departure.
const MSDevice_Vehroutes::SortedRouteInfo & getRouteInfo()
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.
int getTeleportsAbortWait() const
return the number of teleports due to excessive waiting for a ride
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
MSDevice_Vehroutes::SortedRouteInfo myRouteInfos
Information needed to sort transportable output by departure time.
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:63
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
Representation of a vehicle.
Definition: SUMOVehicle.h:60
Structure representing possible vehicle parameter.
Information needed to sort vehicle / transportable output by departure time.