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;
373  Links2LogicMap myLinks2Logic;
374 
375 
377  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
379  Logics2WrapperMap myLogics2Wrapper;
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:
407  EdgeFloatTimeLineRetriever_GUI(MSEdgeWeightsStorage* weightStorage) : myWeightStorage(weightStorage) {}
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 
int myLastSimDuration
The step durations (simulation, /*visualisation, */idle)
Definition: GUINet.h:383
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:358
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
Definition: GUINet.cpp:176
double getAvgWaitingTime() const
Definition: GUINet.h:216
The class responsible for building and deletion of vehicles (gui-version)
Interface for a class which obtains read weights for named edges.
long long int SUMOTime
Definition: SUMOTime.h:35
std::map< std::string, MSEdgeWeightsStorage * > myLoadedEdgeData
loaded edge data for visualization
Definition: GUINet.h:389
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:364
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:430
double getAvgDuration() const
Definition: GUINet.h:213
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:538
int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:189
std::set< std::string > edgeAttrs
Definition: GUINet.h:401
static double getAvgTimeLoss()
std::map< MSLink *, std::string > Links2LogicMap
Definition of a link-to-logic-id map.
Definition: GUINet.h:371
Stores the information about how to visualize structures.
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:355
void initTLMap()
Initialises the tl-logic map and wrappers.
Definition: GUINet.cpp:138
bool loadEdgeData(const std::string &file)
load edgeData from file
Definition: GUINet.cpp:595
const SUMORTree & getVisualisationSpeedUp() const
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:297
double getAvgWalkDuration() const
Definition: GUINet.h:231
double getMeanUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:374
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:543
The class responsible for building and deletion of vehicles (gui-version)
~GUINet()
Destructor.
Definition: GUINet.cpp:88
void initGUIStructures()
Initialises gui wrappers.
Definition: GUINet.cpp:258
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:532
EdgeFloatTimeLineRetriever_GUI(MSEdgeWeightsStorage *weightStorage)
Constructor.
Definition: GUINet.h:407
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
Definition: GUINet.h:373
A storage for edge travel times and efforts.
SAX-handler base for SUMO-files.
bool isGUINet() const override
Returns whether this is a GUI Net.
Definition: GUINet.h:107
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:289
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:69
int myLastIdleDuration
Definition: GUINet.h:383
long myOverallVehicleCount
Definition: GUINet.h:385
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
void setIdleDuration(int val)
Sets the duration of the last step&#39;s idle part.
Definition: GUINet.cpp:405
The simulated network and simulation perfomer.
Definition: MSNet.h:92
Container for junctions; performs operations on all stored junctions.
static double getAvgDuration()
A class that stores and controls tls and switching of their programs.
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
Definition: GUINet.h:379
static double getAvgWalkTimeLoss()
bool isSelected(const MSTrafficLightLogic *tll) const override
return wheter the given logic (or rather it&#39;s wrapper) is selected in the GUI
Definition: GUINet.cpp:629
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:53
A road/street connecting two junctions.
Definition: MSEdge.h:76
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
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUINet.cpp:510
std::vector< GUIDetectorWrapper * > myDetectorWrapper
A detector dictionary.
Definition: GUINet.h:367
double getAvgDepartDelay() const
Definition: GUINet.h:222
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:516
static double getAvgWalkRouteLength()
Encapsulated SAX-Attributes.
MSEdgeWeightsStorage * myWeightStorage
The storage that edges shall be added to.
Definition: GUINet.h:424
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUINet.cpp:411
std::vector< GUIGlID > getTLSIDs() const
Returns the gl-ids of all traffic light logics within the net.
Definition: GUINet.cpp:243
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:73
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
Definition: GUINet.cpp:620
void createTLWrapper(MSTrafficLightLogic *tll) override
creates a wrapper for the given logic
Definition: GUINet.cpp:149
friend class GUIOSGBuilder
Definition: GUINet.h:351
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
Definition: GUINet.cpp:231
static double getAvgWalkDuration()
double getAvgTripSpeed() const
Definition: GUINet.h:225
int getSimDuration() const
Returns the duration of the last step&#39;s simulation part (in ms)
Definition: GUINet.cpp:333
double getAvgWalkTimeLoss() const
Definition: GUINet.h:234
double getAvgTimeLoss() const
Definition: GUINet.h:219
int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
Definition: GUINet.cpp:327
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUINet.cpp:506
void setSimDuration(int val)
Sets the duration of the last step&#39;s simulation part.
Definition: GUINet.cpp:389
static double getAvgWaitingTime()
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:361
~EdgeFloatTimeLineRetriever_GUI()
Destructor.
Definition: GUINet.h:410
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:83
double getAvgRouteLength() const
Definition: GUINet.h:210
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GUINet.cpp:114
class for discovering edge attributes
Definition: GUINet.h:392
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
Definition: GUINet.cpp:183
long myOverallSimDuration
Definition: GUINet.h:386
The popup menu of a globject.
DiscoverAttributes(const std::string &file)
Definition: GUINet.h:394
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:526
A RT-tree for efficient storing of SUMO&#39;s GL-objects in layers.
Definition: LayeredRTree.h:49
MSTransportableControl & getPersonControl() override
Returns the person control.
Definition: GUINet.cpp:120
static double getAvgRouteLength()
accessors for GUINet-Parameters
double getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:365
static double getAvgDepartDelay()
The parent class for traffic light logics.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
void simulationStep()
Performs a single simulation step (locking the simulation)
Definition: GUINet.cpp:224
double getRTFactor() const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:347
The class responsible for building and deletion of vehicles.
double getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:356
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
Definition: GUINet.cpp:77
void guiSimulationStep()
Some further steps needed for gui processing.
Definition: GUINet.cpp:217
double getAvgWalkRouteLength() const
Definition: GUINet.h:228
std::map< MSTrafficLightLogic *, GUITrafficLightLogicWrapper * > Logics2WrapperMap
Definition of a traffic light-to-wrapper map.
Definition: GUINet.h:377
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Callback method for an opening tag to implement by derived classes.
Definition: GUINet.cpp:566
int getLinkTLIndex(MSLink *link) const
Definition: GUINet.cpp:204
A window containing a gl-object&#39;s parameter.
Stores time-dependant events and executes them at the proper time.
long myLastVehicleMovementCount
Definition: GUINet.h:385
int getIdleDuration() const
Returns the duration of the last step&#39;s idle part (in ms)
Definition: GUINet.cpp:383
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUINet.cpp:423
MSTransportableControl & getContainerControl() override
Returns the container control.
Definition: GUINet.cpp:129
std::vector< std::string > getEdgeAttrs()
Definition: GUINet.cpp:577
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:54