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 GNEDetectorE2.h 11 /// @author Pablo Alvarez Lopez 12 /// @date Nov 2015 13 /// @version $Id$ 14 /// 15 // 16 /****************************************************************************/ 17 #ifndef GNEDetectorE2_h 18 #define GNEDetectorE2_h 19 20 21 // =========================================================================== 22 // included modules 23 // =========================================================================== 24 25 #include "GNEDetector.h" 26 27 28 // =========================================================================== 29 // class definitions 30 // =========================================================================== 31 /** 32 * @class GNEDetectorE2 33 * class for detector of type E2 34 */ 35 class GNEDetectorE2 : public GNEDetector { 36 37 public: 38 /**@brief Constructor for Single-Lane E2 detectors 39 * @param[in] id The storage of gl-ids to get the one for this lane representation from 40 * @param[in] lane Lane of this StoppingPlace belongs 41 * @param[in] viewNet pointer to GNEViewNet of this additional element belongs 42 * @param[in] pos position of the detector on the lane 43 * @param[in] length The length of the detector in meters. 44 * @param[in] freq the aggregation period the values the detector collects shall be summed up. 45 * @param[in] filename The path to the output file. 46 * @param[in] vehicleTypes space separated list of vehicle type ids to consider 47 * @param[in] name E2 detector name 48 * @param[in] timeThreshold The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting 49 * @param[in] speedThreshold The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting 50 * @param[in] speedThreshold The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam 51 * @param[in] friendlyPos enable or disable friendly positions 52 * @param[in] block movement enable or disable additional movement 53 */ 54 GNEDetectorE2(const std::string& id, GNELane* lane, GNEViewNet* viewNet, double pos, double length, double freq, const std::string& filename, const std::string& vehicleTypes, 55 const std::string& name, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement); 56 57 /**@brief Constructor for Multi-Lane detectors 58 * @param[in] id The storage of gl-ids to get the one for this lane representation from 59 * @param[in] lanes vector of lanes Lane of this StoppingPlace belongs 60 * @param[in] viewNet pointer to GNEViewNet of this additional element belongs 61 * @param[in] pos position of the detector on the first lane 62 * @param[in] endPos position of the detector on the last lane 63 * @param[in] freq the aggregation period the values the detector collects shall be summed up. 64 * @param[in] filename The path to the output file. 65 * @param[in] vehicleTypes space separated list of vehicle type ids to consider 66 * @param[in] name E2 detector name 67 * @param[in] timeThreshold The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting 68 * @param[in] speedThreshold The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting 69 * @param[in] speedThreshold The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam 70 * @param[in] friendlyPos enable or disable friendly positions 71 * @param[in] block movement enable or disable additional movement 72 */ 73 GNEDetectorE2(const std::string& id, std::vector<GNELane*> lanes, GNEViewNet* viewNet, double pos, double endPos, double freq, const std::string& filename, const std::string& vehicleTypes, 74 const std::string& name, const double timeThreshold, double speedThreshold, double jamThreshold, bool friendlyPos, bool blockMovement); 75 76 /// @brief Destructor 77 ~GNEDetectorE2(); 78 79 /// @name members and functions relative to write additionals into XML 80 /// @{ 81 /// @brief check if current additional is valid to be writed into XML 82 bool isAdditionalValid() const; 83 84 /// @brief return a string with the current additional problem 85 std::string getAdditionalProblem() const; 86 87 /// @brief fix additional problem 88 void fixAdditionalProblem(); 89 /// @} 90 91 /// @brief get length of E2 Detector 92 double getLength() const; 93 94 /// @brief check if E2 is valid (all of their lanes are connected, it must called after every operation which involves lane's connections) 95 void checkE2MultilaneIntegrity(); 96 97 /// @name Functions related with geometry of element 98 /// @{ 99 /**@brief change the position of the element geometry without saving in undoList 100 * @param[in] offset Position used for calculate new position of geometry without updating RTree 101 */ 102 void moveGeometry(const Position& offset); 103 104 /**@brief commit geometry changes in the attributes of an element after use of moveGeometry(...) 105 * @param[in] undoList The undoList on which to register changes 106 */ 107 void commitGeometryMoving(GNEUndoList* undoList); 108 109 /// @brief update pre-computed geometry information 110 void updateGeometry(bool updateGrid); 111 /// @} 112 113 /// @name inherited from GUIGlObject 114 /// @{ 115 /**@brief Draws the object 116 * @param[in] s The settings for the current view (may influence drawing) 117 * @see GUIGlObject::drawGL 118 */ 119 void drawGL(const GUIVisualizationSettings& s) const; 120 /// @} 121 122 /// @name inherited from GNEAttributeCarrier 123 /// @{ 124 /* @brief method for getting the Attribute of an XML key 125 * @param[in] key The attribute key 126 * @return string with the value associated to key 127 */ 128 std::string getAttribute(SumoXMLAttr key) const; 129 130 /* @brief method for setting the attribute and letting the object perform additional changes 131 * @param[in] key The attribute key 132 * @param[in] value The new value 133 * @param[in] undoList The undoList on which to register changes 134 */ 135 void setAttribute(SumoXMLAttr key, const std::string& value, GNEUndoList* undoList); 136 137 /* @brief method for checking if the key and their correspond attribute are valids 138 * @param[in] key The attribute key 139 * @param[in] value The value asociated to key key 140 * @return true if the value is valid, false in other case 141 */ 142 bool isValid(SumoXMLAttr key, const std::string& value); 143 /// @} 144 145 protected: 146 /// @brief E2 detector length 147 double myLength; 148 149 /// @brief end position over lane (only for Multilane E2 detectors) 150 double myEndPositionOverLane; 151 152 /// @brief The time-based threshold that describes how much time has to pass until a vehicle is recognized as halting 153 double myTimeThreshold; 154 155 /// @brief The speed-based threshold that describes how slow a vehicle has to be to be recognized as halting 156 double mySpeedThreshold; 157 158 /// @brief The minimum distance to the next standing vehicle in order to make this vehicle count as a participant to the jam 159 double myJamThreshold; 160 161 /// @brief flag to check if E2 multilane is valid or invalid 162 bool myE2valid; 163 164 private: 165 /// @brief set attribute after validation 166 void setAttribute(SumoXMLAttr key, const std::string& value); 167 168 /// @brief Invalidated copy constructor. 169 GNEDetectorE2(const GNEDetectorE2&) = delete; 170 171 /// @brief Invalidated assignment operator. 172 GNEDetectorE2& operator=(const GNEDetectorE2&) = delete; 173 }; 174 175 #endif 176 /****************************************************************************/ 177