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>
40#include <microsim/MSNet.h>
42#include <microsim/MSJunction.h>
44#include <microsim/MSEdge.h>
51#include <guisim/GUIEdge.h>
52#include <guisim/GUILane.h>
60#include <gui/GUIGlobals.h>
62#include "GUINet.h"
63
65
66
67// ===========================================================================
68// definition of static variables used for visualisation of objects' values
69// ===========================================================================
70template std::vector< GLObjectValuePassConnector<double>* > GLObjectValuePassConnector<double>::myContainer;
72
73template std::vector< GLObjectValuePassConnector<std::pair<int, class MSPhaseDefinition> >* > GLObjectValuePassConnector<std::pair<int, class MSPhaseDefinition> >::myContainer;
75
76
77// ===========================================================================
78// member method definitions
79// ===========================================================================
81 MSEventControl* endOfTimestepEvents,
82 MSEventControl* insertionEvents) :
83 MSNet(vc, beginOfTimestepEvents, endOfTimestepEvents, insertionEvents, new GUIShapeContainer(myGrid)),
84 GUIGlObject(GLO_NETWORK, "", nullptr),
85 myLastSimDuration(0), /*myLastVisDuration(0),*/ myLastIdleDuration(0),
86 myLastVehicleMovementCount(0), myOverallVehicleCount(0), myOverallSimDuration(0) {
88}
89
90
92 if (myLock.locked()) {
93 myLock.unlock();
94 }
95 // delete allocated wrappers
96 // of junctions
97 for (std::vector<GUIJunctionWrapper*>::iterator i1 = myJunctionWrapper.begin(); i1 != myJunctionWrapper.end(); i1++) {
98 delete (*i1);
99 }
100 // of additional structures
102 // of tl-logics
103 for (Logics2WrapperMap::iterator i3 = myLogics2Wrapper.begin(); i3 != myLogics2Wrapper.end(); i3++) {
104 delete (*i3).second;
105 }
106 // of detectors
107 for (std::vector<GUIDetectorWrapper*>::iterator i = myDetectorWrapper.begin(); i != myDetectorWrapper.end(); ++i) {
108 delete *i;
109 }
110 // of calibrators
112 delete cw;
113 }
114 for (auto& item : myLoadedEdgeData) {
115 delete item.second;
116 }
117}
118
119
120const Boundary&
122 return myBoundary;
123}
124
125
128 if (myPersonControl == nullptr) {
130 }
131 return *myPersonControl;
132}
133
134
137 if (myContainerControl == nullptr) {
139 }
140 return *myContainerControl;
141}
142
143
144void
146 // go through the loaded tl-logics
147 for (MSTrafficLightLogic* const tll : getTLSControl().getAllLogics()) {
148 createTLWrapper(tll);
149 }
150}
151
152
153void
155 if (myLogics2Wrapper.count(tll) > 0) {
156 return;
157 }
158 // get the links
160 if (links.size() == 0) { // @legacy this should never happen in 0.13.0+ networks
161 return;
162 }
163 // build the wrapper
165 if (tll->knowsParameter("hotkeyAbort")) {
167 }
168 // build the association link->wrapper
169 MSTrafficLightLogic::LinkVectorVector::const_iterator j;
170 for (j = links.begin(); j != links.end(); ++j) {
171 MSTrafficLightLogic::LinkVector::const_iterator j2;
172 for (j2 = (*j).begin(); j2 != (*j).end(); ++j2) {
173 myLinks2Logic[*j2] = tll->getID();
174 }
175 }
177 myLogics2Wrapper[tll] = tllw;
178}
179
180
182GUINet::getJunctionPosition(const std::string& name) const {
183 // !!! no check for existance!
184 return myJunctions->get(name)->getPosition();
185}
186
187
188bool
189GUINet::vehicleExists(const std::string& name) const {
190 return myVehicleControl->getVehicle(name) != nullptr;
191}
192
193
194int
195GUINet::getLinkTLID(const MSLink* const link) const {
196 if (myLinks2Logic.count(link) == 0) {
197 assert(false);
198 return 0;
199 }
200 MSTrafficLightLogic* tll = myLogics->getActive(myLinks2Logic.find(link)->second);
201 if (myLogics2Wrapper.count(tll) == 0) {
202 // tll may have been added via traci. @see ticket #459
203 return 0;
204 }
205 return myLogics2Wrapper.find(tll)->second->getGlID();
206}
207
208
209int
210GUINet::getLinkTLIndex(const MSLink* const link) const {
211 Links2LogicMap::const_iterator i = myLinks2Logic.find(link);
212 if (i == myLinks2Logic.end()) {
213 return -1;
214 }
215 if (myLogics2Wrapper.find(myLogics->getActive((*i).second)) == myLogics2Wrapper.end()) {
216 return -1;
217 }
218 return myLogics2Wrapper.find(myLogics->getActive((*i).second))->second->getLinkIndex(link);
219}
220
221
222void
226}
227
228
229void
231 FXMutexLock locker(myLock);
233}
234
235
236std::vector<GUIGlID>
237GUINet::getJunctionIDs(bool includeInternal) const {
238 std::vector<GUIGlID> ret;
239 for (std::vector<GUIJunctionWrapper*>::const_iterator i = myJunctionWrapper.begin(); i != myJunctionWrapper.end(); ++i) {
240 if (!(*i)->isInternal() || includeInternal) {
241 ret.push_back((*i)->getGlID());
242 }
243 }
244 return ret;
245}
246
247
248std::vector<GUIGlID>
250 std::vector<GUIGlID> ret;
251 std::vector<std::string> ids;
252 for (std::map<MSTrafficLightLogic*, GUITrafficLightLogicWrapper*>::const_iterator i = myLogics2Wrapper.begin(); i != myLogics2Wrapper.end(); ++i) {
253 std::string sid = (*i).second->getMicrosimID();
254 if (find(ids.begin(), ids.end(), sid) == ids.end()) {
255 ret.push_back((*i).second->getGlID());
256 ids.push_back(sid);
257 }
258 }
259 return ret;
260}
261
262
263void
265 // initialise detector storage for gui
266 const std::vector<SumoXMLTag> types = myDetectorControl->getAvailableTypes();
267 for (std::vector<SumoXMLTag>::const_iterator i = types.begin(); i != types.end(); ++i) {
268 for (const auto& j : myDetectorControl->getTypedDetectors(*i)) {
269 GUIDetectorWrapper* wrapper = j.second->buildDetectorGUIRepresentation();
270 if (wrapper != nullptr) {
271 myDetectorWrapper.push_back(wrapper);
273 }
274 }
275 }
276 // let's always track emission parameters for the GUI
278 // initialise calibrators
279 for (auto& item : MSCalibrator::getInstances()) {
280 GUICalibrator* wrapper = new GUICalibrator(item.second);
281 myCalibratorWrapper.push_back(wrapper);
283 }
284 // initialise the tl-map
285 initTLMap();
286 // initialise edge storage for gui
287 const MSEdgeVector& edges = MSEdge::getAllEdges();
288 myEdgeWrapper.reserve(edges.size());
289 for (MSEdgeVector::const_iterator i = edges.begin(); i != edges.end(); ++i) {
290 // VISIM connector edges shall be drawn (they have lanes)
291 if (!(*i)->isTazConnector() || (*i)->getLanes().size() > 0) {
292 myEdgeWrapper.push_back(static_cast<GUIEdge*>(*i));
293 }
294 }
295 // initialise junction storage for gui
296 int size = myJunctions->size();
297 myJunctionWrapper.reserve(size);
298 std::map<MSJunction*, std::string> junction2TLL;
299 for (const auto tls : getTLSControl().getAllLogics()) {
300 for (const auto& links : tls->getLinks()) {
301 for (const MSLink* l : links) {
302 junction2TLL[l->getJunction()] = l->getTLLogic()->getID();
303 }
304 }
305 }
306 for (const auto& i : *myJunctions) {
307 myJunctionWrapper.push_back(new GUIJunctionWrapper(*i.second, junction2TLL[i.second]));
308 }
309 // build the visualization tree
310 for (std::vector<GUIEdge*>::iterator i = myEdgeWrapper.begin(); i != myEdgeWrapper.end(); ++i) {
311 GUIEdge* edge = *i;
312 Boundary b;
313 const std::vector<MSLane*>& lanes = edge->getLanes();
314 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
315 b.add((*j)->getShape().getBoxBoundary());
316 }
317 // make sure persons are always drawn and selectable since they depend on their edge being drawn
319 const float cmin[2] = { (float)b.xmin(), (float)b.ymin() };
320 const float cmax[2] = { (float)b.xmax(), (float)b.ymax() };
321 myGrid.Insert(cmin, cmax, edge);
322 myBoundary.add(b);
323 if (myBoundary.getWidth() > 10e16 || myBoundary.getHeight() > 10e16) {
324 throw ProcessError("Network size exceeds 1 Lightyear. Please reconsider your inputs.\n");
325 }
326 }
327 for (std::vector<GUIJunctionWrapper*>::iterator i = myJunctionWrapper.begin(); i != myJunctionWrapper.end(); ++i) {
328 GUIJunctionWrapper* junction = *i;
329 Boundary b = junction->getBoundary();
330 b.grow(2.);
331 const float cmin[2] = { (float)b.xmin(), (float)b.ymin() };
332 const float cmax[2] = { (float)b.xmax(), (float)b.ymax() };
333 myGrid.Insert(cmin, cmax, junction);
334 myBoundary.add(b);
335 }
337}
338
339
340int
342 return myLastSimDuration +/*myLastVisDuration+*/myLastIdleDuration;
343}
344
345
346int
348 return myLastSimDuration;
349}
350
351/*
352int
353GUINet::getVisDuration() const
354{
355 return myLastVisDuration;
356}
357*/
358
359
360double
362 if (myLastSimDuration == 0) {
363 return -1;
364 }
365 return (double)DELTA_T / (double)myLastSimDuration;
366}
367
368
369double
371 if (myLastSimDuration == 0) {
372 return -1;
373 }
374 return (double) myLastVehicleMovementCount / (double) myLastSimDuration * (double) 1000.;
375}
376
377
378double
379GUINet::getMeanRTFactor(int duration) const {
380 if (myOverallSimDuration == 0) {
381 return -1;
382 }
383 return ((double)(duration) * (double) 1000. / (double)myOverallSimDuration);
384}
385
386
387double
389 if (myOverallSimDuration == 0) {
390 return -1;
391 }
392 return ((double)myVehiclesMoved / (double)myOverallSimDuration * (double) 1000.);
393}
394
395
396int
398 return myLastIdleDuration;
399}
400
401
402void
404 myLastSimDuration = val;
408}
409
410/*
411void
412GUINet::setVisDuration(int val)
413{
414 myLastVisDuration = val;
415}
416*/
417
418void
420 myLastIdleDuration = val;
421}
422
423
426 GUISUMOAbstractView& parent) {
427 GUIGLObjectPopupMenu* ret = new GUIGLObjectPopupMenu(app, parent, *this);
428 buildPopupHeader(ret, app);
431 buildPositionCopyEntry(ret, app);
432 return ret;
433}
434
435
438 GUISUMOAbstractView& parent) {
440 // add items
441 ret->mkItem("loaded vehicles [#]", true,
443 ret->mkItem("insertion-backlogged vehicles [#]", true,
445 ret->mkItem("departed vehicles [#]", true,
447 ret->mkItem("running vehicles [#]", true,
449 ret->mkItem("arrived vehicles [#]", true,
451 ret->mkItem("discarded vehicles [#]", true,
453 ret->mkItem("collisions [#]", true,
455 ret->mkItem("teleports [#]", true,
457 ret->mkItem("halting [#]", true,
459 ret->mkItem("stopped [#]", true,
461 ret->mkItem("avg. speed [m/s]", true,
463 ret->mkItem("avg. relative speed", true,
465 if (myPersonControl != nullptr) {
466 ret->mkItem("loaded persons [#]", true,
468 ret->mkItem("running persons [#]", true,
470 ret->mkItem("jammed persons [#]", true,
472 }
473 ret->mkItem("end time [s]", false, OptionsCont::getOptions().getString("end"));
474 ret->mkItem("begin time [s]", false, OptionsCont::getOptions().getString("begin"));
475// ret->mkItem("time step [s]", true, new FunctionBinding<GUINet, SUMOTime>(this, &GUINet::getCurrentTimeStep));
476 if (logSimulationDuration()) {
477 ret->mkItem("step duration [ms]", true, new FunctionBinding<GUINet, int>(this, &GUINet::getWholeDuration));
479 ret->mkItem("simulation duration [ms]", true, new FunctionBinding<GUINet, int>(this, &GUINet::getSimDuration));
480 /*
481 ret->mkItem("visualisation duration [ms]", true,
482 new CastingFunctionBinding<GUINet, double, int>(
483 &(getNet()), &GUINet::getVisDuration));
484 */
485 ret->mkItem("idle duration [ms]", true, new FunctionBinding<GUINet, int>(this, &GUINet::getIdleDuration));
486 ret->mkItem("duration factor", true, new FunctionBinding<GUINet, double>(this, &GUINet::getRTFactor));
487 /*
488 ret->mkItem("mean duration factor []", true,
489 new FuncBinding_IntParam<GUINet, double>(
490 &(getNet()), &GUINet::getMeanRTFactor), 1);
491 */
492 ret->mkItem("updates per second", true, new FunctionBinding<GUINet, double>(this, &GUINet::getUPS));
493 ret->mkItem("avg. updates per second", true, new FunctionBinding<GUINet, double>(this, &GUINet::getMeanUPS));
494 if (OptionsCont::getOptions().getBool("duration-log.statistics")) {
495 ret->mkItem("avg. trip length [m]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgRouteLength));
496 ret->mkItem("avg. trip duration [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgDuration));
497 ret->mkItem("avg. trip waiting time [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgWaitingTime));
498 ret->mkItem("avg. trip time loss [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgTimeLoss));
499 ret->mkItem("avg. trip depart delay [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgDepartDelay));
500 ret->mkItem("avg. trip speed [m/s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgTripSpeed));
501 if (myPersonControl != nullptr) {
502 ret->mkItem("avg. walk length [m]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgWalkRouteLength));
503 ret->mkItem("avg. walk duration [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgWalkDuration));
504 ret->mkItem("avg. walk time loss [s]", true, new FunctionBinding<GUINet, double>(this, &GUINet::getAvgWalkTimeLoss));
505 }
506 }
507 }
508 ret->mkItem("nodes [#]", false, (int)getJunctionIDs(false).size());
509 ret->mkItem("edges [#]", false, (int)GUIEdge::getIDs(false).size());
510 ret->mkItem("total edge length [km]", false, GUIEdge::getTotalLength(false, false) / 1000);
511 ret->mkItem("total lane length [km]", false, GUIEdge::getTotalLength(false, true) / 1000);
512 ret->mkItem("network version ", false, toString(myVersion));
513
514 // close building
515 ret->closeBuilding();
516 return ret;
517}
518
519
520void
522}
523
524
527 return getBoundary();
528}
529
530
531double
533 return 1;
534}
535
536
537GUINet*
539 GUINet* net = dynamic_cast<GUINet*>(MSNet::getInstance());
540 if (net != nullptr) {
541 return net;
542 }
543 throw ProcessError("A gui-network was not yet constructed.");
544}
545
546
549 return dynamic_cast<GUIVehicleControl*>(myVehicleControl);
550}
551
552
553void
555 myLock.lock();
556}
557
558
559void
561 myLock.unlock();
562}
563
566 return dynamic_cast<GUIMEVehicleControl*>(myVehicleControl);
567}
568
569
570double
571GUINet::getEdgeData(const MSEdge* edge, const std::string& attr) {
572 auto it = myLoadedEdgeData.find(attr);
573 if (it != myLoadedEdgeData.end()) {
574 double value;
575 bool found = it->second->retrieveExistingEffort(edge, STEPS2TIME(getCurrentTimeStep()), value);
576 if (found) {
577 return value;
578 } else {
580 }
581 } else {
583 }
584}
585
586
587double
588GUINet::getMeanData(const MSLane* lane, const std::string& id, const std::string& attr) {
589 auto item = myDetectorControl->getMeanData().find(id);
590 if (item != myDetectorControl->getMeanData().end() && !item->second.empty()) {
592 return item->second.front()->getAttributeValue(lane, a, GUIVisualizationSettings::MISSING_DATA);
593 } else {
595 }
596}
597
598
599void
601 if (element == SUMO_TAG_EDGE || element == SUMO_TAG_LANE) {
602 std::vector<std::string> tmp = attrs.getAttributeNames();
603 edgeAttrs.insert(tmp.begin(), tmp.end());
604 } else if (element == SUMO_TAG_EDGEREL) {
605 for (const std::string& a : attrs.getAttributeNames()) {
606 if (a != "from" && a != "to") {
607 edgeAttrs.insert(a);
608 }
609 }
610 } else if (element == SUMO_TAG_INTERVAL) {
611 bool ok;
612 numIntervals++;
615 }
616}
617
618
619std::vector<std::string>
621 edgeAttrs.erase(toString(SUMO_ATTR_ID));
622 return std::vector<std::string>(edgeAttrs.begin(), edgeAttrs.end());
623}
624
625
626void
628 double value, double begTime, double endTime) const {
629 MSEdge* const edge = MSEdge::dictionary(id);
630 if (edge != nullptr) {
631 myWeightStorage->addEffort(edge, begTime, endTime, value);
632 } else {
633 WRITE_WARNINGF(TL("Trying to set data value for the unknown edge '%'."), id);
634 }
635}
636
637
638void
639GUINet::EdgeFloatTimeLineRetriever_GUI::addEdgeRelWeight(const std::string& from, const std::string& to,
640 double val, double beg, double end) const {
641 MSEdge* const fromEdge = MSEdge::dictionary(from);
642 MSEdge* const toEdge = MSEdge::dictionary(to);
643 bool haveRel = false;
644 if (fromEdge != nullptr && toEdge != nullptr) {
645 for (auto item : fromEdge->getViaSuccessors()) {
646 if (item.first == toEdge) {
647 const MSEdge* edge = item.second;
648 while (edge != nullptr && edge->isInternal()) {
649 myWeightStorage->addEffort(edge, beg, end, val);
650 edge = edge->getViaSuccessors().front().second;
651 haveRel = true;
652 }
653 }
654 }
655 }
656 if (!haveRel) {
657 WRITE_WARNINGF(TL("Trying to set data value for the unknown relation from edge '%' to edge '%'."), from, to);
658 }
659}
660
661
662bool
663GUINet::loadEdgeData(const std::string& file) {
664 // discover edge attributes
665 DiscoverAttributes discoveryHandler(file);
666 XMLSubSys::runParser(discoveryHandler, file);
667 std::vector<std::string> attrs = discoveryHandler.getEdgeAttrs();
668 WRITE_MESSAGE("Loading edgedata from '" + file + "':"
669 + "\n " + toString(discoveryHandler.numIntervals) + " intervals between"
670 + " " + time2string(discoveryHandler.firstIntervalBegin) + " and"
671 + " " + time2string(discoveryHandler.lastIntervalEnd)
672 + ".\n Found " + toString(attrs.size())
673 + " attributes: " + toString(attrs));
674 if (discoveryHandler.lastIntervalEnd < string2time(OptionsCont::getOptions().getString("begin"))) {
675 WRITE_WARNING(TL("No data defined after simulation begin time."));
676 }
678 // create a retriever for each attribute
679 std::vector<EdgeFloatTimeLineRetriever_GUI> retrieverDefsInternal;
680 retrieverDefsInternal.reserve(attrs.size());
681 std::vector<SAXWeightsHandler::ToRetrieveDefinition*> retrieverDefs;
682 for (const std::string& attr : attrs) {
684 myLoadedEdgeData[attr] = ws;
685 retrieverDefsInternal.push_back(EdgeFloatTimeLineRetriever_GUI(ws));
686 retrieverDefs.push_back(new SAXWeightsHandler::ToRetrieveDefinition(attr, true, retrieverDefsInternal.back()));
687 }
688 SAXWeightsHandler handler(retrieverDefs, "");
689 return XMLSubSys::runParser(handler, file);
690}
691
692
693std::vector<std::string>
695 std::vector<std::string> result;
696 for (const auto& item : myLoadedEdgeData) {
697 result.push_back(item.first);
698 }
699 return result;
700}
701
702
703std::vector<std::string>
705 std::vector<std::string> result;
706
707 for (auto item : myDetectorControl->getMeanData()) {
708 result.push_back(item.first);
709 }
710 std::sort(result.begin(), result.end());
711 return result;
712}
713
714std::vector<std::string>
715GUINet::getMeanDataAttrs(const std::string& meanDataID) const {
716 auto item = myDetectorControl->getMeanData().find(meanDataID);
717 if (item != myDetectorControl->getMeanData().end() && !item->second.empty()) {
718 return item->second.front()->getAttributeNames();
719 } else {
720 return std::vector<std::string>();
721 }
722}
723
724
725bool
727 const auto it = myLogics2Wrapper.find(const_cast<MSTrafficLightLogic*>(tll));
728 return it != myLogics2Wrapper.end() && gSelected.isSelected(GLO_TLLOGIC, it->second->getGlID());
729}
730
731void
733 try {
734 // gui only
736 // update the view
737 aw->handleEvent_SimulationStep(nullptr);
738 } catch (ProcessError&) { }
739}
740
741void
742GUINet::addHotkey(int key, Command* press, Command* release) {
743 try {
744 // gui only
746 // update the view
747 aw->addHotkey(key, press, release);
748 } catch (ProcessError&) { }
749}
750
751
752#ifdef HAVE_OSG
753void
754GUINet::updateColor(const GUIVisualizationSettings& s) {
755 for (std::vector<GUIEdge*>::const_iterator i = myEdgeWrapper.begin(); i != myEdgeWrapper.end(); ++i) {
756 if (!(*i)->isInternal()) {
757 const std::vector<MSLane*>& lanes = (*i)->getLanes();
758 for (std::vector<MSLane*>::const_iterator j = lanes.begin(); j != lanes.end(); ++j) {
759 static_cast<GUILane*>(*j)->updateColor(s);
760 }
761 }
762 }
763 for (std::vector<GUIJunctionWrapper*>::iterator i = myJunctionWrapper.begin(); i != myJunctionWrapper.end(); ++i) {
764 (*i)->updateColor(s);
765 }
766}
767#endif
768
769
770/****************************************************************************/
@ 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_WARNINGF(...)
Definition: MsgHandler.h:266
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:267
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:265
#define TL(string)
Definition: MsgHandler.h:282
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:54
@ 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
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ 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:71
T MAX2(T a, T b)
Definition: StdDefs.h:77
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:78
double ymin() const
Returns minimum y-coordinate.
Definition: Boundary.cpp:130
double xmin() const
Returns minimum x-coordinate.
Definition: Boundary.cpp:118
Boundary & grow(double by)
extends the boundary by the given amount
Definition: Boundary.cpp:300
double getHeight() const
Returns the height of the boundary (y-axis)
Definition: Boundary.cpp:160
double getWidth() const
Returns the width of the boudary (x-axis)
Definition: Boundary.cpp:154
double ymax() const
Returns maximum y-coordinate.
Definition: Boundary.cpp:136
double xmax() const
Returns maximum x-coordinate.
Definition: Boundary.cpp:124
static bool registerHotkey(const std::string &key, MSTrafficLightLogic &tll)
register hotkey actions
Base (microsim) event class.
Definition: Command.h:50
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)
void addHotkey(int key, Command *press, Command *release)
register custom hotkey action
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 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 buildPositionCopyEntry(GUIGLObjectPopupMenu *ret, const GUIMainWindow &app) const
Builds an entry which allows to copy the cursor position if geo projection is used,...
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:60
The class responsible for building and deletion of vehicles (gui-version)
static GUIMainWindow * getInstance()
get instance
class for discovering edge attributes
Definition: GUINet.h:407
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Callback method for an opening tag to implement by derived classes.
Definition: GUINet.cpp:600
SUMOTime firstIntervalBegin
Definition: GUINet.h:414
std::set< std::string > edgeAttrs
Definition: GUINet.h:418
std::vector< std::string > getEdgeAttrs()
Definition: GUINet.cpp:620
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:627
void addEdgeRelWeight(const std::string &from, const std::string &to, double val, double beg, double end) const
Definition: GUINet.cpp:639
A MSNet extended by some values for usage within the gui.
Definition: GUINet.h:82
double getAvgTripSpeed() const
Definition: GUINet.h:224
double getAvgRouteLength() const
Definition: GUINet.h:209
double getAvgDuration() const
Definition: GUINet.h:212
int getWholeDuration() const
Returns the duration of the last step (sim+visualisation+idle) (in ms)
Definition: GUINet.cpp:341
Boundary getCenteringBoundary() const override
Returns the boundary to which the view shall be centered in order to show the object.
Definition: GUINet.cpp:526
void setIdleDuration(int val)
Sets the duration of the last step's idle part.
Definition: GUINet.cpp:419
GUIVehicleControl * getGUIVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:548
void unlock()
release exclusive access to the simulation state
Definition: GUINet.cpp:560
double getUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:370
bool loadEdgeData(const std::string &file)
load edgeData from file
Definition: GUINet.cpp:663
void drawGL(const GUIVisualizationSettings &s) const override
Draws the object.
Definition: GUINet.cpp:521
long myLastVehicleMovementCount
Definition: GUINet.h:400
std::vector< GUIGlID > getJunctionIDs(bool includeInternal) const
Definition: GUINet.cpp:237
MSTransportableControl & getPersonControl() override
Returns the person control.
Definition: GUINet.cpp:127
FXMutex myLock
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition: GUINet.h:448
double getExaggeration(const GUIVisualizationSettings &s) const override
return exaggeration associated with this GLObject
Definition: GUINet.cpp:532
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:726
~GUINet()
Destructor.
Definition: GUINet.cpp:91
long myOverallVehicleCount
Definition: GUINet.h:400
void simulationStep()
Performs a single simulation step (locking the simulation)
Definition: GUINet.cpp:230
int getSimDuration() const
Returns the duration of the last step's simulation part (in ms)
Definition: GUINet.cpp:347
void initGUIStructures()
Initialises gui wrappers.
Definition: GUINet.cpp:264
long myOverallSimDuration
Definition: GUINet.h:401
std::vector< std::string > getEdgeDataAttrs() const
return list of loaded edgeData attributes
Definition: GUINet.cpp:694
const Boundary & getBoundary() const
returns the bounder of the network
Definition: GUINet.cpp:121
double getRTFactor() const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:361
std::vector< GUIEdge * > myEdgeWrapper
Wrapped MS-edges.
Definition: GUINet.h:374
double getAvgWalkDuration() const
Definition: GUINet.h:230
int getLinkTLID(const MSLink *const link) const
Definition: GUINet.cpp:195
void setSimDuration(int val)
Sets the duration of the last step's simulation part.
Definition: GUINet.cpp:403
std::vector< GUICalibrator * > myCalibratorWrapper
A calibrator dictionary.
Definition: GUINet.h:383
std::vector< std::string > getMeanDataIDs() const
return list of loaded edgeData ids (being computed in the current simulation)
Definition: GUINet.cpp:704
double getMeanUPS() const
Returns the update per seconds rate.
Definition: GUINet.cpp:388
double getMeanData(const MSLane *lane, const std::string &id, const std::string &attr)
retrieve live lane/edge weight for the given meanData id and attribute
Definition: GUINet.cpp:588
void initTLMap()
Initialises the tl-logic map and wrappers.
Definition: GUINet.cpp:145
int getLinkTLIndex(const MSLink *const link) const
Definition: GUINet.cpp:210
Boundary myBoundary
The networks boundary.
Definition: GUINet.h:371
double getAvgWalkTimeLoss() const
Definition: GUINet.h:233
std::vector< GUIGlID > getTLSIDs() const
Returns the gl-ids of all traffic light logics within the net.
Definition: GUINet.cpp:249
std::map< std::string, MSEdgeWeightsStorage * > myLoadedEdgeData
loaded edge data for visualization
Definition: GUINet.h:404
GUIParameterTableWindow * getParameterWindow(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own parameter window.
Definition: GUINet.cpp:437
Logics2WrapperMap myLogics2Wrapper
The traffic light-to-wrapper map.
Definition: GUINet.h:394
int getIdleDuration() const
Returns the duration of the last step's idle part (in ms)
Definition: GUINet.cpp:397
double getMeanRTFactor(int duration) const
Returns the simulation speed as a factor to real time.
Definition: GUINet.cpp:379
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:189
std::vector< GUIDetectorWrapper * > myDetectorWrapper
A detector dictionary.
Definition: GUINet.h:380
void addHotkey(int key, Command *press, Command *release=nullptr)
register custom hotkey action
Definition: GUINet.cpp:742
double getAvgWalkRouteLength() const
Definition: GUINet.h:227
void lock()
grant exclusive access to the simulation state
Definition: GUINet.cpp:554
std::vector< GUIJunctionWrapper * > myJunctionWrapper
Wrapped MS-junctions.
Definition: GUINet.h:377
void updateGUI() const override
update view after simulation.loadState
Definition: GUINet.cpp:732
static GUINet * getGUIInstance()
Returns the pointer to the unique instance of GUINet (singleton).
Definition: GUINet.cpp:538
double getAvgTimeLoss() const
Definition: GUINet.h:218
double getAvgDepartDelay() const
Definition: GUINet.h:221
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:571
double getAvgWaitingTime() const
Definition: GUINet.h:215
friend class GUITrafficLightLogicWrapper
Definition: GUINet.h:84
std::vector< std::string > getMeanDataAttrs(const std::string &meanDataID) const
return list of available attributes for the given meanData id
Definition: GUINet.cpp:715
int myLastSimDuration
The step durations (simulation, /*visualisation, *‍/idle)
Definition: GUINet.h:398
Position getJunctionPosition(const std::string &name) const
returns the position of a junction
Definition: GUINet.cpp:182
GUIGLObjectPopupMenu * getPopUpMenu(GUIMainWindow &app, GUISUMOAbstractView &parent) override
Returns an own popup-menu.
Definition: GUINet.cpp:425
int myLastIdleDuration
Definition: GUINet.h:398
void guiSimulationStep()
Some further steps needed for gui processing.
Definition: GUINet.cpp:223
MSTransportableControl & getContainerControl() override
Returns the container control.
Definition: GUINet.cpp:136
GUINet(MSVehicleControl *vc, MSEventControl *beginOfTimestepEvents, MSEventControl *endOfTimestepEvents, MSEventControl *insertionEvents)
Constructor.
Definition: GUINet.cpp:80
GUIMEVehicleControl * getGUIMEVehicleControl()
Returns the vehicle control.
Definition: GUINet.cpp:565
Links2LogicMap myLinks2Logic
The link-to-logic-id map.
Definition: GUINet.h:388
LayeredRTree myGrid
The visualization speed-up.
Definition: GUINet.h:368
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:92
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
const std::map< std::string, std::vector< MSMeanData * > > & getMeanData() const
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:984
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:168
const MSConstEdgePairVector & getViaSuccessors(SUMOVehicleClass vClass=SVC_IGNORING) const
Returns the following edges with internal vias, restricted by vClass.
Definition: MSEdge.cpp:1185
bool isInternal() const
return whether this edge is an internal edge
Definition: MSEdge.h:265
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:945
A storage for edge travel times and efforts.
Stores time-dependant events and executes them at the proper time.
static bool gHaveEmissions
Whether emission output of some type is needed (files or GUI)
Definition: MSGlobals.h:177
int getWaitingVehicleNo() const
Returns the number of waiting vehicles.
const Position & getPosition() const
Definition: MSJunction.cpp:68
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
The simulated network and simulation perfomer.
Definition: MSNet.h:88
MSTransportableControl * myPersonControl
Controls person building and deletion;.
Definition: MSNet.h:867
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:183
MSJunctionControl * myJunctions
Controls junctions, realizes right-of-way rules;.
Definition: MSNet.h:873
double myVersion
the network version
Definition: MSNet.h:967
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:452
MSVehicleControl * myVehicleControl
Controls vehicle building and deletion;.
Definition: MSNet.h:865
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:321
void simulationStep()
Performs a single simulation step.
Definition: MSNet.cpp:656
MSTransportableControl * myContainerControl
Controls container building and deletion;.
Definition: MSNet.h:869
SUMOTime myEdgeDataEndTime
end of loaded edgeData
Definition: MSNet.h:970
MSTLLogicControl * myLogics
Controls tls logics, realizes waiting on tls rules;.
Definition: MSNet.h:875
bool logSimulationDuration() const
Returns whether duration shall be logged.
Definition: MSNet.cpp:1090
long long int myVehiclesMoved
The overall number of vehicle movements.
Definition: MSNet.h:915
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:432
MSDetectorControl * myDetectorControl
Controls detectors;.
Definition: MSNet.h:879
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:379
static const double SIDEWALK_OFFSET
the offset for computing person positions when walking on edges without a sidewalk
Definition: MSPModel.h:125
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:59
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
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 StringBijection< int > Attrs
The names of SUMO-XML attributes for use in netbuild.
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:137
auto get(const nlohmann::detail::iteration_proxy_value< IteratorType > &i) -> decltype(i.key())
Definition: json.hpp:4451