Eclipse SUMO - Simulation of Urban MObility
GUINet.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 /****************************************************************************/
17 // A MSNet extended by some values for usage within the gui
18 /****************************************************************************/
19 #ifndef GUINet_h
20 #define GUINet_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <utility>
30 #include <microsim/MSNet.h>
32 #include <utils/geom/Boundary.h>
33 #include <utils/geom/Position.h>
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class MSEdgeControl;
49 class MSJunctionControl;
50 class MSTLLogicControl;
52 class MSLink;
53 class GUIJunctionWrapper;
54 class GUIDetectorWrapper;
56 class RGBColor;
57 class GUIEdge;
58 class OutputDevice;
59 class GUIVehicle;
60 class GUIVehicleControl;
61 class MSVehicleControl;
63 
64 
65 // ===========================================================================
66 // class definitions
67 // ===========================================================================
83 class GUINet : public MSNet, public GUIGlObject {
84 
85  friend class GUITrafficLightLogicWrapper; // see createTLWrapper
86 
87 public:
95  GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
96  MSEventControl* endOfTimestepEvents,
97  MSEventControl* insertionEvents);
98 
99 
101  ~GUINet();
102 
103 
107  bool isGUINet() const override {
108  return true;
109  }
110 
111 
113 
114 
123 
124 
133 
134 
140  Boundary getCenteringBoundary() const override;
141 
142 
147  void drawGL(const GUIVisualizationSettings& s) const override;
149 
150 
152  const Boundary& getBoundary() const;
153 
155  Position getJunctionPosition(const std::string& name) const;
156 
158  bool vehicleExists(const std::string& name) const;
159 
161  void guiSimulationStep();
162 
165  void simulationStep();
166 
169 
173  int getWholeDuration() const;
174 
175 
179  int getSimDuration() const;
180 
181 
183  double getRTFactor() const;
184 
186  double getUPS() const;
187 
189  double getMeanRTFactor(int duration) const;
190 
192  double getMeanUPS() const;
193 
194  // Returns the duration of the last step's visualisation part (in ms)
195  //int getVisDuration() const;
196 
198  int getIdleDuration() const;
199 
201  void setSimDuration(int val);
202 
203  // Sets the duration of the last step's visualisation part
204  //void setVisDuration(int val);
205 
207  void setIdleDuration(int val);
208  //}
209 
210  double getAvgRouteLength() const {
212  }
213  double getAvgDuration() const {
215  }
216  double getAvgWaitingTime() const {
218  }
219  double getAvgTimeLoss() const {
221  }
222  double getAvgDepartDelay() const {
224  }
225  double getAvgTripSpeed() const {
227  }
228  double getAvgWalkRouteLength() const {
230  }
231  double getAvgWalkDuration() const {
233  }
234  double getAvgWalkTimeLoss() const {
236  }
237 
247 
248 
258 
259 
262  int getLinkTLID(MSLink* link) const;
263 
266  int getLinkTLIndex(MSLink* link) const;
267 
268 
270 
271 
272  /* @brief Returns the gl-ids of all junctions within the net
273  * @param[in] includeInternal Whether to include ids of internal junctions
274  */
275  std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
276 
278  std::vector<GUIGlID> getTLSIDs() const;
280 
281 
283  void initGUIStructures();
284 
285 
290  return myGrid;
291  }
292 
293 
298  return myGrid;
299  }
300 
307 
314 
316  double getEdgeData(const MSEdge* edge, const std::string& attr);
317 
319  bool loadEdgeData(const std::string& file);
320 
321 
323  std::vector<std::string> getEdgeDataAttrs() const;
324 
325 #ifdef HAVE_OSG
326  void updateColor(const GUIVisualizationSettings& s);
327 #endif
328 
330  void lock();
331 
333  void unlock();
334 
339  static GUINet* getGUIInstance();
340 
342  void createTLWrapper(MSTrafficLightLogic* tll) override;
343 
345  bool isSelected(const MSTrafficLightLogic* tll) const override;
346 
347 private:
349  void initTLMap();
350 
351  friend class GUIOSGBuilder;
352 
353 protected:
356 
359 
361  std::vector<GUIEdge*> myEdgeWrapper;
362 
364  std::vector<GUIJunctionWrapper*> myJunctionWrapper;
365 
367  std::vector<GUIDetectorWrapper*> myDetectorWrapper;
368 
369 
371  typedef std::map<MSLink*, std::string> Links2LogicMap;
374 
375 
377  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
380 
381 
383  int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
384 
387 
389  std::map<std::string, MSEdgeWeightsStorage*> myLoadedEdgeData;
390 
393  public:
394  DiscoverAttributes(const std::string& file):
395  SUMOSAXHandler(file), lastIntervalEnd(0) {};
397  void myStartElement(int element, const SUMOSAXAttributes& attrs);
398  std::vector<std::string> getEdgeAttrs();
400  private:
401  std::set<std::string> edgeAttrs;
402  };
403 
405  public:
408 
411 
420  void addEdgeWeight(const std::string& id, double val, double beg, double end) const;
421 
422  private:
425 
426  };
427 
428 private:
430  mutable FXMutex myLock;
431 
432 };
433 
434 
435 #endif
436 
437 /****************************************************************************/
438 
GUINet::setIdleDuration
void setIdleDuration(int val)
Sets the duration of the last step's idle part.
Definition: GUINet.cpp:405
GUINet::getUPS
double getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:356
Boundary.h
GUINet::myBoundary
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:358
MSEventControl
Stores time-dependant events and executes them at the proper time.
Definition: MSEventControl.h:50
GUINet::DiscoverAttributes
class for discovering edge attributes
Definition: GUINet.h:392
GUINet::myLinks2Logic
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
Definition: GUINet.h:373
MSDevice_Tripinfo::getAvgWaitingTime
static double getAvgWaitingTime()
Definition: MSDevice_Tripinfo.cpp:400
GUIGlObject.h
GUINet::myGrid
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:355
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:63
GUINet::isGUINet
bool isGUINet() const override
Returns whether this is a GUI Net.
Definition: GUINet.h:107
GUINet::DiscoverAttributes::~DiscoverAttributes
~DiscoverAttributes()
Definition: GUINet.h:396
GUINet::myLoadedEdgeData
std::map< std::string, MSEdgeWeightsStorage * > myLoadedEdgeData
loaded edge data for visualization
Definition: GUINet.h:389
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:73
MSNet.h
GUINet::getMeanUPS
double getMeanUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:374
MSDevice_Tripinfo::getAvgWalkRouteLength
static double getAvgWalkRouteLength()
Definition: MSDevice_Tripinfo.cpp:430
SUMOSAXHandler
SAX-handler base for SUMO-files.
Definition: SUMOSAXHandler.h:42
GUINet::getAvgRouteLength
double getAvgRouteLength() const
Definition: GUINet.h:210
GUINet::getLinkTLID
int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:189
GUINet::getIdleDuration
int getIdleDuration() const
Returns the duration of the last step's idle part (in ms)
Definition: GUINet.cpp:383
GUINet::DiscoverAttributes::myStartElement
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Callback method for an opening tag to implement by derived classes.
Definition: GUINet.cpp:566
GUIDetectorWrapper
Definition: GUIDetectorWrapper.h:43
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
GUINet::getContainerControl
MSTransportableControl & getContainerControl() override
Returns the container control.
Definition: GUINet.cpp:129
GUINet::isSelected
bool isSelected(const MSTrafficLightLogic *tll) const override
return wheter the given logic (or rather it's wrapper) is selected in the GUI
Definition: GUINet.cpp:629
GUINet::getGUIInstance
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:516
GUINet::initTLMap
void initTLMap()
Initialises the tl-logic map and wrappers.
Definition: GUINet.cpp:138
GUINet::GUINet
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
Definition: GUINet.cpp:77
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:92
GUIGLObjectPopupMenu.h
SUMOSAXHandler.h
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
SAXWeightsHandler.h
GUIVehicleControl
The class responsible for building and deletion of vehicles (gui-version)
Definition: GUIVehicleControl.h:47
GUINet::myLastSimDuration
int myLastSimDuration
The step durations (simulation, /*visualisation, *‍/idle)
Definition: GUINet.h:383
GUINet::getVisualisationSpeedUp
const SUMORTree & getVisualisationSpeedUp() const
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:297
GUINet::getSimDuration
int getSimDuration() const
Returns the duration of the last step's simulation part (in ms)
Definition: GUINet.cpp:333
GUINet::getAvgWalkTimeLoss
double getAvgWalkTimeLoss() const
Definition: GUINet.h:234
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:48
GUIMEVehicleControl
The class responsible for building and deletion of vehicles (gui-version)
Definition: GUIMEVehicleControl.h:41
GUINet::GUIOSGBuilder
friend class GUIOSGBuilder
Definition: GUINet.h:351
MSEdgeWeightsStorage
A storage for edge travel times and efforts.
Definition: MSEdgeWeightsStorage.h:44
GUINet::myDetectorWrapper
std::vector< GUIDetectorWrapper * > myDetectorWrapper
A detector dictionary.
Definition: GUINet.h:367
GUINet::getAvgWalkDuration
double getAvgWalkDuration() const
Definition: GUINet.h:231
GUIGlObjectStorage.h
GUINet::getGUIMEVehicleControl
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:543
GUINet::loadEdgeData
bool loadEdgeData(const std::string &file)
load edgeData from file
Definition: GUINet.cpp:595
GUINet::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUINet.cpp:411
GUINet::getAvgDepartDelay
double getAvgDepartDelay() const
Definition: GUINet.h:222
MSTransportableControl
Definition: MSTransportableControl.h:52
MSDevice_Tripinfo::getAvgWalkDuration
static double getAvgWalkDuration()
Definition: MSDevice_Tripinfo.cpp:439
SUMORTree
A RT-tree for efficient storing of SUMO's GL-objects.
Definition: SUMORTree.h:69
MSJunctionControl
Container for junctions; performs operations on all stored junctions.
Definition: MSJunctionControl.h:45
GUINet::getAvgWaitingTime
double getAvgWaitingTime() const
Definition: GUINet.h:216
RGBColor
Definition: RGBColor.h:40
GUINet::Links2LogicMap
std::map< MSLink *, std::string > Links2LogicMap
Definition of a link-to-logic-id map.
Definition: GUINet.h:371
GUINet::getWholeDuration
int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
Definition: GUINet.cpp:327
GUINet::myEdgeWrapper
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:361
GUINet::myLastIdleDuration
int myLastIdleDuration
Definition: GUINet.h:383
GUINet::getCenteringBoundary
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUINet.cpp:510
MSDevice_Tripinfo::getAvgTimeLoss
static double getAvgTimeLoss()
Definition: MSDevice_Tripinfo.cpp:410
GUINet::myLock
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:430
GUINet::myJunctionWrapper
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:364
GUINet::getPersonControl
MSTransportableControl & getPersonControl() override
Returns the person control.
Definition: GUINet.cpp:120
MSDevice_Tripinfo::getAvgRouteLength
static double getAvgRouteLength()
accessors for GUINet-Parameters
Definition: MSDevice_Tripinfo.cpp:382
SUMORTree.h
GUIVehicle
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:54
GUINet::getEdgeData
double getEdgeData(const MSEdge *edge, const std::string &attr)
retrieve loaded edged weight for the given attribute and the current simulation time
Definition: GUINet.cpp:549
GUINet::getAvgDuration
double getAvgDuration() const
Definition: GUINet.h:213
GUINet::EdgeFloatTimeLineRetriever_GUI::EdgeFloatTimeLineRetriever_GUI
EdgeFloatTimeLineRetriever_GUI(MSEdgeWeightsStorage *weightStorage)
Constructor.
Definition: GUINet.h:407
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
GUINet::getBoundary
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GUINet.cpp:114
GUINet::myLogics2Wrapper
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
Definition: GUINet.h:379
GUINet::myOverallSimDuration
long myOverallSimDuration
Definition: GUINet.h:386
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
GUINet::initGUIStructures
void initGUIStructures()
Initialises gui wrappers.
Definition: GUINet.cpp:258
GUINet::DiscoverAttributes::lastIntervalEnd
SUMOTime lastIntervalEnd
Definition: GUINet.h:399
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
GUIGlObject_AbstractAdd.h
GUINet::DiscoverAttributes::getEdgeAttrs
std::vector< std::string > getEdgeAttrs()
Definition: GUINet.cpp:577
MSTrafficLightLogic
The parent class for traffic light logics.
Definition: MSTrafficLightLogic.h:56
GUIGlObject
Definition: GUIGlObject.h:66
MSDevice_Tripinfo::getAvgDepartDelay
static double getAvgDepartDelay()
Definition: MSDevice_Tripinfo.cpp:420
GUIJunctionWrapper
Definition: GUIJunctionWrapper.h:61
GUINet::myOverallVehicleCount
long myOverallVehicleCount
Definition: GUINet.h:385
GUINet::EdgeFloatTimeLineRetriever_GUI
Definition: GUINet.h:404
GUINet::lock
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:532
GUINet::myLastVehicleMovementCount
long myLastVehicleMovementCount
Definition: GUINet.h:385
GUINet::getAvgTripSpeed
double getAvgTripSpeed() const
Definition: GUINet.h:225
LayeredRTree.h
GUINet::drawGL
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUINet.cpp:506
Position.h
GUINet::EdgeFloatTimeLineRetriever_GUI::addEdgeWeight
void addEdgeWeight(const std::string &id, double val, double beg, double end) const
Adds an effort for a given edge and time period.
Definition: GUINet.cpp:583
GUIMainWindow
Definition: GUIMainWindow.h:47
GUINet::EdgeFloatTimeLineRetriever_GUI::myWeightStorage
MSEdgeWeightsStorage * myWeightStorage
The storage that edges shall be added to.
Definition: GUINet.h:424
GUIEdge
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:53
GUINet::getAvgTimeLoss
double getAvgTimeLoss() const
Definition: GUINet.h:219
MSDevice_Tripinfo::getAvgWalkTimeLoss
static double getAvgWalkTimeLoss()
Definition: MSDevice_Tripinfo.cpp:449
GUITrafficLightLogicWrapper
Definition: GUITrafficLightLogicWrapper.h:48
GUINet::getTLSIDs
std::vector< GUIGlID > getTLSIDs() const
Returns the gl-ids of all traffic light logics within the net.
Definition: GUINet.cpp:243
GUINet::unlock
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:538
GUINet::getRTFactor
double getRTFactor() const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:347
GUINet::vehicleExists
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
Definition: GUINet.cpp:183
GUINet::getLinkTLIndex
int getLinkTLIndex(MSLink *link) const
Definition: GUINet.cpp:204
config.h
GUINet::getJunctionIDs
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
Definition: GUINet.cpp:231
MSVehicleControl
The class responsible for building and deletion of vehicles.
Definition: MSVehicleControl.h:72
MSEdgeControl
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:73
MSDevice_Tripinfo.h
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:60
GUINet::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUINet.cpp:423
GUINet::DiscoverAttributes::DiscoverAttributes
DiscoverAttributes(const std::string &file)
Definition: GUINet.h:394
GUINet::getMeanRTFactor
double getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:365
GUINet::getAvgWalkRouteLength
double getAvgWalkRouteLength() const
Definition: GUINet.h:228
GUINet::Logics2WrapperMap
std::map< MSTrafficLightLogic *, GUITrafficLightLogicWrapper * > Logics2WrapperMap
Definition of a traffic light-to-wrapper map.
Definition: GUINet.h:377
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:346
GUINet::createTLWrapper
void createTLWrapper(MSTrafficLightLogic *tll) override
creates a wrapper for the given logic
Definition: GUINet.cpp:149
GUINet::getJunctionPosition
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
Definition: GUINet.cpp:176
GUINet
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:83
GUINet::EdgeFloatTimeLineRetriever_GUI::~EdgeFloatTimeLineRetriever_GUI
~EdgeFloatTimeLineRetriever_GUI()
Destructor.
Definition: GUINet.h:410
GUINet::simulationStep
void simulationStep()
Performs a single simulation step (locking the simulation)
Definition: GUINet.cpp:224
GUINet::getEdgeDataAttrs
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
Definition: GUINet.cpp:620
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:57
GUINet::setSimDuration
void setSimDuration(int val)
Sets the duration of the last step's simulation part.
Definition: GUINet.cpp:389
GUINet::getGUIVehicleControl
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:526
PositionVector.h
GUINet::guiSimulationStep
void guiSimulationStep()
Some further steps needed for gui processing.
Definition: GUINet.cpp:217
SAXWeightsHandler::EdgeFloatTimeLineRetriever
Interface for a class which obtains read weights for named edges.
Definition: SAXWeightsHandler.h:75
LayeredRTree
A RT-tree for efficient storing of SUMO's GL-objects in layers.
Definition: LayeredRTree.h:49
GUINet::DiscoverAttributes::edgeAttrs
std::set< std::string > edgeAttrs
Definition: GUINet.h:401
GUINet::getVisualisationSpeedUp
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:289
GUINet::~GUINet
~GUINet()
Destructor.
Definition: GUINet.cpp:88
MSDevice_Tripinfo::getAvgDuration
static double getAvgDuration()
Definition: MSDevice_Tripinfo.cpp:391