Eclipse SUMO - Simulation of Urban MObility
MSDetectorControl.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-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 /****************************************************************************/
18 // Detectors container; responsible for string and output generation
19 /****************************************************************************/
20 #ifndef MSDetectorControl_h
21 #define MSDetectorControl_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <vector>
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class MSMeanData;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
53 public:
57 
58 
64 
65 
73  void close(SUMOTime step);
74 
75 
92  void add(SumoXMLTag type, MSDetectorFileOutput* d, const std::string& device, SUMOTime splInterval, SUMOTime begin = -1);
93 
94 
95 
108  void add(SumoXMLTag type, MSDetectorFileOutput* d);
109 
110 
122  void add(MSMeanData* mn, const std::string& device,
123  SUMOTime frequency, SUMOTime begin);
124 
125 
126 
135  OutputDevice* device,
136  SUMOTime interval, SUMOTime begin = -1);
137 
138 
139 
144  const std::vector<SumoXMLTag> getAvailableTypes() const;
145 
146 
153 
154 
163  void updateDetectors(const SUMOTime step);
164 
165 
177  void writeOutput(SUMOTime step, bool closing);
178 
179 
180 protected:
183 
185  typedef std::pair< MSDetectorFileOutput*, OutputDevice* > DetectorFilePair;
186 
188  typedef std::vector< DetectorFilePair > DetectorFileVec;
189 
191  typedef std::pair<SUMOTime, SUMOTime> IntervalsKey;
192 
194  typedef std::map< IntervalsKey, DetectorFileVec > Intervals;
196 
208  struct detectorEquals : public std::binary_function< DetectorFilePair, MSDetectorFileOutput*, bool > {
210  bool operator()(const DetectorFilePair& pair, const MSDetectorFileOutput* det) const {
211  return pair.first == det;
212  }
213  };
214 
215 protected:
217  std::map<SumoXMLTag, NamedObjectCont< MSDetectorFileOutput*> > myDetectors;
218 
219 
222 
224  std::map<IntervalsKey, SUMOTime> myLastCalls;
225 
227  std::vector<MSMeanData*> myMeanData;
228 
231 
232 
233 private:
236 
239 
240 
241 };
242 
243 
244 #endif
245 
246 /****************************************************************************/
247 
MSDetectorControl::MSDetectorControl
MSDetectorControl(const MSDetectorControl &)
Invalidated copy constructor.
MSDetectorControl::Intervals
std::map< IntervalsKey, DetectorFileVec > Intervals
Association of intervals to DetectorFilePair containers.
Definition: MSDetectorControl.h:194
MSDetectorFileOutput
Base of value-generating classes (detectors)
Definition: MSDetectorFileOutput.h:63
MSDetectorControl::operator=
MSDetectorControl & operator=(const MSDetectorControl &)
Invalidated assignment operator.
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
MSDetectorControl
Detectors container; responsible for string and output generation.
Definition: MSDetectorControl.h:52
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSDetectorControl::MSDetectorControl
MSDetectorControl()
Constructor.
Definition: MSDetectorControl.cpp:39
MSDetectorControl::myEmptyContainer
NamedObjectCont< MSDetectorFileOutput * > myEmptyContainer
An empty container to return in getTypedDetectors() if no detectors of the asked type exist.
Definition: MSDetectorControl.h:230
MSDetectorControl::DetectorFileVec
std::vector< DetectorFilePair > DetectorFileVec
Container holding DetectorFilePair (with the same interval).
Definition: MSDetectorControl.h:188
MSDetectorControl::close
void close(SUMOTime step)
Closes the detector outputs.
Definition: MSDetectorControl.cpp:54
MSE2Collector.h
MSDetectorControl::detectorEquals
Returns true if detectors are equal.
Definition: MSDetectorControl.h:208
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:41
MSDetectorControl::getAvailableTypes
const std::vector< SumoXMLTag > getAvailableTypes() const
Returns the list of available detector types.
Definition: MSDetectorControl.cpp:93
MSDetectorControl::~MSDetectorControl
~MSDetectorControl()
Destructor.
Definition: MSDetectorControl.cpp:43
MSDetectorControl::writeOutput
void writeOutput(SUMOTime step, bool closing)
Writes the output to be generated within the given time step.
Definition: MSDetectorControl.cpp:125
MSMeanData
Data collector for edges/lanes.
Definition: MSMeanData.h:59
NamedObjectCont< MSDetectorFileOutput * >
MSDetectorControl::myLastCalls
std::map< IntervalsKey, SUMOTime > myLastCalls
The map that holds the last call for each sample interval.
Definition: MSDetectorControl.h:224
MSDetectorControl::getTypedDetectors
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
Definition: MSDetectorControl.cpp:103
MSDetectorControl::addDetectorAndInterval
void addDetectorAndInterval(MSDetectorFileOutput *det, OutputDevice *device, SUMOTime interval, SUMOTime begin=-1)
Adds one of the detectors as a new MSDetectorFileOutput.
Definition: MSDetectorControl.cpp:143
NamedObjectCont.h
MSDetectorControl::myIntervals
Intervals myIntervals
Map that hold DetectorFileVec for given intervals.
Definition: MSDetectorControl.h:221
MSDetectorControl::detectorEquals::operator()
bool operator()(const DetectorFilePair &pair, const MSDetectorFileOutput *det) const
Returns true if detectors are equal.
Definition: MSDetectorControl.h:210
MSRouteProbe.h
MSDetectorControl::DetectorFilePair
std::pair< MSDetectorFileOutput *, OutputDevice * > DetectorFilePair
A pair of a Detector with it's associated file-stream.
Definition: MSDetectorControl.h:185
MSDetectorControl::add
void add(SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime splInterval, SUMOTime begin=-1)
Adds a detector/output combination into the containers.
Definition: MSDetectorControl.cpp:63
config.h
MSDetectorControl::myDetectors
std::map< SumoXMLTag, NamedObjectCont< MSDetectorFileOutput * > > myDetectors
The detectors map, first by detector type, then using NamedObjectCont (.
Definition: MSDetectorControl.h:217
MSDetectorControl::IntervalsKey
std::pair< SUMOTime, SUMOTime > IntervalsKey
Definition of the interval key.
Definition: MSDetectorControl.h:191
MSInductLoop.h
MSDetectorControl::myMeanData
std::vector< MSMeanData * > myMeanData
List of harmonoise detectors.
Definition: MSDetectorControl.h:227
MSE3Collector.h
SUMOXMLDefinitions.h
MSDetectorControl::updateDetectors
void updateDetectors(const SUMOTime step)
Computes detector values.
Definition: MSDetectorControl.cpp:112