![]() |
Eclipse SUMO - Simulation of Urban MObility
|
Detectors container; responsible for string and output generation. More...
#include <MSDetectorControl.h>
Data Structures | |
struct | detectorEquals |
Returns true if detectors are equal. More... | |
Public Member Functions | |
void | add (SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime splInterval, SUMOTime begin=-1) |
Adds a detector/output combination into the containers. More... | |
void | add (SumoXMLTag type, MSDetectorFileOutput *d) |
Adds only the detector into the containers. More... | |
void | add (MSMeanData *mn, const std::string &device, SUMOTime frequency, SUMOTime begin) |
Adds a mean data object. More... | |
void | addDetectorAndInterval (MSDetectorFileOutput *det, OutputDevice *device, SUMOTime interval, SUMOTime begin=-1) |
Adds one of the detectors as a new MSDetectorFileOutput. More... | |
void | close (SUMOTime step) |
Closes the detector outputs. More... | |
const std::vector< SumoXMLTag > | getAvailableTypes () const |
Returns the list of available detector types. More... | |
const NamedObjectCont< MSDetectorFileOutput * > & | getTypedDetectors (SumoXMLTag type) const |
Returns the list of detectors of the given type. More... | |
MSDetectorControl () | |
Constructor. More... | |
void | updateDetectors (const SUMOTime step) |
Computes detector values. More... | |
void | writeOutput (SUMOTime step, bool closing) |
Writes the output to be generated within the given time step. More... | |
~MSDetectorControl () | |
Destructor. More... | |
Protected Types | |
Structures needed for assigning detectors to intervals | |
typedef std::pair< MSDetectorFileOutput *, OutputDevice *> | DetectorFilePair |
A pair of a Detector with it's associated file-stream. More... | |
typedef std::vector< DetectorFilePair > | DetectorFileVec |
Container holding DetectorFilePair (with the same interval). More... | |
typedef std::pair< SUMOTime, SUMOTime > | IntervalsKey |
Definition of the interval key. More... | |
typedef std::map< IntervalsKey, DetectorFileVec > | Intervals |
Association of intervals to DetectorFilePair containers. More... | |
Protected Attributes | |
std::map< SumoXMLTag, NamedObjectCont< MSDetectorFileOutput * > > | myDetectors |
The detectors map, first by detector type, then using NamedObjectCont (. More... | |
NamedObjectCont< MSDetectorFileOutput * > | myEmptyContainer |
An empty container to return in getTypedDetectors() if no detectors of the asked type exist. More... | |
Intervals | myIntervals |
Map that hold DetectorFileVec for given intervals. More... | |
std::map< IntervalsKey, SUMOTime > | myLastCalls |
The map that holds the last call for each sample interval. More... | |
std::vector< MSMeanData * > | myMeanData |
List of harmonoise detectors. More... | |
Private Member Functions | |
MSDetectorControl (const MSDetectorControl &) | |
Invalidated copy constructor. More... | |
MSDetectorControl & | operator= (const MSDetectorControl &) |
Invalidated assignment operator. More... | |
Detectors container; responsible for string and output generation.
Definition at line 53 of file MSDetectorControl.h.
|
protected |
A pair of a Detector with it's associated file-stream.
Definition at line 186 of file MSDetectorControl.h.
|
protected |
Container holding DetectorFilePair (with the same interval).
Definition at line 189 of file MSDetectorControl.h.
|
protected |
Association of intervals to DetectorFilePair containers.
Definition at line 195 of file MSDetectorControl.h.
|
protected |
Definition of the interval key.
Definition at line 192 of file MSDetectorControl.h.
MSDetectorControl::MSDetectorControl | ( | ) |
Constructor.
Definition at line 40 of file MSDetectorControl.cpp.
MSDetectorControl::~MSDetectorControl | ( | ) |
Destructor.
Deletes all stored detectors.
Definition at line 44 of file MSDetectorControl.cpp.
References myDetectors, and myMeanData.
|
private |
Invalidated copy constructor.
void MSDetectorControl::add | ( | SumoXMLTag | type, |
MSDetectorFileOutput * | d, | ||
const std::string & | device, | ||
SUMOTime | splInterval, | ||
SUMOTime | begin = -1 |
||
) |
Adds a detector/output combination into the containers.
The detector is tried to be added into "myDetectors". If the detector is already known (the id was already used for a similar detector), a ProcessError is thrown.
Otherwise, the Detector2File-mechanism is instantiated for the detector.
Please note, that the detector control gets responsible for the detector.
[in] | type | The type of the detector |
[in] | d | The detector to add |
[in] | device | The device the detector uses |
[in] | splInterval | The sample interval of the detector |
ProcessError | If the detector is already known |
Definition at line 64 of file MSDetectorControl.cpp.
References addDetectorAndInterval(), OutputDevice::getDevice(), Named::getID(), myDetectors, and toString().
Referenced by add(), MSSOTLE2Sensors::buildContinueSensior(), MSSOTLE2Sensors::buildCountSensorForLane(), MSSOTLE2Sensors::buildCountSensorForOutLane(), NLDetectorBuilder::buildE2Detector(), NLDetectorBuilder::buildInductLoop(), NLDetectorBuilder::buildInstantInductLoop(), NLDetectorBuilder::buildRouteProbe(), MSSOTLE2Sensors::buildSensorForLane(), MSSOTLE2Sensors::buildSensorForOutLane(), NLDetectorBuilder::createEdgeLaneMeanData(), NLDetectorBuilder::endE3Detector(), MSDelayBasedTrafficLightLogic::init(), and MSActuatedTrafficLightLogic::init().
void MSDetectorControl::add | ( | SumoXMLTag | type, |
MSDetectorFileOutput * | d | ||
) |
Adds only the detector into the containers.
The detector is tried to be added into "myDetectors". If the detector is already known (the id was already used for a similar detector), a ProcessError is thrown.
Please note, that the detector control gets responsible for the detector.
[in] | type | The type of the detector |
[in] | d | The detector to add |
ProcessError | If the detector is already known |
Definition at line 74 of file MSDetectorControl.cpp.
References add(), Named::getID(), myDetectors, and toString().
void MSDetectorControl::add | ( | MSMeanData * | mn, |
const std::string & | device, | ||
SUMOTime | frequency, | ||
SUMOTime | begin | ||
) |
Adds a mean data object.
The detector is pushed into the internal list.
Please note, that the detector control gets responsible for the detector.
[in] | mn | The mean data to add |
[in] | device | The output device to use |
[in] | frequency | The frequency for output generation |
[in] | begin | The begin of the first interval |
Definition at line 83 of file MSDetectorControl.cpp.
References addDetectorAndInterval(), OutputDevice::getDevice(), OptionsCont::getOptions(), MSMeanData::init(), myMeanData, and string2time().
void MSDetectorControl::addDetectorAndInterval | ( | MSDetectorFileOutput * | det, |
OutputDevice * | device, | ||
SUMOTime | interval, | ||
SUMOTime | begin = -1 |
||
) |
Adds one of the detectors as a new MSDetectorFileOutput.
[in] | det | The generator to add |
[in] | device | The device to use |
[in] | interval | The sample interval to use |
[in] | begin | The start of the first sample interval to use |
Definition at line 144 of file MSDetectorControl.cpp.
References OptionsCont::getOptions(), myIntervals, myLastCalls, string2time(), WRITE_WARNING, and MSDetectorFileOutput::writeXMLDetectorProlog().
Referenced by add().
void MSDetectorControl::close | ( | SUMOTime | step | ) |
Closes the detector outputs.
Goes through the intervals to write and writes the last step using the current simulation time as end.
[in] | step | The time step (the simulation has ended at) |
Definition at line 55 of file MSDetectorControl.cpp.
References myIntervals, and writeOutput().
Referenced by MSNet::closeSimulation().
const std::vector< SumoXMLTag > MSDetectorControl::getAvailableTypes | ( | ) | const |
Returns the list of available detector types.
Definition at line 94 of file MSDetectorControl.cpp.
References myDetectors.
Referenced by GUINet::initGUIStructures().
const NamedObjectCont< MSDetectorFileOutput * > & MSDetectorControl::getTypedDetectors | ( | SumoXMLTag | type | ) | const |
Returns the list of detectors of the given type.
[in] | type | The type of detectors to be retrieved |
Definition at line 104 of file MSDetectorControl.cpp.
References myDetectors, and myEmptyContainer.
Referenced by libsumo::MultiEntryExit::getDetector(), libsumo::LaneArea::getDetector(), libsumo::InductionLoop::getDetector(), libsumo::LaneArea::getIDCount(), libsumo::MultiEntryExit::getIDCount(), libsumo::InductionLoop::getIDCount(), libsumo::LaneArea::getIDList(), libsumo::MultiEntryExit::getIDList(), libsumo::InductionLoop::getIDList(), GUINet::initGUIStructures(), NLTriggerBuilder::parseAndBuildCalibrator(), and updateDetectors().
|
private |
Invalidated assignment operator.
void MSDetectorControl::updateDetectors | ( | const SUMOTime | step | ) |
Computes detector values.
Some detectors need to be touched each time step in order to compute values from the vehicles stored in their containers. This method goes through all of these detectors and forces a recomputation of the values.
[in] | step | The current time step |
Definition at line 113 of file MSDetectorControl.cpp.
References getTypedDetectors(), myDetectors, and myMeanData.
Referenced by MSNet::writeOutput().
void MSDetectorControl::writeOutput | ( | SUMOTime | step, |
bool | closing | ||
) |
Writes the output to be generated within the given time step.
Goes through the list of intervals. If one interval has ended within the given step or if the closing-flag is set and the output was not written in this step already, the writeXMLOutput method is called for all MSDetectorFileOutputs within this interval.
[in] | step | The current time step |
[in] | closing | Whether the device is closed |
IOError | If an error on writing occurs (!!! not yet implemented) |
Definition at line 126 of file MSDetectorControl.cpp.
References myIntervals, myLastCalls, and MSDetectorFileOutput::writeXMLOutput().
Referenced by close(), and MSNet::writeOutput().
|
protected |
The detectors map, first by detector type, then using NamedObjectCont (.
Definition at line 218 of file MSDetectorControl.h.
Referenced by add(), getAvailableTypes(), getTypedDetectors(), updateDetectors(), and ~MSDetectorControl().
|
protected |
An empty container to return in getTypedDetectors() if no detectors of the asked type exist.
Definition at line 231 of file MSDetectorControl.h.
Referenced by getTypedDetectors().
|
protected |
Map that hold DetectorFileVec for given intervals.
Definition at line 222 of file MSDetectorControl.h.
Referenced by addDetectorAndInterval(), close(), and writeOutput().
|
protected |
The map that holds the last call for each sample interval.
Definition at line 225 of file MSDetectorControl.h.
Referenced by addDetectorAndInterval(), and writeOutput().
|
protected |
List of harmonoise detectors.
Definition at line 228 of file MSDetectorControl.h.
Referenced by add(), updateDetectors(), and ~MSDetectorControl().