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 /****************************************************************************/
16 // A MSNet extended by some values for usage within the gui
17 /****************************************************************************/
18 #ifndef GUINet_h
19 #define GUINet_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <utility>
29 #include <microsim/MSNet.h>
31 #include <utils/geom/Boundary.h>
32 #include <utils/geom/Position.h>
42 
43 
44 // ===========================================================================
45 // class declarations
46 // ===========================================================================
47 class MSEdgeControl;
48 class MSJunctionControl;
49 class MSTLLogicControl;
51 class MSLink;
52 class GUIJunctionWrapper;
53 class GUIDetectorWrapper;
55 class RGBColor;
56 class GUIEdge;
57 class OutputDevice;
58 class GUIVehicle;
59 class GUIVehicleControl;
60 class MSVehicleControl;
62 
63 
64 // ===========================================================================
65 // class definitions
66 // ===========================================================================
82 class GUINet : public MSNet, public GUIGlObject {
83 
84  friend class GUITrafficLightLogicWrapper; // see createTLWrapper
85 
86 public:
94  GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
95  MSEventControl* endOfTimestepEvents,
96  MSEventControl* insertionEvents);
97 
98 
100  ~GUINet();
101 
102 
106  bool isGUINet() const override {
107  return true;
108  }
109 
110 
112 
113 
122 
123 
132 
133 
139  Boundary getCenteringBoundary() const override;
140 
141 
146  void drawGL(const GUIVisualizationSettings& s) const override;
148 
149 
151  const Boundary& getBoundary() const;
152 
154  Position getJunctionPosition(const std::string& name) const;
155 
157  bool vehicleExists(const std::string& name) const;
158 
160  void guiSimulationStep();
161 
164  void simulationStep();
165 
168 
172  int getWholeDuration() const;
173 
174 
178  int getSimDuration() const;
179 
180 
182  double getRTFactor() const;
183 
185  double getUPS() const;
186 
188  double getMeanRTFactor(int duration) const;
189 
191  double getMeanUPS() const;
192 
193  // Returns the duration of the last step's visualisation part (in ms)
194  //int getVisDuration() const;
195 
197  int getIdleDuration() const;
198 
200  void setSimDuration(int val);
201 
202  // Sets the duration of the last step's visualisation part
203  //void setVisDuration(int val);
204 
206  void setIdleDuration(int val);
207  //}
208 
209  double getAvgRouteLength() const {
211  }
212  double getAvgDuration() const {
214  }
215  double getAvgWaitingTime() const {
217  }
218  double getAvgTimeLoss() const {
220  }
221  double getAvgDepartDelay() const {
223  }
224  double getAvgTripSpeed() const {
226  }
227  double getAvgWalkRouteLength() const {
229  }
230  double getAvgWalkDuration() const {
232  }
233  double getAvgWalkTimeLoss() const {
235  }
236 
246 
247 
257 
258 
261  int getLinkTLID(MSLink* link) const;
262 
265  int getLinkTLIndex(MSLink* link) const;
266 
267 
269 
270 
271  /* @brief Returns the gl-ids of all junctions within the net
272  * @param[in] includeInternal Whether to include ids of internal junctions
273  */
274  std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
275 
277  std::vector<GUIGlID> getTLSIDs() const;
279 
280 
282  void initGUIStructures();
283 
284 
289  return myGrid;
290  }
291 
292 
297  return myGrid;
298  }
299 
306 
313 
315  double getEdgeData(const MSEdge* edge, const std::string& attr);
316 
318  bool loadEdgeData(const std::string& file);
319 
320 
322  std::vector<std::string> getEdgeDataAttrs() const;
323 
324 #ifdef HAVE_OSG
325  void updateColor(const GUIVisualizationSettings& s);
326 #endif
327 
329  void lock();
330 
332  void unlock();
333 
338  static GUINet* getGUIInstance();
339 
341  void createTLWrapper(MSTrafficLightLogic* tll) override;
342 
344  bool isSelected(const MSTrafficLightLogic* tll) const override;
345 
346 private:
348  void initTLMap();
349 
350  friend class GUIOSGBuilder;
351 
352 protected:
355 
358 
360  std::vector<GUIEdge*> myEdgeWrapper;
361 
363  std::vector<GUIJunctionWrapper*> myJunctionWrapper;
364 
366  std::vector<GUIDetectorWrapper*> myDetectorWrapper;
367 
368 
370  typedef std::map<MSLink*, std::string> Links2LogicMap;
373 
374 
376  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
379 
380 
382  int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
383 
386 
388  std::map<std::string, MSEdgeWeightsStorage*> myLoadedEdgeData;
389 
392  public:
393  DiscoverAttributes(const std::string& file):
394  SUMOSAXHandler(file), lastIntervalEnd(0) {};
396  void myStartElement(int element, const SUMOSAXAttributes& attrs);
397  std::vector<std::string> getEdgeAttrs();
399  private:
400  std::set<std::string> edgeAttrs;
401  };
402 
404  public:
407 
410 
419  void addEdgeWeight(const std::string& id, double val, double beg, double end) const;
420 
421  private:
424 
425  };
426 
427 private:
429  mutable FXMutex myLock;
430 
431 };
432 
433 
434 #endif
435 
436 /****************************************************************************/
437 
GUINet::setIdleDuration
void setIdleDuration(int val)
Sets the duration of the last step's idle part.
Definition: GUINet.cpp:404
GUINet::getUPS
double getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:355
Boundary.h
GUINet::myBoundary
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:357
MSEventControl
Stores time-dependant events and executes them at the proper time.
Definition: MSEventControl.h:49
GUINet::DiscoverAttributes
class for discovering edge attributes
Definition: GUINet.h:391
GUINet::myLinks2Logic
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
Definition: GUINet.h:372
MSDevice_Tripinfo::getAvgWaitingTime
static double getAvgWaitingTime()
Definition: MSDevice_Tripinfo.cpp:408
GUIGlObject.h
GUINet::myGrid
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:354
GUIParameterTableWindow
A window containing a gl-object's parameter.
Definition: GUIParameterTableWindow.h:62
GUINet::isGUINet
bool isGUINet() const override
Returns whether this is a GUI Net.
Definition: GUINet.h:106
GUINet::DiscoverAttributes::~DiscoverAttributes
~DiscoverAttributes()
Definition: GUINet.h:395
GUINet::myLoadedEdgeData
std::map< std::string, MSEdgeWeightsStorage * > myLoadedEdgeData
loaded edge data for visualization
Definition: GUINet.h:388
GUISUMOAbstractView
Definition: GUISUMOAbstractView.h:72
MSNet.h
GUINet::getMeanUPS
double getMeanUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:373
MSDevice_Tripinfo::getAvgWalkRouteLength
static double getAvgWalkRouteLength()
Definition: MSDevice_Tripinfo.cpp:438
SUMOSAXHandler
SAX-handler base for SUMO-files.
Definition: SUMOSAXHandler.h:41
GUINet::getAvgRouteLength
double getAvgRouteLength() const
Definition: GUINet.h:209
GUINet::getLinkTLID
int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:188
GUINet::getIdleDuration
int getIdleDuration() const
Returns the duration of the last step's idle part (in ms)
Definition: GUINet.cpp:382
GUINet::DiscoverAttributes::myStartElement
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Callback method for an opening tag to implement by derived classes.
Definition: GUINet.cpp:565
GUIDetectorWrapper
Definition: GUIDetectorWrapper.h:42
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
GUINet::getContainerControl
MSTransportableControl & getContainerControl() override
Returns the container control.
Definition: GUINet.cpp:128
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:628
GUINet::getGUIInstance
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:515
GUINet::initTLMap
void initTLMap()
Initialises the tl-logic map and wrappers.
Definition: GUINet.cpp:137
GUINet::GUINet
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
Definition: GUINet.cpp:76
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:91
GUIGLObjectPopupMenu.h
SUMOSAXHandler.h
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
SAXWeightsHandler.h
GUIVehicleControl
The class responsible for building and deletion of vehicles (gui-version)
Definition: GUIVehicleControl.h:46
GUINet::myLastSimDuration
int myLastSimDuration
The step durations (simulation, /*visualisation, *‍/idle)
Definition: GUINet.h:382
GUINet::getVisualisationSpeedUp
const SUMORTree & getVisualisationSpeedUp() const
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:296
GUINet::getSimDuration
int getSimDuration() const
Returns the duration of the last step's simulation part (in ms)
Definition: GUINet.cpp:332
GUINet::getAvgWalkTimeLoss
double getAvgWalkTimeLoss() const
Definition: GUINet.h:233
GUIGLObjectPopupMenu
The popup menu of a globject.
Definition: GUIGLObjectPopupMenu.h:47
GUIMEVehicleControl
The class responsible for building and deletion of vehicles (gui-version)
Definition: GUIMEVehicleControl.h:40
GUINet::GUIOSGBuilder
friend class GUIOSGBuilder
Definition: GUINet.h:350
MSEdgeWeightsStorage
A storage for edge travel times and efforts.
Definition: MSEdgeWeightsStorage.h:43
GUINet::myDetectorWrapper
std::vector< GUIDetectorWrapper * > myDetectorWrapper
A detector dictionary.
Definition: GUINet.h:366
GUINet::getAvgWalkDuration
double getAvgWalkDuration() const
Definition: GUINet.h:230
GUIGlObjectStorage.h
GUINet::getGUIMEVehicleControl
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:542
GUINet::loadEdgeData
bool loadEdgeData(const std::string &file)
load edgeData from file
Definition: GUINet.cpp:594
GUINet::getPopUpMenu
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUINet.cpp:410
GUINet::getAvgDepartDelay
double getAvgDepartDelay() const
Definition: GUINet.h:221
MSTransportableControl
Definition: MSTransportableControl.h:51
MSDevice_Tripinfo::getAvgWalkDuration
static double getAvgWalkDuration()
Definition: MSDevice_Tripinfo.cpp:447
SUMORTree
A RT-tree for efficient storing of SUMO's GL-objects.
Definition: SUMORTree.h:68
MSJunctionControl
Container for junctions; performs operations on all stored junctions.
Definition: MSJunctionControl.h:44
GUINet::getAvgWaitingTime
double getAvgWaitingTime() const
Definition: GUINet.h:215
RGBColor
Definition: RGBColor.h:39
GUINet::Links2LogicMap
std::map< MSLink *, std::string > Links2LogicMap
Definition of a link-to-logic-id map.
Definition: GUINet.h:370
GUINet::getWholeDuration
int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
Definition: GUINet.cpp:326
GUINet::myEdgeWrapper
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:360
GUINet::myLastIdleDuration
int myLastIdleDuration
Definition: GUINet.h:382
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:509
MSDevice_Tripinfo::getAvgTimeLoss
static double getAvgTimeLoss()
Definition: MSDevice_Tripinfo.cpp:418
GUINet::myLock
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:429
GUINet::myJunctionWrapper
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:363
GUINet::getPersonControl
MSTransportableControl & getPersonControl() override
Returns the person control.
Definition: GUINet.cpp:119
MSDevice_Tripinfo::getAvgRouteLength
static double getAvgRouteLength()
accessors for GUINet-Parameters
Definition: MSDevice_Tripinfo.cpp:390
SUMORTree.h
GUIVehicle
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:53
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:548
GUINet::getAvgDuration
double getAvgDuration() const
Definition: GUINet.h:212
GUINet::EdgeFloatTimeLineRetriever_GUI::EdgeFloatTimeLineRetriever_GUI
EdgeFloatTimeLineRetriever_GUI(MSEdgeWeightsStorage *weightStorage)
Constructor.
Definition: GUINet.h:406
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
GUINet::getBoundary
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GUINet.cpp:113
GUINet::myLogics2Wrapper
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
Definition: GUINet.h:378
GUINet::myOverallSimDuration
long myOverallSimDuration
Definition: GUINet.h:385
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
GUINet::initGUIStructures
void initGUIStructures()
Initialises gui wrappers.
Definition: GUINet.cpp:257
GUINet::DiscoverAttributes::lastIntervalEnd
SUMOTime lastIntervalEnd
Definition: GUINet.h:398
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:78
GUIGlObject_AbstractAdd.h
GUINet::DiscoverAttributes::getEdgeAttrs
std::vector< std::string > getEdgeAttrs()
Definition: GUINet.cpp:576
MSTrafficLightLogic
The parent class for traffic light logics.
Definition: MSTrafficLightLogic.h:55
GUIGlObject
Definition: GUIGlObject.h:65
MSDevice_Tripinfo::getAvgDepartDelay
static double getAvgDepartDelay()
Definition: MSDevice_Tripinfo.cpp:428
GUIJunctionWrapper
Definition: GUIJunctionWrapper.h:60
GUINet::myOverallVehicleCount
long myOverallVehicleCount
Definition: GUINet.h:384
GUINet::EdgeFloatTimeLineRetriever_GUI
Definition: GUINet.h:403
GUINet::lock
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:531
GUINet::myLastVehicleMovementCount
long myLastVehicleMovementCount
Definition: GUINet.h:384
GUINet::getAvgTripSpeed
double getAvgTripSpeed() const
Definition: GUINet.h:224
LayeredRTree.h
GUINet::drawGL
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUINet.cpp:505
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:582
GUIMainWindow
Definition: GUIMainWindow.h:46
GUINet::EdgeFloatTimeLineRetriever_GUI::myWeightStorage
MSEdgeWeightsStorage * myWeightStorage
The storage that edges shall be added to.
Definition: GUINet.h:423
GUIEdge
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:52
GUINet::getAvgTimeLoss
double getAvgTimeLoss() const
Definition: GUINet.h:218
MSDevice_Tripinfo::getAvgWalkTimeLoss
static double getAvgWalkTimeLoss()
Definition: MSDevice_Tripinfo.cpp:457
GUITrafficLightLogicWrapper
Definition: GUITrafficLightLogicWrapper.h:47
GUINet::getTLSIDs
std::vector< GUIGlID > getTLSIDs() const
Returns the gl-ids of all traffic light logics within the net.
Definition: GUINet.cpp:242
GUINet::unlock
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:537
GUINet::getRTFactor
double getRTFactor() const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:346
GUINet::vehicleExists
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
Definition: GUINet.cpp:182
GUINet::getLinkTLIndex
int getLinkTLIndex(MSLink *link) const
Definition: GUINet.cpp:203
config.h
GUINet::getJunctionIDs
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
Definition: GUINet.cpp:230
MSVehicleControl
The class responsible for building and deletion of vehicles.
Definition: MSVehicleControl.h:71
MSEdgeControl
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:74
MSDevice_Tripinfo.h
MSTLLogicControl
A class that stores and controls tls and switching of their programs.
Definition: MSTLLogicControl.h:59
GUINet::getParameterWindow
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUINet.cpp:422
GUINet::DiscoverAttributes::DiscoverAttributes
DiscoverAttributes(const std::string &file)
Definition: GUINet.h:393
GUINet::getMeanRTFactor
double getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:364
GUINet::getAvgWalkRouteLength
double getAvgWalkRouteLength() const
Definition: GUINet.h:227
GUINet::Logics2WrapperMap
std::map< MSTrafficLightLogic *, GUITrafficLightLogicWrapper * > Logics2WrapperMap
Definition of a traffic light-to-wrapper map.
Definition: GUINet.h:376
GUIVisualizationSettings
Stores the information about how to visualize structures.
Definition: GUIVisualizationSettings.h:345
GUINet::createTLWrapper
void createTLWrapper(MSTrafficLightLogic *tll) override
creates a wrapper for the given logic
Definition: GUINet.cpp:148
GUINet::getJunctionPosition
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
Definition: GUINet.cpp:175
GUINet
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:82
GUINet::EdgeFloatTimeLineRetriever_GUI::~EdgeFloatTimeLineRetriever_GUI
~EdgeFloatTimeLineRetriever_GUI()
Destructor.
Definition: GUINet.h:409
GUINet::simulationStep
void simulationStep()
Performs a single simulation step (locking the simulation)
Definition: GUINet.cpp:223
GUINet::getEdgeDataAttrs
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
Definition: GUINet.cpp:619
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56
GUINet::setSimDuration
void setSimDuration(int val)
Sets the duration of the last step's simulation part.
Definition: GUINet.cpp:388
GUINet::getGUIVehicleControl
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:525
PositionVector.h
GUINet::guiSimulationStep
void guiSimulationStep()
Some further steps needed for gui processing.
Definition: GUINet.cpp:216
SAXWeightsHandler::EdgeFloatTimeLineRetriever
Interface for a class which obtains read weights for named edges.
Definition: SAXWeightsHandler.h:74
LayeredRTree
A RT-tree for efficient storing of SUMO's GL-objects in layers.
Definition: LayeredRTree.h:48
GUINet::DiscoverAttributes::edgeAttrs
std::set< std::string > edgeAttrs
Definition: GUINet.h:400
GUINet::getVisualisationSpeedUp
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:288
GUINet::~GUINet
~GUINet()
Destructor.
Definition: GUINet.cpp:87
MSDevice_Tripinfo::getAvgDuration
static double getAvgDuration()
Definition: MSDevice_Tripinfo.cpp:399