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-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>
38 #include <utils/geom/Boundary.h>
39 #include <utils/geom/Position.h>
47 
48 
49 // ===========================================================================
50 // class declarations
51 // ===========================================================================
52 class MSEdgeControl;
53 class MSJunctionControl;
54 class MSTLLogicControl;
56 class MSLink;
57 class GUIJunctionWrapper;
58 class GUIDetectorWrapper;
60 class RGBColor;
61 class GUIEdge;
62 class OutputDevice;
63 class GUIVehicle;
64 class GUIVehicleControl;
65 class MSVehicleControl;
66 class MFXMutex;
67 #ifdef HAVE_INTERNAL
68 class GUIMEVehicleControl;
69 #endif
70 
71 
72 // ===========================================================================
73 // class definitions
74 // ===========================================================================
90 class GUINet : public MSNet, public GUIGlObject {
91 
92  friend class GUITrafficLightLogicWrapper; // see createTLWrapper
93 
94 public:
102  GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
103  MSEventControl* endOfTimestepEvents, MSEventControl* insertionEvents);
104 
105 
107  ~GUINet();
108 
109 
110 
112 
113 
122  GUISUMOAbstractView& parent);
123 
124 
133  GUIMainWindow& app, GUISUMOAbstractView& parent);
134 
135 
142 
143 
148  void drawGL(const GUIVisualizationSettings& s) const;
150 
151 
153  const Boundary& getBoundary() const;
154 
156  Position getJunctionPosition(const std::string& name) const;
157 
159  bool vehicleExists(const std::string& name) const;
160 
162  void guiSimulationStep();
163 
166  void simulationStep();
167 
170 
174  unsigned int getWholeDuration() const;
175 
176 
180  unsigned int getSimDuration() const;
181 
182 
184  SUMOReal getRTFactor() const;
185 
187  SUMOReal getUPS() const;
188 
190  SUMOReal getMeanRTFactor(int duration) const;
191 
193  SUMOReal getMeanUPS() const;
194 
195  // Returns the duration of the last step's visualisation part (in ms)
196  //int getVisDuration() const;
197 
199  unsigned int getIdleDuration() const;
200 
202  void setSimDuration(int val);
203 
204  // Sets the duration of the last step's visualisation part
205  //void setVisDuration(int val);
206 
208  void setIdleDuration(int val);
209  //}
210 
211 
221 
222 
232 
233 
236  unsigned int getLinkTLID(MSLink* link) const;
237 
240  int getLinkTLIndex(MSLink* link) const;
241 
242 
244 
245 
246  /* @brief Returns the gl-ids of all junctions within the net
247  * @param[in] includeInternal Whether to include ids of internal junctions
248  */
249  std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
250 
252  std::vector<GUIGlID> getTLSIDs() const;
254 
255 
257  void initGUIStructures();
258 
259 
264  return myGrid;
265  }
266 
267 
272  return myGrid;
273  }
274 
281 
282 #ifdef HAVE_INTERNAL
283 
288  GUIMEVehicleControl* getGUIMEVehicleControl();
289 #endif
290 
291 #ifdef HAVE_OSG
292  void updateColor(const GUIVisualizationSettings& s);
293 #endif
294 
296  void lock();
297 
299  void unlock();
300 
305  static GUINet* getGUIInstance();
306 
307 
308 private:
310  void initTLMap();
311 
314 
315  friend class GUIOSGBuilder;
316 
317 protected:
320 
323 
325  std::vector<GUIEdge*> myEdgeWrapper;
326 
328  std::vector<GUIJunctionWrapper*> myJunctionWrapper;
329 
331  std::vector<MSTrafficLightLogic*> myTLLogicWrappers;
332 
334  std::vector<GUIDetectorWrapper*> myDetectorDict;
335 
336 
338  typedef std::map<MSLink*, std::string> Links2LogicMap;
340  Links2LogicMap myLinks2Logic;
341 
342 
344  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
346  Logics2WrapperMap myLogics2Wrapper;
347 
348 
350  unsigned int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
351 
354 
355 private:
357  mutable MFXMutex myLock;
358 
359 };
360 
361 
362 #endif
363 
364 /****************************************************************************/
365 
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:322
The class responsible for building and deletion of vehicles (gui-version)
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:328
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:512
std::map< MSLink *, std::string > Links2LogicMap
Definition of a link-to-logic-id map.
Definition: GUINet.h:338
Stores the information about how to visualize structures.
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:319
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
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:506
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:340
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:334
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:263
A RT-tree for efficient storing of SUMO's GL-objects.
Definition: SUMORTree.h:74
long myOverallVehicleCount
Definition: GUINet.h:352
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUINet.cpp:480
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'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.
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:346
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:61
SUMOReal getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:361
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:490
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:331
friend class GUIOSGBuilder
Definition: GUINet.h:315
unsigned int myLastIdleDuration
Definition: GUINet.h:350
unsigned int getSimDuration() const
Returns the duration of the last step's simulation part (in ms)
Definition: GUINet.cpp:338
unsigned int GUIGlID
Definition: GUIGlObject.h:48
void setSimDuration(int val)
Sets the duration of the last step's simulation part.
Definition: GUINet.cpp:394
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:325
const SUMORTree & getVisualisationSpeedUp() const
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:271
unsigned int getIdleDuration() const
Returns the duration of the last step's idle part (in ms)
Definition: GUINet.cpp:388
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:90
SUMOReal getMeanUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:379
long myOverallSimDuration
Definition: GUINet.h:353
The popup menu of a globject.
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:500
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: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:350
unsigned int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:198
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:218
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:344
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUINet.cpp:484
MSContainerControl & getContainerControl()
Returns the container control.
Definition: GUINet.cpp:136
A window containing a gl-object's parameter.
Stores time-dependant events and executes them at the proper time.
long myLastVehicleMovementCount
Definition: GUINet.h:352
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:357
MSPersonControl & getPersonControl()
Returns the person control.
Definition: GUINet.cpp:127
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:68