LCOV - code coverage report
Current view: top level - src/guisim - GUITrafficLightLogicWrapper.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 7.4 % 188 14
Test Date: 2024-11-22 15:46:21 Functions: 15.2 % 33 5

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2024 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              : /****************************************************************************/
      14              : /// @file    GUITrafficLightLogicWrapper.cpp
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Jakob Erdmann
      17              : /// @author  Michael Behrisch
      18              : /// @author  Laura Bieker
      19              : /// @date    Oct/Nov 2003
      20              : ///
      21              : // A wrapper for tl-logics to allow their visualisation and interaction
      22              : /****************************************************************************/
      23              : #include <config.h>
      24              : 
      25              : #include <cassert>
      26              : #include <utils/common/MsgHandler.h>
      27              : #include <utils/geom/GeomHelper.h>
      28              : #include <utils/gui/globjects/GUIGlObject.h>
      29              : #include <utils/gui/div/GLObjectValuePassConnector.h>
      30              : #include <utils/gui/windows/GUIAppEnum.h>
      31              : #include <utils/gui/images/GUIIconSubSys.h>
      32              : #include <utils/gui/div/GLHelper.h>
      33              : #include <utils/gui/div/GUIParameterTableWindow.h>
      34              : #include <utils/gui/globjects/GUIGLObjectPopupMenu.h>
      35              : #include <utils/gui/div/GUIGlobalSelection.h>
      36              : #include <microsim/MSLane.h>
      37              : #include <microsim/traffic_lights/MSTrafficLightLogic.h>
      38              : #include <microsim/traffic_lights/MSTLLogicControl.h>
      39              : #include <microsim/traffic_lights/MSOffTrafficLightLogic.h>
      40              : #include <microsim/traffic_lights/MSActuatedTrafficLightLogic.h>
      41              : #include <microsim/traffic_lights/MSDelayBasedTrafficLightLogic.h>
      42              : #include <microsim/traffic_lights/NEMAController.h>
      43              : #include <microsim/traffic_lights/MSRailSignal.h>
      44              : #include <microsim/logging/FunctionBinding.h>
      45              : #include <microsim/logging/FuncBinding_StringParam.h>
      46              : #include <gui/GUIApplicationWindow.h>
      47              : #include <gui/GUITLLogicPhasesTrackerWindow.h>
      48              : #include <gui/GUIGlobals.h>
      49              : #include <utils/gui/globjects/GLIncludes.h>
      50              : #include <utils/gui/div/GUIDesigns.h>
      51              : 
      52              : #include "GUITrafficLightLogicWrapper.h"
      53              : #include "GUINet.h"
      54              : 
      55              : // ===========================================================================
      56              : // FOX callback mapping
      57              : // ===========================================================================
      58              : FXDEFMAP(GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu)
      59              : GUITrafficLightLogicWrapperPopupMenuMap[] = {
      60              :     FXMAPFUNC(SEL_COMMAND,  MID_SHOWPHASES,             GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::onCmdShowPhases),
      61              :     FXMAPFUNC(SEL_COMMAND,  MID_TRACKPHASES,            GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::onCmdBegin2TrackPhases),
      62              :     FXMAPFUNC(SEL_COMMAND,  MID_SHOW_DETECTORS,         GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::onCmdShowDetectors),
      63              :     FXMAPFUNC(SEL_COMMAND,  MID_SWITCH_OFF,             GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::onCmdSwitchTLS2Off),
      64              :     FXMAPFUNCS(SEL_COMMAND, MID_SWITCH, MID_SWITCH + 20, GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::onCmdSwitchTLSLogic),
      65              : };
      66              : 
      67              : // Object implementation
      68            0 : FXIMPLEMENT(GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu, GUIGLObjectPopupMenu, GUITrafficLightLogicWrapperPopupMenuMap, ARRAYNUMBER(GUITrafficLightLogicWrapperPopupMenuMap))
      69              : 
      70              : 
      71              : // ===========================================================================
      72              : // method definitions
      73              : // ===========================================================================
      74              : /* -------------------------------------------------------------------------
      75              :  * GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu - methods
      76              :  * ----------------------------------------------------------------------- */
      77            0 : GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::GUITrafficLightLogicWrapperPopupMenu(
      78              :     GUIMainWindow& app, GUISUMOAbstractView& parent,
      79            0 :     GUIGlObject& o)
      80            0 :     : GUIGLObjectPopupMenu(app, parent, o) {}
      81              : 
      82              : 
      83            0 : GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::~GUITrafficLightLogicWrapperPopupMenu() {}
      84              : 
      85              : 
      86              : 
      87              : long
      88            0 : GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::onCmdBegin2TrackPhases(
      89              :     FXObject*, FXSelector, void*) {
      90              :     assert(myObject->getType() == GLO_TLLOGIC);
      91            0 :     static_cast<GUITrafficLightLogicWrapper*>(myObject)->begin2TrackPhases();
      92            0 :     return 1;
      93              : }
      94              : 
      95              : 
      96              : long
      97            0 : GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::onCmdShowPhases(
      98              :     FXObject*, FXSelector, void*) {
      99              :     assert(myObject->getType() == GLO_TLLOGIC);
     100            0 :     static_cast<GUITrafficLightLogicWrapper*>(myObject)->showPhases();
     101            0 :     return 1;
     102              : }
     103              : 
     104              : long
     105            0 : GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::onCmdShowDetectors(
     106              :     FXObject*, FXSelector, void*) {
     107              :     assert(myObject->getType() == GLO_TLLOGIC);
     108            0 :     GUITrafficLightLogicWrapper* w = static_cast<GUITrafficLightLogicWrapper*>(myObject);
     109            0 :     MSActuatedTrafficLightLogic* act = dynamic_cast<MSActuatedTrafficLightLogic*>(&w->getTLLogic());
     110            0 :     if (act != nullptr) {
     111            0 :         act->setShowDetectors(!act->showDetectors());
     112              :     } else {
     113            0 :         MSDelayBasedTrafficLightLogic* db = dynamic_cast<MSDelayBasedTrafficLightLogic*>(&w->getTLLogic());
     114            0 :         if (db != nullptr) {
     115            0 :             db->setShowDetectors(!db->showDetectors());
     116              :         } else {
     117            0 :             NEMALogic* nema = dynamic_cast<NEMALogic*>(&w->getTLLogic());
     118            0 :             if (nema != nullptr) {
     119            0 :                 nema->setShowDetectors(!nema->showDetectors());
     120              :             }
     121              :         }
     122              :     }
     123            0 :     myParent->update();
     124            0 :     return 1;
     125              : }
     126              : 
     127              : long
     128            0 : GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::onCmdSwitchTLS2Off(
     129              :     FXObject*, FXSelector /*sel*/, void*) {
     130              :     assert(myObject->getType() == GLO_TLLOGIC);
     131            0 :     static_cast<GUITrafficLightLogicWrapper*>(myObject)->switchTLSLogic(-1);
     132            0 :     myParent->update();
     133            0 :     return 1;
     134              : }
     135              : 
     136              : 
     137              : long
     138            0 : GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapperPopupMenu::onCmdSwitchTLSLogic(
     139              :     FXObject*, FXSelector sel, void*) {
     140              :     assert(myObject->getType() == GLO_TLLOGIC);
     141            0 :     static_cast<GUITrafficLightLogicWrapper*>(myObject)->switchTLSLogic(FXSELID(sel) - MID_SWITCH);
     142            0 :     myParent->update();
     143            0 :     return 1;
     144              : }
     145              : 
     146              : 
     147              : 
     148              : /* -------------------------------------------------------------------------
     149              :  * GUITrafficLightLogicWrapper - methods
     150              :  * ----------------------------------------------------------------------- */
     151        20275 : GUITrafficLightLogicWrapper::GUITrafficLightLogicWrapper(MSTLLogicControl& control, MSTrafficLightLogic& tll) :
     152              :     GUIGlObject(GLO_TLLOGIC, tll.getID(), GUIIconSubSys::getIcon(GUIIcon::LOCATETLS)),
     153        20275 :     myTLLogicControl(control), myTLLogic(tll) {
     154        20275 : }
     155              : 
     156              : 
     157        40524 : GUITrafficLightLogicWrapper::~GUITrafficLightLogicWrapper() {}
     158              : 
     159              : 
     160              : GUIGLObjectPopupMenu*
     161            0 : GUITrafficLightLogicWrapper::getPopUpMenu(GUIMainWindow& app,
     162              :         GUISUMOAbstractView& parent) {
     163            0 :     myApp = &app;
     164            0 :     GUIGLObjectPopupMenu* ret = new GUITrafficLightLogicWrapperPopupMenu(app, parent, *this);
     165            0 :     buildPopupHeader(ret, app);
     166            0 :     buildCenterPopupEntry(ret);
     167            0 :     const MSTLLogicControl::TLSLogicVariants& vars = myTLLogicControl.get(myTLLogic.getID());
     168            0 :     std::vector<MSTrafficLightLogic*> logics = vars.getAllLogics();
     169            0 :     if (logics.size() > 1) {
     170              :         std::vector<MSTrafficLightLogic*>::const_iterator i;
     171              :         int index = 0;
     172            0 :         for (i = logics.begin(); i != logics.end(); ++i, ++index) {
     173            0 :             if (!vars.isActive(*i) && dynamic_cast<MSOffTrafficLightLogic*>(*i) == nullptr) {
     174            0 :                 GUIDesigns::buildFXMenuCommand(ret, TLF("Switch to '%'", (*i)->getProgramID()),
     175            0 :                                                GUIIconSubSys::getIcon(GUIIcon::FLAG_MINUS), ret, (FXSelector)(MID_SWITCH + index));
     176              :             }
     177              :         }
     178            0 :         new FXMenuSeparator(ret);
     179              :     }
     180            0 :     MSOffTrafficLightLogic* offLogic = dynamic_cast<MSOffTrafficLightLogic*>(vars.getActive());
     181            0 :     if (offLogic == nullptr) {
     182            0 :         GUIDesigns::buildFXMenuCommand(ret, TL("Switch off"), GUIIconSubSys::getIcon(GUIIcon::FLAG_MINUS), ret, MID_SWITCH_OFF);
     183              :     }
     184            0 :     GUIDesigns::buildFXMenuCommand(ret, TL("Track Phases"), nullptr, ret, MID_TRACKPHASES);
     185            0 :     GUIDesigns::buildFXMenuCommand(ret, TL("Show Phases"), nullptr, ret, MID_SHOWPHASES);
     186            0 :     MSActuatedTrafficLightLogic* act = dynamic_cast<MSActuatedTrafficLightLogic*>(&myTLLogic);
     187            0 :     if (act != nullptr) {
     188            0 :         GUIDesigns::buildFXMenuCommand(ret, act->showDetectors() ? TL("Hide Detectors") : TL("Show Detectors"), nullptr, ret, MID_SHOW_DETECTORS);
     189              :     }
     190            0 :     MSDelayBasedTrafficLightLogic* db = dynamic_cast<MSDelayBasedTrafficLightLogic*>(&myTLLogic);
     191            0 :     if (db != nullptr) {
     192            0 :         GUIDesigns::buildFXMenuCommand(ret, db->showDetectors() ? TL("Hide Detectors") : TL("Show Detectors"), nullptr, ret, MID_SHOW_DETECTORS);
     193              :     }
     194            0 :     NEMALogic* nema = dynamic_cast<NEMALogic*>(&myTLLogic);
     195            0 :     if (nema != nullptr) {
     196            0 :         GUIDesigns::buildFXMenuCommand(ret, nema->showDetectors() ? TL("Hide Detectors") : TL("Show Detectors"), nullptr, ret, MID_SHOW_DETECTORS);
     197              :     }
     198            0 :     new FXMenuSeparator(ret);
     199            0 :     MSTrafficLightLogic* tll = getActiveTLLogic();
     200            0 :     buildNameCopyPopupEntry(ret);
     201            0 :     buildSelectionPopupEntry(ret);
     202            0 :     GUIDesigns::buildFXMenuCommand(ret, TLF("Phase: %", toString(tll->getCurrentPhaseIndex())), nullptr, nullptr, 0);
     203            0 :     const std::string& name =  tll->getCurrentPhaseDef().getName();
     204            0 :     if (name != "") {
     205            0 :         GUIDesigns::buildFXMenuCommand(ret, TLF("Phase name: %", name), nullptr, nullptr, 0);
     206              :     }
     207            0 :     new FXMenuSeparator(ret);
     208            0 :     buildShowParamsPopupEntry(ret, false);
     209            0 :     buildPositionCopyEntry(ret, app);
     210            0 :     return ret;
     211            0 : }
     212              : 
     213              : 
     214              : void
     215            0 : GUITrafficLightLogicWrapper::begin2TrackPhases() {
     216              :     GUITLLogicPhasesTrackerWindow* window =
     217            0 :         new GUITLLogicPhasesTrackerWindow(*myApp, myTLLogic, *this,
     218              :                                           new FuncBinding_StringParam<MSTLLogicControl, std::pair<SUMOTime, MSPhaseDefinition> >
     219            0 :                                           (&MSNet::getInstance()->getTLSControl(), &MSTLLogicControl::getPhaseDef, myTLLogic.getID()));
     220            0 :     window->create();
     221            0 :     window->show();
     222            0 : }
     223              : 
     224              : 
     225              : void
     226            0 : GUITrafficLightLogicWrapper::showPhases() {
     227              :     GUITLLogicPhasesTrackerWindow* window =
     228            0 :         new GUITLLogicPhasesTrackerWindow(*myApp, myTLLogic, *this,
     229            0 :                                           static_cast<MSSimpleTrafficLightLogic&>(myTLLogic).getPhases());
     230            0 :     window->setBeginTime(0);
     231            0 :     window->create();
     232            0 :     window->show();
     233            0 : }
     234              : 
     235              : 
     236              : GUIParameterTableWindow*
     237            0 : GUITrafficLightLogicWrapper::getParameterWindow(GUIMainWindow& app,
     238              :         GUISUMOAbstractView&) {
     239            0 :     GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this);
     240            0 :     ret->mkItem(TL("tlLogic [id]"), false, myTLLogic.getID());
     241            0 :     ret->mkItem(TL("type"), false, toString(myTLLogic.getLogicType()));
     242            0 :     ret->mkItem(TL("program"), false, myTLLogic.getProgramID());
     243            0 :     ret->mkItem(TL("phase"), true, new FunctionBinding<GUITrafficLightLogicWrapper, int>(this, &GUITrafficLightLogicWrapper::getCurrentPhase));
     244            0 :     ret->mkItem(TL("phase name"), true, new FunctionBindingString<GUITrafficLightLogicWrapper>(this, &GUITrafficLightLogicWrapper::getCurrentPhaseName));
     245            0 :     ret->mkItem(TL("duration"), true, new FunctionBinding<GUITrafficLightLogicWrapper, int>(this, &GUITrafficLightLogicWrapper::getCurrentDurationSeconds));
     246            0 :     ret->mkItem(TL("minDur"), true, new FunctionBinding<GUITrafficLightLogicWrapper, int>(this, &GUITrafficLightLogicWrapper::getCurrentMinDurSeconds));
     247            0 :     ret->mkItem(TL("maxDur"), true, new FunctionBinding<GUITrafficLightLogicWrapper, int>(this, &GUITrafficLightLogicWrapper::getCurrentMaxDurSeconds));
     248            0 :     ret->mkItem(TL("running duration"), true, new FunctionBinding<GUITrafficLightLogicWrapper, int>(this, &GUITrafficLightLogicWrapper::getRunningDurationSeconds));
     249            0 :     ret->mkItem(TL("earliestEnd"), true, new FunctionBinding<GUITrafficLightLogicWrapper, int>(this, &GUITrafficLightLogicWrapper::getCurrentEarliestEndSeconds));
     250            0 :     ret->mkItem(TL("latestEnd"), true, new FunctionBinding<GUITrafficLightLogicWrapper, int>(this, &GUITrafficLightLogicWrapper::getCurrentLatestEndSeconds));
     251            0 :     ret->mkItem(TL("time in cycle"), true, new FunctionBinding<GUITrafficLightLogicWrapper, int>(this, &GUITrafficLightLogicWrapper::getCurrentTimeInCycleSeconds));
     252            0 :     ret->mkItem(TL("cycle time"), true, new FunctionBinding<GUITrafficLightLogicWrapper, int>(this, &GUITrafficLightLogicWrapper::getDefaultCycleTimeSeconds));
     253            0 :     MSRailSignal* rs = dynamic_cast<MSRailSignal*>(&myTLLogic);
     254            0 :     if (rs != nullptr) {
     255            0 :         ret->mkItem(TL("req driveway"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getRequestedDriveWay));
     256            0 :         ret->mkItem(TL("blocking"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getBlockingVehicleIDs));
     257            0 :         ret->mkItem(TL("blocking driveways"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getBlockingDriveWayIDs));
     258            0 :         ret->mkItem(TL("rival"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getRivalVehicleIDs));
     259            0 :         ret->mkItem(TL("priority"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getPriorityVehicleIDs));
     260            0 :         ret->mkItem(TL("constraint"), true, new FunctionBindingString<MSRailSignal>(rs, &MSRailSignal::getConstraintInfo));
     261              :     }
     262              :     // close building
     263            0 :     ret->closeBuilding(&myTLLogic);
     264            0 :     return ret;
     265              : }
     266              : 
     267              : 
     268              : Boundary
     269        20275 : GUITrafficLightLogicWrapper::getCenteringBoundary() const {
     270        20275 :     Boundary ret;
     271        20275 :     const MSTrafficLightLogic::LaneVectorVector& lanes = myTLLogic.getLaneVectors();
     272       228930 :     for (MSTrafficLightLogic::LaneVectorVector::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
     273              :         const MSTrafficLightLogic::LaneVector& lanes2 = (*i);
     274       416998 :         for (MSTrafficLightLogic::LaneVector::const_iterator j = lanes2.begin(); j != lanes2.end(); ++j) {
     275       208343 :             ret.add((*j)->getShape()[-1]);
     276              :         }
     277              :     }
     278        20275 :     ret.grow(20);
     279        20275 :     return ret;
     280            0 : }
     281              : 
     282              : const std::string
     283            0 : GUITrafficLightLogicWrapper::getOptionalName() const {
     284            0 :     return myTLLogic.getParameter("name", "");
     285              : }
     286              : 
     287              : 
     288              : void
     289            0 : GUITrafficLightLogicWrapper::switchTLSLogic(int to) {
     290            0 :     if (to == -1) {
     291            0 :         myTLLogicControl.switchTo(myTLLogic.getID(), "off");
     292            0 :         GUINet::getGUIInstance()->createTLWrapper(getActiveTLLogic());
     293              :     } else {
     294            0 :         const MSTLLogicControl::TLSLogicVariants& vars = myTLLogicControl.get(myTLLogic.getID());
     295            0 :         std::vector<MSTrafficLightLogic*> logics = vars.getAllLogics();
     296            0 :         myTLLogicControl.switchTo(myTLLogic.getID(), logics[to]->getProgramID());
     297            0 :     }
     298            0 : }
     299              : 
     300              : 
     301              : int
     302            0 : GUITrafficLightLogicWrapper::getLinkIndex(const MSLink* const link) const {
     303            0 :     return myTLLogic.getLinkIndex(link);
     304              : }
     305              : 
     306              : 
     307              : void
     308       543590 : GUITrafficLightLogicWrapper::drawGL(const GUIVisualizationSettings& s) const {
     309       543590 :     if (s.gaming) {
     310            0 :         if (!MSNet::getInstance()->getTLSControl().isActive(&myTLLogic) || myTLLogic.getPhases().size() == 0) {
     311            0 :             return;
     312              :         }
     313            0 :         const std::string& curState = myTLLogic.getCurrentPhaseDef().getState();
     314            0 :         if (curState.find_first_of("gG") == std::string::npos) {
     315              :             // no link is 'green' at the moment. find those that turn green next
     316            0 :             const MSTrafficLightLogic::Phases& phases = myTLLogic.getPhases();
     317            0 :             int curPhaseIdx = myTLLogic.getCurrentPhaseIndex();
     318            0 :             int phaseIdx = (curPhaseIdx + 1) % phases.size();
     319              :             std::vector<int> nextGreen;
     320            0 :             while (phaseIdx != curPhaseIdx) {
     321            0 :                 const std::string& state = phases[phaseIdx]->getState();
     322            0 :                 for (int linkIdx = 0; linkIdx < (int)state.size(); linkIdx++) {
     323            0 :                     if ((LinkState)state[linkIdx] == LINKSTATE_TL_GREEN_MINOR ||
     324              :                             (LinkState)state[linkIdx] == LINKSTATE_TL_GREEN_MAJOR) {
     325            0 :                         nextGreen.push_back(linkIdx);
     326              :                     }
     327              :                 }
     328            0 :                 if (nextGreen.size() > 0) {
     329              :                     break;
     330              :                 }
     331            0 :                 phaseIdx = (phaseIdx + 1) % phases.size();
     332              :             }
     333              :             // highlight nextGreen links
     334            0 :             for (const int idx : nextGreen) {
     335            0 :                 for (const MSLane* const lane : myTLLogic.getLanesAt(idx)) {
     336            0 :                     GLHelper::pushMatrix();
     337              :                     // split circle in red and yellow
     338              :                     const Position& pos = lane->getShape().back();
     339            0 :                     glTranslated(pos.x(), pos.y(), GLO_MAX);
     340            0 :                     double rot = RAD2DEG(lane->getShape().angleAt2D((int)lane->getShape().size() - 2)) - 90;
     341            0 :                     glRotated(rot, 0, 0, 1);
     342            0 :                     GLHelper::setColor(s.getLinkColor(LINKSTATE_TL_RED));
     343            0 :                     GLHelper::drawFilledCircle(lane->getWidth() / 2., 8, -90, 90);
     344            0 :                     GLHelper::setColor(s.getLinkColor(LINKSTATE_TL_YELLOW_MAJOR));
     345            0 :                     GLHelper::drawFilledCircle(lane->getWidth() / 2., 8, 90, 270);
     346            0 :                     GLHelper::popMatrix();
     347              :                 }
     348              :             }
     349            0 :         }
     350              :     }
     351              : }
     352              : 
     353              : MSTrafficLightLogic*
     354            0 : GUITrafficLightLogicWrapper::getActiveTLLogic() const {
     355            0 :     return myTLLogicControl.getActive(myTLLogic.getID());
     356              : }
     357              : 
     358              : int
     359            0 : GUITrafficLightLogicWrapper::getCurrentPhase() const {
     360            0 :     return getActiveTLLogic()->getCurrentPhaseIndex();
     361              : }
     362              : 
     363              : std::string
     364            0 : GUITrafficLightLogicWrapper::getCurrentPhaseName() const {
     365            0 :     return getActiveTLLogic()->getCurrentPhaseDef().getName();
     366              : }
     367              : 
     368              : int
     369            0 : GUITrafficLightLogicWrapper::getCurrentDurationSeconds() const {
     370            0 :     return (int)STEPS2TIME(getActiveTLLogic()->getCurrentPhaseDef().duration);
     371              : }
     372              : 
     373              : int
     374            0 : GUITrafficLightLogicWrapper::getCurrentMinDurSeconds() const {
     375            0 :     return (int)STEPS2TIME(getActiveTLLogic()->getMinDur());
     376              : }
     377              : 
     378              : int
     379            0 : GUITrafficLightLogicWrapper::getCurrentMaxDurSeconds() const {
     380            0 :     return (int)STEPS2TIME(getActiveTLLogic()->getMaxDur());
     381              : }
     382              : 
     383              : int
     384            0 : GUITrafficLightLogicWrapper::getCurrentEarliestEndSeconds() const {
     385            0 :     const SUMOTime earliestEnd = getActiveTLLogic()->getEarliestEnd();
     386            0 :     return earliestEnd == MSPhaseDefinition::UNSPECIFIED_DURATION ? -1 : (int)STEPS2TIME(earliestEnd);
     387              : }
     388              : 
     389              : int
     390            0 : GUITrafficLightLogicWrapper::getCurrentLatestEndSeconds() const {
     391            0 :     const SUMOTime latestEnd = getActiveTLLogic()->getLatestEnd();
     392            0 :     return latestEnd == MSPhaseDefinition::UNSPECIFIED_DURATION ? -1 : (int)STEPS2TIME(latestEnd);
     393              : }
     394              : 
     395              : int
     396            0 : GUITrafficLightLogicWrapper::getDefaultCycleTimeSeconds() const {
     397            0 :     return (int)STEPS2TIME(getActiveTLLogic()->getDefaultCycleTime());
     398              : }
     399              : 
     400              : int
     401            0 : GUITrafficLightLogicWrapper::getCurrentTimeInCycleSeconds() const {
     402            0 :     return (int)STEPS2TIME(getActiveTLLogic()->getTimeInCycle());
     403              : }
     404              : 
     405              : int
     406            0 : GUITrafficLightLogicWrapper::getRunningDurationSeconds() const {
     407            0 :     return (int)STEPS2TIME(getActiveTLLogic()->getSpentDuration());
     408              : }
     409              : 
     410              : 
     411              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1