SUMO - Simulation of Urban MObility
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-2015 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;
68 #ifdef HAVE_INTERNAL
69 class GUIMEVehicleControl;
70 #endif
71 
72 
73 // ===========================================================================
74 // class definitions
75 // ===========================================================================
91 class GUINet : public MSNet, public GUIGlObject {
92 
93  friend class GUITrafficLightLogicWrapper; // see createTLWrapper
94 
95 public:
103  GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
104  MSEventControl* endOfTimestepEvents, MSEventControl* insertionEvents);
105 
106 
108  ~GUINet();
109 
110 
111 
113 
114 
123  GUISUMOAbstractView& parent);
124 
125 
134  GUIMainWindow& app, GUISUMOAbstractView& parent);
135 
136 
143 
144 
149  void drawGL(const GUIVisualizationSettings& s) const;
151 
152 
154  const Boundary& getBoundary() const;
155 
157  Position getJunctionPosition(const std::string& name) const;
158 
160  bool vehicleExists(const std::string& name) const;
161 
163  void guiSimulationStep();
164 
167  void simulationStep();
168 
171 
175  unsigned int getWholeDuration() const;
176 
177 
181  unsigned int getSimDuration() const;
182 
183 
185  SUMOReal getRTFactor() const;
186 
188  SUMOReal getUPS() const;
189 
191  SUMOReal getMeanRTFactor(int duration) const;
192 
194  SUMOReal getMeanUPS() const;
195 
196  // Returns the duration of the last step's visualisation part (in ms)
197  //int getVisDuration() const;
198 
200  unsigned int getIdleDuration() const;
201 
203  void setSimDuration(int val);
204 
205  // Sets the duration of the last step's visualisation part
206  //void setVisDuration(int val);
207 
209  void setIdleDuration(int val);
210  //}
211 
214  }
217  }
220  }
223  }
226  }
227 
237 
238 
248 
249 
252  unsigned int getLinkTLID(MSLink* link) const;
253 
256  int getLinkTLIndex(MSLink* link) const;
257 
258 
260 
261 
262  /* @brief Returns the gl-ids of all junctions within the net
263  * @param[in] includeInternal Whether to include ids of internal junctions
264  */
265  std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
266 
268  std::vector<GUIGlID> getTLSIDs() const;
270 
271 
273  void initGUIStructures();
274 
275 
280  return myGrid;
281  }
282 
283 
288  return myGrid;
289  }
290 
297 
298 #ifdef HAVE_INTERNAL
299 
304  GUIMEVehicleControl* getGUIMEVehicleControl();
305 #endif
306 
307 #ifdef HAVE_OSG
308  void updateColor(const GUIVisualizationSettings& s);
309 #endif
310 
312  void lock();
313 
315  void unlock();
316 
321  static GUINet* getGUIInstance();
322 
323 
324 private:
326  void initTLMap();
327 
330 
331  friend class GUIOSGBuilder;
332 
333 protected:
336 
339 
341  std::vector<GUIEdge*> myEdgeWrapper;
342 
344  std::vector<GUIJunctionWrapper*> myJunctionWrapper;
345 
347  std::vector<MSTrafficLightLogic*> myTLLogicWrappers;
348 
350  std::vector<GUIDetectorWrapper*> myDetectorDict;
351 
352 
354  typedef std::map<MSLink*, std::string> Links2LogicMap;
356  Links2LogicMap myLinks2Logic;
357 
358 
360  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
362  Logics2WrapperMap myLogics2Wrapper;
363 
364 
366  unsigned int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
367 
370 
371 private:
373  mutable MFXMutex myLock;
374 
375 };
376 
377 
378 #endif
379 
380 /****************************************************************************/
381 
SUMOReal getAvgDuration() const
Definition: GUINet.h:215
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:338
The class responsible for building and deletion of vehicles (gui-version)
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:344
static SUMOReal getAvgDepartDelay()
SUMOReal getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:370
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:528
std::map< MSLink *, std::string > Links2LogicMap
Definition of a link-to-logic-id map.
Definition: GUINet.h:354
Stores the information about how to visualize structures.
SUMOReal getAvgWaitingTime() const
Definition: GUINet.h:218
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:335
void initTLMap()
Initialises the tl-logic map and wrappers.
Definition: GUINet.cpp:145
~GUINet()
Destructor.
Definition: GUINet.cpp:98
void initGUIStructures()
Initialises gui wrappers.
Definition: GUINet.cpp:268
SUMOReal getAvgDepartDelay() const
Definition: GUINet.h:224
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:522
unsigned int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
Definition: GUINet.cpp:332
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
Definition: GUINet.h:356
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
Definition: GUINet.cpp:185
std::vector< GUIDetectorWrapper * > myDetectorDict
A detector dictionary.
Definition: GUINet.h:350
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:279
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:74
long myOverallVehicleCount
Definition: GUINet.h:368
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUINet.cpp:496
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GUINet.cpp:121
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:48
void setIdleDuration(int val)
Sets the duration of the last step&#39;s idle part.
Definition: GUINet.cpp:410
The simulated network and simulation perfomer.
Definition: MSNet.h:94
Container for junctions; performs operations on all stored junctions.
SUMOReal getAvgRouteLength() const
Definition: GUINet.h:212
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:416
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
Definition: GUINet.h:362
static SUMOReal getAvgRouteLength()
accessors for GUINet-Parameters
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:62
SUMOReal getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:361
static SUMOReal getAvgDuration()
GUIGlID createTLWrapper(MSTrafficLightLogic *tll)
creates a wrapper for the given logic and returns the GlID
Definition: GUINet.cpp:158
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
Definition: GUINet.cpp:241
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUINet.cpp:428
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:506
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:213
std::vector< MSTrafficLightLogic * > myTLLogicWrappers
Wrapped TL-Logics.
Definition: GUINet.h:347
friend class GUIOSGBuilder
Definition: GUINet.h:331
unsigned int myLastIdleDuration
Definition: GUINet.h:366
unsigned int getSimDuration() const
Returns the duration of the last step&#39;s simulation part (in ms)
Definition: GUINet.cpp:338
unsigned int GUIGlID
Definition: GUIGlObject.h:49
void setSimDuration(int val)
Sets the duration of the last step&#39;s simulation part.
Definition: GUINet.cpp:394
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:341
const SUMORTree & getVisualisationSpeedUp() const
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:287
unsigned int getIdleDuration() const
Returns the duration of the last step&#39;s idle part (in ms)
Definition: GUINet.cpp:388
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:91
SUMOReal getMeanUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:379
long myOverallSimDuration
Definition: GUINet.h:369
The popup menu of a globject.
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:516
A RT-tree for efficient storing of SUMO&#39;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:253
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
Definition: GUINet.cpp:192
unsigned int myLastSimDuration
The step durations (simulation, /*visualisation, */idle)
Definition: GUINet.h:366
unsigned int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:198
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:352
void simulationStep()
Performs a single simulation step (locking the simulation)
Definition: GUINet.cpp:234
The class responsible for building and deletion of vehicles.
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
Definition: GUINet.cpp:88
void guiSimulationStep()
Some further steps needed for gui processing.
Definition: GUINet.cpp:226
std::map< MSTrafficLightLogic *, GUITrafficLightLogicWrapper * > Logics2WrapperMap
Definition of a traffic light-to-wrapper map.
Definition: GUINet.h:360
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUINet.cpp:500
MSContainerControl & getContainerControl()
Returns the container control.
Definition: GUINet.cpp:136
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:368
SUMOReal getAvgTimeLoss() const
Definition: GUINet.h:221
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:373
MSPersonControl & getPersonControl()
Returns the person control.
Definition: GUINet.cpp:127
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:61