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.org/sumo
3 // Copyright (C) 2010-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
16 // The base abstract class for SOTL sensors
17 /****************************************************************************/
18 #ifndef MSSOTLSensors_h
19 #define MSSOTLSensors_h
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include "MSSOTLDefinitions.h"
27 #include "MSTrafficLightLogic.h"
28 #include <string>
29 #include <microsim/MSLane.h>
31 //#include <microsim/MSEdgeContinuations.h>
32 
34 protected:
36  std::string tlLogicID;
38 
39 protected :
46  virtual void buildSensorForLane(MSLane* lane, NLDetectorBuilder& nb) = 0;
53  virtual void buildSensorForOutLane(MSLane* lane, NLDetectorBuilder& nb) = 0;
54 
55 public:
56  /*
57  *
58  */
59  MSSOTLSensors(std::string tlLogicID, const MSTrafficLightLogic::Phases* phases);
60 
61  /*
62  *
63  */
64  virtual ~MSSOTLSensors();
65 
72  virtual void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb) = 0;
79  virtual void buildOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb) = 0;
80 
81  /*
82  * Returns the number of vehicles currently approaching the
83  * junction for the given lane.
84  * Vehicles are effectively counted or guessed in the space from the sensor.
85  * @param[in] lane The lane to count vehicles
86  */
87  virtual int countVehicles(MSLane* lane) = 0;
88 
89  /*
90  * Returns the number of vehicles currently approaching the
91  * junction for the given lane.
92  * Vehicles are effectively counted or guessed in the space from the sensor.
93  * @param[in] laneId The lane to count vehicles by ID
94  */
95  virtual int countVehicles(std::string laneId) = 0;
96 
97  /*
98  * Returns the average speed of vehicles currently approaching the
99  * junction for the given lane.
100  * Vehicles speed is effectively sensed or guessed in the space from the sensor.
101  * @param[in] lane The lane to count vehicles
102  */
103  virtual double meanVehiclesSpeed(MSLane* lane) = 0;
104 
105  /*
106  * Returns the average speed of vehicles currently approaching the
107  * junction for the given lane.
108  * Vehicles speed is effectively sensed or guessed in the space from the sensor.
109  * @param[in] laneId The lane to count vehicles by ID
110  */
111  virtual double meanVehiclesSpeed(std::string laneId) = 0;
112 
113  /*
114  * @param[in] laneId The lane given by Id
115  * @return The maximum speed allowed for the given laneId
116  */
117  virtual double getMaxSpeed(std::string laneId) = 0;
118 
119  /*
120  * @brief Indicate which lane has given green
121  * This member is useful to inform the sensor logic about changes in traffic lights,
122  * s.t. the logic can better guess the state of lanes accoding to sensors info and
123  * traffic lights state.
124  * This member has to be specified only by sensor logics with a limited amount of knowledge coming
125  * from sensors, like inductor loops. These logics need to know the current phase to guess the number
126  * of vehicles waiting in front of a red light.
127  */
128  virtual void stepChanged(int newStep) {
129  currentStep = newStep;
130  }
131 };
132 
133 #endif
134 /****************************************************************************/
Builds detectors for microsim.
const MSTrafficLightLogic::Phases * myPhases
Definition: MSSOTLSensors.h:35
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 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 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 ...
virtual ~MSSOTLSensors()
virtual int countVehicles(MSLane *lane)=0
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
virtual double meanVehiclesSpeed(MSLane *lane)=0
virtual double getMaxSpeed(std::string laneId)=0
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
MSSOTLSensors(std::string tlLogicID, const MSTrafficLightLogic::Phases *phases)
std::string tlLogicID
Definition: MSSOTLSensors.h:36
virtual void stepChanged(int newStep)
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...
Representation of a lane in the micro simulation.
Definition: MSLane.h:83