SUMO - Simulation of Urban MObility
MSSOTLSensors.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // The base abstract class for SOTL sensors
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright (C) 2010-2017 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 #ifndef MSSOTLSensors_h
22 #define MSSOTLSensors_h
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "MSSOTLDefinitions.h"
34 #include "MSTrafficLightLogic.h"
35 #include <string>
36 #include <microsim/MSLane.h>
38 //#include <microsim/MSEdgeContinuations.h>
39 
41 protected:
43  std::string tlLogicID;
45 
46 protected :
53  virtual void buildSensorForLane(MSLane* lane, NLDetectorBuilder& nb) = 0;
60  virtual void buildSensorForOutLane(MSLane* lane, NLDetectorBuilder& nb) = 0;
61 
62 public:
63  /*
64  *
65  */
66  MSSOTLSensors(std::string tlLogicID, const MSTrafficLightLogic::Phases* phases);
67 
68  /*
69  *
70  */
71  virtual ~MSSOTLSensors();
72 
79  virtual void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb) = 0;
86  virtual void buildOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb) = 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] lane The lane to count vehicles
93  */
94  virtual int countVehicles(MSLane* lane) = 0;
95 
96  /*
97  * Returns the number of vehicles currently approaching the
98  * junction for the given lane.
99  * Vehicles are effectively counted or guessed in the space from the sensor.
100  * @param[in] laneId The lane to count vehicles by ID
101  */
102  virtual int countVehicles(std::string laneId) = 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] lane The lane to count vehicles
109  */
110  virtual double meanVehiclesSpeed(MSLane* lane) = 0;
111 
112  /*
113  * Returns the average speed of vehicles currently approaching the
114  * junction for the given lane.
115  * Vehicles speed is effectively sensed or guessed in the space from the sensor.
116  * @param[in] laneId The lane to count vehicles by ID
117  */
118  virtual double meanVehiclesSpeed(std::string laneId) = 0;
119 
120  /*
121  * @param[in] laneId The lane given by Id
122  * @return The maximum speed allowed for the given laneId
123  */
124  virtual double getMaxSpeed(std::string laneId) = 0;
125 
126  /*
127  * @brief Indicate which lane has given green
128  * This member is useful to inform the sensor logic about changes in traffic lights,
129  * s.t. the logic can better guess the state of lanes accoding to sensors info and
130  * traffic lights state.
131  * This member has to be specified only by sensor logics with a limited amount of knowledge coming
132  * from sensors, like inductor loops. These logics need to know the current phase to guess the number
133  * of vehicles waiting in front of a red light.
134  */
135  virtual void stepChanged(int newStep) {
136  currentStep = newStep;
137  }
138 };
139 
140 #endif
141 /****************************************************************************/
Builds detectors for microsim.
const MSTrafficLightLogic::Phases * myPhases
Definition: MSSOTLSensors.h:42
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:43
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:79