SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GUINet.h
Go to the documentation of this file.
1 /****************************************************************************/
9 // A MSNet extended by some values for usage within the gui
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 #ifndef GUINet_h
23 #define GUINet_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <utility>
37 #include <microsim/MSNet.h>
39 #include <utils/geom/Boundary.h>
40 #include <utils/geom/Position.h>
48 
49 
50 // ===========================================================================
51 // class declarations
52 // ===========================================================================
53 class MSEdgeControl;
54 class MSJunctionControl;
55 class MSTLLogicControl;
57 class MSLink;
58 class GUIJunctionWrapper;
59 class GUIDetectorWrapper;
61 class RGBColor;
62 class GUIEdge;
63 class OutputDevice;
64 class GUIVehicle;
65 class GUIVehicleControl;
66 class MSVehicleControl;
67 class MFXMutex;
69 
70 
71 // ===========================================================================
72 // class definitions
73 // ===========================================================================
89 class GUINet : public MSNet, public GUIGlObject {
90 
91  friend class GUITrafficLightLogicWrapper; // see createTLWrapper
92 
93 public:
101  GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
102  MSEventControl* endOfTimestepEvents, MSEventControl* insertionEvents);
103 
104 
106  ~GUINet();
107 
108 
109 
111 
112 
121  GUISUMOAbstractView& parent);
122 
123 
132  GUIMainWindow& app, GUISUMOAbstractView& parent);
133 
134 
141 
142 
147  void drawGL(const GUIVisualizationSettings& s) const;
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  SUMOReal getRTFactor() const;
184 
186  SUMOReal getUPS() const;
187 
189  SUMOReal getMeanRTFactor(int duration) const;
190 
192  SUMOReal 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 
212  }
215  }
218  }
221  }
224  }
225 
235 
236 
246 
247 
250  int getLinkTLID(MSLink* link) const;
251 
254  int getLinkTLIndex(MSLink* link) const;
255 
256 
258 
259 
260  /* @brief Returns the gl-ids of all junctions within the net
261  * @param[in] includeInternal Whether to include ids of internal junctions
262  */
263  std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
264 
266  std::vector<GUIGlID> getTLSIDs() const;
268 
269 
271  void initGUIStructures();
272 
273 
278  return myGrid;
279  }
280 
281 
286  return myGrid;
287  }
288 
295 
302 
303 #ifdef HAVE_OSG
304  void updateColor(const GUIVisualizationSettings& s);
305 #endif
306 
308  void lock();
309 
311  void unlock();
312 
317  static GUINet* getGUIInstance();
318 
319 
320 private:
322  void initTLMap();
323 
326 
327  friend class GUIOSGBuilder;
328 
329 protected:
332 
335 
337  std::vector<GUIEdge*> myEdgeWrapper;
338 
340  std::vector<GUIJunctionWrapper*> myJunctionWrapper;
341 
343  std::vector<MSTrafficLightLogic*> myTLLogicWrappers;
344 
346  std::vector<GUIDetectorWrapper*> myDetectorDict;
347 
348 
350  typedef std::map<MSLink*, std::string> Links2LogicMap;
352  Links2LogicMap myLinks2Logic;
353 
354 
356  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
358  Logics2WrapperMap myLogics2Wrapper;
359 
360 
362  int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
363 
366 
367 private:
369  mutable MFXMutex myLock;
370 
371 };
372 
373 
374 #endif
375 
376 /****************************************************************************/
377 
SUMOReal getAvgDuration() const
Definition: GUINet.h:213
int getIdleDuration() const
Returns the duration of the last step's idle part (in ms)
Definition: GUINet.cpp:376
int myLastSimDuration
The step durations (simulation, /*visualisation, */idle)
Definition: GUINet.h:362
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:334
The class responsible for building and deletion of vehicles (gui-version)
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:340
static SUMOReal getAvgDepartDelay()
SUMOReal getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:358
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:516
int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:195
std::map< MSLink *, std::string > Links2LogicMap
Definition of a link-to-logic-id map.
Definition: GUINet.h:350
Stores the information about how to visualize structures.
SUMOReal getAvgWaitingTime() const
Definition: GUINet.h:216
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:331
void initTLMap()
Initialises the tl-logic map and wrappers.
Definition: GUINet.cpp:142
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:521
The class responsible for building and deletion of vehicles (gui-version)
~GUINet()
Destructor.
Definition: GUINet.cpp:95
void initGUIStructures()
Initialises gui wrappers.
Definition: GUINet.cpp:264
SUMOReal getAvgDepartDelay() const
Definition: GUINet.h:222
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:510
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
Definition: GUINet.h:352
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
Definition: GUINet.cpp:182
std::vector< GUIDetectorWrapper * > myDetectorDict
A detector dictionary.
Definition: GUINet.h:346
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:277
A RT-tree for efficient storing of SUMO's GL-objects.
Definition: SUMORTree.h:74
int myLastIdleDuration
Definition: GUINet.h:362
long myOverallVehicleCount
Definition: GUINet.h:364
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUINet.cpp:484
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GUINet.cpp:118
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
void setIdleDuration(int val)
Sets the duration of the last step's idle part.
Definition: GUINet.cpp:398
The simulated network and simulation perfomer.
Definition: MSNet.h:93
Container for junctions; performs operations on all stored junctions.
SUMOReal getAvgRouteLength() const
Definition: GUINet.h:210
A class that stores and controls tls and switching of their programs.
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own popup-menu.
Definition: GUINet.cpp:404
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
Definition: GUINet.h:358
static SUMOReal getAvgRouteLength()
accessors for GUINet-Parameters
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:60
SUMOReal getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:349
static SUMOReal getAvgDuration()
GUIGlID createTLWrapper(MSTrafficLightLogic *tll)
creates a wrapper for the given logic and returns the GlID
Definition: GUINet.cpp:155
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
Definition: GUINet.cpp:237
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUINet.cpp:416
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:494
static SUMOReal getAvgWaitingTime()
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:74
int getLinkTLIndex(MSLink *link) const
Definition: GUINet.cpp:210
std::vector< MSTrafficLightLogic * > myTLLogicWrappers
Wrapped TL-Logics.
Definition: GUINet.h:343
friend class GUIOSGBuilder
Definition: GUINet.h:327
MSTransportableControl & getPersonControl()
Returns the person control.
Definition: GUINet.cpp:124
unsigned int GUIGlID
Definition: GUIGlObject.h:50
void setSimDuration(int val)
Sets the duration of the last step's simulation part.
Definition: GUINet.cpp:382
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:337
const SUMORTree & getVisualisationSpeedUp() const
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:285
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:89
SUMOReal getMeanUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:367
long myOverallSimDuration
Definition: GUINet.h:365
The popup menu of a globject.
int getSimDuration() const
Returns the duration of the last step's simulation part (in ms)
Definition: GUINet.cpp:326
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:504
A RT-tree for efficient storing of SUMO's GL-objects in layers.
Definition: LayeredRTree.h:56
std::vector< GUIGlID > getTLSIDs() const
Returns the gl-ids of all traffic light logics within the net.
Definition: GUINet.cpp:249
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
Definition: GUINet.cpp:189
static SUMOReal getAvgTimeLoss()
The parent class for traffic light logics.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:214
SUMOReal getRTFactor() const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:340
void simulationStep()
Performs a single simulation step (locking the simulation)
Definition: GUINet.cpp:230
The class responsible for building and deletion of vehicles.
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
Definition: GUINet.cpp:85
void guiSimulationStep()
Some further steps needed for gui processing.
Definition: GUINet.cpp:223
int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
Definition: GUINet.cpp:320
std::map< MSTrafficLightLogic *, GUITrafficLightLogicWrapper * > Logics2WrapperMap
Definition of a traffic light-to-wrapper map.
Definition: GUINet.h:356
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUINet.cpp:488
A window containing a gl-object's parameter.
Stores time-dependant events and executes them at the proper time.
long myLastVehicleMovementCount
Definition: GUINet.h:364
SUMOReal getAvgTimeLoss() const
Definition: GUINet.h:219
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:369
MSTransportableControl & getContainerControl()
Returns the container control.
Definition: GUINet.cpp:133
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:61