LCOV - code coverage report
Current view: top level - src/microsim/traffic_lights - MSSOTLPolicyBasedTrafficLightLogic.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 14 21 66.7 %
Date: 2024-05-19 15:37:39 Functions: 4 6 66.7 %

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2010-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    MSSOTLPolicyBasedTrafficLightLogic.cpp
      15             : /// @author  Alessio Bonfietti
      16             : /// @author  Riccardo Belletti
      17             : /// @date    2014-03-20
      18             : ///
      19             : // The class for SOTL Congestion logics
      20             : /****************************************************************************/
      21             : 
      22             : #include "MSSOTLPolicyBasedTrafficLightLogic.h"
      23             : //#define SWARM_DEBUG
      24             : 
      25             : 
      26             : // ===========================================================================
      27             : // method definitions
      28             : // ===========================================================================
      29         128 : MSSOTLPolicyBasedTrafficLightLogic::MSSOTLPolicyBasedTrafficLightLogic(
      30             :     MSTLLogicControl& tlcontrol, const std::string& id,
      31             :     const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
      32             :     SUMOTime delay, const Parameterised::Map& parameters,
      33         128 :     MSSOTLPolicy* policy) :
      34             :     MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
      35         128 :                             parameters), myPolicy(policy) {
      36             : 
      37         256 :     MsgHandler::getMessageInstance()->inform(
      38         256 :         "*** Intersection " + id + " will run using MSSOTL"
      39         256 :         + policy->getName() + "TrafficLightLogic ***");
      40             : 
      41         128 : }
      42             : 
      43           0 : MSSOTLPolicyBasedTrafficLightLogic::MSSOTLPolicyBasedTrafficLightLogic(
      44             :     MSTLLogicControl& tlcontrol, const std::string& id,
      45             :     const std::string& programID, const TrafficLightType logicType, const Phases& phases, int step,
      46             :     SUMOTime delay, const Parameterised::Map& parameters,
      47           0 :     MSSOTLPolicy* policy, MSSOTLSensors* sensors) :
      48             :     MSSOTLTrafficLightLogic(tlcontrol, id, programID, logicType, phases, step, delay,
      49           0 :                             parameters, sensors), myPolicy(policy) {
      50           0 : }
      51             : 
      52         256 : MSSOTLPolicyBasedTrafficLightLogic::~MSSOTLPolicyBasedTrafficLightLogic(void) {
      53             : 
      54         256 : }
      55             : 
      56      135536 : int MSSOTLPolicyBasedTrafficLightLogic::decideNextPhase() {
      57             : #ifdef SWARM_DEBUG
      58             :     std::ostringstream str;
      59             :     str << "\n" << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << getID() << "invoked MSSOTLPolicyBasedTrafficLightLogic::decideNextPhase()";
      60             :     WRITE_MESSAGE(str.str());
      61             : #endif
      62      406608 :     return myPolicy->decideNextPhase(getCurrentPhaseElapsed(),
      63      135536 :                                      &getCurrentPhaseDef(), getCurrentPhaseIndex(),
      64      135536 :                                      getPhaseIndexWithMaxCTS(), isThresholdPassed(), isPushButtonPressed(),
      65      271072 :                                      countVehicles(getCurrentPhaseDef()));
      66             : }
      67             : 
      68           0 : bool MSSOTLPolicyBasedTrafficLightLogic::canRelease() {
      69             : #ifdef SWARM_DEBUG
      70             :     std::ostringstream str;
      71             :     str << "\n" << time2string(MSNet::getInstance()->getCurrentTimeStep()) << " " << getID() << "invoked MSSOTLPolicyBasedTrafficLightLogic::canRelease()";
      72             :     WRITE_MESSAGE(str.str());
      73             : #endif
      74           0 :     return myPolicy->canRelease(getCurrentPhaseElapsed(), isThresholdPassed(), isPushButtonPressed(),
      75           0 :                                 &getCurrentPhaseDef(), countVehicles(getCurrentPhaseDef()));
      76             : }

Generated by: LCOV version 1.14