Eclipse SUMO - Simulation of Urban MObility
MSSOTLSensors.h
Go to the documentation of this file.
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 /****************************************************************************/
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>
29 //#include <microsim/MSEdgeContinuations.h>
30 
32 protected:
34  std::string tlLogicID;
36 
37 protected :
44  virtual void buildSensorForLane(MSLane* lane, NLDetectorBuilder& nb) = 0;
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 
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  virtual void stepChanged(int newStep) {
127  currentStep = newStep;
128  }
129 };
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
virtual int countVehicles(std::string laneId)=0
virtual double meanVehiclesSpeed(MSLane *lane)=0
const MSTrafficLightLogic::Phases * myPhases
Definition: MSSOTLSensors.h:33
MSSOTLSensors(std::string tlLogicID, const MSTrafficLightLogic::Phases *phases)
virtual void buildOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)=0
This function member has to be extended to properly build sensors for the output lanes Sensors has to...
virtual void stepChanged(int newStep)
virtual double meanVehiclesSpeed(std::string laneId)=0
virtual double getMaxSpeed(std::string laneId)=0
virtual void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)=0
This function member has to be extended to properly build sensors for the input lanes Sensors has to ...
virtual ~MSSOTLSensors()
virtual void buildSensorForLane(MSLane *lane, NLDetectorBuilder &nb)=0
This function member has to be extended to properly build a sensor for a specific input lane Sensors ...
std::string tlLogicID
Definition: MSSOTLSensors.h:34
virtual int countVehicles(MSLane *lane)=0
virtual void buildSensorForOutLane(MSLane *lane, NLDetectorBuilder &nb)=0
This function member has to be extended to properly build a sensor for a specific output lane Sensors...
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Builds detectors for microsim.