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 MSMeanData_Harmonoise.h 11 /// @author Daniel Krajzewicz 12 /// @author Michael Behrisch 13 /// @date Mon, 10.05.2004 14 /// @version $Id$ 15 /// 16 // Noise data collector for edges/lanes 17 /****************************************************************************/ 18 #ifndef MSMeanData_Harmonoise_h 19 #define MSMeanData_Harmonoise_h 20 21 22 // =========================================================================== 23 // included modules 24 // =========================================================================== 25 #include <config.h> 26 27 #include <vector> 28 #include <limits> 29 #include "MSMeanData.h" 30 31 32 // =========================================================================== 33 // class declarations 34 // =========================================================================== 35 class OutputDevice; 36 class MSLane; 37 38 39 // =========================================================================== 40 // class definitions 41 // =========================================================================== 42 /** 43 * @class MSMeanData_Harmonoise 44 * @brief Noise data collector for edges/lanes 45 * 46 * This structure does not contain the data itself, it is stored within 47 * MSLaneMeanDataValues-MoveReminder objects. 48 * This class is used to build the output, optionally, in the case 49 * of edge-based dump, aggregated over the edge's lanes. 50 * 51 * @todo consider error-handling on write (using IOError) 52 */ 53 class MSMeanData_Harmonoise : public MSMeanData { 54 public: 55 /** 56 * @class MSLaneMeanDataValues 57 * @brief Data structure for mean (aggregated) edge/lane values 58 * 59 * Structure holding values that describe the noise aggregated over 60 * some seconds. 61 */ 62 class MSLaneMeanDataValues : public MSMeanData::MeanDataValues { 63 public: 64 /** @brief Constructor */ 65 MSLaneMeanDataValues(MSLane* const lane, const double length, const bool doAdd, 66 const MSMeanData_Harmonoise* parent); 67 68 /** @brief Destructor */ 69 virtual ~MSLaneMeanDataValues(); 70 71 72 /** @brief Resets values so they may be used for the next interval 73 */ 74 void reset(bool afterWrite = false); 75 76 /** @brief Add the values to this meanData 77 */ 78 void addTo(MSMeanData::MeanDataValues& val) const; 79 80 81 /** @brief Computes the noise in the last time step 82 * 83 * The sum of noises collected so far (in the last seen step) 84 * is built, and added to meanNTemp; currentTimeN is resetted. 85 */ 86 void update(); 87 88 /** @brief Writes output values into the given stream 89 * 90 * @param[in] dev The output device to write the data into 91 * @param[in] period Length of the period the data were gathered 92 * @param[in] numLanes The total number of lanes for which the data was collected 93 * @param[in] length The length of the object for which the data was collected 94 * @exception IOError If an error on writing occurs (!!! not yet implemented) 95 */ 96 void write(OutputDevice& dev, const SUMOTime period, 97 const double numLanes, const double defaultTravelTime, 98 const int numVehicles = -1) const; 99 100 101 protected: 102 /** @brief Internal notification about the vehicle moves 103 * @see MSMoveReminder::notifyMoveInternal() 104 */ 105 void notifyMoveInternal(const SUMOTrafficObject& veh, const double /* frontOnLane */, const double timeOnLane, const double meanSpeedFrontOnLane, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double /* meanLengthOnLane */); 106 107 private: 108 /// @name Collected values 109 /// @{ 110 111 /// @brief Sum of produced noise at this time step(pow(10, (<NOISE>/10.))) 112 double currentTimeN; 113 114 /// @brief Sum of produced noise over time (pow(10, (<NOISE>/10.))) 115 double meanNTemp; 116 //@} 117 118 119 /// @brief The meandata parent 120 const MSMeanData_Harmonoise* myParent; 121 }; 122 123 124 public: 125 /** @brief Constructor 126 * 127 * @param[in] id The id of the detector 128 * @param[in] dumpBegin Begin time of dump 129 * @param[in] dumpEnd End time of dump 130 * @param[in] useLanes Information whether lane-based or edge-based dump shall be generated 131 * @param[in] withEmpty Information whether empty lanes/edges shall be written 132 * @param[in] printDefaults Information whether defaults for empty lanes/edges shall be written 133 * @param[in] withInternal Information whether internal lanes/edges shall be written 134 * @param[in] trackVehicles Information whether vehicles shall be tracked 135 * @param[in] maxTravelTime the maximum travel time to use when calculating per vehicle output 136 * @param[in] minSamples the minimum number of sample seconds before the values are valid 137 * @param[in] vTypes the set of vehicle types to consider 138 */ 139 MSMeanData_Harmonoise(const std::string& id, 140 const SUMOTime dumpBegin, const SUMOTime dumpEnd, 141 const bool useLanes, const bool withEmpty, 142 const bool printDefaults, const bool withInternal, 143 const bool trackVehicles, 144 const double minSamples, const double maxTravelTime, 145 const std::string& vTypes); 146 147 148 /// @brief Destructor 149 virtual ~MSMeanData_Harmonoise(); 150 151 /** @brief Updates the detector 152 */ 153 virtual void detectorUpdate(const SUMOTime step); 154 155 156 protected: 157 /** @brief Create an instance of MeanDataValues 158 * 159 * @param[in] lane The lane to create for 160 * @param[in] doAdd whether to add the values as reminder to the lane 161 */ 162 MSMeanData::MeanDataValues* createValues(MSLane* const lane, const double length, const bool doAdd) const; 163 164 private: 165 /// @brief Invalidated copy constructor. 166 MSMeanData_Harmonoise(const MSMeanData_Harmonoise&); 167 168 /// @brief Invalidated assignment operator. 169 MSMeanData_Harmonoise& operator=(const MSMeanData_Harmonoise&); 170 171 }; 172 173 174 #endif 175 176 /****************************************************************************/ 177 178