SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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-sim.org/
12 // Copyright (C) 2001-2013 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 
225  unsigned int getLinkTLID(MSLink* link) const;
226 
229  int getLinkTLIndex(MSLink* link) const;
230 
231 
233 
234 
235  /* @brief Returns the gl-ids of all junctions within the net
236  * @param[in] includeInternal Whether to include ids of internal junctions
237  */
238  std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
239 
241  std::vector<GUIGlID> getTLSIDs() const;
243 
244 
246  void initGUIStructures();
247 
248 
253  return myGrid;
254  }
255 
256 
261  return myGrid;
262  }
263 
270 
271 #ifdef HAVE_INTERNAL
272 
277  GUIMEVehicleControl* getGUIMEVehicleControl();
278 #endif
279 
280 #ifdef HAVE_OSG
281  void updateColor(const GUIVisualizationSettings& s);
282 #endif
283 
285  void lock();
286 
288  void unlock();
289 
294  static GUINet* getGUIInstance();
295 
296 
297 private:
299  void initTLMap();
300 
303 
304  friend class GUIOSGBuilder;
305 
306 protected:
309 
312 
314  std::vector<GUIEdge*> myEdgeWrapper;
315 
317  std::vector<GUIJunctionWrapper*> myJunctionWrapper;
318 
320  std::vector<MSTrafficLightLogic*> myTLLogicWrappers;
321 
323  std::vector<GUIDetectorWrapper*> myDetectorDict;
324 
325 
327  typedef std::map<MSLink*, std::string> Links2LogicMap;
330 
331 
333  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
336 
337 
339  unsigned int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
340 
343 
344 private:
346  mutable MFXMutex myLock;
347 
348 };
349 
350 
351 #endif
352 
353 /****************************************************************************/
354 
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:311
The class responsible for building and deletion of vehicles (gui-version)
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:317
SUMOReal getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:357
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:494
std::map< MSLink *, std::string > Links2LogicMap
Definition of a link-to-logic-id map.
Definition: GUINet.h:327
Stores the information about how to visualize structures.
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:308
void initTLMap()
Initialises the tl-logic map and wrappers.
Definition: GUINet.cpp:134
~GUINet()
Destructor.
Definition: GUINet.cpp:96
void initGUIStructures()
Initialises gui wrappers.
Definition: GUINet.cpp:256
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:488
unsigned int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
Definition: GUINet.cpp:319
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
Definition: GUINet.h:329
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
Definition: GUINet.cpp:174
std::vector< GUIDetectorWrapper * > myDetectorDict
A detector dictionary.
Definition: GUINet.h:323
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:252
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:61
long myOverallVehicleCount
Definition: GUINet.h:341
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUINet.cpp:462
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GUINet.cpp:119
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:397
The simulated network and simulation perfomer.
Definition: MSNet.h:87
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:403
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
Definition: GUINet.h:335
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:61
SUMOReal getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:348
GUIGlID createTLWrapper(MSTrafficLightLogic *tll)
creates a wrapper for the given logic and returns the GlID
Definition: GUINet.cpp:147
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
Definition: GUINet.cpp:229
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUINet.cpp:415
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:472
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:73
int getLinkTLIndex(MSLink *link) const
Definition: GUINet.cpp:202
std::vector< MSTrafficLightLogic * > myTLLogicWrappers
Wrapped TL-Logics.
Definition: GUINet.h:320
friend class GUIOSGBuilder
Definition: GUINet.h:304
unsigned int myLastIdleDuration
Definition: GUINet.h:339
unsigned int getSimDuration() const
Returns the duration of the last step&#39;s simulation part (in ms)
Definition: GUINet.cpp:325
unsigned int GUIGlID
Definition: GUIGlObject.h:48
void setSimDuration(int val)
Sets the duration of the last step&#39;s simulation part.
Definition: GUINet.cpp:381
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:314
const SUMORTree & getVisualisationSpeedUp() const
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:260
unsigned int getIdleDuration() const
Returns the duration of the last step&#39;s idle part (in ms)
Definition: GUINet.cpp:375
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:366
long myOverallSimDuration
Definition: GUINet.h:342
The popup menu of a globject.
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:482
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:241
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
Definition: GUINet.cpp:181
unsigned int myLastSimDuration
The step durations (simulation, /*visualisation, */idle)
Definition: GUINet.h:339
unsigned int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:187
The parent class for traffic light logics.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
#define SUMOReal
Definition: config.h:221
SUMOReal getRTFactor() const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:339
void simulationStep()
Performs a single simulation step (locking the simulation)
Definition: GUINet.cpp:222
The class responsible for building and deletion of vehicles.
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
Definition: GUINet.cpp:86
void guiSimulationStep()
Some further steps needed for gui processing.
Definition: GUINet.cpp:215
std::map< MSTrafficLightLogic *, GUITrafficLightLogicWrapper * > Logics2WrapperMap
Definition of a traffic light-to-wrapper map.
Definition: GUINet.h:333
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUINet.cpp:466
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:341
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:346
MSPersonControl & getPersonControl()
Returns the person control.
Definition: GUINet.cpp:125
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:74