Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDetectorControl.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
22// Detectors container; responsible for string and output generation
23/****************************************************************************/
24#pragma once
25#include <config.h>
26
27#include <string>
28#include <vector>
35
36
37// ===========================================================================
38// class declarations
39// ===========================================================================
40class MSMeanData;
41
42
43// ===========================================================================
44// class definitions
45// ===========================================================================
51public:
55
56
62
63
71 void close(SUMOTime step);
72
73
90 void add(SumoXMLTag type, MSDetectorFileOutput* d, const std::string& device, SUMOTime interval, SUMOTime begin = -1);
91
92
93
106 void add(SumoXMLTag type, MSDetectorFileOutput* d);
107
108
120 void add(MSMeanData* mn, const std::string& device,
121 SUMOTime frequency, SUMOTime begin);
122
123
124
133 OutputDevice* device,
134 SUMOTime interval, SUMOTime begin = -1);
135
136
137
142 const std::vector<SumoXMLTag> getAvailableTypes() const;
143
144
151
152 const std::map<std::string, std::vector<MSMeanData*> >& getMeanData() const {
153 return myMeanData;
154 }
155
164 void updateDetectors(const SUMOTime step);
165
166
178 void writeOutput(SUMOTime step, bool closing);
179
181 void clearState(SUMOTime step);
182
183protected:
186
188 typedef std::pair< MSDetectorFileOutput*, OutputDevice* > DetectorFilePair;
189
191 typedef std::vector< DetectorFilePair > DetectorFileVec;
192
194 typedef std::pair<SUMOTime, SUMOTime> IntervalsKey;
195
197 typedef std::map< IntervalsKey, DetectorFileVec > Intervals;
199
200protected:
202 std::map<SumoXMLTag, NamedObjectCont< MSDetectorFileOutput*> > myDetectors;
203
206
208 std::map<IntervalsKey, SUMOTime> myLastCalls;
209
211 std::map<std::string, std::vector<MSMeanData*> > myMeanData;
212
215
216
217private:
220
223
224
225};
long long int SUMOTime
Definition GUI.h:36
SumoXMLTag
Numbers representing SUMO-XML - element names.
Detectors container; responsible for string and output generation.
void writeOutput(SUMOTime step, bool closing)
Writes the output to be generated within the given time step.
MSDetectorControl(const MSDetectorControl &)
Invalidated copy constructor.
std::pair< SUMOTime, SUMOTime > IntervalsKey
Definition of the interval key (interval, begin)
std::map< IntervalsKey, DetectorFileVec > Intervals
Association of intervals to DetectorFilePair containers.
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
std::map< IntervalsKey, SUMOTime > myLastCalls
The map that holds the last call for each sample interval.
Intervals myIntervals
Map that hold DetectorFileVec for given intervals.
const std::map< std::string, std::vector< MSMeanData * > > & getMeanData() const
void clearState(SUMOTime step)
Remove all vehicles before quick-loading state.
~MSDetectorControl()
Destructor.
MSDetectorControl & operator=(const MSDetectorControl &)
Invalidated assignment operator.
void updateDetectors(const SUMOTime step)
Computes detector values.
void add(SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime interval, SUMOTime begin=-1)
Adds a detector/output combination into the containers.
std::vector< DetectorFilePair > DetectorFileVec
Container holding DetectorFilePair (with the same interval).
std::map< std::string, std::vector< MSMeanData * > > myMeanData
List of meanData detectors.
void close(SUMOTime step)
Closes the detector outputs.
const std::vector< SumoXMLTag > getAvailableTypes() const
Returns the list of available detector types.
MSDetectorControl()
Constructor.
std::pair< MSDetectorFileOutput *, OutputDevice * > DetectorFilePair
A pair of a Detector with it's associated file-stream.
NamedObjectCont< MSDetectorFileOutput * > myEmptyContainer
An empty container to return in getTypedDetectors() if no detectors of the asked type exist.
std::map< SumoXMLTag, NamedObjectCont< MSDetectorFileOutput * > > myDetectors
The detectors map, first by detector type, then using NamedObjectCont (.
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)
Data collector for edges/lanes.
Definition MSMeanData.h:57
A map of named object pointers.
Static storage of an output device and its base (abstract) implementation.