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.sourceforge.net/
12 // Copyright (C) 2001-2012 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;
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 #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 
164 
167 
171  unsigned int getWholeDuration() const;
172 
173 
177  unsigned int getSimDuration() const;
178 
179 
181  SUMOReal getRTFactor() const;
182 
184  SUMOReal getUPS() const;
185 
187  SUMOReal getMeanRTFactor(int duration) const;
188 
190  SUMOReal getMeanUPS() const;
191 
192  // Returns the duration of the last step's visualisation part (in ms)
193  //int getVisDuration() const;
194 
196  unsigned int getIdleDuration() const;
197 
199  void setSimDuration(int val);
200 
201  // Sets the duration of the last step's visualisation part
202  //void setVisDuration(int val);
203 
205  void setIdleDuration(int val);
206  //}
207 
208 
218 
219 
222  unsigned int getLinkTLID(MSLink* link) const;
223 
226  int getLinkTLIndex(MSLink* link) const;
227 
228 
230 
231 
232  /* @brief Returns the gl-ids of all junctions within the net
233  * @param[in] includeInternal Whether to include ids of internal junctions
234  */
235  std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
236 
238  std::vector<GUIGlID> getTLSIDs() const;
240 
241 
243  void initGUIStructures();
244 
245 
250  return myGrid;
251  }
252 
253 
258  return myGrid;
259  }
260 
267 
268 #ifdef HAVE_INTERNAL
269 
274  GUIMEVehicleControl* getGUIMEVehicleControl();
275 #endif
276 
281  static GUINet* getGUIInstance();
282 
283 
284 private:
286  void initTLMap();
287 
290 
291  friend class GUIOSGBuilder;
292 
293 protected:
296 
299 
301  std::vector<GUIEdge*> myEdgeWrapper;
302 
304  std::vector<GUIJunctionWrapper*> myJunctionWrapper;
305 
307  std::vector<MSTrafficLightLogic*> myTLLogicWrappers;
308 
310  std::vector<GUIDetectorWrapper*> myDetectorDict;
311 
312 
314  typedef std::map<MSLink*, std::string> Links2LogicMap;
317 
318 
320  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
323 
324 
326  unsigned int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
327 
330 
331 };
332 
333 
334 #endif
335 
336 /****************************************************************************/
337