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-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 /****************************************************************************/
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>
61 #include "GUINet.h"
62 
64 
65 
66 // ===========================================================================
67 // definition of static variables used for visualisation of objects' values
68 // ===========================================================================
69 template std::vector< GLObjectValuePassConnector<double>* > GLObjectValuePassConnector<double>::myContainer;
71 
72 template std::vector< GLObjectValuePassConnector<std::pair<int, class MSPhaseDefinition> >* > GLObjectValuePassConnector<std::pair<int, class MSPhaseDefinition> >::myContainer;
74 
75 
76 // ===========================================================================
77 // member method definitions
78 // ===========================================================================
79 GUINet::GUINet(MSVehicleControl* vc, MSEventControl* beginOfTimestepEvents,
80  MSEventControl* endOfTimestepEvents,
81  MSEventControl* insertionEvents) :
82  MSNet(vc, beginOfTimestepEvents, endOfTimestepEvents, insertionEvents, new GUIShapeContainer(myGrid)),
84  myLastSimDuration(0), /*myLastVisDuration(0),*/ myLastIdleDuration(0),
85  myLastVehicleMovementCount(0), myOverallVehicleCount(0), myOverallSimDuration(0) {
87 }
88 
89 
91  if (myLock.locked()) {
92  myLock.unlock();
93  }
94  // delete allocated wrappers
95  // of junctions
96  for (std::vector<GUIJunctionWrapper*>::iterator i1 = myJunctionWrapper.begin(); i1 != myJunctionWrapper.end(); i1++) {
97  delete (*i1);
98  }
99  // of additional structures
101  // of tl-logics
102  for (Logics2WrapperMap::iterator i3 = myLogics2Wrapper.begin(); i3 != myLogics2Wrapper.end(); i3++) {
103  delete (*i3).second;
104  }
105  // of detectors
106  for (std::vector<GUIDetectorWrapper*>::iterator i = myDetectorWrapper.begin(); i != myDetectorWrapper.end(); ++i) {
107  delete *i;
108  }
109  // of calibrators
110  for (GUICalibrator* cw : myCalibratorWrapper) {
111  delete cw;
112  }
113  for (auto& item : myLoadedEdgeData) {
114  delete item.second;
115  }
116 }
117 
118 
119 const Boundary&
121  return myBoundary;
122 }
123 
124 
127  if (myPersonControl == nullptr) {
129  }
130  return *myPersonControl;
131 }
132 
133 
136  if (myContainerControl == nullptr) {
138  }
139  return *myContainerControl;
140 }
141 
142 
143 void
145  // go through the loaded tl-logics
146  for (MSTrafficLightLogic* const tll : getTLSControl().getAllLogics()) {
147  createTLWrapper(tll);
148  }
149 }
150 
151 
152 void
154  if (myLogics2Wrapper.count(tll) > 0) {
155  return;
156  }
157  // get the links
158  const MSTrafficLightLogic::LinkVectorVector& links = tll->getLinks();
159  if (links.size() == 0) { // @legacy this should never happen in 0.13.0+ networks
160  return;
161  }
162  // build the wrapper
165  // build the association link->wrapper
166  MSTrafficLightLogic::LinkVectorVector::const_iterator j;
167  for (j = links.begin(); j != links.end(); ++j) {
168  MSTrafficLightLogic::LinkVector::const_iterator j2;
169  for (j2 = (*j).begin(); j2 != (*j).end(); ++j2) {
170  myLinks2Logic[*j2] = tll->getID();
171  }
172  }
174  myLogics2Wrapper[tll] = tllw;
175 }
176 
177 
178 Position
179 GUINet::getJunctionPosition(const std::string& name) const {
180  // !!! no check for existance!
181  return myJunctions->get(name)->getPosition();
182 }
183 
184 
185 bool
186 GUINet::vehicleExists(const std::string& name) const {
187  return myVehicleControl->getVehicle(name) != nullptr;
188 }
189 
190 
191 int
192 GUINet::getLinkTLID(const MSLink* const link) const {
193  if (myLinks2Logic.count(link) == 0) {
194  assert(false);
195  return 0;
196  }
197  MSTrafficLightLogic* tll = myLogics->getActive(myLinks2Logic.find(link)->second);
198  if (myLogics2Wrapper.count(tll) == 0) {
199  // tll may have been added via traci. @see ticket #459
200  return 0;
201  }
202  return myLogics2Wrapper.find(tll)->second->getGlID();
203 }
204 
205 
206 int
207 GUINet::getLinkTLIndex(const MSLink* const link) const {
208  Links2LogicMap::const_iterator i = myLinks2Logic.find(link);
209  if (i == myLinks2Logic.end()) {
210  return -1;
211  }
212  if (myLogics2Wrapper.find(myLogics->getActive((*i).second)) == myLogics2Wrapper.end()) {
213  return -1;
214  }
215  return myLogics2Wrapper.find(myLogics->getActive((*i).second))->second->getLinkIndex(link);
216 }
217 
218 
219 void
223 }
224 
225 
226 void
228  FXMutexLock locker(myLock);
230 }
231 
232 
233 std::vector<GUIGlID>
234 GUINet::getJunctionIDs(bool includeInternal) const {
235  std::vector<GUIGlID> ret;
236  for (std::vector<GUIJunctionWrapper*>::const_iterator i = myJunctionWrapper.begin(); i != myJunctionWrapper.end(); ++i) {
237  if (!(*i)->isInternal() || includeInternal) {
238  ret.push_back((*i)->getGlID());
239  }
240  }
241  return ret;
242 }
243 
244 
245 std::vector<GUIGlID>
247  std::vector<GUIGlID> ret;
248  std::vector<std::string> ids;
249  for (std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*>::const_iterator i = myLogics2Wrapper.begin(); i != myLogics2Wrapper.end(); ++i) {
250  std::string sid = (*i).second->getMicrosimID();
251  if (find(ids.begin(), ids.end(), sid) == ids.end()) {
252  ret.push_back((*i).second->getGlID());
253  ids.push_back(sid);
254  }
255  }
256  return ret;
257 }
258 
259 
260 void
262  // initialise detector storage for gui
263  const std::vector<SumoXMLTag> types = myDetectorControl->getAvailableTypes();
264  for (std::vector<SumoXMLTag>::const_iterator i = types.begin(); i != types.end(); ++i) {
265  for (const auto& j : myDetectorControl->getTypedDetectors(*i)) {
266  GUIDetectorWrapper* wrapper = j.second->buildDetectorGUIRepresentation();
267  if (wrapper != nullptr) {
268  myDetectorWrapper.push_back(wrapper);
269  myGrid.addAdditionalGLObject(wrapper);
270  }
271  }
272  }
273  // initialise calibrators
274  for (auto& item : MSCalibrator::getInstances()) {
275  GUICalibrator* wrapper = new GUICalibrator(item.second);
276  myCalibratorWrapper.push_back(wrapper);
277  myGrid.addAdditionalGLObject(wrapper);
278  }
279  // initialise the tl-map
280  initTLMap();
281  // initialise edge storage for gui
282  const MSEdgeVector& edges = MSEdge::getAllEdges();
283  myEdgeWrapper.reserve(edges.size());
284  for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
285  // VISIM connector edges shall be drawn (they have lanes)
286  if (!(*i)->isTazConnector() || (*i)->getLanes().size() > 0) {
287  myEdgeWrapper.push_back(static_cast<GUIEdge*>(*i));
288  }
289  }
290  // initialise junction storage for gui
291  int size = myJunctions->size();
292  myJunctionWrapper.reserve(size);
293  std::map<MSJunction*, std::string> junction2TLL;
294  for (const auto tls : getTLSControl().getAllLogics()) {
295  for (const auto& links : tls->getLinks()) {
296  for (const MSLink* l : links) {
297  junction2TLL[l->getJunction()] = l->getTLLogic()->getID();
298  }
299  }
300  }
301  for (const auto& i : *myJunctions) {
302  myJunctionWrapper.push_back(new GUIJunctionWrapper(*i.second, junction2TLL[i.second]));
303  }
304  // build the visualization tree
305  for (std::vector<GUIEdge*>::iterator i = myEdgeWrapper.begin(); i != myEdgeWrapper.end(); ++i) {
306  GUIEdge* edge = *i;
307  Boundary b;
308  const std::vector<MSLane*>& lanes = edge->getLanes();
309  for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
310  b.add((*j)->getShape().getBoxBoundary());
311  }
312  // make sure persons are always drawn and selectable since they depend on their edge being drawn
314  const float cmin[2] = { (float)b.xmin(), (float)b.ymin() };
315  const float cmax[2] = { (float)b.xmax(), (float)b.ymax() };
316  myGrid.Insert(cmin, cmax, edge);
317  myBoundary.add(b);
318  if (myBoundary.getWidth() > 10e16 || myBoundary.getHeight() > 10e16) {
319  throw ProcessError("Network size exceeds 1 Lightyear. Please reconsider your inputs.\n");
320  }
321  }
322  for (std::vector<GUIJunctionWrapper*>::iterator i = myJunctionWrapper.begin(); i != myJunctionWrapper.end(); ++i) {
323  GUIJunctionWrapper* junction = *i;
324  Boundary b = junction->getBoundary();
325  b.grow(2.);
326  const float cmin[2] = { (float)b.xmin(), (float)b.ymin() };
327  const float cmax[2] = { (float)b.xmax(), (float)b.ymax() };
328  myGrid.Insert(cmin, cmax, junction);
329  myBoundary.add(b);
330  }
332 }
333 
334 
335 int
337  return myLastSimDuration +/*myLastVisDuration+*/myLastIdleDuration;
338 }
339 
340 
341 int
343  return myLastSimDuration;
344 }
345 
346 /*
347 int
348 GUINet::getVisDuration() const
349 {
350  return myLastVisDuration;
351 }
352 */
353 
354 
355 double
357  if (myLastSimDuration == 0) {
358  return -1;
359  }
360  return (double)DELTA_T / (double)myLastSimDuration;
361 }
362 
363 
364 double
365 GUINet::getUPS() const {
366  if (myLastSimDuration == 0) {
367  return -1;
368  }
369  return (double) myLastVehicleMovementCount / (double) myLastSimDuration * (double) 1000.;
370 }
371 
372 
373 double
374 GUINet::getMeanRTFactor(int duration) const {
375  if (myOverallSimDuration == 0) {
376  return -1;
377  }
378  return ((double)(duration) * (double) 1000. / (double)myOverallSimDuration);
379 }
380 
381 
382 double
384  if (myOverallSimDuration == 0) {
385  return -1;
386  }
387  return ((double)myVehiclesMoved / (double)myOverallSimDuration * (double) 1000.);
388 }
389 
390 
391 int
393  return myLastIdleDuration;
394 }
395 
396 
397 void
399  myLastSimDuration = val;
400  myOverallSimDuration += val;
403 }
404 
405 /*
406 void
407 GUINet::setVisDuration(int val)
408 {
409  myLastVisDuration = val;
410 }
411 */
412 
413 void
415  myLastIdleDuration = val;
416 }
417 
418 
421  GUISUMOAbstractView& parent) {
422  GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
423  buildPopupHeader(ret, app);
426  buildPositionCopyEntry(ret, false);
427  return ret;
428 }
429 
430 
433  GUISUMOAbstractView& parent) {
434  GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
435  // add items
436  ret->mkItem("loaded vehicles [#]", true,
438  ret->mkItem("insertion-backlogged vehicles [#]", true,
440  ret->mkItem("departed vehicles [#]", true,
442  ret->mkItem("running vehicles [#]", true,
444  ret->mkItem("arrived vehicles [#]", true,
446  ret->mkItem("discarded vehicles [#]", true,
448  ret->mkItem("collisions [#]", true,
450  ret->mkItem("teleports [#]", true,
452  ret->mkItem("halting [#]", true,
454  ret->mkItem("stopped [#]", 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 
520 Boundary
522  return getBoundary();
523 }
524 
525 
526 double
528  return 1;
529 }
530 
531 
532 GUINet*
534  GUINet* net = dynamic_cast<GUINet*>(MSNet::getInstance());
535  if (net != nullptr) {
536  return net;
537  }
538  throw ProcessError("A gui-network was not yet constructed.");
539 }
540 
541 
544  return dynamic_cast<GUIVehicleControl*>(myVehicleControl);
545 }
546 
547 
548 void
550  myLock.lock();
551 }
552 
553 
554 void
556  myLock.unlock();
557 }
558 
561  return dynamic_cast<GUIMEVehicleControl*>(myVehicleControl);
562 }
563 
564 
565 double
566 GUINet::getEdgeData(const MSEdge* edge, const std::string& attr) {
567  auto it = myLoadedEdgeData.find(attr);
568  if (it != myLoadedEdgeData.end()) {
569  double value;
570  bool found = it->second->retrieveExistingEffort(edge, STEPS2TIME(getCurrentTimeStep()), value);
571  if (found) {
572  return value;
573  } else {
575  }
576  } else {
578  }
579 }
580 
581 
582 void
584  if (element == SUMO_TAG_EDGE || element == SUMO_TAG_LANE) {
585  std::vector<std::string> tmp = attrs.getAttributeNames();
586  edgeAttrs.insert(tmp.begin(), tmp.end());
587  } else if (element == SUMO_TAG_EDGEREL) {
588  for (const std::string& a : attrs.getAttributeNames()) {
589  if (a != "from" && a != "to") {
590  edgeAttrs.insert(a);
591  }
592  }
593  } else if (element == SUMO_TAG_INTERVAL) {
594  bool ok;
595  numIntervals++;
598  }
599 }
600 
601 std::vector<std::string>
603  edgeAttrs.erase(toString(SUMO_ATTR_ID));
604  return std::vector<std::string>(edgeAttrs.begin(), edgeAttrs.end());
605 }
606 
607 void
609  double value, double begTime, double endTime) const {
610  MSEdge* edge = MSEdge::dictionary(id);
611  if (edge != nullptr) {
612  myWeightStorage->addEffort(edge, begTime, endTime, value);
613  } else {
614  WRITE_ERROR("Trying to set the effort for the unknown edge '" + id + "'.");
615  }
616 }
617 
618 void
619 GUINet::EdgeFloatTimeLineRetriever_GUI::addEdgeRelWeight(const std::string& from, const std::string& to,
620  double val, double beg, double end) const {
621  MSEdge* fromEdge = MSEdge::dictionary(from);
622  MSEdge* toEdge = MSEdge::dictionary(to);
623  if (fromEdge != nullptr && toEdge != nullptr) {
624  for (auto item : fromEdge->getViaSuccessors()) {
625  if (item.first == toEdge) {
626  const MSEdge* edge = item.second;
627  while (edge != nullptr && edge->isInternal()) {
628  myWeightStorage->addEffort(edge, beg, end, val);
629  edge = edge->getViaSuccessors().front().second;
630  }
631  }
632  }
633  } else if (fromEdge == nullptr) {
634  WRITE_ERROR("Trying to set the effort for the unknown edge '" + from + "'.");
635  } else {
636  WRITE_ERROR("Trying to set the effort for the unknown edge '" + to + "'.");
637  }
638 }
639 
640 bool
641 GUINet::loadEdgeData(const std::string& file) {
642  // discover edge attributes
643  DiscoverAttributes discoveryHandler(file);
644  XMLSubSys::runParser(discoveryHandler, file);
645  std::vector<std::string> attrs = discoveryHandler.getEdgeAttrs();
646  WRITE_MESSAGE("Loading edgedata from '" + file + "':"
647  + "\n " + toString(discoveryHandler.numIntervals) + " intervals between"
648  + " " + time2string(discoveryHandler.firstIntervalBegin) + " and"
649  + " " + time2string(discoveryHandler.lastIntervalEnd)
650  + ".\n Found " + toString(attrs.size())
651  + " attributes: " + toString(attrs));
652  if (discoveryHandler.lastIntervalEnd < string2time(OptionsCont::getOptions().getString("begin"))) {
653  WRITE_WARNING("No data defined after simulation begin time");
654  }
656  // create a retriever for each attribute
657  std::vector<EdgeFloatTimeLineRetriever_GUI> retrieverDefsInternal;
658  retrieverDefsInternal.reserve(attrs.size());
659  std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
660  for (const std::string& attr : attrs) {
662  myLoadedEdgeData[attr] = ws;
663  retrieverDefsInternal.push_back(EdgeFloatTimeLineRetriever_GUI(ws));
664  retrieverDefs.push_back(new SAXWeightsHandler::ToRetrieveDefinition(attr, true, retrieverDefsInternal.back()));
665  }
666  SAXWeightsHandler handler(retrieverDefs, "");
667  return XMLSubSys::runParser(handler, file);
668 }
669 
670 
671 std::vector<std::string>
673  std::vector<std::string> result;
674  for (const auto& item : myLoadedEdgeData) {
675  result.push_back(item.first);
676  }
677  return result;
678 }
679 
680 bool
682  const auto it = myLogics2Wrapper.find(const_cast<MSTrafficLightLogic*>(tll));
683  return it != myLogics2Wrapper.end() && gSelected.isSelected(GLO_TLLOGIC, it->second->getGlID());
684 }
685 
686 void GUINet::updateGUI() const {
687  try {
688  // gui only
690  // update the view
691  aw->handleEvent_SimulationStep(nullptr);
692  } catch (ProcessError&) { }
693 }
694 
695 
696 
697 #ifdef HAVE_OSG
698 void
699 GUINet::updateColor(const GUIVisualizationSettings& s) {
700  for (std::vector<GUIEdge*>::const_iterator i = myEdgeWrapper.begin(); i != myEdgeWrapper.end(); ++i) {
701  if (!(*i)->isInternal()) {
702  const std::vector<MSLane*>& lanes = (*i)->getLanes();
703  for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
704  static_cast<GUILane*>(*j)->updateColor(s);
705  }
706  }
707  }
708  for (std::vector<GUIJunctionWrapper*>::iterator i = myJunctionWrapper.begin(); i != myJunctionWrapper.end(); ++i) {
709  (*i)->updateColor(s);
710  }
711 }
712 #endif
713 
714 
715 /****************************************************************************/
@ 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:282
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:288
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:280
SUMOTime DELTA_T
Definition: SUMOTime.cpp:37
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
Definition: SUMOTime.cpp:45
#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_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_ID
T MIN2(T a, T b)
Definition: StdDefs.h:74
T MAX2(T a, T b)
Definition: StdDefs.h:80
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
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)
The main window of the SUMO-gui.
void handleEvent_SimulationStep(GUIEvent *e)
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:118
static std::vector< GUIGlID > getIDs(bool includeInternal)
Definition: GUIEdge.cpp:103
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)
static GUIMainWindow * getInstance()
get instance
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
std::set< std::string > edgeAttrs
Definition: GUINet.h:406
std::vector< std::string > getEdgeAttrs()
Definition: GUINet.cpp:602
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
void addEdgeRelWeight(const std::string &from, const std::string &to, double val, double beg, double end) const
Definition: GUINet.cpp:619
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
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
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
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
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
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
friend class GUITrafficLightLogicWrapper
Definition: GUINet.h:83
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
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.
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:918
const MSConstEdgePairVector & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges with internal vias, restricted by vClass.
Definition: MSEdge.cpp:1114
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:262
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:885
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:88
MSTransportableControl * myPersonControl
Controls person building and deletion;.
Definition: MSNet.h:857
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:449
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition: MSNet.h:863
double myVersion
the network version
Definition: MSNet.h:957
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:376
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
Definition: MSNet.h:855
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:318
void simulationStep()
Performs a single simulation step.
Definition: MSNet.cpp:583
MSTransportableControl * myContainerControl
Controls container building and deletion;.
Definition: MSNet.h:859
SUMOTime myEdgeDataEndTime
end of loaded edgeData
Definition: MSNet.h:960
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:429
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
Definition: MSNet.h:865
bool logSimulationDuration() const
Returns whether duration shall be logged.
Definition: MSNet.cpp:1053
long long int myVehiclesMoved
The overall number of vehicle movements.
Definition: MSNet.h:905
MSDetectorControl * myDetectorControl
Controls detectors;.
Definition: MSNet.h:869
static const double SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk
Definition: MSPModel.h:116
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
int getStoppedVehiclesCount() const
return the number of vehicles that are currently stopped
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:74
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:37
Complete definition about what shall be retrieved and where to store it.
An XML-handler for network weights.
void addAdditionalGLObject(GUIGlObject *o, const double exaggeration=1)
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:149