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