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