SUMO - Simulation of Urban MObility
GUINet.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // A MSNet extended by some values for usage within the gui
20 /****************************************************************************/
21 #ifndef GUINet_h
22 #define GUINet_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <string>
35 #include <utility>
36 #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;
68 
69 
70 // ===========================================================================
71 // class definitions
72 // ===========================================================================
88 class GUINet : public MSNet, public GUIGlObject {
89 
90  friend class GUITrafficLightLogicWrapper; // see createTLWrapper
91 
92 public:
100  GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
101  MSEventControl* endOfTimestepEvents, MSEventControl* insertionEvents);
102 
103 
105  ~GUINet();
106 
107 
108 
110 
111 
120  GUISUMOAbstractView& parent);
121 
122 
131  GUIMainWindow& app, GUISUMOAbstractView& parent);
132 
133 
140 
141 
146  void drawGL(const GUIVisualizationSettings& s) const;
148 
149 
151  const Boundary& getBoundary() const;
152 
154  Position getJunctionPosition(const std::string& name) const;
155 
157  bool vehicleExists(const std::string& name) const;
158 
160  void guiSimulationStep();
161 
164  void simulationStep();
165 
168 
172  int getWholeDuration() const;
173 
174 
178  int getSimDuration() const;
179 
180 
182  double getRTFactor() const;
183 
185  double getUPS() const;
186 
188  double getMeanRTFactor(int duration) const;
189 
191  double getMeanUPS() const;
192 
193  // Returns the duration of the last step's visualisation part (in ms)
194  //int getVisDuration() const;
195 
197  int getIdleDuration() const;
198 
200  void setSimDuration(int val);
201 
202  // Sets the duration of the last step's visualisation part
203  //void setVisDuration(int val);
204 
206  void setIdleDuration(int val);
207  //}
208 
209  double getAvgRouteLength() const {
211  }
212  double getAvgDuration() const {
214  }
215  double getAvgWaitingTime() const {
217  }
218  double getAvgTimeLoss() const {
220  }
221  double getAvgDepartDelay() const {
223  }
224  double getAvgTripSpeed() const {
226  }
227  double getAvgWalkRouteLength() const {
229  }
230  double getAvgWalkDuration() const {
232  }
233  double getAvgWalkTimeLoss() const {
235  }
236 
246 
247 
257 
258 
261  int getLinkTLID(MSLink* link) const;
262 
265  int getLinkTLIndex(MSLink* link) const;
266 
267 
269 
270 
271  /* @brief Returns the gl-ids of all junctions within the net
272  * @param[in] includeInternal Whether to include ids of internal junctions
273  */
274  std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
275 
277  std::vector<GUIGlID> getTLSIDs() const;
279 
280 
282  void initGUIStructures();
283 
284 
289  return myGrid;
290  }
291 
292 
297  return myGrid;
298  }
299 
306 
313 
314 #ifdef HAVE_OSG
315  void updateColor(const GUIVisualizationSettings& s);
316 #endif
317 
319  void lock();
320 
322  void unlock();
323 
328  static GUINet* getGUIInstance();
329 
330 
331 private:
333  void initTLMap();
334 
337 
338  friend class GUIOSGBuilder;
339 
340 protected:
343 
346 
348  std::vector<GUIEdge*> myEdgeWrapper;
349 
351  std::vector<GUIJunctionWrapper*> myJunctionWrapper;
352 
354  std::vector<MSTrafficLightLogic*> myTLLogicWrapper;
355 
357  std::vector<GUIDetectorWrapper*> myDetectorWrapper;
358 
359 
361  typedef std::map<MSLink*, std::string> Links2LogicMap;
363  Links2LogicMap myLinks2Logic;
364 
365 
367  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
369  Logics2WrapperMap myLogics2Wrapper;
370 
371 
373  int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
374 
377 
378 private:
380  mutable MFXMutex myLock;
381 
382 };
383 
384 
385 #endif
386 
387 /****************************************************************************/
388 
int myLastSimDuration
The step durations (simulation, /*visualisation, */idle)
Definition: GUINet.h:373
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:345
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
Definition: GUINet.cpp:177
double getAvgWaitingTime() const
Definition: GUINet.h:215
The class responsible for building and deletion of vehicles (gui-version)
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:351
double getAvgDuration() const
Definition: GUINet.h:212
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:528
int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:190
static double getAvgTimeLoss()
std::map< MSLink *, std::string > Links2LogicMap
Definition of a link-to-logic-id map.
Definition: GUINet.h:361
Stores the information about how to visualize structures.
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:342
void initTLMap()
Initialises the tl-logic map and wrappers.
Definition: GUINet.cpp:137
const SUMORTree & getVisualisationSpeedUp() const
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:296
double getAvgWalkDuration() const
Definition: GUINet.h:230
double getMeanUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:367
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:533
The class responsible for building and deletion of vehicles (gui-version)
~GUINet()
Destructor.
Definition: GUINet.cpp:90
void initGUIStructures()
Initialises gui wrappers.
Definition: GUINet.cpp:259
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:522
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
Definition: GUINet.h:363
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:288
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:73
int myLastIdleDuration
Definition: GUINet.h:373
long myOverallVehicleCount
Definition: GUINet.h:375
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:47
void setIdleDuration(int val)
Sets the duration of the last step&#39;s idle part.
Definition: GUINet.cpp:398
The simulated network and simulation perfomer.
Definition: MSNet.h:90
Container for junctions; performs operations on all stored junctions.
static double getAvgDuration()
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:404
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
Definition: GUINet.h:369
static double getAvgWalkTimeLoss()
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:59
GUIGlID createTLWrapper(MSTrafficLightLogic *tll)
creates a wrapper for the given logic and returns the GlID
Definition: GUINet.cpp:150
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUINet.cpp:496
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUINet.cpp:416
std::vector< GUIDetectorWrapper * > myDetectorWrapper
A detector dictionary.
Definition: GUINet.h:357
double getAvgDepartDelay() const
Definition: GUINet.h:221
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:506
static double getAvgWalkRouteLength()
std::vector< GUIGlID > getTLSIDs() const
Returns the gl-ids of all traffic light logics within the net.
Definition: GUINet.cpp:244
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:73
friend class GUIOSGBuilder
Definition: GUINet.h:338
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
Definition: GUINet.cpp:232
static double getAvgWalkDuration()
double getAvgTripSpeed() const
Definition: GUINet.h:224
int getSimDuration() const
Returns the duration of the last step&#39;s simulation part (in ms)
Definition: GUINet.cpp:326
double getAvgWalkTimeLoss() const
Definition: GUINet.h:233
MSTransportableControl & getPersonControl()
Returns the person control.
Definition: GUINet.cpp:119
double getAvgTimeLoss() const
Definition: GUINet.h:218
int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
Definition: GUINet.cpp:320
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:382
static double getAvgWaitingTime()
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:348
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUINet.cpp:500
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:88
double getAvgRouteLength() const
Definition: GUINet.h:209
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GUINet.cpp:113
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
Definition: GUINet.cpp:184
long myOverallSimDuration
Definition: GUINet.h:376
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:55
static double getAvgRouteLength()
accessors for GUINet-Parameters
std::vector< MSTrafficLightLogic * > myTLLogicWrapper
Wrapped TL-Logics.
Definition: GUINet.h:354
double getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:358
static double getAvgDepartDelay()
The parent class for traffic light logics.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
void simulationStep()
Performs a single simulation step (locking the simulation)
Definition: GUINet.cpp:225
double getRTFactor() const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:340
The class responsible for building and deletion of vehicles.
double getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:349
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
Definition: GUINet.cpp:80
void guiSimulationStep()
Some further steps needed for gui processing.
Definition: GUINet.cpp:218
double getAvgWalkRouteLength() const
Definition: GUINet.h:227
std::map< MSTrafficLightLogic *, GUITrafficLightLogicWrapper * > Logics2WrapperMap
Definition of a traffic light-to-wrapper map.
Definition: GUINet.h:367
int getLinkTLIndex(MSLink *link) const
Definition: GUINet.cpp:205
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:375
int getIdleDuration() const
Returns the duration of the last step&#39;s idle part (in ms)
Definition: GUINet.cpp:376
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:380
MSTransportableControl & getContainerControl()
Returns the container control.
Definition: GUINet.cpp:128
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:60