1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
10 /// @file    GNEDetectorE3.h
11 /// @author  Pablo Alvarez Lopez
12 /// @date    Nov 2015
13 /// @version $Id$
14 ///
15 //
16 /****************************************************************************/
17 #ifndef GNEDetectorE3_h
18 #define GNEDetectorE3_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 
25 #include "GNEAdditional.h"
26 
27 
28 // ===========================================================================
29 // class definitions
30 // ===========================================================================
31 /**
32  * @class GNEDetectorE3
33  * Class for multy Entry/multy Exits detectors
34  */
35 class GNEDetectorE3 : public GNEAdditional {
36 
37 public:
38     /**@brief GNEDetectorE3 Constructor
39      * @param[in] id The storage of gl-ids to get the one for this lane representation from
40      * @param[in] viewNet pointer to GNEViewNet of this additional element belongs
41      * @param[in] pos position (center) of the detector in the map
42      * @param[in] freq the aggregation period the values the detector collects shall be summed up.
43      * @param[in] filename The path to the output file
44      * @param[in] vehicleTypes space separated list of vehicle type ids to consider
45      * @param[in] name E3 detector name
46      * @param[in] timeThreshold The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting
47      * @param[in] speedThreshold The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting
48      * @param[in] block movement enable or disable additional movement
49      */
50     GNEDetectorE3(const std::string& id, GNEViewNet* viewNet, Position pos, double freq, const std::string& filename, const std::string& vehicleTypes, const std::string& name, const double timeThreshold, double speedThreshold, bool blockMovement);
51 
52     /// @brief GNEDetectorE3 Destructor
53     ~GNEDetectorE3();
54 
55     /// @name Functions related with geometry of element
56     /// @{
57     /**@brief change the position of the element geometry without saving in undoList
58      * @param[in] offset Position used for calculate new position of geometry without updating RTree
59      */
60     void moveGeometry(const Position& offset);
61 
62     /**@brief commit geometry changes in the attributes of an element after use of moveGeometry(...)
63      * @param[in] undoList The undoList on which to register changes
64      */
65     void commitGeometryMoving(GNEUndoList* undoList);
66 
67     /// @brief update pre-computed geometry information
68     void updateGeometry(bool updateGrid);
69 
70     /// @brief Returns position of additional in view
71     Position getPositionInView() const;
72     /// @}
73 
74     /// @name inherited from GUIGlObject
75     /// @{
76     /// @brief Returns the name of the parent object
77     /// @return This object's parent id
78     std::string getParentName() const;
79 
80     /**@brief Draws the object
81      * @param[in] s The settings for the current view (may influence drawing)
82      * @see GUIGlObject::drawGL
83      */
84     void drawGL(const GUIVisualizationSettings& s) const;
85     /// @}
86 
87     /// @name inherited from GNEAttributeCarrier
88     /// @{
89     /* @brief method for getting the Attribute of an XML key
90      * @param[in] key The attribute key
91      * @return string with the value associated to key
92      */
93     std::string getAttribute(SumoXMLAttr key) const;
94 
95     /* @brief method for setting the attribute and letting the object perform additional changes
96      * @param[in] key The attribute key
97      * @param[in] value The new value
98      * @param[in] undoList The undoList on which to register changes
99      */
100     void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList);
101 
102     /* @brief method for checking if the key and their conrrespond attribute are valids
103      * @param[in] key The attribute key
104      * @param[in] value The value asociated to key key
105      * @return true if the value is valid, false in other case
106      */
107     bool isValid(SumoXMLAttr key, const std::string& value);
108 
109     /// @brief get PopPup ID (Used in AC Hierarchy)
110     std::string getPopUpID() const;
111 
112     /// @brief get Hierarchy Name (Used in AC Hierarchy)
113     std::string getHierarchyName() const;
114     /// @}
115 
116 protected:
117     /// @brief position of E3 in view
118     Position myPosition;
119 
120     /// @brief frequency of E3 detector
121     double myFreq;
122 
123     /// @brief fielname of E3 detector
124     std::string myFilename;
125 
126     /// @brief attribute vehicle types
127     std::string myVehicleTypes;
128 
129     /// @brief The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting
130     double myTimeThreshold;
131 
132     /// @brief The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting
133     double mySpeedThreshold;
134 
135 private:
136     /// @brief check restriction with the number of childs
137     bool checkAdditionalChildRestriction() const;
138 
139     /// @brief set attribute after validation
140     void setAttribute(SumoXMLAttr key, const std::string& value);
141 
142     /// @brief Invalidated copy constructor.
143     GNEDetectorE3(const GNEDetectorE3&) = delete;
144 
145     /// @brief Invalidated assignment operator.
146     GNEDetectorE3& operator=(const GNEDetectorE3&) = delete;
147 };
148 
149 #endif
150 /****************************************************************************/
151