Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MSDetectorControl Class Reference

Detectors container; responsible for string and output generation. More...

#include <MSDetectorControl.h>

Collaboration diagram for MSDetectorControl:
[legend]

Public Member Functions

void add (MSMeanData *mn, const std::string &device, SUMOTime frequency, SUMOTime begin)
 Adds a mean data object.
 
void add (SumoXMLTag type, MSDetectorFileOutput *d)
 Adds only the detector into the containers.
 
void add (SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime interval, SUMOTime begin=-1)
 Adds a detector/output combination into the containers.
 
void addDetectorAndInterval (MSDetectorFileOutput *det, OutputDevice *device, SUMOTime interval, SUMOTime begin=-1)
 Adds one of the detectors as a new MSDetectorFileOutput.
 
void clearState (SUMOTime step)
 Remove all vehicles before quick-loading state.
 
void close (SUMOTime step)
 Closes the detector outputs.
 
const std::vector< SumoXMLTaggetAvailableTypes () const
 Returns the list of available detector types.
 
const std::map< std::string, std::vector< MSMeanData * > > & getMeanData () const
 
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors (SumoXMLTag type) const
 Returns the list of detectors of the given type.
 
 MSDetectorControl ()
 Constructor.
 
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.
 
 ~MSDetectorControl ()
 Destructor.
 

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.
 
typedef std::vector< DetectorFilePairDetectorFileVec
 Container holding DetectorFilePair (with the same interval).
 
typedef std::pair< SUMOTime, SUMOTimeIntervalsKey
 Definition of the interval key (interval, begin)
 
typedef std::map< IntervalsKey, DetectorFileVecIntervals
 Association of intervals to DetectorFilePair containers.
 

Protected Attributes

