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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
18 // The base abstract class for SOTL sensors
19 /****************************************************************************/
20 #ifndef MSSOTLSensors_h
21 #define MSSOTLSensors_h
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include "MSSOTLDefinitions.h"
33 #include "MSTrafficLightLogic.h"
34 #include <string>
35 #include <microsim/MSLane.h>
37 //#include <microsim/MSEdgeContinuations.h>
38 
40 protected:
42  std::string tlLogicID;
44 
45 protected :
52  virtual void buildSensorForLane(MSLane* lane, NLDetectorBuilder& nb) = 0;
59  virtual void buildSensorForOutLane(MSLane* lane, NLDetectorBuilder& nb) = 0;
60 
61 public:
62  /*
63  *
64  */
65  MSSOTLSensors(std::string tlLogicID, const MSTrafficLightLogic::Phases* phases);
66 
67  /*
68  *
69  */
70  virtual ~MSSOTLSensors();
71 
78  virtual void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb) = 0;
85  virtual void buildOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb) = 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] lane The lane to count vehicles
92  */
93  virtual int countVehicles(MSLane* lane) = 0;
94 
95  /*
96  * Returns the number of vehicles currently approaching the
97  * junction for the given lane.
98  * Vehicles are effectively counted or guessed in the space from the sensor.
99  * @param[in] laneId The lane to count vehicles by ID
100  */
101  virtual int countVehicles(std::string laneId) = 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] lane The lane to count vehicles
108  */
109  virtual double meanVehiclesSpeed(MSLane* lane) = 0;
110 
111  /*
112  * Returns the average speed of vehicles currently approaching the
113  * junction for the given lane.
114  * Vehicles speed is effectively sensed or guessed in the space from the sensor.
115  * @param[in] laneId The lane to count vehicles by ID
116  */
117  virtual double meanVehiclesSpeed(std::string laneId) = 0;
118 
119  /*
120  * @param[in] laneId The lane given by Id
121  * @return The maximum speed allowed for the given laneId
122  */
123  virtual double getMaxSpeed(std::string laneId) = 0;
124 
125  /*
126  * @brief Indicate which lane has given green
127  * This member is useful to inform the sensor logic about changes in traffic lights,
128  * s.t. the logic can better guess the state of lanes accoding to sensors info and
129  * traffic lights state.
130  * This member has to be specified only by sensor logics with a limited amount of knowledge coming
131  * from sensors, like inductor loops. These logics need to know the current phase to guess the number
132  * of vehicles waiting in front of a red light.
133  */
134  virtual void stepChanged(int newStep) {
135  currentStep = newStep;
136  }
137 };
138 
139 #endif
140 /****************************************************************************/
Builds detectors for microsim.
const MSTrafficLightLogic::Phases * myPhases
Definition: MSSOTLSensors.h:41
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:42
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:77