LCOV - code coverage report
Current view: top level - src/microsim/traffic_lights - MSSOTLE2Sensors.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 5 20.0 %
Date: 2024-05-19 15:37:39 Functions: 0 3 0.0 %

          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    MSSOTLE2Sensors.h
      15             : /// @author  Gianfilippo Slager
      16             : /// @author  Federico Caselli
      17             : /// @date    Feb 2010
      18             : ///
      19             : // The class for SOTL sensors of "E2" type
      20             : // XXX: Not tested with MSMultiLaneE2Collector (Generalization of MSE2Collector). If this is to be used in the future and you run into problems,
      21             : //      start taking a look at the getEstimateQueueLength() method of the collector.
      22             : /****************************************************************************/
      23             : #pragma once
      24             : #include <config.h>
      25             : 
      26             : 
      27             : #include <cmath>
      28             : #include <map>
      29             : #include <utility>
      30             : #include <microsim/output/MSE2Collector.h>
      31             : #include "MSSOTLSensors.h"
      32             : #include "MSSOTLDefinitions.h"
      33             : 
      34             : class MSSOTLE2Sensors : public MSSOTLSensors {
      35             : protected :
      36             :     void buildSensorForLane(MSLane* lane, NLDetectorBuilder& nb);
      37             :     void buildSensorForLane(MSLane* lane, NLDetectorBuilder& nb, double sensorLength);
      38             :     void buildContinueSensior(MSLane* lane, NLDetectorBuilder& nb, double sensorLength, MSLane* continueOnLane, double usedLength);
      39             :     void buildSensorForOutLane(MSLane* lane, NLDetectorBuilder& nb);
      40             :     void buildSensorForOutLane(MSLane* lane, NLDetectorBuilder& nb, double sensorLength);
      41             : 
      42             :     void buildCountSensorForLane(MSLane* lane, NLDetectorBuilder& nb);
      43             :     void buildCountSensorForOutLane(MSLane* lane, NLDetectorBuilder& nb);
      44             : 
      45             : public:
      46             :     /*
      47             :     * @brief This sensor logic contructor
      48             :     */
      49             :     MSSOTLE2Sensors(std::string tlLogicID, const MSTrafficLightLogic::Phases* phases);
      50             : 
      51             :     /*
      52             :     * @brief This sensor logic destructor
      53             :     */
      54             :     ~MSSOTLE2Sensors(void);
      55             : 
      56             :     void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb);
      57             :     void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb, double sensorLength);
      58             :     void buildOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb);
      59             :     void buildOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb, double sensorLength);
      60             :     void buildCountSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb);
      61             :     void buildCountOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb);
      62             : 
      63             :     /*
      64             :      * Returns the number of vehicles that have passed the sensor.
      65             :      * Vehicles are effectively counted or guessed in the space from the sensor to the junction.
      66             :      * @param[in] laneId The ID of the lane of which you want to count vehicles.
      67             :      * @param[in] out boolean that indicate if the lane is an incoming or an outgoing one (@todo review)
      68             :      */
      69             :     int getPassedVeh(std::string laneId, bool out);
      70             : 
      71             :     /*
      72             :      * Sets the number of vehicles that have passed the sensor.
      73             :      * @param[in] laneId The ID of the lane of which you want to set vehicles.
      74             :      * @param[in] passed int indicating the number of vehicles to subtract.
      75             :      */
      76             :     void subtractPassedVeh(std::string laneId, int passed);
      77             : 
      78             :     void setSpeedThresholdParam(double newThreshold) {
      79         192 :         speedThresholdParam = newThreshold;
      80             :     }
      81             : 
      82             :     /*
      83             :      * Returns the number of vehicles currently approaching the
      84             :      * junction for the given lane.
      85             :      * Vehicles are effectively counted or guessed in the space from the sensor to the junction.
      86             :      * @param[in] lane The lane to count vehicles
      87             :      */
      88             :     int countVehicles(MSLane* lane);
      89             : 
      90             :     /*
      91             :      * Returns the number of vehicles currently approaching the
      92             :      * junction for the given lane.
      93             :      * Vehicles are effectively counted or guessed in the space from the sensor to the junction.
      94             :      * @param[in] lane The lane to count vehicles given by ID
      95             :      */
      96             :     int countVehicles(std::string laneId);
      97             : 
      98             :     int estimateVehicles(std::string laneId);
      99             : 
     100             :     double getEstimateQueueLength(std::string laneId);
     101             :     /*
     102             :     * @param[in] The lane given by Id
     103             :     * @return The maximum speed allowed for the given laneId
     104             :     */
     105             :     virtual double getMaxSpeed(std::string laneId);
     106             : 
     107             :     /*
     108             :      * Returns the average speed of vehicles currently approaching or leaving the
     109             :      * junction for the given lane.
     110             :      * Vehicles speed is effectively sensed or guessed in the space from the sensor.
     111             :      * @param[in] lane The lane to count vehicles
     112             :      */
     113             :     virtual double meanVehiclesSpeed(MSLane* lane);
     114             : 
     115             :     /*
     116             :      * Returns the average speed of vehicles currently approaching or leaving the
     117             :      * junction for the given lane.
     118             :      * Vehicles speed is effectively sensed or guessed in the space from the sensor.
     119             :      * @param[in] laneID The lane to count vehicles by ID
     120             :      */
     121             :     virtual double meanVehiclesSpeed(std::string laneId);
     122             : 
     123             :     /*
     124             :      * Set the weight of the vehicle types to be used by countVehicles
     125             :      * @param[in] the value of the param VEHICLE_TYPES_WEIGHTS. Format type1=value1; type2=value2 etc..
     126             :      */
     127             :     virtual void setVehicleWeigths(const std::string& weightString);
     128             : 
     129             : protected:
     130             :     int count(MSE2Collector* sensor);
     131             :     template<typename Method, typename ValueType>
     132           0 :     bool getVelueFromSensor(std::string laneId, Method function, ValueType& value) {
     133           0 :         if (m_sensorMap.find(laneId) != m_sensorMap.end()) {
     134           0 :             value = (m_sensorMap[laneId]->*function)();
     135           0 :             return true;
     136             :         }
     137             :         return false;
     138             :     }
     139             : 
     140             : //      MSLane_MSE2CollectorMap m_sensorMap;
     141             :     MSLaneID_MSE2CollectorMap m_sensorMap;
     142             :     MSLaneID_MaxSpeedMap m_maxSpeedMap;
     143             : 
     144             : //      MSLane_MSE2CollectorMap mySensorsMap_OutLanes;
     145             : //      MSLaneID_MSE2CollectorMap mySensorsIDMap_OutLanes;
     146             : //      MSLaneID_MaxSpeedMap myMaxSpeedMap_OutLanes;
     147             : 
     148             :     double speedThresholdParam;
     149             :     std::map<std::string, std::vector<std::string> > m_continueSensorOnLanes;
     150             :     std::map<const std::string, int> m_typeWeightMap;
     151             : 
     152             : };

Generated by: LCOV version 1.14