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 /****************************************************************************/
19 // Detectors container; responsible for string and output generation
20 /****************************************************************************/
21 #ifndef MSDetectorControl_h
22 #define MSDetectorControl_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
30 #include <string>
31 #include <vector>
38 
39 
40 // ===========================================================================
41 // class declarations
42 // ===========================================================================
43 class MSMeanData;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
54 public:
58 
59 
65 
66 
74  void close(SUMOTime step);
75 
76 
93  void add(SumoXMLTag type, MSDetectorFileOutput* d, const std::string& device, SUMOTime splInterval, SUMOTime begin = -1);
94 
95 
96 
109  void add(SumoXMLTag type, MSDetectorFileOutput* d);
110 
111 
123  void add(MSMeanData* mn, const std::string& device,
124  SUMOTime frequency, SUMOTime begin);
125 
126 
127 
136  OutputDevice* device,
137  SUMOTime interval, SUMOTime begin = -1);
138 
139 
140 
145  const std::vector<SumoXMLTag> getAvailableTypes() const;
146 
147 
154 
155 
164  void updateDetectors(const SUMOTime step);
165 
166 
178  void writeOutput(SUMOTime step, bool closing);
179 
180 
181 protected:
184 
186  typedef std::pair< MSDetectorFileOutput*, OutputDevice* > DetectorFilePair;
187 
189  typedef std::vector< DetectorFilePair > DetectorFileVec;
190 
192  typedef std::pair<SUMOTime, SUMOTime> IntervalsKey;
193 
195  typedef std::map< IntervalsKey, DetectorFileVec > Intervals;
197 
209  struct detectorEquals : public std::binary_function< DetectorFilePair, MSDetectorFileOutput*, bool > {
211  bool operator()(const DetectorFilePair& pair, const MSDetectorFileOutput* det) const {
212  return pair.first == det;
213  }
214  };
215 
216 protected:
218  std::map<SumoXMLTag, NamedObjectCont< MSDetectorFileOutput*> > myDetectors;
219 
220 
223 
225  std::map<IntervalsKey, SUMOTime> myLastCalls;
226 
228  std::vector<MSMeanData*> myMeanData;
229 
232 
233 
234 private:
237 
240 
241 
242 };
243 
244 
245 #endif
246 
247 /****************************************************************************/
248 
MSDetectorControl::Intervals
std::map< IntervalsKey, DetectorFileVec > Intervals
Association of intervals to DetectorFilePair containers.
Definition: MSDetectorControl.h:195
MSDetectorFileOutput
Base of value-generating classes (detectors)
Definition: MSDetectorFileOutput.h:64
MSDetectorControl::operator=
MSDetectorControl & operator=(const MSDetectorControl &)
Invalidated assignment operator.
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
MSDetectorControl
Detectors container; responsible for string and output generation.
Definition: MSDetectorControl.h:53
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MSDetectorControl::MSDetectorControl
MSDetectorControl()
Constructor.
Definition: MSDetectorControl.cpp:40
MSDetectorControl::myEmptyContainer
NamedObjectCont< MSDetectorFileOutput * > myEmptyContainer
An empty container to return in getTypedDetectors() if no detectors of the asked type exist.
Definition: MSDetectorControl.h:231
MSDetectorControl::DetectorFileVec
std::vector< DetectorFilePair > DetectorFileVec
Container holding DetectorFilePair (with the same interval).
Definition: MSDetectorControl.h:189
MSDetectorControl::close
void close(SUMOTime step)
Closes the detector outputs.
Definition: MSDetectorControl.cpp:55
MSE2Collector.h
MSDetectorControl::detectorEquals
Returns true if detectors are equal.
Definition: MSDetectorControl.h:209
SumoXMLTag
SumoXMLTag
Numbers representing SUMO-XML - element names.
Definition: SUMOXMLDefinitions.h:42
MSDetectorControl::getAvailableTypes
const std::vector< SumoXMLTag > getAvailableTypes() const
Returns the list of available detector types.
Definition: MSDetectorControl.cpp:94
MSDetectorControl::~MSDetectorControl
~MSDetectorControl()
Destructor.
Definition: MSDetectorControl.cpp:44
MSDetectorControl::writeOutput
void writeOutput(SUMOTime step, bool closing)
Writes the output to be generated within the given time step.
Definition: MSDetectorControl.cpp:126
MSMeanData
Data collector for edges/lanes.
Definition: MSMeanData.h:60
NamedObjectCont< MSDetectorFileOutput * >
MSDetectorControl::myLastCalls
std::map< IntervalsKey, SUMOTime > myLastCalls
The map that holds the last call for each sample interval.
Definition: MSDetectorControl.h:225
MSDetectorControl::getTypedDetectors
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
Definition: MSDetectorControl.cpp:104
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:144
NamedObjectCont.h
MSDetectorControl::myIntervals
Intervals myIntervals
Map that hold DetectorFileVec for given intervals.
Definition: MSDetectorControl.h:222
MSDetectorControl::detectorEquals::operator()
bool operator()(const DetectorFilePair &pair, const MSDetectorFileOutput *det) const
Returns true if detectors are equal.
Definition: MSDetectorControl.h:211
MSRouteProbe.h
MSDetectorControl::DetectorFilePair
std::pair< MSDetectorFileOutput *, OutputDevice * > DetectorFilePair
A pair of a Detector with it's associated file-stream.
Definition: MSDetectorControl.h:186
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:64
config.h
MSDetectorControl::myDetectors
std::map< SumoXMLTag, NamedObjectCont< MSDetectorFileOutput * > > myDetectors
The detectors map, first by detector type, then using NamedObjectCont (.
Definition: MSDetectorControl.h:218
MSDetectorControl::IntervalsKey
std::pair< SUMOTime, SUMOTime > IntervalsKey
Definition of the interval key.
Definition: MSDetectorControl.h:192
MSInductLoop.h
MSDetectorControl::myMeanData
std::vector< MSMeanData * > myMeanData
List of harmonoise detectors.
Definition: MSDetectorControl.h:228
MSE3Collector.h
SUMOXMLDefinitions.h
MSDetectorControl::updateDetectors
void updateDetectors(const SUMOTime step)
Computes detector values.
Definition: MSDetectorControl.cpp:113