SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MSDetectorControl.h
Go to the documentation of this file.
1 /****************************************************************************/
11 // Detectors container; responsible for string and output generation
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 #ifndef MSDetectorControl_h
25 #define MSDetectorControl_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <string>
38 #include <vector>
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class MSMeanData;
52 
53 
54 // ===========================================================================
55 // class definitions
56 // ===========================================================================
62 public:
66 
67 
73 
74 
82  void close(SUMOTime step);
83 
84 
101  void add(SumoXMLTag type, MSDetectorFileOutput* d, const std::string& device, SUMOTime splInterval, SUMOTime begin = -1);
102 
103 
104 
117  void add(SumoXMLTag type, MSDetectorFileOutput* d);
118 
119 
131  void add(MSMeanData* mn, const std::string& device,
132  SUMOTime frequency, SUMOTime begin);
133 
134 
135 
144  OutputDevice* device,
145  SUMOTime interval, SUMOTime begin = -1);
146 
147 
148 
153  const std::vector<SumoXMLTag> getAvailableTypes() const;
154 
155 
162 
163 
172  void updateDetectors(const SUMOTime step);
173 
174 
186  void writeOutput(SUMOTime step, bool closing);
187 
188 
189 protected:
192 
194  typedef std::pair< MSDetectorFileOutput*, OutputDevice* > DetectorFilePair;
195 
197  typedef std::vector< DetectorFilePair > DetectorFileVec;
198 
200  typedef std::pair<SUMOTime, SUMOTime> IntervalsKey;
201 
203  typedef std::map< IntervalsKey, DetectorFileVec > Intervals;
205 
217  struct detectorEquals : public std::binary_function< DetectorFilePair, MSDetectorFileOutput*, bool > {
219  bool operator()(const DetectorFilePair& pair, const MSDetectorFileOutput* det) const {
220  return pair.first == det;
221  }
222  };
223 
224 protected:
226  std::map<SumoXMLTag, NamedObjectCont< MSDetectorFileOutput*> > myDetectors;
227 
228 
230  Intervals myIntervals;
231 
233  std::map<IntervalsKey, SUMOTime> myLastCalls;
234 
236  std::vector<MSMeanData*> myMeanData;
237 
240 
241 
242 private:
245 
248 
249 
250 };
251 
252 
253 #endif
254 
255 /****************************************************************************/
256 
std::vector< DetectorFilePair > DetectorFileVec
Container holding DetectorFilePair (with the same interval).
std::pair< MSDetectorFileOutput *, OutputDevice * > DetectorFilePair
A pair of a Detector with it's associated file-stream.
Data collector for edges/lanes.
Definition: MSMeanData.h:67
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::vector< MSMeanData * > myMeanData
List of harmonoise detectors.
long long int SUMOTime
Definition: SUMOTime.h:43
std::map< IntervalsKey, SUMOTime > myLastCalls
The map that holds the last call for each sample interval.
void updateDetectors(const SUMOTime step)
Computes detector values.
void writeOutput(SUMOTime step, bool closing)
Writes the output to be generated within the given time step.
Detectors container; responsible for string and output generation.
Returns true if detectors are equal.
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
NamedObjectCont< MSDetectorFileOutput * > myEmptyContainer
An empty container to return in getTypedDetectors() if no detectors of the asked type exist...
void add(SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime splInterval, SUMOTime begin=-1)
Adds a detector/output combination into the containers.
MSDetectorControl & operator=(const MSDetectorControl &)
Invalidated assignment operator.
std::map< IntervalsKey, DetectorFileVec > Intervals
Association of intervals to DetectorFilePair containers.
std::pair< SUMOTime, SUMOTime > IntervalsKey
Definition of the interval key.
bool operator()(const DetectorFilePair &pair, const MSDetectorFileOutput *det) const
Returns true if detectors are equal.
std::map< SumoXMLTag, NamedObjectCont< MSDetectorFileOutput * > > myDetectors
The detectors map, first by detector type, then using NamedObjectCont (.
const std::vector< SumoXMLTag > getAvailableTypes() const
Returns the list of available detector types.
void close(SUMOTime step)
Closes the detector outputs.
~MSDetectorControl()
Destructor.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
MSDetectorControl()
Constructor.
Intervals myIntervals
Map that hold DetectorFileVec for given intervals.
void addDetectorAndInterval(MSDetectorFileOutput *det, OutputDevice *device, SUMOTime interval, SUMOTime begin=-1)
Adds one of the detectors as a new MSDetectorFileOutput.
Base of value-generating classes (detectors)