SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MSSOTLE2Sensors.h
Go to the documentation of this file.
1 /****************************************************************************/
8 // The class for SOTL sensors of "E2" type
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
11 // Copyright 2001-2009 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 MSSOTLE2Sensors_h
22 #define MSSOTLE2Sensors_h
23 
24 
25 #define SWARM_DEBUG
27 #include "MSSOTLSensors.h"
28 #include "MSSOTLDefinitions.h"
29 #include <math.h>
30 #include <map>
31 #include <utility>
33 
35 protected :
37  void buildSensorForLane(MSLane* lane, NLDetectorBuilder& nb, SUMOReal sensorLength);
38  void buildContinueSensior(MSLane* lane, NLDetectorBuilder& nb, SUMOReal sensorLength, MSLane* continueOnLane, SUMOReal usedLength);
40  void buildSensorForOutLane(MSLane* lane, NLDetectorBuilder& nb, SUMOReal sensorLength);
41 
44 
45 public:
46  /*
47  * @brief This sensor logic contructor
48  */
49  MSSOTLE2Sensors(std::string tlLogicID, const MSTrafficLightLogic::Phases* phases);
50 
51  /*
52  * @brief This sensor logic destructor
53  */
54  ~MSSOTLE2Sensors(void);
55 
57  void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder& nb, SUMOReal sensorLength);
62 
63  /*
64  * Returns the number of vehicles that have passed the sensor.
65  * Vehicles are effectively counted or guessed in the space from the sensor to the junction.
66  * @param[in] laneId The ID of the lane of which you want to count vehicles.
67  * @param[in] out boolean that indicate if the lane is an incoming or an outgoing one (@todo review)
68  */
69  int getPassedVeh(std::string laneId, bool out);
70 
71  /*
72  * Sets the number of vehicles that have passed the sensor.
73  * @param[in] laneId The ID of the lane of which you want to set vehicles.
74  * @param[in] passed int indicating the number of vehicles to subtract.
75  */
76  void subtractPassedVeh(std::string laneId, int passed);
77 
78  void setSpeedThresholdParam(SUMOReal newThreshold) {
79  speedThresholdParam = newThreshold;
80  }
81 
82  /*
83  * Returns the number of vehicles currently approaching the
84  * junction for the given lane.
85  * Vehicles are effectively counted or guessed in the space from the sensor to the junction.
86  * @param[in] lane The lane to count vehicles
87  */
88  int countVehicles(MSLane* lane);
89 
90  /*
91  * Returns the number of vehicles currently approaching the
92  * junction for the given lane.
93  * Vehicles are effectively counted or guessed in the space from the sensor to the junction.
94  * @param[in] lane The lane to count vehicles given by ID
95  */
96  int countVehicles(std::string laneId);
97 
98  int estimateVehicles(std::string laneId);
99 
100  SUMOReal getEstimateQueueLength(std::string laneId);
101  /*
102  * @param[in] The lane given by Id
103  * @return The maximum speed allowed for the given laneId
104  */
105  virtual SUMOReal getMaxSpeed(std::string laneId);
106 
107  /*
108  * Returns the average speed of vehicles currently approaching or leaving the
109  * junction for the given lane.
110  * Vehicles speed is effectively sensed or guessed in the space from the sensor.
111  * @param[in] lane The lane to count vehicles
112  */
113  virtual SUMOReal meanVehiclesSpeed(MSLane* lane);
114 
115  /*
116  * Returns the average speed of vehicles currently approaching or leaving the
117  * junction for the given lane.
118  * Vehicles speed is effectively sensed or guessed in the space from the sensor.
119  * @param[in] laneID The lane to count vehicles by ID
120  */
121  virtual SUMOReal meanVehiclesSpeed(std::string laneId);
122 
123  /*
124  * Set the weight of the vehicle types to be used by countVehicles
125  * @param[in] the value of the param VEHICLE_TYPES_WEIGHTS. Format type1=value1; type2=value2 etc..
126  */
127  virtual void setVehicleWeigths(const std::string& weightString);
128 
129 protected:
130  int count(MSE2Collector* sensor);
131  template<typename Method, typename ValueType>
132  bool getVelueFromSensor(std::string laneId, Method function, ValueType& value) {
133  if (m_sensorMap.find(laneId) != m_sensorMap.end()) {
134  value = (m_sensorMap[laneId]->*function)();
135  return true;
136  }
137  return false;
138  }
139 
140 // MSLane_MSE2CollectorMap m_sensorMap;
143 
144 // MSLane_MSE2CollectorMap mySensorsMap_OutLanes;
145 // MSLaneID_MSE2CollectorMap mySensorsIDMap_OutLanes;
146 // MSLaneID_MaxSpeedMap myMaxSpeedMap_OutLanes;
147 
149  std::map<std::string, std::vector<std::string> > m_continueSensorOnLanes;
150  std::map<const std::string, int> m_typeWeightMap;
151 
152 };
153 
154 #endif
155 /****************************************************************************/
Builds detectors for microsim.
void buildCountSensorForOutLane(MSLane *lane, NLDetectorBuilder &nb)
int countVehicles(MSLane *lane)
SUMOReal getEstimateQueueLength(std::string laneId)
void buildOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
This function member has to be extended to properly build sensors for the output lanes Sensors has to...
An areal (along a single lane) detector.
Definition: MSE2Collector.h:83
std::map< const std::string, int > m_typeWeightMap
SUMOReal speedThresholdParam
MSLaneID_MSE2CollectorMap m_sensorMap
MSSOTLE2Sensors(std::string tlLogicID, const MSTrafficLightLogic::Phases *phases)
void buildCountOutSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
void setSpeedThresholdParam(SUMOReal newThreshold)
std::map< std::string, std::vector< std::string > > m_continueSensorOnLanes
int estimateVehicles(std::string laneId)
void buildCountSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
int getPassedVeh(std::string laneId, bool out)
void buildSensorForOutLane(MSLane *lane, NLDetectorBuilder &nb)
This function member has to be extended to properly build a sensor for a specific output lane Sensors...
virtual SUMOReal getMaxSpeed(std::string laneId)
bool getVelueFromSensor(std::string laneId, Method function, ValueType &value)
std::map< std::string, MSE2Collector * > MSLaneID_MSE2CollectorMap
MSLaneID_MaxSpeedMap m_maxSpeedMap
void buildSensorForLane(MSLane *lane, NLDetectorBuilder &nb)
This function member has to be extended to properly build a sensor for a specific input lane Sensors ...
virtual void setVehicleWeigths(const std::string &weightString)
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of links that do have the same attribute.
void buildSensors(MSTrafficLightLogic::LaneVectorVector controlledLanes, NLDetectorBuilder &nb)
This function member has to be extended to properly build sensors for the input lanes Sensors has to ...
void buildCountSensorForLane(MSLane *lane, NLDetectorBuilder &nb)
std::map< std::string, SUMOReal > MSLaneID_MaxSpeedMap
void buildContinueSensior(MSLane *lane, NLDetectorBuilder &nb, SUMOReal sensorLength, MSLane *continueOnLane, SUMOReal usedLength)
#define SUMOReal
Definition: config.h:214
void subtractPassedVeh(std::string laneId, int passed)
std::string tlLogicID
Definition: MSSOTLSensors.h:43
virtual SUMOReal meanVehiclesSpeed(MSLane *lane)
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
int count(MSE2Collector *sensor)