Eclipse 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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
20 // A MSNet extended by some values for usage within the gui
21 /****************************************************************************/
22 #pragma once
23 #include <config.h>
24 
25 #include <string>
26 #include <utility>
27 #include <microsim/MSNet.h>
29 #include <utils/geom/Boundary.h>
30 #include <utils/geom/Position.h>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
45 class MSEdgeControl;
46 class MSJunctionControl;
47 class MSTLLogicControl;
49 class MSLink;
50 class GUIJunctionWrapper;
51 class GUIDetectorWrapper;
52 class GUICalibrator;
54 class RGBColor;
55 class GUIEdge;
56 class OutputDevice;
57 class GUIVehicle;
58 class GUIVehicleControl;
59 class MSVehicleControl;
61 
62 
63 // ===========================================================================
64 // class definitions
65 // ===========================================================================
81 class GUINet : public MSNet, public GUIGlObject {
82 
83  friend class GUITrafficLightLogicWrapper; // see createTLWrapper
84 
85 public:
93  GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
94  MSEventControl* endOfTimestepEvents,
95  MSEventControl* insertionEvents);
96 
97 
99  ~GUINet();
100 
101 
105  bool isGUINet() const override {
106  return true;
107  }
108 
109 
111 
112 
121 
130 
136  Boundary getCenteringBoundary() const override;
137 
139  double getExaggeration(const GUIVisualizationSettings& s) const override;
140 
145  void drawGL(const GUIVisualizationSettings& s) const override;
147 
148 
150  const Boundary& getBoundary() const;
151 
153  Position getJunctionPosition(const std::string& name) const;
154 
156  bool vehicleExists(const std::string& name) const;
157 
159  void guiSimulationStep();
160 
163  void simulationStep();
164 
167 
171  int getWholeDuration() const;
172 
173 
177  int getSimDuration() const;
178 
179 
181  double getRTFactor() const;
182 
184  double getUPS() const;
185 
187  double getMeanRTFactor(int duration) const;
188 
190  double getMeanUPS() const;
191 
192  // Returns the duration of the last step's visualisation part (in ms)
193  //int getVisDuration() const;
194 
196  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  double getAvgRouteLength() const {
210  }
211  double getAvgDuration() const {
213  }
214  double getAvgWaitingTime() const {
216  }
217  double getAvgTimeLoss() const {
219  }
220  double getAvgDepartDelay() const {
222  }
223  double getAvgTripSpeed() const {
225  }
226  double getAvgWalkRouteLength() const {
228  }
229  double getAvgWalkDuration() const {
231  }
232  double getAvgWalkTimeLoss() const {
234  }
235 
245 
246 
256 
257 
260  int getLinkTLID(const MSLink* const link) const;
261 
264  int getLinkTLIndex(const MSLink* const link) const;
265 
266 
268 
269 
270  /* @brief Returns the gl-ids of all junctions within the net
271  * @param[in] includeInternal Whether to include ids of internal junctions
272  */
273  std::vector<GUIGlID> getJunctionIDs(bool includeInternal) const;
274 
276  std::vector<GUIGlID> getTLSIDs() const;
278 
279 
281  void initGUIStructures();
282 
283 
288  return myGrid;
289  }
290 
291 
296  return myGrid;
297  }
298 
305 
312 
314  double getEdgeData(const MSEdge* edge, const std::string& attr);
315 
317  bool loadEdgeData(const std::string& file);
318 
319 
321  std::vector<std::string> getEdgeDataAttrs() const;
322 
323 #ifdef HAVE_OSG
324  void updateColor(const GUIVisualizationSettings& s);
325 #endif
326 
328  void lock();
329 
331  void unlock();
332 
337  static GUINet* getGUIInstance();
338 
340  void createTLWrapper(MSTrafficLightLogic* tll) override;
341 
343  bool isSelected(const MSTrafficLightLogic* tll) const override;
344 
346  void updateGUI() const override;
347 
348 private:
350  void initTLMap();
351 
352  friend class GUIOSGBuilder;
353 
354 protected:
357 
360 
362  std::vector<GUIEdge*> myEdgeWrapper;
363 
365  std::vector<GUIJunctionWrapper*> myJunctionWrapper;
366 
368  std::vector<GUIDetectorWrapper*> myDetectorWrapper;
369 
371  std::vector<GUICalibrator*> myCalibratorWrapper;
372 
374  typedef std::map<const MSLink*, std::string> Links2LogicMap;
377 
378 
380  typedef std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*> Logics2WrapperMap;
383 
384 
386  int myLastSimDuration, /*myLastVisDuration, */myLastIdleDuration;
387 
390 
392  std::map<std::string, MSEdgeWeightsStorage*> myLoadedEdgeData;
393 
396  public:
397  DiscoverAttributes(const std::string& file):
400  void myStartElement(int element, const SUMOSAXAttributes& attrs);
401  std::vector<std::string> getEdgeAttrs();
405  private:
406  std::set<std::string> edgeAttrs;
407  };
408 
410  public:
413 
416 
425  void addEdgeWeight(const std::string& id, double val, double beg, double end) const;
426  void addEdgeRelWeight(const std::string& from, const std::string& to, double val, double beg, double end) const;
427 
428  private:
431 
432  };
433 
434 private:
436  mutable FXMutex myLock;
437 
438 };
#define SUMOTime_MAX
Definition: SUMOTime.h:33
long long int SUMOTime
Definition: SUMOTime.h:32
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
Changes the speed allowed on a set of lanes (gui version)
Definition: GUICalibrator.h:42
A road/street connecting two junctions (gui-version)
Definition: GUIEdge.h:50
The popup menu of a globject.
The class responsible for building and deletion of vehicles (gui-version)
class for discovering edge attributes
Definition: GUINet.h:395
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Callback method for an opening tag to implement by derived classes.
Definition: GUINet.cpp:583
SUMOTime firstIntervalBegin
Definition: GUINet.h:402
DiscoverAttributes(const std::string &file)
Definition: GUINet.h:397
std::set< std::string > edgeAttrs
Definition: GUINet.h:406
std::vector< std::string > getEdgeAttrs()
Definition: GUINet.cpp:602
MSEdgeWeightsStorage * myWeightStorage
The storage that edges shall be added to.
Definition: GUINet.h:430
void addEdgeWeight(const std::string &id, double val, double beg, double end) const
Adds an effort for a given edge and time period.
Definition: GUINet.cpp:608
~EdgeFloatTimeLineRetriever_GUI()
Destructor.
Definition: GUINet.h:415
void addEdgeRelWeight(const std::string &from, const std::string &to, double val, double beg, double end) const
Definition: GUINet.cpp:619
EdgeFloatTimeLineRetriever_GUI(MSEdgeWeightsStorage *weightStorage)
Constructor.
Definition: GUINet.h:412
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:81
double getAvgTripSpeed() const
Definition: GUINet.h:223
double getAvgRouteLength() const
Definition: GUINet.h:208
double getAvgDuration() const
Definition: GUINet.h:211
int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
Definition: GUINet.cpp:336
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUINet.cpp:521
void setIdleDuration(int val)
Sets the duration of the last step's idle part.
Definition: GUINet.cpp:414
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:543
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:555
double getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:365
const SUMORTree & getVisualisationSpeedUp() const
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:295
bool loadEdgeData(const std::string &file)
load edgeData from file
Definition: GUINet.cpp:641
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUINet.cpp:516
long myLastVehicleMovementCount
Definition: GUINet.h:388
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
Definition: GUINet.cpp:234
std::map< const MSLink *, std::string > Links2LogicMap
Definition of a link-to-logic-id map.
Definition: GUINet.h:374
MSTransportableControl & getPersonControl() override
Returns the person control.
Definition: GUINet.cpp:126
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:436
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration asociated with this GLObject
Definition: GUINet.cpp:527
SUMORTree & getVisualisationSpeedUp()
Returns the RTree used for visualisation speed-up.
Definition: GUINet.h:287
bool isSelected(const MSTrafficLightLogic *tll) const override
return wheter the given logic (or rather it's wrapper) is selected in the GUI
Definition: GUINet.cpp:681
~GUINet()
Destructor.
Definition: GUINet.cpp:90
long myOverallVehicleCount
Definition: GUINet.h:388
void simulationStep()
Performs a single simulation step (locking the simulation)
Definition: GUINet.cpp:227
int getSimDuration() const
Returns the duration of the last step's simulation part (in ms)
Definition: GUINet.cpp:342
void initGUIStructures()
Initialises gui wrappers.
Definition: GUINet.cpp:261
long myOverallSimDuration
Definition: GUINet.h:389
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
Definition: GUINet.cpp:672
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GUINet.cpp:120
double getRTFactor() const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:356
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:362
std::map< MSTrafficLightLogic *, GUITrafficLightLogicWrapper * > Logics2WrapperMap
Definition of a traffic light-to-wrapper map.
Definition: GUINet.h:380
double getAvgWalkDuration() const
Definition: GUINet.h:229
int getLinkTLID(const MSLink *const link) const
Definition: GUINet.cpp:192
void setSimDuration(int val)
Sets the duration of the last step's simulation part.
Definition: GUINet.cpp:398
std::vector< GUICalibrator * > myCalibratorWrapper
A calibrator dictionary.
Definition: GUINet.h:371
bool isGUINet() const override
Returns whether this is a GUI Net.
Definition: GUINet.h:105
double getMeanUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:383
void initTLMap()
Initialises the tl-logic map and wrappers.
Definition: GUINet.cpp:144
int getLinkTLIndex(const MSLink *const link) const
Definition: GUINet.cpp:207
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:359
double getAvgWalkTimeLoss() const
Definition: GUINet.h:232
std::vector< GUIGlID > getTLSIDs() const
Returns the gl-ids of all traffic light logics within the net.
Definition: GUINet.cpp:246
std::map< std::string, MSEdgeWeightsStorage * > myLoadedEdgeData
loaded edge data for visualization
Definition: GUINet.h:392
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUINet.cpp:432
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
Definition: GUINet.h:382
int getIdleDuration() const
Returns the duration of the last step's idle part (in ms)
Definition: GUINet.cpp:392
double getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:374
void createTLWrapper(MSTrafficLightLogic *tll) override
creates a wrapper for the given logic
Definition: GUINet.cpp:153
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
Definition: GUINet.cpp:186
std::vector< GUIDetectorWrapper * > myDetectorWrapper
A detector dictionary.
Definition: GUINet.h:368
double getAvgWalkRouteLength() const
Definition: GUINet.h:226
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:549
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:365
void updateGUI() const override
update view after simulation.loadState
Definition: GUINet.cpp:686
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:533
double getAvgTimeLoss() const
Definition: GUINet.h:217
double getAvgDepartDelay() const
Definition: GUINet.h:220
double getEdgeData(const MSEdge *edge, const std::string &attr)
retrieve loaded edged weight for the given attribute and the current simulation time
Definition: GUINet.cpp:566
double getAvgWaitingTime() const
Definition: GUINet.h:214
int myLastSimDuration
The step durations (simulation, /*visualisation, *‍/idle)
Definition: GUINet.h:386
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
Definition: GUINet.cpp:179
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUINet.cpp:420
int myLastIdleDuration
Definition: GUINet.h:386
friend class GUIOSGBuilder
Definition: GUINet.h:352
void guiSimulationStep()
Some further steps needed for gui processing.
Definition: GUINet.cpp:220
MSTransportableControl & getContainerControl() override
Returns the container control.
Definition: GUINet.cpp:135
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
Definition: GUINet.cpp:79
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:560
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
Definition: GUINet.h:376
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:356
A window containing a gl-object's parameter.
The class responsible for building and deletion of vehicles (gui-version)
A MSVehicle extended by some values for usage within the gui.
Definition: GUIVehicle.h:51
Stores the information about how to visualize structures.
A RT-tree for efficient storing of SUMO's GL-objects in layers.
Definition: LayeredRTree.h:46
static double getAvgWalkRouteLength()
static double getAvgTimeLoss()
static double getAvgDepartDelay()
static double getAvgRouteLength()
accessors for GUINet-Parameters
static double getAvgWaitingTime()
static double getAvgDuration()
static double getAvgWalkDuration()
static double getAvgWalkTimeLoss()
Stores edges and lanes, performs moving of vehicle.
Definition: MSEdgeControl.h:81
A road/street connecting two junctions.
Definition: MSEdge.h:77
A storage for edge travel times and efforts.
Stores time-dependant events and executes them at the proper time.
Container for junctions; performs operations on all stored junctions.
The simulated network and simulation perfomer.
Definition: MSNet.h:88
A class that stores and controls tls and switching of their programs.
The parent class for traffic light logics.
The class responsible for building and deletion of vehicles.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
Interface for a class which obtains read weights for named edges.
A RT-tree for efficient storing of SUMO's GL-objects.
Definition: SUMORTree.h:66
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.