SUMO - Simulation of Urban MObility
MSDetectorControl Class Reference

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, int 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< SumoXMLTaggetAvailableTypes () 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< DetectorFilePairDetectorFileVec
 Container holding DetectorFilePair (with the same interval). More...
 
typedef std::pair< SUMOTime, SUMOTimeIntervalsKey
 Definition of the interval key. More...
 
typedef std::map< IntervalsKey, DetectorFileVecIntervals
 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, SUMOTimemyLastCalls
 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...
 
MSDetectorControloperator= (const MSDetectorControl &)
 Invalidated assignment operator. More...
 

Detailed Description

Detectors container; responsible for string and output generation.

Definition at line 65 of file MSDetectorControl.h.

Member Typedef Documentation

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

Definition at line 198 of file MSDetectorControl.h.

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

Container holding DetectorFilePair (with the same interval).

Definition at line 201 of file MSDetectorControl.h.

Association of intervals to DetectorFilePair containers.

Definition at line 207 of file MSDetectorControl.h.

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

Definition of the interval key.

Definition at line 204 of file MSDetectorControl.h.

Constructor & Destructor Documentation

MSDetectorControl::MSDetectorControl ( )

Constructor.

Definition at line 55 of file MSDetectorControl.cpp.

MSDetectorControl::~MSDetectorControl ( )

Destructor.

Deletes all stored detectors.

Definition at line 59 of file MSDetectorControl.cpp.

References myDetectors, and myMeanData.

MSDetectorControl::MSDetectorControl ( const MSDetectorControl )
private

Invalidated copy constructor.

Member Function Documentation

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

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

Definition at line 79 of file MSDetectorControl.cpp.

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

Referenced by add(), NLDetectorBuilder::buildE2Detector(), NLDetectorBuilder::buildInductLoop(), NLDetectorBuilder::buildInstantInductLoop(), NLDetectorBuilder::buildRouteProbe(), NLDetectorBuilder::createEdgeLaneMeanData(), NLDetectorBuilder::endE3Detector(), 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.

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

Definition at line 89 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.

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

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

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

Definition at line 70 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.

Returns
The list of types

Definition at line 109 of file MSDetectorControl.cpp.

References myDetectors.

Referenced by GUINet::initGUIStructures().

const NamedObjectCont< MSDetectorFileOutput * > & MSDetectorControl::getTypedDetectors ( SumoXMLTag  type) const
MSDetectorControl& MSDetectorControl::operator= ( const MSDetectorControl )
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.

Parameters
[in]stepThe current time step

Definition at line 128 of file MSDetectorControl.cpp.

References NamedObjectCont< T >::getMyMap(), 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.

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 142 of file MSDetectorControl.cpp.

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

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

Field Documentation

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

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

See also
NamedObjectCont)

Definition at line 230 of file MSDetectorControl.h.

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

NamedObjectCont< MSDetectorFileOutput*> MSDetectorControl::myEmptyContainer
protected

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

Definition at line 243 of file MSDetectorControl.h.

Referenced by getTypedDetectors().

Intervals MSDetectorControl::myIntervals
protected

Map that hold DetectorFileVec for given intervals.

Definition at line 234 of file MSDetectorControl.h.

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

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

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

Definition at line 237 of file MSDetectorControl.h.

Referenced by addDetectorAndInterval(), and writeOutput().

std::vector<MSMeanData*> MSDetectorControl::myMeanData
protected

List of harmonoise detectors.

Definition at line 240 of file MSDetectorControl.h.

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


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