68 const std::string
id = d->
getID();
70 throw ProcessError(
toString(type) +
" detector '" +
id +
"' could not be built (declared twice?).");
79 const std::string
id = d->
getID();
81 throw ProcessError(
toString(type) +
" detector '" +
id +
"' could not be built (declared twice?).");
98const std::vector<SumoXMLTag>
100 std::vector<SumoXMLTag> result;
102 result.push_back(i->first);
121 j.second->detectorUpdate(step);
126 md->detectorUpdate(step);
140 for (DetectorFileVec::iterator it = dfVec.begin(); it != dfVec.end(); ++it) {
164 detAndFileVec.push_back(std::make_pair(det, device));
165 myIntervals.insert(std::make_pair(key, detAndFileVec));
167 if (begin < simBegin) {
168 SUMOTime divRest = (simBegin - begin) % interval;
169 lastCall = simBegin - divRest;
174 if (find_if(detAndFileVec.begin(), detAndFileVec.end(), [&](
const DetectorFilePair & pair) {
175 return pair.first == det;
176 }) == detAndFileVec.end()) {
177 detAndFileVec.push_back(std::make_pair(det, device));
180 WRITE_WARNING(
"MSDetectorControl::addDetectorAndInterval: detector already in container. Ignoring.");
191 j.second->clearState(step);
#define WRITE_WARNING(msg)
SUMOTime string2time(const std::string &r)
convert string to SUMOTime
SumoXMLTag
Numbers representing SUMO-XML - element names.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void writeOutput(SUMOTime step, bool closing)
Writes the output to be generated within the given time step.
std::pair< SUMOTime, SUMOTime > IntervalsKey
Definition of the interval key (interval, begin)
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.
void clearState(SUMOTime step)
Remove all vehicles before quick-loading state.
~MSDetectorControl()
Destructor.
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)
virtual void writeXMLDetectorProlog(OutputDevice &dev) const =0
Open the XML-output.
virtual void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)=0
Write the generated output to the given device.
static bool gHaveEmissions
Whether emission output of some type is needed (files or GUI)
Emission data collector for edges/lanes.
Data collector for edges/lanes.
void init()
Adds the value collectors to all relevant edges.
const std::string & getID() const
Returns the id.
A map of named object pointers.
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
static OptionsCont & getOptions()
Retrieves the options.
Static storage of an output device and its base (abstract) implementation.
static OutputDevice & getDevice(const std::string &name, bool usePrefix=true)
Returns the described OutputDevice.