Eclipse SUMO - Simulation of Urban MObility
GNEDetectorE2.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 //
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 #include "GNEDetector.h"
23 
24 
25 // ===========================================================================
26 // class definitions
27 // ===========================================================================
32 class GNEDetectorE2 : public GNEDetector {
33 
34 public:
36  GNEDetectorE2(SumoXMLTag tag, GNENet* net);
37 
55  GNEDetectorE2(const std::string& id, GNELane* lane, GNENet* net, double pos, double length, const SUMOTime freq, const std::string& trafficLight,
56  const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::string& name, SUMOTime timeThreshold, double speedThreshold,
57  double jamThreshold, bool friendlyPos, const std::map<std::string, std::string>& parameters);
58 
76  GNEDetectorE2(const std::string& id, std::vector<GNELane*> lanes, GNENet* net, double pos, double endPos, const SUMOTime freq, const std::string& trafficLight,
77  const std::string& filename, const std::vector<std::string>& vehicleTypes, const std::string& name, SUMOTime timeThreshold, double speedThreshold, double jamThreshold,
78  bool friendlyPos, const std::map<std::string, std::string>& parameters);
79 
82 
85 
88  void writeAdditional(OutputDevice& device) const;
89 
91  bool isAdditionalValid() const;
92 
94  std::string getAdditionalProblem() const;
95 
97  void fixAdditionalProblem();
99 
101  void updateGeometry();
102 
105 
109  void drawGL(const GUIVisualizationSettings& s) const;
111 
114  /* @brief method for getting the Attribute of an XML key
115  * @param[in] key The attribute key
116  * @return string with the value associated to key
117  */
118  std::string getAttribute(SumoXMLAttr key) const;
119 
120  /* @brief method for getting the Attribute of an XML key in double format (to avoid unnecessary parse<double>(...) for certain attributes)
121  * @param[in] key The attribute key
122  * @return double with the value associated to key
123  */
124  double getAttributeDouble(SumoXMLAttr key) const;
125 
126  /* @brief method for setting the attribute and letting the object perform additional changes
127  * @param[in] key The attribute key
128  * @param[in] value The new value
129  * @param[in] undoList The undoList on which to register changes
130  */
131  void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
132 
133  /* @brief method for checking if the key and their correspond attribute are valids
134  * @param[in] key The attribute key
135  * @param[in] value The value asociated to key key
136  * @return true if the value is valid, false in other case
137  */
138  bool isValid(SumoXMLAttr key, const std::string& value);
139 
140  /* @brief method for check if the value for certain attribute is set
141  * @param[in] key The attribute key
142  */
143  bool isAttributeEnabled(SumoXMLAttr key) const;
145 
146 protected:
149 
152 
155 
158 
160  std::string myTrafficLight;
161 
162 private:
164  void setAttribute(SumoXMLAttr key, const std::string& value);
165 
167  void setMoveShape(const GNEMoveResult& moveResult);
168 
170  void commitMoveShape(const GNEMoveResult& moveResult, GNEUndoList* undoList);
171 
173  bool areLaneConsecutives() const;
174 
176  double getStartGeometryPositionOverLane() const;
177 
179  double getEndGeometryPositionOverLane() const;
180 
182  GNEDetectorE2(const GNEDetectorE2&) = delete;
183 
186 };
long long int SUMOTime
Definition: SUMOTime.h:32
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
double getEndGeometryPositionOverLane() const
get end position over lane that is applicable to the shape
void updateGeometry()
update pre-computed geometry information
std::string getAttribute(SumoXMLAttr key) const
void commitMoveShape(const GNEMoveResult &moveResult, GNEUndoList *undoList)
commit move shape
bool isAdditionalValid() const
check if current additional is valid to be writed into XML
bool isValid(SumoXMLAttr key, const std::string &value)
method for checking if the key and their conrrespond attribute are valids
double mySpeedThreshold
The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting.
double myJamThreshold
The minimum distance to the next standing vehicle in order to make this vehicle count as a participan...
void writeAdditional(OutputDevice &device) const
writte additional element into a xml file
bool areLaneConsecutives() const
check if lanes are consecutives
void fixAdditionalProblem()
fix additional problem
GNEDetectorE2(const GNEDetectorE2 &)=delete
Invalidated copy constructor.
void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)
method for setting the attribute and letting the object perform additional changes
SUMOTime myTimeThreshold
The time-based threshold that describes how much time has to pass until a vehicle is recognized as ha...
double getStartGeometryPositionOverLane() const
get start position over lane that is applicable to the shape
bool isAttributeEnabled(SumoXMLAttr key) const
std::string myTrafficLight
Traffic light vinculated with this E2 Detector.
double getAttributeDouble(SumoXMLAttr key) const
~GNEDetectorE2()
Destructor.
GNEDetectorE2 & operator=(const GNEDetectorE2 &)=delete
Invalidated assignment operator.
GNEDetectorE2(SumoXMLTag tag, GNENet *net)
default Constructor
std::string getAdditionalProblem() const
return a string with the current additional problem
void setMoveShape(const GNEMoveResult &moveResult)
set move shape
double myEndPositionOverLane
end position over lane (only for Multilane E2 detectors)
void drawGL(const GUIVisualizationSettings &s) const
Draws the object.
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:46
move result
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:42
Stores the information about how to visualize structures.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61