std::map< SumoXMLTag, NamedObjectCont< MSDetectorFileOutput * > > myDetectors
 The detectors map, first by detector type, then using NamedObjectCont (.
 
NamedObjectCont< MSDetectorFileOutput * > myEmptyContainer
 An empty container to return in getTypedDetectors() if no detectors of the asked type exist.
 
Intervals myIntervals
 Map that hold DetectorFileVec for given intervals.
 
std::map< IntervalsKey, SUMOTimemyLastCalls
 The map that holds the last call for each sample interval.
 
std::map< std::string, std::vector< MSMeanData * > > myMeanData
 List of meanData detectors.
 

Private Member Functions

 MSDetectorControl (const MSDetectorControl &)
 Invalidated copy constructor.
 
MSDetectorControloperator= (const MSDetectorControl &)
 Invalidated assignment operator.
 

Detailed Description

Detectors container; responsible for string and output generation.

Definition at line 50 of file MSDetectorControl.h.

Member Typedef Documentation

◆ DetectorFilePair

A pair of a Detector with it's associated file-stream.

Definition at line 188 of file MSDetectorControl.h.

◆ DetectorFileVec

typedef std::vector< DetectorFilePair > MSDetectorControl::DetectorFileVec
protected

Container holding DetectorFilePair (with the same interval).

Definition at line 191 of file MSDetectorControl.h.

◆ Intervals

Association of intervals to DetectorFilePair containers.

Definition at line 197 of file MSDetectorControl.h.

◆ IntervalsKey

typedef std::pair<SUMOTime, SUMOTime> MSDetectorControl::IntervalsKey
protected

Definition of the interval key (interval, begin)

Definition at line 194 of file MSDetectorControl.h.

Constructor & Destructor Documentation

◆ MSDetectorControl() [1/2]

MSDetectorControl::MSDetectorControl ( )

Constructor.

Definition at line 39 of file MSDetectorControl.cpp.

◆ ~MSDetectorControl()

MSDetectorControl::~MSDetectorControl ( )

Destructor.

Deletes all stored detectors.

Definition at line 43 of file MSDetectorControl.cpp.

References myDetectors, and myMeanData.

◆ MSDetectorControl() [2/2]

MSDetectorControl::MSDetectorControl ( const MSDetectorControl )
private

Invalidated copy constructor.

Member Function Documentation

◆ add() [1/3]

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.

Parameters
[in]mnThe mean data to add
[in]deviceThe output device to use
[in]frequencyThe frequency for output generation
[in]beginThe begin of the first interval

Definition at line 87 of file MSDetectorControl.cpp.

References addDetectorAndInterval(), OutputDevice::getDevice(), Named::getID(), OptionsCont::getOptions(), MSGlobals::gHaveEmissions, MSMeanData::init(), myMeanData, and string2time().

◆ add() [2/3]

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.

Parameters
[in]typeThe type of the detector
[in]dThe detector to add
Exceptions
ProcessErrorIf the detector is already known

Definition at line 77 of file MSDetectorControl.cpp.

References add(), Named::getID(), myDetectors, and toString().

◆ add() [3/3]

void MSDetectorControl::add ( SumoXMLTag  type,
MSDetectorFileOutput d,
const std::string &  device,
SUMOTime  interval,
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.

Parameters
[in]typeThe type of the detector
[in]dThe detector to add
[in]deviceThe device the detector uses
[in]intervalThe sample interval of the detector
Exceptions
ProcessErrorIf the detector is already known

Definition at line 66 of file MSDetectorControl.cpp.

References add(), addDetectorAndInterval(), OutputDevice::getDevice(), Named::getID(), myDetectors, and toString().

Referenced by add(), add(), MSSOTLE2Sensors::buildContinueSensior(), MSSOTLE2Sensors::buildCountSensorForLane(), MSSOTLE2Sensors::buildCountSensorForOutLane(), NLDetectorBuilder::buildE2Detector(), NLDetectorBuilder::buildE2Detector(), NLDetectorBuilder::buildInductLoop(), NLDetectorBuilder::buildInstantInductLoop(), NLDetectorBuilder::buildRouteProbe(), MSSOTLE2Sensors::buildSensorForLane(), MSSOTLE2Sensors::buildSensorForOutLane(), NLDetectorBuilder::createEdgeLaneMeanData(), NLDetectorBuilder::endE3Detector(), MSActuatedTrafficLightLogic::init(), and MSDelayBasedTrafficLightLogic::init().

Here is the caller graph for this function:

◆ addDetectorAndInterval()

void MSDetectorControl::addDetectorAndInterval ( MSDetectorFileOutput det,
OutputDevice device,
SUMOTime  interval,
SUMOTime  begin = -1 
)

Adds one of the detectors as a new MSDetectorFileOutput.

Parameters
[in]detThe generator to add
[in]deviceThe device to use
[in]intervalThe sample interval to use
[in]beginThe start of the first sample interval to use

Definition at line 151 of file MSDetectorControl.cpp.

References OptionsCont::getOptions(), myIntervals, myLastCalls, string2time(), WRITE_WARNING, and MSDetectorFileOutput::writeXMLDetectorProlog().

Referenced by add(), and add().

Here is the caller graph for this function:

◆ clearState()

void MSDetectorControl::clearState ( SUMOTime  step)

Remove all vehicles before quick-loading state.

Definition at line 188 of file MSDetectorControl.cpp.

References getTypedDetectors(), and myDetectors.

Referenced by MSNet::clearState().

Here is the caller graph for this function:

◆ close()

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.

Parameters
[in]stepThe time step (the simulation has ended at)

Definition at line 57 of file MSDetectorControl.cpp.

References myIntervals, and writeOutput().

Referenced by MSNet::closeSimulation(), and GUINet::flushOutputsAtEnd().

Here is the caller graph for this function:

◆ getAvailableTypes()

const std::vector< SumoXMLTag > MSDetectorControl::getAvailableTypes ( ) const

Returns the list of available detector types.

Returns
The list of types

Definition at line 99 of file MSDetectorControl.cpp.

References NamedObjectCont< T >::begin(), and myDetectors.

Referenced by GUINet::initGUIStructures().

Here is the caller graph for this function:

◆ getMeanData()

const std::map< std::string, std::vector< MSMeanData * > > & MSDetectorControl::getMeanData ( ) const
inline

Definition at line 152 of file MSDetectorControl.h.

References myMeanData.

Referenced by GUINet::getMeanData(), LIBSUMO_NAMESPACE::MeanData::getMeanData(), GUINet::getMeanDataAttrs(), and GUINet::getMeanDataIDs().

Here is the caller graph for this function:

◆ getTypedDetectors()

const NamedObjectCont< MSDetectorFileOutput * > & MSDetectorControl::getTypedDetectors ( SumoXMLTag  type) const

Returns the list of detectors of the given type.

Parameters
[in]typeThe type of detectors to be retrieved
Returns
The container of detectors

Definition at line 109 of file MSDetectorControl.cpp.

References myDetectors, and myEmptyContainer.

Referenced by clearState(), LIBSUMO_NAMESPACE::LaneArea::getDetector(), LIBSUMO_NAMESPACE::MultiEntryExit::getDetector(), LIBSUMO_NAMESPACE::InductionLoop::getDetector(), LIBSUMO_NAMESPACE::InductionLoop::getMEDetector(), LIBSUMO_NAMESPACE::RouteProbe::getRouteProbe(), LIBSUMO_NAMESPACE::InductionLoop::getTree(), MSActuatedTrafficLightLogic::init(), MSDelayBasedTrafficLightLogic::init(), NEMALogic::init(), GUINet::initGUIStructures(), NLTriggerBuilder::parseAndBuildCalibrator(), MSActuatedTrafficLightLogic::retrieveDetExpression(), and updateDetectors().

Here is the caller graph for this function:

◆ operator=()

MSDetectorControl & MSDetectorControl::operator= ( const MSDetectorControl )
private

Invalidated assignment operator.

◆ updateDetectors()

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.

Parameters
[in]stepThe current time step

Definition at line 118 of file MSDetectorControl.cpp.

References getTypedDetectors(), myDetectors, and myMeanData.

Referenced by MSNet::clearState(), and MSNet::writeOutput().

Here is the caller graph for this function:

◆ 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.

Parameters
[in]stepThe current time step
[in]closingWhether the device is closed
Exceptions
IOErrorIf an error on writing occurs (!!! not yet implemented)

Definition at line 133 of file MSDetectorControl.cpp.

References myIntervals, myLastCalls, and MSDetectorFileOutput::writeXMLOutput().

Referenced by MSNet::clearState(), close(), and MSNet::writeOutput().

Here is the caller graph for this function:

Field Documentation

◆ myDetectors

std::map<SumoXMLTag, NamedObjectCont< MSDetectorFileOutput*> > MSDetectorControl::myDetectors
protected

The detectors map, first by detector type, then using NamedObjectCont (.

See also
NamedObjectCont)

Definition at line 202 of file MSDetectorControl.h.

Referenced by add(), add(), clearState(), getAvailableTypes(), getTypedDetectors(), updateDetectors(), and ~MSDetectorControl().

◆ myEmptyContainer

NamedObjectCont< MSDetectorFileOutput*> MSDetectorControl::myEmptyContainer
protected

An empty container to return in getTypedDetectors() if no detectors of the asked type exist.

Definition at line 214 of file MSDetectorControl.h.

Referenced by getTypedDetectors().

◆ myIntervals

Intervals MSDetectorControl::myIntervals
protected

Map that hold DetectorFileVec for given intervals.

Definition at line 205 of file MSDetectorControl.h.

Referenced by addDetectorAndInterval(), close(), and writeOutput().

◆ myLastCalls

std::map<IntervalsKey, SUMOTime> MSDetectorControl::myLastCalls
protected

The map that holds the last call for each sample interval.

Definition at line 208 of file MSDetectorControl.h.

Referenced by addDetectorAndInterval(), and writeOutput().

◆ myMeanData

std::map<std::string, std::vector<MSMeanData*> > MSDetectorControl::myMeanData
protected

List of meanData detectors.

Definition at line 211 of file MSDetectorControl.h.

Referenced by add(), getMeanData(), updateDetectors(), and ~MSDetectorControl().


The documentation for this class was generated from the following files: