LCOV - code coverage report
Current view: top level - src/microsim/traffic_lights - MSSOTLSensors.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 3 3
Test Date: 2024-11-22 15:46:21 Functions: 100.0 % 1 1

            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    MSSOTLSensors.h
      15              : /// @author  Gianfilippo Slager
      16              : /// @author  Anna Chiara Bellini
      17              : /// @date    Feb 2010
      18              : ///
      19              : // The base abstract class for SOTL sensors
      20              : /****************************************************************************/
      21              : #pragma once
      22              : #include <config.h>
      23              : 
      24              : #include "MSSOTLDefinitions.h"
      25              : #include "MSTrafficLightLogic.h"
      26              : #include <string>
      27              : #include <microsim/MSLane.h>
      28              : #include <netload/NLDetectorBuilder.h>
      29              : //#include <microsim/MSEdgeContinuations.h>
      30              : 
      31              : class MSSOTLSensors {
      32              : protected:
      33              :     const MSTrafficLightLogic::Phases* myPhases;
      34              :     std::string tlLogicID;
      35              :     int currentStep;
      36              : 
      37              : protected :
      38              :     /**
      39              :     * \brief This function member has to be extended to properly build a sensor for a specific input lane
      40              :     * Sensors has to be constrained on lane dimension
      41              :     * Built sensors has to be collected and associated properly to the respective MSLane for retrieval using MSSOTLSensors::countVehicles(std::string)
      42              :     * See extension classes for further specifications on sensor building
      43              :     */
      44              :     virtual void buildSensorForLane(MSLane* lane, NLDetectorBuilder& nb) = 0;
      45              :     /**
      46              :     * \brief This function member has to be extended to properly build a sensor for a specific output lane
      47              :     * Sensors has to be constrained on lane dimension
      48              :     * Built sensors has to be collected and associated properly to the respective MSLane for retrieval using MSSOTLSensors::countVehicles(std::string)
      49              :     * See extension classes for further specifications on sensor building
      50              :     */
      51              :     virtual void buildSensorForOutLane(MSLane* lane, NLDetectorBuilder& nb) = 0;
      52              : 
      53              : public:
      54              :     /*
      55              :     *
      56              :     */
      57              :     MSSOTLSensors(std::string tlLogicID, const MSTrafficLightLogic::Phases* phases);
      58              : 
      59              :     /*
      60              :     *
      61              :     */
      62              :     virtual ~MSSOTLSensors();
      63              : 
      64              :     /**
      65              :     * \brief This function member has to be extended to properly build sensors for the input lanes
      66              :     * Sensors has to be constrained on lane dimension
      67              :     * Built sensors has to be collected and associated properly to theirs MSLane for retrieval using MSSOTLSensors::countVehicles(std::string)
      68              :     * See extension classes for further specifications on sensor building
      69              :     */
      70              :     virtual void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb) = 0;
      71              :     /**
      72              :     * \brief This function member has to be extended to properly build sensors for the output lanes
      73              :     * Sensors has to be constrained on lane dimension
      74              :     * Built sensors has to be collected and associated properly to theirs MSLane for retrieval using MSSOTLSensors::countVehicles(std::string)
      75              :     * See extension classes for further specifications on sensor building
      76              :     */
      77              :     virtual void buildOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb) = 0;
      78              : 
      79              :     /*
      80              :      * Returns the number of vehicles currently approaching the
      81              :      * junction for the given lane.
      82              :      * Vehicles are effectively counted or guessed in the space from the sensor.
      83              :      * @param[in] lane The lane to count vehicles
      84              :      */
      85              :     virtual int countVehicles(MSLane* lane) = 0;
      86              : 
      87              :     /*
      88              :      * Returns the number of vehicles currently approaching the
      89              :      * junction for the given lane.
      90              :      * Vehicles are effectively counted or guessed in the space from the sensor.
      91              :      * @param[in] laneId The lane to count vehicles by ID
      92              :      */
      93              :     virtual int countVehicles(std::string laneId) = 0;
      94              : 
      95              :     /*
      96              :      * Returns the average speed of vehicles currently approaching the
      97              :      * junction for the given lane.
      98              :      * Vehicles speed is effectively sensed or guessed in the space from the sensor.
      99              :      * @param[in] lane The lane to count vehicles
     100              :      */
     101              :     virtual double meanVehiclesSpeed(MSLane* lane) = 0;
     102              : 
     103              :     /*
     104              :      * Returns the average speed of vehicles currently approaching the
     105              :      * junction for the given lane.
     106              :      * Vehicles speed is effectively sensed or guessed in the space from the sensor.
     107              :      * @param[in] laneId The lane to count vehicles by ID
     108              :      */
     109              :     virtual double meanVehiclesSpeed(std::string laneId) = 0;
     110              : 
     111              :     /*
     112              :     * @param[in] laneId The lane given by Id
     113              :     * @return The maximum speed allowed for the given laneId
     114              :     */
     115              :     virtual double getMaxSpeed(std::string laneId) = 0;
     116              : 
     117              :     /*
     118              :      * @brief Indicate which lane has given green
     119              :      * This member is useful to inform the sensor logic about changes in traffic lights,
     120              :      * s.t. the logic can better guess the state of lanes accoding to sensors info and
     121              :      * traffic lights state.
     122              :      * This member has to be specified only by sensor logics with a limited amount of knowledge coming
     123              :      * from sensors, like inductor loops. These logics need to know the current phase to guess the number
     124              :      * of vehicles waiting in front of a red light.
     125              :      */
     126        10737 :     virtual void stepChanged(int newStep) {
     127        10737 :         currentStep = newStep;
     128        10737 :     }
     129              : };
        

Generated by: LCOV version 2.0-1