Eclipse SUMO - Simulation of Urban MObility
MSNet.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-2022 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 /****************************************************************************/
25 // The simulated network and simulation performer
26 /****************************************************************************/
27 #pragma once
28 #include <config.h>
29 
30 #include <typeinfo>
31 #include <vector>
32 #include <map>
33 #include <string>
34 #include <fstream>
35 #include <iostream>
36 #include <cmath>
37 #include <iomanip>
38 #include <memory>
39 #include <utils/common/SUMOTime.h>
44 #include <mesosim/MESegment.h>
45 #include "MSJunction.h"
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class MSEdge;
52 class MSEdgeControl;
53 class MSEventControl;
54 class MSVehicleControl;
55 class MSJunctionControl;
56 class MSInsertionControl;
59 class MSTransportable;
60 class MSVehicle;
61 class MSRoute;
62 class MSLane;
63 class MSTLLogicControl;
65 class MSDetectorControl;
66 class ShapeContainer;
68 class PolygonDynamics;
70 class SUMOVehicle;
71 class SUMOTrafficObject;
73 class MSStoppingPlace;
74 template<class E, class L, class N, class V>
75 class IntermodalRouter;
76 template<class E, class L, class N, class V>
77 class PedestrianRouter;
78 class OptionsCont;
79 
80 
81 // ===========================================================================
82 // class definitions
83 // ===========================================================================
88 class MSNet : public Parameterised {
89 public:
110  };
111 
114 
116  struct Collision {
117  std::string victim;
118  std::string colliderType;
119  std::string victimType;
121  double victimSpeed;
122  std::string type;
123  const MSLane* lane;
124  double pos;
126  };
127 
128  typedef std::map<std::string, std::vector<Collision> > CollisionMap;
129 
130 public:
135  static MSNet* getInstance();
136 
140  virtual bool isGUINet() const {
141  return false;
142  }
143 
145  static void initStatic();
146 
148  static void cleanupStatic();
149 
150 
154  static bool hasInstance() {
155  return myInstance != nullptr;
156  }
157 
158 
173  MSNet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
174  MSEventControl* endOfTimestepEvents,
175  MSEventControl* insertionEvents,
176  ShapeContainer* shapeCont = 0);
177 
178 
180  virtual ~MSNet();
181 
182 
198  void closeBuilding(const OptionsCont& oc, MSEdgeControl* edges, MSJunctionControl* junctions,
199  SUMORouteLoaderControl* routeLoaders, MSTLLogicControl* tlc,
200  std::vector<SUMOTime> stateDumpTimes, std::vector<std::string> stateDumpFiles,
201  bool hasInternalLinks,
202  bool junctionHigherSpeeds,
203  double version);
204 
205 
209  bool hasPermissions() const {
210  return myHavePermissions;
211  }
212 
213 
216  myHavePermissions = true;
217  }
218 
219 
225  void addRestriction(const std::string& id, const SUMOVehicleClass svc, const double speed);
226 
227 
233  const std::map<SUMOVehicleClass, double>* getRestrictions(const std::string& id) const;
234 
239  void addMesoType(const std::string& typeID, const MESegment::MesoEdgeType& edgeType);
240 
244  const MESegment::MesoEdgeType& getMesoType(const std::string& typeID);
245 
249  static void clearAll();
250 
251 
260 
261 
265  void simulationStep();
266 
267 
269  void loadRoutes();
270 
271 
276  const std::string generateStatistics(SUMOTime start);
277 
279  void writeCollisions() const;
280 
282  void writeStatistics() const;
283 
290  void closeSimulation(SUMOTime start, const std::string& reason = "");
291 
292 
298  SimulationState simulationState(SUMOTime stopTime) const;
299 
300 
306  SimulationState adaptToState(const SimulationState state) const;
307 
308 
312  static std::string getStateMessage(SimulationState state);
313 
314 
318  inline SUMOTime getCurrentTimeStep() const {
319  return myStep;
320  }
321 
322 
326  inline void setCurrentTimeStep(const SUMOTime step) {
327  myStep = step;
328  }
329 
330 
334  void clearState(const SUMOTime step);
335 
339  void writeOutput();
340 
341 
345  bool logSimulationDuration() const;
346 
347 
348 
350 
351 
356  void preSimStepOutput() const;
357 
358 
363  void postSimStepOutput() const;
364  //}
365 
366 
367 
370 
377  return *myVehicleControl;
378  }
379 
380 
390 
393  bool hasPersons() const {
394  return myPersonControl != nullptr;
395  }
396 
406 
409  bool hasContainers() const {
410  return myContainerControl != nullptr;
411  }
412 
413 
420  return *myEdges;
421  }
422 
423 
430  return *myInserter;
431  }
432 
433 
440  return *myDetectorControl;
441  }
442 
443 
450  return *myLogics;
451  }
452 
453 
460  return *myJunctions;
461  }
462 
463 
471  }
472 
473 
480  return myEndOfTimestepEvents;
481  }
482 
483 
490  return myInsertionEvents;
491  }
492 
493 
500  return *myShapeContainer;
501  }
502 
507  return myDynamicShapeUpdater.get();
508  }
509 
514 
522 
525 
536  bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace* stop);
537 
538 
548 
549 
555  MSStoppingPlace* getStoppingPlace(const std::string& id, const SumoXMLTag category) const;
556 
563  std::string getStoppingPlaceID(const MSLane* lane, const double pos, const SumoXMLTag category) const;
565 
567 
569  void writeChargingStationOutput() const;
570 
572  void writeRailSignalBlocks() const;
573 
576 
578  void writeOverheadWireSegmentOutput() const;
579 
581  void writeSubstationOutput() const;
582 
584  virtual bool isSelected(const MSTrafficLightLogic*) const {
585  return false;
586  }
588  virtual void updateGUI() const { }
589 
592 
594  enum class VehicleState {
596  BUILT,
598  DEPARTED,
604  ARRIVED,
606  NEWROUTE,
614  ENDING_STOP,
616  COLLISION,
621  };
622 
623 
628  public:
631 
633  virtual ~VehicleStateListener() { }
634 
640  virtual void vehicleStateChanged(const SUMOVehicle* const vehicle, VehicleState to, const std::string& info = "") = 0;
641 
642  };
643 
644 
649 
650 
655 
656 
663  void informVehicleStateListener(const SUMOVehicle* const vehicle, VehicleState to, const std::string& info = "");
665 
666 
669 
671  enum class TransportableState {
680  };
681 
682 
687  public:
690 
693 
699  virtual void transportableStateChanged(const MSTransportable* const transportable, TransportableState to, const std::string& info = "") = 0;
700 
701  };
702 
703 
708 
709 
714 
715 
722  void informTransportableStateListener(const MSTransportable* const transportable, TransportableState to, const std::string& info = "");
724 
725 
727  bool registerCollision(const SUMOTrafficObject* collider, const SUMOTrafficObject* victim, const std::string& collisionType, const MSLane* lane, double pos);
728 
729  const CollisionMap& getCollisions() const {
730  return myCollisions;
731  }
732 
733 
741  static double getTravelTime(const MSEdge* const e, const SUMOVehicle* const v, double t);
742 
743 
751  static double getEffort(const MSEdge* const e, const SUMOVehicle* const v, double t);
752 
753 
754  /* @brief get the router, initialize on first use
755  * @param[in] prohibited The vector of forbidden edges (optional)
756  */
758  const MSEdgeVector& prohibited = MSEdgeVector()) const;
760  const MSEdgeVector& prohibited = MSEdgeVector()) const;
761  MSPedestrianRouter& getPedestrianRouter(const int rngIndex, const MSEdgeVector& prohibited = MSEdgeVector()) const;
762  MSIntermodalRouter& getIntermodalRouter(const int rngIndex, const int routingMode = 0, const MSEdgeVector& prohibited = MSEdgeVector()) const;
763 
764  static void adaptIntermodalRouter(MSIntermodalRouter& router);
765 
766 
768  bool hasInternalLinks() const {
769  return myHasInternalLinks;
770  }
771 
773  bool hasJunctionHigherSpeeds() const {
774  return myJunctionHigherSpeeds;
775  }
776 
778  bool hasElevation() const {
779  return myHasElevation;
780  }
781 
783  bool hasPedestrianNetwork() const {
784  return myHasPedestrianNetwork;
785 
786  }
788  bool hasBidiEdges() const {
789  return myHasBidiEdges;
790  }
791 
793  double getNetworkVersion() const {
794  return myVersion;
795  }
796 
798  bool warnOnce(const std::string& typeAndID);
799 
800  void interrupt() {
801  myAmInterrupted = true;
802  }
803 
804  bool isInterrupted() const {
805  return myAmInterrupted;
806  }
807 
809  MSTractionSubstation* findTractionSubstation(const std::string& substationId);
810 
812  bool existTractionSubstation(const std::string& substationId);
813 
815  static const std::string STAGE_EVENTS;
816  static const std::string STAGE_MOVEMENTS;
817  static const std::string STAGE_LANECHANGE;
818  static const std::string STAGE_INSERTIONS;
819 
820 protected:
822  bool checkElevation();
823 
825  bool checkWalkingarea();
826 
828  bool checkBidiEdges();
829 
832 
833 protected:
835  static MSNet* myInstance;
836 
839 
842 
845 
848 
849 
850 
853 
881 
882 
883 
886 
889 
894 
897 
900 
903 
905  long long int myVehiclesMoved;
906  long long int myPersonsMoved;
907  //}
908 
909 
910 
913 
915  std::vector<SUMOTime> myStateDumpTimes;
917  std::vector<std::string> myStateDumpFiles;
919  std::vector<std::string> myPeriodicStateFiles;
923  std::string myStateDumpPrefix;
924  std::string myStateDumpSuffix;
926 
927 
928 
931 
933  std::map<std::string, std::map<SUMOVehicleClass, double> > myRestrictions;
934 
936  std::map<std::string, MESegment::MesoEdgeType> myMesoEdgeTypes;
937 
940 
943 
946 
949 
952 
955 
957  double myVersion;
958 
961 
963  std::map<SumoXMLTag, NamedObjectCont<MSStoppingPlace*> > myStoppingPlaces;
964 
966  std::vector<MSTractionSubstation*> myTractionSubstations;
967 
969  std::vector<VehicleStateListener*> myVehicleStateListeners;
970 
972  std::vector<TransportableStateListener*> myTransportableStateListeners;
973 
976 
977 #ifdef HAVE_FOX
979  FXMutex myVehicleStateListenerMutex;
980 
982  FXMutex myTransportableStateListenerMutex;
983 #endif
984 
986  std::map<std::string, bool> myWarnedOnce;
987 
988  /* @brief The router instance for routing by trigger and by traci
989  * @note MSDevice_Routing has its own instance since it uses a different weight function
990  * @note we provide one member for every switchable router type
991  * because the class structure makes it inconvenient to use a superclass
992  */
993  mutable std::map<int, SUMOAbstractRouter<MSEdge, SUMOVehicle>*> myRouterTT;
994  mutable std::map<int, SUMOAbstractRouter<MSEdge, SUMOVehicle>*> myRouterEffort;
995  mutable std::map<int, MSPedestrianRouter*> myPedestrianRouter;
996  mutable std::map<int, MSIntermodalRouter*> myIntermodalRouter;
997 
999  mutable std::pair<bool, NamedRTree> myLanesRTree;
1000 
1004  std::unique_ptr<MSDynamicShapeUpdater> myDynamicShapeUpdater;
1005 
1006 private:
1008  MSNet(const MSNet&);
1009 
1012 
1013 
1014 };
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:73
long long int SUMOTime
Definition: SUMOTime.h:32
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLTag
Numbers representing SUMO-XML - element names.
Detectors container; responsible for string and output generation.
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:81
A road/street connecting two junctions.
Definition: MSEdge.h:77
A storage for edge travel times and efforts.
Stores time-dependant events and executes them at the proper time.
Inserts vehicles into the network when their departure time is reached.
Container for junctions; performs operations on all stored junctions.
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Interface for objects listening to transportable state changes.
Definition: MSNet.h:686
virtual void transportableStateChanged(const MSTransportable *const transportable, TransportableState to, const std::string &info="")=0
Called if a transportable changes its state.
TransportableStateListener()
Constructor.
Definition: MSNet.h:689
virtual ~TransportableStateListener()
Destructor.
Definition: MSNet.h:692
Interface for objects listening to vehicle state changes.
Definition: MSNet.h:627
virtual ~VehicleStateListener()
Destructor.
Definition: MSNet.h:633
virtual void vehicleStateChanged(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")=0
Called if a vehicle changes its state.
VehicleStateListener()
Constructor.
Definition: MSNet.h:630
The simulated network and simulation perfomer.
Definition: MSNet.h:88
std::map< SumoXMLTag, NamedObjectCont< MSStoppingPlace * > > myStoppingPlaces
Dictionary of bus / container stops.
Definition: MSNet.h:963
long myTraCIMillis
The overall time spent waiting for traci operations including.
Definition: MSNet.h:902
static double getEffort(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the effort to pass an edge.
Definition: MSNet.cpp:143
bool warnOnce(const std::string &typeAndID)
return whether a warning regarding the given object shall be issued
Definition: MSNet.cpp:1510
std::map< int, SUMOAbstractRouter< MSEdge, SUMOVehicle > * > myRouterEffort
Definition: MSNet.h:994
MSIntermodalRouter & getIntermodalRouter(const int rngIndex, const int routingMode=0, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1390
bool myLogExecutionTime
Information whether the simulation duration shall be logged.
Definition: MSNet.h:888
MSTransportableControl * myPersonControl
Controls person building and deletion;.
Definition: MSNet.h:857
void removeVehicleStateListener(VehicleStateListener *listener)
Removes a vehicle states listener.
Definition: MSNet.cpp:1135
SUMORouteLoaderControl * myRouteLoaders
Route loader for dynamic loading of routes.
Definition: MSNet.h:838
bool addStoppingPlace(const SumoXMLTag category, MSStoppingPlace *stop)
Adds a stopping place.
Definition: MSNet.cpp:1234
void informTransportableStateListener(const MSTransportable *const transportable, TransportableState to, const std::string &info="")
Informs all added listeners about a transportable's state change.
Definition: MSNet.cpp:1172
SUMOTime myStateDumpPeriod
The period for writing state.
Definition: MSNet.h:921
const std::string generateStatistics(SUMOTime start)
Writes performance output and running vehicle stats.
Definition: MSNet.cpp:423
void writeOverheadWireSegmentOutput() const
write the output generated by an overhead wire segment
Definition: MSNet.cpp:1307
void writeChargingStationOutput() const
write charging station output
Definition: MSNet.cpp:1284
std::pair< bool, NamedRTree > myLanesRTree
An RTree structure holding lane IDs.
Definition: MSNet.h:999
bool checkBidiEdges()
check wether bidirectional edges occur in the network
Definition: MSNet.cpp:1500
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:594
@ ENDING_PARKING
The vehicle ends to park.
@ STARTING_STOP
The vehicles starts to stop.
@ BUILT
The vehicle was built, but has not yet departed.
@ STARTING_PARKING
The vehicles starts to park.
@ NEWROUTE
The vehicle got a new route.
@ STARTING_TELEPORT
The vehicle started to teleport.
@ ENDING_STOP
The vehicle ends to stop.
@ ENDING_TELEPORT
The vehicle ended being teleported.
@ ARRIVED
The vehicle arrived at his destination (is deleted)
@ DEPARTED
The vehicle has departed (was inserted into the network)
@ COLLISION
The vehicle is involved in a collision.
@ EMERGENCYSTOP
The vehicle had to brake harder than permitted.
@ MANEUVERING
Vehicle maneuvering either entering or exiting a parking space.
int myLogStepPeriod
Period between successive step-log outputs.
Definition: MSNet.h:893
SUMOTime myStep
Current time step.
Definition: MSNet.h:841
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition: MSNet.h:439
virtual bool isSelected(const MSTrafficLightLogic *) const
return wheter the given logic (or rather it's wrapper) is selected in the GUI
Definition: MSNet.h:584
bool myHasBidiEdges
Whether the network contains bidirectional rail edges.
Definition: MSNet.h:951
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:449
MSEventControl * myBeginOfTimestepEvents
Controls events executed at the begin of a time step;.
Definition: MSNet.h:871
bool addTractionSubstation(MSTractionSubstation *substation)
Adds a traction substation.
Definition: MSNet.cpp:1240
std::map< std::string, bool > myWarnedOnce
container to record warnings that shall only be issued once
Definition: MSNet.h:986
static void initStatic()
Place for static initializations of simulation components (called after successful net build)
Definition: MSNet.cpp:182
void removeOutdatedCollisions()
remove collisions from the previous simulation step
Definition: MSNet.cpp:1215
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition: MSNet.h:863
std::vector< std::string > myPeriodicStateFiles
The names of the last K periodic state files (only only K shall be kept)
Definition: MSNet.h:919
const CollisionMap & getCollisions() const
Definition: MSNet.h:729
ShapeContainer * myShapeContainer
A container for geometrical shapes;.
Definition: MSNet.h:877
bool hasBidiEdges() const
return whether the network contains bidirectional rail edges
Definition: MSNet.h:788
double myVersion
the network version
Definition: MSNet.h:957
std::string myStateDumpSuffix
Definition: MSNet.h:924
MSDynamicShapeUpdater * getDynamicShapeUpdater()
Returns the dynamic shapes updater.
Definition: MSNet.h:506
bool checkElevation()
check all lanes for elevation data
Definition: MSNet.cpp:1475
bool myHavePermissions
Whether the network contains edges which not all vehicles may pass.
Definition: MSNet.h:930
bool existTractionSubstation(const std::string &substationId)
return whether given electrical substation exists in the network
Definition: MSNet.cpp:1341
void removeTransportableStateListener(TransportableStateListener *listener)
Removes a transportable states listener.
Definition: MSNet.cpp:1163
bool myLogStepNumber
Information whether the number of the simulation step shall be logged.
Definition: MSNet.h:891
MSEventControl * myInsertionEvents
Controls insertion events;.
Definition: MSNet.h:875
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:1068
void closeBuilding(const OptionsCont &oc, MSEdgeControl *edges, MSJunctionControl *junctions, SUMORouteLoaderControl *routeLoaders, MSTLLogicControl *tlc, std::vector< SUMOTime > stateDumpTimes, std::vector< std::string > stateDumpFiles, bool hasInternalLinks, bool junctionHigherSpeeds, double version)
Closes the network's building process.
Definition: MSNet.cpp:247
SimulationState
Possible states of a simulation - running or stopped with different reasons.
Definition: MSNet.h:93
@ SIMSTATE_TOO_MANY_TELEPORTS
The simulation had too many teleports.
Definition: MSNet.h:109
@ SIMSTATE_NO_FURTHER_VEHICLES
The simulation does not contain further vehicles.
Definition: MSNet.h:101
@ SIMSTATE_LOADING
The simulation is loading.
Definition: MSNet.h:95
@ SIMSTATE_ERROR_IN_SIM
An error occurred during the simulation step.
Definition: MSNet.h:105
@ SIMSTATE_CONNECTION_CLOSED
The connection to a client was closed by the client.
Definition: MSNet.h:103
@ SIMSTATE_INTERRUPTED
An external interrupt occured.
Definition: MSNet.h:107
@ SIMSTATE_RUNNING
The simulation is running.
Definition: MSNet.h:97
@ SIMSTATE_END_STEP_REACHED
The final simulation step has been performed.
Definition: MSNet.h:99
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterTT(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1352
std::map< int, MSPedestrianRouter * > myPedestrianRouter
Definition: MSNet.h:995
static const std::string STAGE_MOVEMENTS
Definition: MSNet.h:816
int myMaxTeleports
Maximum number of teleports.
Definition: MSNet.h:844
long mySimStepDuration
Definition: MSNet.h:896
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:376
PedestrianRouter< MSEdge, MSLane, MSJunction, MSVehicle > MSPedestrianRouter
Definition: MSNet.h:112
MSEventControl * myEndOfTimestepEvents
Controls events executed at the end of a time step;.
Definition: MSNet.h:873
static std::string getStateMessage(SimulationState state)
Returns the message to show if a certain state occurs.
Definition: MSNet.cpp:774
std::string getStoppingPlaceID(const MSLane *lane, const double pos, const SumoXMLTag category) const
Returns the stop of the given category close to the given position.
Definition: MSNet.cpp:1259
bool myHasInternalLinks
Whether the network contains internal links/lanes/edges.
Definition: MSNet.h:939
void interrupt()
Definition: MSNet.h:800
double getNetworkVersion() const
return the network version
Definition: MSNet.h:793
SimulationState adaptToState(const SimulationState state) const
Called after a simulation step, this method adapts the current simulation state if necessary.
Definition: MSNet.cpp:753
void writeSubstationOutput() const
write electrical substation output
Definition: MSNet.cpp:1318
static const std::string STAGE_INSERTIONS
Definition: MSNet.h:818
long long int myPersonsMoved
Definition: MSNet.h:906
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
Definition: MSNet.h:855
ShapeContainer & getShapeContainer()
Returns the shapes container.
Definition: MSNet.h:499
bool hasJunctionHigherSpeeds() const
return whether the network was built with higher junction speeds
Definition: MSNet.h:773
static void clearAll()
Clears all dictionaries.
Definition: MSNet.cpp:799
static void cleanupStatic()
Place for static initializations of simulation components (called after successful net build)
Definition: MSNet.cpp:189
void setPermissionsFound()
Labels the network to contain vehicle class permissions.
Definition: MSNet.h:215
MSJunctionControl & getJunctionControl()
Returns the junctions control.
Definition: MSNet.h:459
IntermodalRouter< MSEdge, MSLane, MSJunction, SUMOVehicle > MSIntermodalRouter
Definition: MSNet.h:113
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:318
std::map< std::string, std::vector< Collision > > CollisionMap
Definition: MSNet.h:128
MSEdgeControl * myEdges
Controls edges, performs vehicle movement;.
Definition: MSNet.h:861
std::unique_ptr< MSDynamicShapeUpdater > myDynamicShapeUpdater
Updater for dynamic shapes that are tracking traffic objects (ensures removal of shape dynamics when ...
Definition: MSNet.h:1004
const std::map< SUMOVehicleClass, double > * getRestrictions(const std::string &id) const
Returns the restrictions for an edge type If no restrictions are present, 0 is returned.
Definition: MSNet.cpp:340
static bool hasInstance()
Returns whether the network was already constructed.
Definition: MSNet.h:154
void closeSimulation(SUMOTime start, const std::string &reason="")
Closes the simulation (all files, connections, etc.)
Definition: MSNet.cpp:545
MSEventControl * getEndOfTimestepEvents()
Returns the event control for events executed at the end of a time step.
Definition: MSNet.h:479
MSStoppingPlace * getStoppingPlace(const std::string &id, const SumoXMLTag category) const
Returns the named stopping place of the given category.
Definition: MSNet.cpp:1250
void simulationStep()
Performs a single simulation step.
Definition: MSNet.cpp:583
bool myHasElevation
Whether the network contains elevation data.
Definition: MSNet.h:945
static double getTravelTime(const MSEdge *const e, const SUMOVehicle *const v, double t)
Returns the travel time to pass an edge.
Definition: MSNet.cpp:157
MSTransportableControl * myContainerControl
Controls container building and deletion;.
Definition: MSNet.h:859
std::vector< TransportableStateListener * > myTransportableStateListeners
Container for transportable state listener.
Definition: MSNet.h:972
void writeOutput()
Write netstate, summary and detector output.
Definition: MSNet.cpp:872
virtual void updateGUI() const
update view after simulation.loadState
Definition: MSNet.h:588
void setCurrentTimeStep(const SUMOTime step)
Sets the current simulation step (used by state loading)
Definition: MSNet.h:326
bool myAmInterrupted
whether an interrupt occured
Definition: MSNet.h:847
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:1127
void preSimStepOutput() const
Prints the current step number.
Definition: MSNet.cpp:1091
void writeCollisions() const
write collision output to (xml) file
Definition: MSNet.cpp:493
MSEdgeControl & getEdgeControl()
Returns the edge control.
Definition: MSNet.h:419
std::vector< SUMOTime > myStateDumpTimes
Times at which a state shall be written.
Definition: MSNet.h:915
bool hasContainers() const
Returns whether containers are simulated.
Definition: MSNet.h:409
void addTransportableStateListener(TransportableStateListener *listener)
Adds a transportable states listener.
Definition: MSNet.cpp:1155
std::vector< MSTractionSubstation * > myTractionSubstations
Dictionary of traction substations.
Definition: MSNet.h:966
SUMOTime myEdgeDataEndTime
end of loaded edgeData
Definition: MSNet.h:960
MSEdgeWeightsStorage & getWeightsStorage()
Returns the net's internal edge travel times/efforts container.
Definition: MSNet.cpp:1082
std::map< std::string, std::map< SUMOVehicleClass, double > > myRestrictions
The vehicle class specific speed restrictions.
Definition: MSNet.h:933
std::vector< std::string > myStateDumpFiles
The names for the state files.
Definition: MSNet.h:917
void addMesoType(const std::string &typeID, const MESegment::MesoEdgeType &edgeType)
Adds edge type specific meso parameters.
Definition: MSNet.cpp:349
void writeRailSignalBlocks() const
write rail signal block output
Definition: MSNet.cpp:1295
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:429
MSEventControl * getInsertionEvents()
Returns the event control for insertion events.
Definition: MSNet.h:489
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
Definition: MSNet.h:865
bool logSimulationDuration() const
Returns whether duration shall be logged.
Definition: MSNet.cpp:1053
bool hasPedestrianNetwork() const
return whether the network contains walkingareas and crossings
Definition: MSNet.h:783
long long int myVehiclesMoved
The overall number of vehicle movements.
Definition: MSNet.h:905
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle's state change.
Definition: MSNet.cpp:1144
bool isInterrupted() const
Definition: MSNet.h:804
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
Definition: MSNet.h:469
std::vector< VehicleStateListener * > myVehicleStateListeners
Container for vehicle state listener.
Definition: MSNet.h:969
SimulationState simulationState(SUMOTime stopTime) const
This method returns the current simulation state. It should not modify status.
Definition: MSNet.cpp:723
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:393
long myTraCIStepDuration
The last simulation step duration.
Definition: MSNet.h:896
TransportableState
Definition of a transportable state.
Definition: MSNet.h:671
@ CONTAINER_DEPARTED
The transportable container has departed (was inserted into the network)
@ PERSON_DEPARTED
The transportable person has departed (was inserted into the network)
@ PERSON_ARRIVED
The transportable person arrived at his destination (is deleted)
@ CONTAINER_ARRIVED
The transportable container arrived at his destination (is deleted)
MSDetectorControl * myDetectorControl
Controls detectors;.
Definition: MSNet.h:869
static const std::string STAGE_LANECHANGE
Definition: MSNet.h:817
MSNet(const MSNet &)
Invalidated copy constructor.
MSNet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents, ShapeContainer *shapeCont=0)
Constructor.
Definition: MSNet.cpp:196
void addRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition: MSNet.cpp:334
bool hasPermissions() const
Returns whether the network has specific vehicle class permissions.
Definition: MSNet.h:209
std::map< int, SUMOAbstractRouter< MSEdge, SUMOVehicle > * > myRouterTT
Definition: MSNet.h:993
std::map< std::string, MESegment::MesoEdgeType > myMesoEdgeTypes
The edge type specific meso parameters.
Definition: MSNet.h:936
static void adaptIntermodalRouter(MSIntermodalRouter &router)
Definition: MSNet.cpp:1439
bool myLefthand
Whether the network was built for left-hand traffic.
Definition: MSNet.h:954
MSEdgeWeightsStorage * myEdgeWeights
The net's knowledge about edge efforts/travel times;.
Definition: MSNet.h:879
MSDynamicShapeUpdater * makeDynamicShapeUpdater()
Creates and returns a dynamic shapes updater.
Definition: MSNet.cpp:1076
MSNet & operator=(const MSNet &)
Invalidated assignment operator.
std::map< int, MSIntermodalRouter * > myIntermodalRouter
Definition: MSNet.h:996
virtual ~MSNet()
Destructor.
Definition: MSNet.cpp:282
MSPedestrianRouter & getPedestrianRouter(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1380
MSTractionSubstation * findTractionSubstation(const std::string &substationId)
find electrical substation by its id
Definition: MSNet.cpp:1330
static MSNet * myInstance
Unique instance of MSNet.
Definition: MSNet.h:835
virtual void createTLWrapper(MSTrafficLightLogic *)
creates a wrapper for the given logic (see GUINet)
Definition: MSNet.h:575
MSInsertionControl * myInserter
Controls vehicle insertion;.
Definition: MSNet.h:867
void postSimStepOutput() const
Prints the statistics of the step at its end.
Definition: MSNet.cpp:1097
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:1059
bool registerCollision(const SUMOTrafficObject *collider, const SUMOTrafficObject *victim, const std::string &collisionType, const MSLane *lane, double pos)
register collision and return whether it was the first one involving these vehicles
Definition: MSNet.cpp:1183
static const std::string STAGE_EVENTS
string constants for simstep stages
Definition: MSNet.h:815
void loadRoutes()
loads routes for the next few steps
Definition: MSNet.cpp:417
std::string myStateDumpPrefix
name components for periodic state
Definition: MSNet.h:923
void clearState(const SUMOTime step)
Resets events when quick-loading state.
Definition: MSNet.cpp:824
bool myJunctionHigherSpeeds
Whether the network was built with higher speed on junctions.
Definition: MSNet.h:942
long mySimBeginMillis
The overall simulation duration.
Definition: MSNet.h:899
virtual bool isGUINet() const
Returns whether this is a GUI Net.
Definition: MSNet.h:140
bool myHasPedestrianNetwork
Whether the network contains pedestrian network elements.
Definition: MSNet.h:948
const MESegment::MesoEdgeType & getMesoType(const std::string &typeID)
Returns edge type specific meso parameters if no type specific parameters have been loaded,...
Definition: MSNet.cpp:354
void writeStatistics() const
write statistic output to (xml) file
Definition: MSNet.cpp:515
bool hasInternalLinks() const
return whether the network contains internal links
Definition: MSNet.h:768
SUMOAbstractRouter< MSEdge, SUMOVehicle > & getRouterEffort(const int rngIndex, const MSEdgeVector &prohibited=MSEdgeVector()) const
Definition: MSNet.cpp:1370
bool checkWalkingarea()
check all lanes for type walkingArea
Definition: MSNet.cpp:1489
CollisionMap myCollisions
collisions in the current time step
Definition: MSNet.h:975
bool hasElevation() const
return whether the network contains elevation data
Definition: MSNet.h:778
const NamedObjectCont< MSStoppingPlace * > & getStoppingPlaces(SumoXMLTag category) const
Definition: MSNet.cpp:1273
SimulationState simulate(SUMOTime start, SUMOTime stop)
Simulates from timestep start to stop.
Definition: MSNet.cpp:375
A lane area vehicles can halt at.
A class that stores and controls tls and switching of their programs.
Traction substaction powering one or more overhead wire sections.
The parent class for traffic light logics.
The class responsible for building and deletion of vehicles.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:75
A map of named object pointers.
A storage for options typed value containers)
Definition: OptionsCont.h:89
An upper class for objects with additional parameters.
Definition: Parameterised.h:41
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
Storage for geometrical objects.
edge type specific meso parameters
Definition: MESegment.h:55
collision tracking
Definition: MSNet.h:116
double victimSpeed
Definition: MSNet.h:121
const MSLane * lane
Definition: MSNet.h:123
std::string victimType
Definition: MSNet.h:119
double pos
Definition: MSNet.h:124
std::string type
Definition: MSNet.h:122
std::string colliderType
Definition: MSNet.h:118
std::string victim
Definition: MSNet.h:117
double colliderSpeed
Definition: MSNet.h:120
SUMOTime time
Definition: MSNet.h:125