LCOV - code coverage report
Current view: top level - src/microsim/traffic_lights - MSSOTLPlatoonPolicy.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 80.0 % 25 20
Test Date: 2024-11-22 15:46:21 Functions: 80.0 % 5 4

            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    MSSOTLPlatoonPolicy.cpp
      15              : /// @author  Gianfilippo Slager
      16              : /// @author  Federico Caselli
      17              : /// @date    Feb 2010
      18              : ///
      19              : // The class for SOTL Platoon logics
      20              : /****************************************************************************/
      21              : 
      22              : #include "MSSOTLPlatoonPolicy.h"
      23              : //#define SWARM_DEBUG
      24              : 
      25              : 
      26              : // ===========================================================================
      27              : // method definitions
      28              : // ===========================================================================
      29           16 : MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy(const Parameterised::Map& parameters) :
      30           32 :     MSSOTLPolicy("Platoon", parameters) {
      31           16 :     init();
      32           16 : }
      33              : 
      34            0 : MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy(MSSOTLPolicyDesirability* desirabilityAlgorithm) :
      35            0 :     MSSOTLPolicy("Platoon", desirabilityAlgorithm) {
      36            0 :     getDesirabilityAlgorithm()->setKeyPrefix("PLATOON");
      37            0 :     init();
      38            0 : }
      39              : 
      40           16 : MSSOTLPlatoonPolicy::MSSOTLPlatoonPolicy(MSSOTLPolicyDesirability* desirabilityAlgorithm,
      41           16 :         const Parameterised::Map& parameters) :
      42           32 :     MSSOTLPolicy("Platoon", desirabilityAlgorithm, parameters) {
      43           16 :     getDesirabilityAlgorithm()->setKeyPrefix("PLATOON");
      44           16 :     init();
      45           16 : }
      46              : 
      47        29039 : bool MSSOTLPlatoonPolicy::canRelease(SUMOTime elapsed, bool thresholdPassed, bool pushButtonPressed,
      48              :                                      const MSPhaseDefinition* stage, int vehicleCount) {
      49              : //  DBG(std::ostringstream str; str << "invoked MSTLPlatoonPolicy::canRelease()"; WRITE_MESSAGE(str.str()););
      50              : #ifdef SWARM_DEBUG
      51              :     std::ostringstream str;
      52              :     str << "MSSOTLPlatoonPolicy::canRelease elapsed " << elapsed << " threshold " << thresholdPassed << " pushbutton " << pushButtonPressed << " vcount " << vehicleCount
      53              :         << " minD " << stage->minDuration << " maxD " << stage->maxDuration;
      54              :     str << " will return " << ((thresholdPassed && ((vehicleCount == 0) || (elapsed >= stage->maxDuration))) ? "true" : "false");
      55              :     WRITE_MESSAGE(str.str());
      56              : #endif
      57        29039 :     if (elapsed >= stage->minDuration) {
      58        25508 :         if (pushButtonLogic(elapsed, pushButtonPressed, stage)) {
      59              :             return true;
      60              :         }
      61        25508 :         if (thresholdPassed) {
      62              :             //If there are no other vehicles approaching green lights
      63              :             //or the declared maximum duration has been reached
      64        11218 :             return ((vehicleCount == 0) || (elapsed >= stage->maxDuration));
      65              :         } else {
      66        14596 :             if (sigmoidLogic(elapsed, stage, vehicleCount)) {
      67              :                 return true;
      68              :             }
      69              :         }
      70              :     }
      71              :     return false;
      72              : }
      73              : 
      74           32 : void MSSOTLPlatoonPolicy::init() {
      75           32 :     SigmoidLogic::init("MSSOTLPlatoonPolicy", this);
      76           32 :     PushButtonLogic::init("MSSOTLPlatoonPolicy", this);
      77           32 : }
        

Generated by: LCOV version 2.0-1