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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 // A MSNet extended by some values for usage within the gui
18 /****************************************************************************/
19 #ifndef GUINet_h
20 #define GUINet_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <utility>
30 #include <microsim/MSNet.h>
32 #include <utils/geom/Boundary.h>
33 #include <utils/geom/Position.h>
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
46 class MSEdgeControl;
47 class MSJunctionControl;
48 class MSTLLogicControl;
50 class MSLink;
51 class GUIJunctionWrapper;
52 class GUIDetectorWrapper;
54 class RGBColor;
55 class GUIEdge;
56 class OutputDevice;
57 class GUIVehicle;
58 class GUIVehicleControl;
59 class MSVehicleControl;
60 class MFXMutex;
62 
63 
64 // ===========================================================================
65 // class definitions
66 // ===========================================================================
82 class GUINet : public MSNet, public GUIGlObject {
83 
84  friend class GUITrafficLightLogicWrapper; // see createTLWrapper
85 
86 public:
94  GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
95  MSEventControl* endOfTimestepEvents,
96  MSEventControl* insertionEvents);
97 
98 
100  ~GUINet();
101 
102 
103 
105 
106 
115  GUISUMOAbstractView& parent);
116 
117 
126  GUIMainWindow& app, GUISUMOAbstractView& parent);
127 
128 
135 
136 
141  void drawGL(const GUIVisualizationSettings& s) const;
143 
144 
146  const Boundary& getBoundary() const;
147 
149  Position getJunctionPosition(const std::string& name) const;
150 
152  bool vehicleExists(const std::string& name) const;
153 
155  void guiSimulationStep();
156 
159  void simulationStep();
160 
163 
167  int getWholeDuration() const;
168 
169 
173  int getSimDuration() const;
174 
175 
177  double getRTFactor() const;
178 
180  double getUPS() const;
181 
183  double getMeanRTFactor(int duration) const;
184 
186  double getMeanUPS() const;
187 
188  // Returns the duration of the last step's visualisation part (in ms)
189  //int getVisDuration() const;
190 
192  int getIdleDuration() const;
193 
195  void setSimDuration(int val);
196 
197  // Sets the duration of the last step's visualisation part
198  //void setVisDuration(int val);
199 
201  void setIdleDuration(int val);
202  //}
203 
204  double getAvgRouteLength() const {
206  }
207  double getAvgDuration() const {
209  }
210  double getAvgWaitingTime() const {
212  }
213  double getAvgTimeLoss() const {
215  }
216  double getAvgDepartDelay() const {
218  }
219  double getAvgTripSpeed() const {
221  }
222  double getAvgWalkRouteLength() const {
224  }
225  double getAvgWalkDuration() const {
227  }
228  double getAvgWalkTimeLoss() const {
230  }
231 
241 
242 
252 
253 
256  int getLinkTLID(MSLink* link) const;
257 
260  int getLinkTLIndex(MSLink* link) const;
261 
262 
264 
265 
266  /* @brief Returns the gl-ids of all junctions within the net
267  * @param[in] includeInternal Whether to include ids of internal junctions
268  */
269  std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
270 
272  std::vector<GUIGlID> getTLSIDs() const;
274 
275 
277  void initGUIStructures();
278 
279 
284  return myGrid;
285  }
286 
287 
292  return myGrid;
293  }
294 
301 
308 
309 #ifdef HAVE_OSG
310  void updateColor(const GUIVisualizationSettings& s);
311 #endif
312 
314  void lock();
315 
317  void unlock();
318 
323  static GUINet* getGUIInstance();
324 
327 
328 
329 private:
331  void initTLMap();
332 
333  friend class GUIOSGBuilder;
334 
335 protected:
338 
341 
343  std::vector<GUIEdge*> myEdgeWrapper;
344 
346  std::vector<GUIJunctionWrapper*> myJunctionWrapper;
347 
349  std::vector<MSTrafficLightLogic*> myTLLogicWrapper;
350 
352  std::vector<GUIDetectorWrapper*> myDetectorWrapper;
353 
354 
356  typedef std::map<MSLink*, std::string> Links2LogicMap;
358  Links2LogicMap myLinks2Logic;
359 
360 
362  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
364  Logics2WrapperMap myLogics2Wrapper;
365 
366 
368  int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
369 
372 
373 private:
375  mutable MFXMutex myLock;
376 
377 };
378 
379 
380 #endif
381 
382 /****************************************************************************/
383 
int myLastSimDuration
The step durations (simulation, /*visualisation, */idle)
Definition: GUINet.h:368
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:340
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
Definition: GUINet.cpp:172
double getAvgWaitingTime() const
Definition: GUINet.h:210
The class responsible for building and deletion of vehicles (gui-version)
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:346
double getAvgDuration() const
Definition: GUINet.h:207
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:525
int getLinkTLID(MSLink *link) const
Definition: GUINet.cpp:185
void createTLWrapper(MSTrafficLightLogic *tll)
creates a wrapper for the given logic
Definition: GUINet.cpp:145
static double getAvgTimeLoss()
std::map< MSLink *, std::string > Links2LogicMap
Definition of a link-to-logic-id map.
Definition: GUINet.h:356
Stores the information about how to visualize structures.
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:337
void initTLMap()
Initialises the tl-logic map and wrappers.
Definition: GUINet.cpp:132
const SUMORTree & getVisualisationSpeedUp() const
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:291
double getAvgWalkDuration() const
Definition: GUINet.h:225
double getMeanUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:362
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:530
The class responsible for building and deletion of vehicles (gui-version)
~GUINet()
Destructor.
Definition: GUINet.cpp:85
void initGUIStructures()
Initialises gui wrappers.
Definition: GUINet.cpp:254
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:519
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
Definition: GUINet.h:358
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:283
A RT-tree for efficient storing of SUMO&#39;s GL-objects.
Definition: SUMORTree.h:69
int myLastIdleDuration
Definition: GUINet.h:368
long myOverallVehicleCount
Definition: GUINet.h:370
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
void setIdleDuration(int val)
Sets the duration of the last step&#39;s idle part.
Definition: GUINet.cpp:393
The simulated network and simulation perfomer.
Definition: MSNet.h:84
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:399
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
Definition: GUINet.h:364
static double getAvgWalkTimeLoss()
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:53
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
Definition: GUINet.cpp:493
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent)
Returns an own parameter window.
Definition: GUINet.cpp:411
std::vector< GUIDetectorWrapper * > myDetectorWrapper
A detector dictionary.
Definition: GUINet.h:352
double getAvgDepartDelay() const
Definition: GUINet.h:216
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:503
static double getAvgWalkRouteLength()
std::vector< GUIGlID > getTLSIDs() const
Returns the gl-ids of all traffic light logics within the net.
Definition: GUINet.cpp:239
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:67
friend class GUIOSGBuilder
Definition: GUINet.h:333
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
Definition: GUINet.cpp:227
static double getAvgWalkDuration()
double getAvgTripSpeed() const
Definition: GUINet.h:219
int getSimDuration() const
Returns the duration of the last step&#39;s simulation part (in ms)
Definition: GUINet.cpp:321
double getAvgWalkTimeLoss() const
Definition: GUINet.h:228
MSTransportableControl & getPersonControl()
Returns the person control.
Definition: GUINet.cpp:114
double getAvgTimeLoss() const
Definition: GUINet.h:213
int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
Definition: GUINet.cpp:315
void setSimDuration(int val)
Sets the duration of the last step&#39;s simulation part.
Definition: GUINet.cpp:377
static double getAvgWaitingTime()
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:343
Boundary getCenteringBoundary() const
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUINet.cpp:497
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:82
double getAvgRouteLength() const
Definition: GUINet.h:204
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GUINet.cpp:108
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
Definition: GUINet.cpp:179
long myOverallSimDuration
Definition: GUINet.h:371
The popup menu of a globject.
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:513
A RT-tree for efficient storing of SUMO&#39;s GL-objects in layers.
Definition: LayeredRTree.h:49
static double getAvgRouteLength()
accessors for GUINet-Parameters
std::vector< MSTrafficLightLogic * > myTLLogicWrapper
Wrapped TL-Logics.
Definition: GUINet.h:349
double getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:353
static double getAvgDepartDelay()
The parent class for traffic light logics.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
void simulationStep()
Performs a single simulation step (locking the simulation)
Definition: GUINet.cpp:220
double getRTFactor() const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:335
The class responsible for building and deletion of vehicles.
double getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:344
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
Definition: GUINet.cpp:74
void guiSimulationStep()
Some further steps needed for gui processing.
Definition: GUINet.cpp:213
double getAvgWalkRouteLength() const
Definition: GUINet.h:222
std::map< MSTrafficLightLogic *, GUITrafficLightLogicWrapper * > Logics2WrapperMap
Definition of a traffic light-to-wrapper map.
Definition: GUINet.h:362
int getLinkTLIndex(MSLink *link) const
Definition: GUINet.cpp:200
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:370
int getIdleDuration() const
Returns the duration of the last step&#39;s idle part (in ms)
Definition: GUINet.cpp:371
MFXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:375
MSTransportableControl & getContainerControl()
Returns the container control.
Definition: GUINet.cpp:123
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:54