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, OutputDevice &device, int splInterval, SUMOTime begin=-1) throw (ProcessError)
 Adds a detector/output combination into the containers.
void add (SumoXMLTag type, MSDetectorFileOutput *d) throw (ProcessError)
 Adds only the detector into the containers.
void add (MSMeanData *mn, OutputDevice &device, SUMOTime frequency, SUMOTime begin) throw ()
 Adds a mean data object.
void addDetectorAndInterval (MSDetectorFileOutput *det, OutputDevice *device, SUMOTime interval, SUMOTime begin=-1) throw ()
 Adds one of the detectors as a new MSDetectorFileOutput.
void close (SUMOTime step)
 Closes the detector outputs.
const NamedObjectCont
< MSDetectorFileOutput * > & 
getTypedDetectors (SumoXMLTag type) const throw ()
 Returns the list of detectors of the given type.
 MSDetectorControl () throw ()
 Constructor.
void updateDetectors (const SUMOTime step) throw ()
 Computes detector values.
void writeOutput (SUMOTime step, bool closing) throw (IOError)
 Writes the output to be generated within the given time step.
 ~MSDetectorControl () throw ()
 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
< DetectorFilePair > 
DetectorFileVec
 Container holding DetectorFilePair (with the same interval).
typedef std::pair< SUMOTime,
SUMOTime > 
IntervalsKey
 Definition of the interval key.
typedef std::map< IntervalsKey,
DetectorFileVec > 
Intervals
 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, SUMOTime > myLastCalls
 The map that holds the last call for each sample interval.
std::vector< MSMeanData * > myMeanData
 List of harmonoise detectors.

Private Member Functions

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

Friends

class GUINet

Detailed Description

Detectors container; responsible for string and output generation.

Definition at line 60 of file MSDetectorControl.h.


Member Typedef Documentation

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

Definition at line 191 of file MSDetectorControl.h.

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

Container holding DetectorFilePair (with the same interval).

Definition at line 194 of file MSDetectorControl.h.

typedef std::map< IntervalsKey, DetectorFileVec > MSDetectorControl::Intervals [protected]

Association of intervals to DetectorFilePair containers.

Definition at line 200 of file MSDetectorControl.h.

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

Definition of the interval key.

Definition at line 197 of file MSDetectorControl.h.


Constructor & Destructor Documentation

MSDetectorControl::MSDetectorControl ( ) throw ()

Constructor.

Definition at line 49 of file MSDetectorControl.cpp.

MSDetectorControl::~MSDetectorControl ( ) throw ()

Destructor.

Deletes all stored detectors.

Definition at line 53 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,
OutputDevice &  device,
int  splInterval,
SUMOTime  begin = -1 
) throw (ProcessError)

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

References NamedObjectCont< T >::add(), and toString().

Referenced by NLDetectorBuilder::buildE2Detector(), NLDetectorBuilder::buildInductLoop(), NLDetectorBuilder::buildInstantInductLoop(), NLDetectorBuilder::buildRouteProbe(), NLDetectorBuilder::createEdgeLaneMeanData(), and NLDetectorBuilder::endE3Detector().

void MSDetectorControl::add ( MSMeanData *  mn,
OutputDevice &  device,
SUMOTime  frequency,
SUMOTime  begin 
) throw ()

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

References OptionsCont::getOptions(), and string2time().

void MSDetectorControl::add ( SumoXMLTag  type,
MSDetectorFileOutput *  d 
) throw (ProcessError)

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

References NamedObjectCont< T >::add(), and toString().

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

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

References OptionsCont::getOptions(), string2time(), and WRITE_WARNING.

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

References myIntervals, and writeOutput().

Referenced by MSNet::closeSimulation().

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

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

Referenced by GUINet::initGUIStructures(), TraCIServerAPI_MeMeDetector::processGet(), and TraCIServerAPI_InductionLoop::processGet().

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

Invalidated assignment operator.

void MSDetectorControl::updateDetectors ( const SUMOTime  step) throw ()

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

Referenced by MSNet::writeOutput().

void MSDetectorControl::writeOutput ( SUMOTime  step,
bool  closing 
) throw (IOError)

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

References MSDetectorFileOutput::writeXMLOutput().

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


Friends And Related Function Documentation

friend class GUINet [friend]

Definition at line 63 of file MSDetectorControl.h.


Field Documentation

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

See also:
NamedObjectCont)

Definition at line 223 of file MSDetectorControl.h.

Referenced by GUINet::initGUIStructures(), and ~MSDetectorControl().

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

Definition at line 236 of file MSDetectorControl.h.

Map that hold DetectorFileVec for given intervals.

Definition at line 227 of file MSDetectorControl.h.

Referenced by close().

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

Definition at line 230 of file MSDetectorControl.h.

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

List of harmonoise detectors.

Definition at line 233 of file MSDetectorControl.h.

Referenced by ~MSDetectorControl().


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines