LCOV - code coverage report
Current view: top level - src/microsim/actions - Command_SaveTLCoupledLaneDet.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 20 20 100.0 %
Date: 2024-05-19 15:37:39 Functions: 4 4 100.0 %

          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    Command_SaveTLCoupledLaneDet.cpp
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Jakob Erdmann
      17             : /// @author  Michael Behrisch
      18             : /// @date    15 Feb 2004
      19             : ///
      20             : // Writes e2 state of a link for the time the link has yellow/red
      21             : /****************************************************************************/
      22             : #include <config.h>
      23             : 
      24             : #include "Command_SaveTLCoupledLaneDet.h"
      25             : #include <microsim/MSNet.h>
      26             : #include <microsim/traffic_lights/MSTrafficLightLogic.h>
      27             : #include <microsim/MSEventControl.h>
      28             : #include <microsim/output/MSDetectorFileOutput.h>
      29             : #include <utils/common/UtilExceptions.h>
      30             : #include <utils/common/MsgHandler.h>
      31             : #include <utils/iodevices/OutputDevice.h>
      32             : 
      33             : 
      34             : // ===========================================================================
      35             : // method definitions
      36             : // ===========================================================================
      37           8 : Command_SaveTLCoupledLaneDet::Command_SaveTLCoupledLaneDet(MSTLLogicControl::TLSLogicVariants& tlls,
      38           8 :         MSDetectorFileOutput* dtf, SUMOTime begin, OutputDevice& device, const MSLink* link)
      39             :     : Command_SaveTLCoupledDet(tlls, dtf, begin, device),
      40           8 :       myLink(link), myLastState(LINKSTATE_TL_RED),
      41           8 :       myHadOne(false) {
      42           8 :     execute();
      43           8 : }
      44             : 
      45             : 
      46          16 : Command_SaveTLCoupledLaneDet::~Command_SaveTLCoupledLaneDet() {
      47          16 : }
      48             : 
      49             : 
      50             : void
      51         392 : Command_SaveTLCoupledLaneDet::execute() {
      52         392 :     if (myLink->getState() == myLastState && myHadOne) {
      53             :         return;
      54             :     }
      55         164 :     myHadOne = true;
      56         164 :     if (myLastState == LINKSTATE_TL_RED && myLink->getState() != LINKSTATE_TL_RED) {
      57          60 :         SUMOTime end = MSNet::getInstance()->getCurrentTimeStep();
      58          60 :         if (myStartTime != end) {
      59          52 :             myDetector->writeXMLOutput(myDevice, myStartTime, end);
      60          52 :             myStartTime = end;
      61             :         }
      62         104 :     } else if (myLink->getState() == LINKSTATE_TL_RED) {
      63          56 :         myDetector->reset();
      64          56 :         myStartTime = MSNet::getInstance()->getCurrentTimeStep();
      65             :     }
      66         164 :     myLastState = myLink->getState();
      67             : }
      68             : 
      69             : 
      70             : /****************************************************************************/

Generated by: LCOV version 1.14