Eclipse SUMO - Simulation of Urban MObility
GUINet.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 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 /****************************************************************************/
21 // A MSNet extended by some values for usage within the gui
22 /****************************************************************************/
23 #include <config.h>
24 
25 #include <utility>
26 #include <set>
27 #include <vector>
28 #include <map>
36 #include <utils/xml/XMLSubSys.h>
38 #include <utils/common/RGBColor.h>
40 #include <microsim/MSNet.h>
42 #include <microsim/MSJunction.h>
44 #include <microsim/MSEdge.h>
50 #include <guisim/GUIEdge.h>
51 #include <guisim/GUILane.h>
55 #include <guisim/GUICalibrator.h>
59 #include <gui/GUIGlobals.h>
60 #include "GUINet.h"
61 
63 
64 
65 // ===========================================================================
66 // definition of static variables used for visualisation of objects' values
67 // ===========================================================================
68 template std::vector< GLObjectValuePassConnector<double>* > GLObjectValuePassConnector<double>::myContainer;
70 
71 template std::vector< GLObjectValuePassConnector<std::pair<int, class MSPhaseDefinition> >* > GLObjectValuePassConnector<std::pair<int, class MSPhaseDefinition> >::myContainer;
73 
74 
75 // ===========================================================================
76 // member method definitions
77 // ===========================================================================
78 GUINet::GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
79  MSEventControl* endOfTimestepEvents,
80  MSEventControl* insertionEvents) :
81  MSNet(vc, beginOfTimestepEvents, endOfTimestepEvents, insertionEvents, new GUIShapeContainer(myGrid)),
83  myLastSimDuration(0), /*myLastVisDuration(0),*/ myLastIdleDuration(0),
84  myLastVehicleMovementCount(0), myOverallVehicleCount(0), myOverallSimDuration(0) {
86 }
87 
88 
90  if (myLock.locked()) {
91  myLock.unlock();
92  }
93  // delete allocated wrappers
94  // of junctions
95  for (std::vector<GUIJunctionWrapper*>::iterator i1 = myJunctionWrapper.begin(); i1 != myJunctionWrapper.end(); i1++) {
96  delete (*i1);
97  }
98  // of additional structures
100  // of tl-logics
101  for (Logics2WrapperMap::iterator i3 = myLogics2Wrapper.begin(); i3 != myLogics2Wrapper.end(); i3++) {
102  delete (*i3).second;
103  }
104  // of detectors
105  for (std::vector<GUIDetectorWrapper*>::iterator i = myDetectorWrapper.begin(); i != myDetectorWrapper.end(); ++i) {
106  delete *i;
107  }
108  // of calibrators
109  for (GUICalibrator* cw : myCalibratorWrapper) {
110  delete cw;
111  }
112  for (auto& item : myLoadedEdgeData) {
113  delete item.second;
114  }
115 }
116 
117 
118 const Boundary&
120  return myBoundary;
121 }
122 
123 
126  if (myPersonControl == nullptr) {
128  }
129  return *myPersonControl;
130 }
131 
132 
135  if (myContainerControl == nullptr) {
137  }
138  return *myContainerControl;
139 }
140 
141 
142 void
144  // get the list of loaded tl-logics
145  const std::vector<MSTrafficLightLogic*>& logics = getTLSControl().getAllLogics();
146  // go through the logics
147  for (std::vector<MSTrafficLightLogic*>::const_iterator i = logics.begin(); i != logics.end(); ++i) {
148  createTLWrapper(*i);
149  }
150 }
151 
152 
153 void
155  if (myLogics2Wrapper.count(tll) > 0) {
156  return;
157  }
158  // get the links
159  const MSTrafficLightLogic::LinkVectorVector& links = tll->getLinks();
160  if (links.size() == 0) { // @legacy this should never happen in 0.13.0+ networks
161  return;
162  }
163  // build the wrapper
166  // build the association link->wrapper
167  MSTrafficLightLogic::LinkVectorVector::const_iterator j;
168  for (j = links.begin(); j != links.end(); ++j) {
169  MSTrafficLightLogic::LinkVector::const_iterator j2;
170  for (j2 = (*j).begin(); j2 != (*j).end(); ++j2) {
171  myLinks2Logic[*j2] = tll->getID();
172  }
173  }
175  myLogics2Wrapper[tll] = tllw;
176  return;
177 }
178 
179 
180 Position
181 GUINet::getJunctionPosition(const std::string& name) const {
182  // !!! no check for existance!
183  return myJunctions->get(name)->getPosition();
184 }
185 
186 
187 bool
188 GUINet::vehicleExists(const std::string& name) const {
189  return myVehicleControl->getVehicle(name) != nullptr;
190 }
191 
192 
193 int
194 GUINet::getLinkTLID(const MSLink* const link) const {
195  if (myLinks2Logic.count(link) == 0) {
196  assert(false);
197  return 0;
198  }
199  MSTrafficLightLogic* tll = myLogics->getActive(myLinks2Logic.find(link)->second);
200  if (myLogics2Wrapper.count(tll) == 0) {
201  // tll may have been added via traci. @see ticket #459
202  return 0;
203  }
204  return myLogics2Wrapper.find(tll)->second->getGlID();
205 }
206 
207 
208 int
209 GUINet::getLinkTLIndex(const MSLink* const link) const {
210  Links2LogicMap::const_iterator i = myLinks2Logic.find(link);
211  if (i == myLinks2Logic.end()) {
212  return -1;
213  }
214  if (myLogics2Wrapper.find(myLogics->getActive((*i).second)) == myLogics2Wrapper.end()) {
215  return -1;
216  }
217  return myLogics2Wrapper.find(myLogics->getActive((*i).second))->second->getLinkIndex(link);
218 }
219 
220 
221 void
225 }
226 
227 
228 void
230  FXMutexLock locker(myLock);
232 }
233 
234 
235 std::vector<GUIGlID>
236 GUINet::getJunctionIDs(bool includeInternal) const {
237  std::vector<GUIGlID> ret;
238  for (std::vector<GUIJunctionWrapper*>::const_iterator i = myJunctionWrapper.begin(); i != myJunctionWrapper.end(); ++i) {
239  if (!(*i)->isInternal() || includeInternal) {
240  ret.push_back((*i)->getGlID());
241  }
242  }
243  return ret;
244 }
245 
246 
247 std::vector<GUIGlID>
249  std::vector<GUIGlID> ret;
250  std::vector<std::string> ids;
251  for (std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*>::const_iterator i = myLogics2Wrapper.begin(); i != myLogics2Wrapper.end(); ++i) {
252  std::string sid = (*i).second->getMicrosimID();
253  if (find(ids.begin(), ids.end(), sid) == ids.end()) {
254  ret.push_back((*i).second->getGlID());
255  ids.push_back(sid);
256  }
257  }
258  return ret;
259 }
260 
261 
262 void
264  // initialise detector storage for gui
265  const std::vector<SumoXMLTag> types = myDetectorControl->getAvailableTypes();
266  for (std::vector<SumoXMLTag>::const_iterator i = types.begin(); i != types.end(); ++i) {
267  for (const auto& j : myDetectorControl->getTypedDetectors(*i)) {
268  GUIDetectorWrapper* wrapper = j.second->buildDetectorGUIRepresentation();
269  if (wrapper != nullptr) {
270  myDetectorWrapper.push_back(wrapper);
271  myGrid.addAdditionalGLObject(wrapper);
272  }
273  }
274  }
275  // initialise calibrators
276  for (auto& item : MSCalibrator::getInstances()) {
277  GUICalibrator* wrapper = new GUICalibrator(item.second);
278  myCalibratorWrapper.push_back(wrapper);
279  myGrid.addAdditionalGLObject(wrapper);
280  }
281  // initialise the tl-map
282  initTLMap();
283  // initialise edge storage for gui
284  const MSEdgeVector& edges = MSEdge::getAllEdges();
285  myEdgeWrapper.reserve(edges.size());
286  for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
287  // VISIM connector edges shall be drawn (they have lanes)
288  if (!(*i)->isTazConnector() || (*i)->getLanes().size() > 0) {
289  myEdgeWrapper.push_back(static_cast<GUIEdge*>(*i));
290  }
291  }
292  // initialise junction storage for gui
293  int size = myJunctions->size();
294  myJunctionWrapper.reserve(size);
295  std::map<MSJunction*, std::string> junction2TLL;
296  for (const auto tls : getTLSControl().getAllLogics()) {
297  for (const auto& links : tls->getLinks()) {
298  for (const MSLink* l : links) {
299  junction2TLL[l->getJunction()] = l->getTLLogic()->getID();
300  }
301  }
302  }
303  for (const auto& i : *myJunctions) {
304  myJunctionWrapper.push_back(new GUIJunctionWrapper(*i.second, junction2TLL[i.second]));
305  }
306  // build the visualization tree
307  for (std::vector<GUIEdge*>::iterator i = myEdgeWrapper.begin(); i != myEdgeWrapper.end(); ++i) {
308  GUIEdge* edge = *i;
309  Boundary b;
310  const std::vector<MSLane*>& lanes = edge->getLanes();
311  for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
312  b.add((*j)->getShape().getBoxBoundary());
313  }
314  // make sure persons are always drawn and selectable since they depend on their edge being drawn
316  const float cmin[2] = { (float)b.xmin(), (float)b.ymin() };
317  const float cmax[2] = { (float)b.xmax(), (float)b.ymax() };
318  myGrid.Insert(cmin, cmax, edge);
319  myBoundary.add(b);
320  if (myBoundary.getWidth() > 10e16 || myBoundary.getHeight() > 10e16) {
321  throw ProcessError("Network size exceeds 1 Lightyear. Please reconsider your inputs.\n");
322  }
323  }
324  for (std::vector<GUIJunctionWrapper*>::iterator i = myJunctionWrapper.begin(); i != myJunctionWrapper.end(); ++i) {
325  GUIJunctionWrapper* junction = *i;
326  Boundary b = junction->getBoundary();
327  b.grow(2.);
328  const float cmin[2] = { (float)b.xmin(), (float)b.ymin() };
329  const float cmax[2] = { (float)b.xmax(), (float)b.ymax() };
330  myGrid.Insert(cmin, cmax, junction);
331  myBoundary.add(b);
332  }
334 }
335 
336 
337 int
339  return myLastSimDuration +/*myLastVisDuration+*/myLastIdleDuration;
340 }
341 
342 
343 int
345  return myLastSimDuration;
346 }
347 
348 /*
349 int
350 GUINet::getVisDuration() const
351 {
352  return myLastVisDuration;
353 }
354 */
355 
356 
357 double
359  if (myLastSimDuration == 0) {
360  return -1;
361  }
362  return (double)DELTA_T / (double)myLastSimDuration;
363 }
364 
365 
366 double
367 GUINet::getUPS() const {
368  if (myLastSimDuration == 0) {
369  return -1;
370  }
371  return (double) myLastVehicleMovementCount / (double) myLastSimDuration * (double) 1000.;
372 }
373 
374 
375 double
376 GUINet::getMeanRTFactor(int duration) const {
377  if (myOverallSimDuration == 0) {
378  return -1;
379  }
380  return ((double)(duration) * (double) 1000. / (double)myOverallSimDuration);
381 }
382 
383 
384 double
386  if (myOverallSimDuration == 0) {
387  return -1;
388  }
389  return ((double)myVehiclesMoved / (double)myOverallSimDuration * (double) 1000.);
390 }
391 
392 
393 int
395  return myLastIdleDuration;
396 }
397 
398 
399 void
401  myLastSimDuration = val;
402  myOverallSimDuration += val;
405 }
406 
407 /*
408 void
409 GUINet::setVisDuration(int val)
410 {
411  myLastVisDuration = val;
412 }
413 */
414 
415 void
417  myLastIdleDuration = val;
418 }
419 
420 
423  GUISUMOAbstractView& parent) {
424  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
425  buildPopupHeader(ret, app);
428  buildPositionCopyEntry(ret, false);
429  return ret;
430 }
431 
432 
435  GUISUMOAbstractView& parent) {
436  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
437  // add items
438  ret->mkItem("loaded vehicles [#]", true,
440  ret->mkItem("insertion-backlogged vehicles [#]", true,
442  ret->mkItem("departed vehicles [#]", true,
444  ret->mkItem("running vehicles [#]", true,
446  ret->mkItem("arrived vehicles [#]", true,
448  ret->mkItem("discarded vehicles [#]", true,
450  ret->mkItem("collisions [#]", true,
452  ret->mkItem("teleports [#]", true,
454  ret->mkItem("halting [#]", true,
456  ret->mkItem("avg. speed [m/s]", true,
458  ret->mkItem("avg. relative speed", true,
460  if (myPersonControl != nullptr) {
461  ret->mkItem("loaded persons [#]", true,
463  ret->mkItem("running persons [#]", true,
465  ret->mkItem("jammed persons [#]", true,
467  }
468  ret->mkItem("end time [s]", false, OptionsCont::getOptions().getString("end"));
469  ret->mkItem("begin time [s]", false, OptionsCont::getOptions().getString("begin"));
470 // ret->mkItem("time step [s]", true, new FunctionBinding<GUINet, SUMOTime>(this, &GUINet::getCurrentTimeStep));
471  if (logSimulationDuration()) {
472  ret->mkItem("step duration [ms]", true, new FunctionBinding<GUINet, int>(this, &GUINet::getWholeDuration));
474  ret->mkItem("simulation duration [ms]", true, new FunctionBinding<GUINet, int>(this, &GUINet::getSimDuration));
475  /*
476  ret->mkItem("visualisation duration [ms]", true,
477  new CastingFunctionBinding<GUINet, double, int>(
478  &(getNet()), &GUINet::getVisDuration));
479  */
480  ret->mkItem("idle duration [ms]", true, new FunctionBinding<GUINet, int>(this, &GUINet::getIdleDuration));
481  ret->mkItem("duration factor", true, new FunctionBinding<GUINet, double>(this, &GUINet::getRTFactor));
482  /*
483  ret->mkItem("mean duration factor []", true,
484  new FuncBinding_IntParam<GUINet, double>(
485  &(getNet()), &GUINet::getMeanRTFactor), 1);
486  */
487  ret->mkItem("updates per second", true, new FunctionBinding<GUINet, double>(this, &GUINet::getUPS));
488  ret->mkItem("avg. updates per second", true, new FunctionBinding<GUINet, double>(this, &GUINet::getMeanUPS));
489  if (OptionsCont::getOptions().getBool("duration-log.statistics")) {
490  ret->mkItem("avg. trip length [m]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgRouteLength));
491  ret->mkItem("avg. trip duration [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgDuration));
492  ret->mkItem("avg. trip waiting time [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgWaitingTime));
493  ret->mkItem("avg. trip time loss [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgTimeLoss));
494  ret->mkItem("avg. trip depart delay [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgDepartDelay));
495  ret->mkItem("avg. trip speed [m/s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgTripSpeed));
496  if (myPersonControl != nullptr) {
497  ret->mkItem("avg. walk length [m]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgWalkRouteLength));
498  ret->mkItem("avg. walk duration [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgWalkDuration));
499  ret->mkItem("avg. walk time loss [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgWalkTimeLoss));
500  }
501  }
502  }
503  ret->mkItem("nodes [#]", false, (int)getJunctionIDs(false).size());
504  ret->mkItem("edges [#]", false, (int)GUIEdge::getIDs(false).size());
505  ret->mkItem("total edge length [km]", false, GUIEdge::getTotalLength(false, false) / 1000);
506  ret->mkItem("total lane length [km]", false, GUIEdge::getTotalLength(false, true) / 1000);
507  ret->mkItem("network version ", false, toString(myVersion));
508 
509  // close building
510  ret->closeBuilding();
511  return ret;
512 }
513 
514 
515 void
517 }
518 
519 Boundary
521  return getBoundary();
522 }
523 
524 
525 GUINet*
527  GUINet* net = dynamic_cast<GUINet*>(MSNet::getInstance());
528  if (net != nullptr) {
529  return net;
530  }
531  throw ProcessError("A gui-network was not yet constructed.");
532 }
533 
534 
537  return dynamic_cast<GUIVehicleControl*>(myVehicleControl);
538 }
539 
540 
541 void
543  myLock.lock();
544 }
545 
546 
547 void
549  myLock.unlock();
550 }
551 
554  return dynamic_cast<GUIMEVehicleControl*>(myVehicleControl);
555 }
556 
557 
558 double
559 GUINet::getEdgeData(const MSEdge* edge, const std::string& attr) {
560  auto it = myLoadedEdgeData.find(attr);
561  if (it != myLoadedEdgeData.end()) {
562  double value;
563  bool found = it->second->retrieveExistingEffort(edge, STEPS2TIME(getCurrentTimeStep()), value);
564  if (found) {
565  return value;
566  } else {
568  }
569  } else {
571  }
572 }
573 
574 
575 void
577  if (element == SUMO_TAG_EDGE || element == SUMO_TAG_LANE) {
578  std::vector<std::string> tmp = attrs.getAttributeNames();
579  edgeAttrs.insert(tmp.begin(), tmp.end());
580  } else if (element == SUMO_TAG_EDGEREL) {
581  for (const std::string& a : attrs.getAttributeNames()) {
582  if (a != "from" && a != "to") {
583  edgeAttrs.insert(a);
584  }
585  }
586  } else if (element == SUMO_TAG_INTERVAL) {
587  bool ok;
589  }
590 }
591 
592 std::vector<std::string>
594  edgeAttrs.erase(toString(SUMO_ATTR_ID));
595  return std::vector<std::string>(edgeAttrs.begin(), edgeAttrs.end());
596 }
597 
598 void
600  double value, double begTime, double endTime) const {
601  MSEdge* edge = MSEdge::dictionary(id);
602  if (edge != nullptr) {
603  myWeightStorage->addEffort(edge, begTime, endTime, value);
604  } else {
605  WRITE_ERROR("Trying to set the effort for the unknown edge '" + id + "'.");
606  }
607 }
608 
609 void
610 GUINet::EdgeFloatTimeLineRetriever_GUI::addEdgeRelWeight(const std::string& from, const std::string& to,
611  double val, double beg, double end) const {
612  MSEdge* fromEdge = MSEdge::dictionary(from);
613  MSEdge* toEdge = MSEdge::dictionary(to);
614  if (fromEdge != nullptr && toEdge != nullptr) {
615  for (auto item : fromEdge->getViaSuccessors()) {
616  if (item.first == toEdge) {
617  const MSEdge* edge = item.second;
618  while (edge != nullptr && edge->isInternal()) {
619  myWeightStorage->addEffort(edge, beg, end, val);
620  edge = edge->getViaSuccessors().front().second;
621  }
622  }
623  }
624  } else if (fromEdge == nullptr) {
625  WRITE_ERROR("Trying to set the effort for the unknown edge '" + from + "'.");
626  } else {
627  WRITE_ERROR("Trying to set the effort for the unknown edge '" + to + "'.");
628  }
629 }
630 
631 bool
632 GUINet::loadEdgeData(const std::string& file) {
633  // discover edge attributes
634  DiscoverAttributes discoveryHandler(file);
635  XMLSubSys::runParser(discoveryHandler, file);
636  std::vector<std::string> attrs = discoveryHandler.getEdgeAttrs();
637  WRITE_MESSAGE("Loading edgedata from '" + file
638  + "' Found " + toString(attrs.size())
639  + " attributes: " + toString(attrs));
641  // create a retriever for each attribute
642  std::vector<EdgeFloatTimeLineRetriever_GUI> retrieverDefsInternal;
643  retrieverDefsInternal.reserve(attrs.size());
644  std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
645  for (const std::string& attr : attrs) {
647  myLoadedEdgeData[attr] = ws;
648  retrieverDefsInternal.push_back(EdgeFloatTimeLineRetriever_GUI(ws));
649  retrieverDefs.push_back(new SAXWeightsHandler::ToRetrieveDefinition(attr, true, retrieverDefsInternal.back()));
650  }
651  SAXWeightsHandler handler(retrieverDefs, "");
652  return XMLSubSys::runParser(handler, file);
653 }
654 
655 
656 std::vector<std::string>
658  std::vector<std::string> result;
659  for (const auto& item : myLoadedEdgeData) {
660  result.push_back(item.first);
661  }
662  return result;
663 }
664 
665 bool
667  const auto it = myLogics2Wrapper.find(const_cast<MSTrafficLightLogic*>(tll));
668  return it != myLogics2Wrapper.end() && gSelected.isSelected(GLO_TLLOGIC, it->second->getGlID());
669 }
670 
671 #ifdef HAVE_OSG
672 void
673 GUINet::updateColor(const GUIVisualizationSettings& s) {
674  for (std::vector<GUIEdge*>::const_iterator i = myEdgeWrapper.begin(); i != myEdgeWrapper.end(); ++i) {
675  if (!(*i)->isInternal()) {
676  const std::vector<MSLane*>& lanes = (*i)->getLanes();
677  for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
678  static_cast<GUILane*>(*j)->updateColor(s);
679  }
680  }
681  }
682  for (std::vector<GUIJunctionWrapper*>::iterator i = myJunctionWrapper.begin(); i != myJunctionWrapper.end(); ++i) {
683  (*i)->updateColor(s);
684  }
685 }
686 #endif
687 
688 
689 /****************************************************************************/
@ GLO_NETWORK
The network - empty.
@ GLO_TLLOGIC
a tl-logic
GUISelectedStorage gSelected
A global holder of selected objects.
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:73
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:278
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:284
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
#define STEPS2TIME(x)
Definition: SUMOTime.h:53
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_EDGEREL
a relation between two edges
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
T MAX2(T a, T b)
Definition: StdDefs.h:79
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:44
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
void add(double x, double y, double z=0)
Makes the boundary include the given coordinate.
Definition: Boundary.cpp:77
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:129
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:117
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:299
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:159
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:153
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:135
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:123
Class passing values from a GUIGlObject to another object.
static void updateAll()
Updates all instances (passes values)
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
static double getTotalLength(bool includeInternal, bool eachLane)
Definition: GUIEdge.cpp:116
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition: GUIEdge.cpp:101
The popup menu of a globject.
static void clearDictionary()
Clears the dictionary (the objects will not be deleted)
void buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to copy the cursor position if geo projection is used,...
void buildShowParamsPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to open the parameter window.
void buildCenterPopupEntry(GUIGLObjectPopupMenu *ret, bool addSeparator=true)
Builds an entry which allows to center to the object.
void buildPopupHeader(GUIGLObjectPopupMenu *ret, GUIMainWindow &app, bool addSeparator=true)
Builds the header.
void setNetObject(GUIGlObject *object)
Sets the given object as the "network" object.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
Boundary getBoundary() const
Returns the boundary of the junction.
Representation of a lane in the micro simulation (gui-version)
Definition: GUILane.h:59
The class responsible for building and deletion of vehicles (gui-version)
class for discovering edge attributes
Definition: GUINet.h:392
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Callback method for an opening tag to implement by derived classes.
Definition: GUINet.cpp:576
std::set< std::string > edgeAttrs
Definition: GUINet.h:401
std::vector< std::string > getEdgeAttrs()
Definition: GUINet.cpp:593
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:599
void addEdgeRelWeight(const std::string &from, const std::string &to, double val, double beg, double end) const
Definition: GUINet.cpp:610
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:338
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUINet.cpp:520
void setIdleDuration(int val)
Sets the duration of the last step's idle part.
Definition: GUINet.cpp:416
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:536
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:548
double getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:367
bool loadEdgeData(const std::string &file)
load edgeData from file
Definition: GUINet.cpp:632
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUINet.cpp:516
long myLastVehicleMovementCount
Definition: GUINet.h:385
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
Definition: GUINet.cpp:236
MSTransportableControl & getPersonControl() override
Returns the person control.
Definition: GUINet.cpp:125
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:431
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:666
~GUINet()
Destructor.
Definition: GUINet.cpp:89
long myOverallVehicleCount
Definition: GUINet.h:385
void simulationStep()
Performs a single simulation step (locking the simulation)
Definition: GUINet.cpp:229
int getSimDuration() const
Returns the duration of the last step's simulation part (in ms)
Definition: GUINet.cpp:344
void initGUIStructures()
Initialises gui wrappers.
Definition: GUINet.cpp:263
long myOverallSimDuration
Definition: GUINet.h:386
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
Definition: GUINet.cpp:657
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GUINet.cpp:119
double getRTFactor() const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:358
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:359
double getAvgWalkDuration() const
Definition: GUINet.h:229
int getLinkTLID(const MSLink *const link) const
Definition: GUINet.cpp:194
void setSimDuration(int val)
Sets the duration of the last step's simulation part.
Definition: GUINet.cpp:400
std::vector< GUICalibrator * > myCalibratorWrapper
A calibrator dictionary.
Definition: GUINet.h:368
double getMeanUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:385
void initTLMap()
Initialises the tl-logic map and wrappers.
Definition: GUINet.cpp:143
int getLinkTLIndex(const MSLink *const link) const
Definition: GUINet.cpp:209
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:356
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:248
std::map< std::string, MSEdgeWeightsStorage * > myLoadedEdgeData
loaded edge data for visualization
Definition: GUINet.h:389
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUINet.cpp:434
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
Definition: GUINet.h:379
int getIdleDuration() const
Returns the duration of the last step's idle part (in ms)
Definition: GUINet.cpp:394
double getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:376
void createTLWrapper(MSTrafficLightLogic *tll) override
creates a wrapper for the given logic
Definition: GUINet.cpp:154
bool vehicleExists(const std::string &name) const
returns the information whether the vehicle still exists
Definition: GUINet.cpp:188
std::vector< GUIDetectorWrapper * > myDetectorWrapper
A detector dictionary.
Definition: GUINet.h:365
double getAvgWalkRouteLength() const
Definition: GUINet.h:226
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:542
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:362
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:526
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:559
double getAvgWaitingTime() const
Definition: GUINet.h:214
friend class GUITrafficLightLogicWrapper
Definition: GUINet.h:83
int myLastSimDuration
The step durations (simulation, /*visualisation, *‍/idle)
Definition: GUINet.h:383
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
Definition: GUINet.cpp:181
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUINet.cpp:422
int myLastIdleDuration
Definition: GUINet.h:383
void guiSimulationStep()
Some further steps needed for gui processing.
Definition: GUINet.cpp:222
MSTransportableControl & getContainerControl() override
Returns the container control.
Definition: GUINet.cpp:134
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
Definition: GUINet.cpp:78
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:553
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
Definition: GUINet.h:373
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:353
A window containing a gl-object's parameter.
void mkItem(const char *name, bool dynamic, ValueSource< T > *src)
Adds a row which obtains its value from a ValueSource.
void closeBuilding(const Parameterised *p=0)
Closes the building of the table.
double getFPS() const
retrieve FPS
bool isSelected(GUIGlObjectType type, GUIGlID id)
Returns the information whether the object with the given type and id is selected.
Storage for geometrical objects extended by mutexes.
GUI-version of the transportable control for building gui persons and containers.
The class responsible for building and deletion of vehicles (gui-version)
Stores the information about how to visualize structures.
void Insert(const float a_min[2], const float a_max[2], GUIGlObject *const &a_dataId)
Insert entry (delegate to appropriate layer)
Definition: LayeredRTree.h:69
static const std::map< std::string, MSCalibrator * > & getInstances()
return all calibrator instances
Definition: MSCalibrator.h:98
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
const std::vector< SumoXMLTag > getAvailableTypes() const
Returns the list of available detector types.
A road/street connecting two junctions.
Definition: MSEdge.h:77
static const MSEdgeVector & getAllEdges()
Returns all edges with a numerical id.
Definition: MSEdge.cpp:847
const MSConstEdgePairVector & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges with internal vias, restricted by vClass.
Definition: MSEdge.cpp:1043
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:166
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:256
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition: MSEdge.cpp:814
A storage for edge travel times and efforts.
Stores time-dependant events and executes them at the proper time.
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
const Position & getPosition() const
Definition: MSJunction.cpp:68
The simulated network and simulation perfomer.
Definition: MSNet.h:89
MSTransportableControl * myPersonControl
Controls person building and deletion;.
Definition: MSNet.h:770
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:171
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:444
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition: MSNet.h:776
double myVersion
the network version
Definition: MSNet.h:862
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:371
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
Definition: MSNet.h:768
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:313
void simulationStep()
Performs a single simulation step.
Definition: MSNet.cpp:540
MSTransportableControl * myContainerControl
Controls container building and deletion;.
Definition: MSNet.h:772
SUMOTime myEdgeDataEndTime
end of loaded edgeData
Definition: MSNet.h:865
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:424
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
Definition: MSNet.h:778
bool logSimulationDuration() const
Returns whether duration shall be logged.
Definition: MSNet.cpp:980
long long int myVehiclesMoved
The overall number of vehicle movements.
Definition: MSNet.h:815
MSDetectorControl * myDetectorControl
Controls detectors;.
Definition: MSNet.h:782
static const double SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk
Definition: MSPModel.h:113
std::vector< MSTrafficLightLogic * > getAllLogics() const
Returns a vector which contains all logics.
MSTrafficLightLogic * getActive(const std::string &id) const
Returns the active program of a named tls.
The parent class for traffic light logics.
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
std::vector< LinkVector > LinkVectorVector
Definition of a list that holds lists of links that do have the same attribute.
int getRunningNumber() const
Returns the number of build and inserted, but not yet deleted transportables.
int getLoadedNumber() const
Returns the number of build transportables.
int getJammedNumber() const
Returns the number of times a transportables was jammed.
The class responsible for building and deletion of vehicles.
int getRunningVehicleNo() const
Returns the number of build and inserted, but not yet deleted vehicles.
int getLoadedVehicleNo() const
Returns the number of build vehicles.
int getCollisionCount() const
return the number of collisions
double getVehicleMeanSpeed() const
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
int getDepartedVehicleNo() const
Returns the number of inserted vehicles.
int getArrivedVehicleNo() const
Returns the number of arrived vehicles.
virtual int getHaltingVehicleNo() const
Returns the number of halting vehicles.
int getTeleportCount() const
return the number of teleports (including collisions)
double getVehicleMeanSpeedRelative() const
int getDiscardedVehicleNo() const
Returns the number of discarded vehicles.
const std::string & getID() const
Returns the id.
Definition: Named.h:73
T get(const std::string &id) const
Retrieves an item.
int size() const
Returns the number of stored items within the container.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
Complete definition about what shall be retrieved and where to store it.
An XML-handler for network weights.
void addAdditionalGLObject(GUIGlObject *o)
Adds an additional object (detector/shape/trigger) for visualisation.
Definition: SUMORTree.h:124
Encapsulated SAX-Attributes.
virtual std::vector< std::string > getAttributeNames() const =0
Retrieves all attribute names.
SUMOTime getSUMOTimeReporting(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
static bool runParser(GenericSAXHandler &handler, const std::string &file, const bool isNet=false, const bool isRoute=false)
Runs the given handler on the given file; returns if everything's ok.
Definition: XMLSubSys.cpp:148