SUMO - Simulation of Urban MObility

MSMeanData Class Reference

Data collector for edges/lanes. More...

#include <MSMeanData.h>

Inheritance diagram for MSMeanData:
MSDetectorFileOutput Named MSMeanData_Harmonoise MSMeanData_HBEFA MSMeanData_Net

Data Structures

class  MeanDataValues
 Data structure for mean (aggregated) edge/lane values. More...
class  MeanDataValueTracker
 Data structure for mean (aggregated) edge/lane values for tracked vehicles. More...

Public Member Functions

virtual void detectorUpdate (const SUMOTime step) throw ()
 Updates the detector.
const std::string & getID () const
 Returns the id.
void init () throw ()
 Adds the value collectors to all relevant edges.
 MSMeanData (const std::string &id, const SUMOTime dumpBegin, const SUMOTime dumpEnd, const bool useLanes, const bool withEmpty, const bool withInternal, const bool trackVehicles, const SUMOReal minSamples, const SUMOReal maxTravelTime, const std::set< std::string > vTypes) throw ()
 Constructor.
void setID (const std::string &newID)
 resets the id
virtual ~MSMeanData () throw ()
 Destructor.
Methods inherited from MSDetectorFileOutput.
void writeXMLOutput (OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime) throw (IOError)
 Writes collected values into the given stream.
void writeXMLDetectorProlog (OutputDevice &dev) const throw (IOError)
 Opens the XML-output using "netstats" as root element.
Virtual methods to implement by derived classes
virtual void reset () throw ()
 Resets collected values.
virtual GUIDetectorWrapper * buildDetectorGUIRepresentation ()
 Builds the graphical representation.

Protected Member Functions

virtual
MSMeanData::MeanDataValues * 
createValues (MSLane *const lane, const SUMOReal length, const bool doAdd) const =0 throw (IOError)
 Create an instance of MeanDataValues.
void resetOnly (SUMOTime stopTime) throw ()
 Resets network value in order to allow processing of the next interval.
void writeEdge (OutputDevice &dev, const std::vector< MeanDataValues * > &edgeValues, MSEdge *edge, SUMOTime startTime, SUMOTime stopTime) throw (IOError)
 Writes edge values into the given stream.
bool writePrefix (OutputDevice &dev, const MeanDataValues &values, const std::string prefix) const throw (IOError)
 Checks for emptiness and writes prefix into the given stream.

Protected Attributes

std::string myID
 The name of the object.
const SUMOReal myMaxTravelTime
 the maximum travel time to write
std::vector< std::vector
< MeanDataValues * > > 
myMeasures
 Value collectors; sorted by edge, then by lane.
const SUMOReal myMinSamples
 the minimum sample seconds
const std::set< std::string > myVehicleTypes
 The vehicle types to look for (empty means all)

Private Member Functions

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

Private Attributes

const bool myAmEdgeBased
 Information whether the output shall be edge-based (not lane-based)
const SUMOTime myDumpBegin
 The first and the last time step to write information (-1 indicates always)
const bool myDumpEmpty
 Whether empty lanes/edges shall be written.
const SUMOTime myDumpEnd
const bool myDumpInternal
 Whether internal lanes/edges shall be written.
std::vector< MSEdge * > myEdges
 The corresponding first edges.
std::list< std::pair< SUMOTime,
SUMOTime > > 
myPendingIntervals
 The intervals for which output still has to be generated (only in the tracking case)
const bool myTrackVehicles
 Whether vehicles are tracked.

Detailed Description

Data collector for edges/lanes.

This structure does not contain the data itself, it is stored within MeanDataValues-MoveReminder objects. This class is used to build the output, optionally, in the case of edge-based dump, aggregated over the edge's lanes.

Todo:
consider error-handling on write (using IOError)

Definition at line 65 of file MSMeanData.h.


Constructor & Destructor Documentation

MSMeanData::MSMeanData ( const std::string &  id,
const SUMOTime  dumpBegin,
const SUMOTime  dumpEnd,
const bool  useLanes,
const bool  withEmpty,
const bool  withInternal,
const bool  trackVehicles,
const SUMOReal  minSamples,
const SUMOReal  maxTravelTime,
const std::set< std::string >  vTypes 
) throw ()

Constructor.

Parameters:
[in]idThe id of the detector
[in]dumpBeginBegin time of dump
[in]dumpEndEnd time of dump
[in]useLanesInformation whether lane-based or edge-based dump shall be generated
[in]withEmptyInformation whether empty lanes/edges shall be written
[in]withInternalInformation whether internal lanes/edges shall be written
[in]trackVehiclesInformation whether vehicles shall be tracked
[in]maxTravelTimethe maximum travel time to use when calculating per vehicle output
[in]minSamplesthe minimum number of sample seconds before the values are valid
[in]vTypesthe set of vehicle types to consider

Definition at line 236 of file MSMeanData.cpp.

MSMeanData::~MSMeanData ( ) throw () [virtual]

Destructor.

Definition at line 302 of file MSMeanData.cpp.

References myMeasures.

MSMeanData::MSMeanData ( const MSMeanData &  ) [private]

Invalidated copy constructor.


Member Function Documentation

virtual GUIDetectorWrapper* MSDetectorFileOutput::buildDetectorGUIRepresentation ( ) [inline, virtual, inherited]

Builds the graphical representation.

Meant to be overridden by grahical versions of the detectors

Returns:
A wrapper for the detector which performs the user I/O within the GUI

Reimplemented in GUI_E2_ZS_Collector, GUI_E2_ZS_CollectorOverLanes, GUIE3Collector, GUIInductLoop, and GUIInstantInductLoop.

Definition at line 117 of file MSDetectorFileOutput.h.

virtual MSMeanData::MeanDataValues* MSMeanData::createValues ( MSLane *const  lane,
const SUMOReal  length,
const bool  doAdd 
) const throw (IOError) [protected, pure virtual]

Create an instance of MeanDataValues.

Parameters:
[in]laneThe lane to create for
[in]doAddwhether to add the values as reminder to the lane

Implemented in MSMeanData_Harmonoise, MSMeanData_HBEFA, and MSMeanData_Net.

Referenced by init(), and writeEdge().

void MSMeanData::detectorUpdate ( const SUMOTime  step) throw () [virtual]

Updates the detector.

Reimplemented from MSDetectorFileOutput.

Reimplemented in MSMeanData_Harmonoise.

Definition at line 461 of file MSMeanData.cpp.

References DELTA_T, init(), and myDumpBegin.

const std::string& Named::getID ( ) const [inline, inherited]

Returns the id.

Returns:
The stored id

Reimplemented in MS_E2_ZS_CollectorOverLanes.

Definition at line 59 of file Named.h.

References Named::myID.

Referenced by RORouteDef_Alternatives::addAlternative(), MSNet::addBusStop(), NLHandler::addConnection(), NBLoadedSUMOTLDef::addConnection(), NIImporter_OpenDrive::addE2EConnectionsSecure(), NIImporter_SUMO::addPhase(), NBDistrict::addSink(), NBDistrict::addSource(), MSRouteHandler::addStop(), NIXMLTrafficLightsHandler::addTlConnection(), NIVissimDisturbance::addToNode(), MSVehicle::addTraciStop(), NIVisumTL::build(), RORouteDef_Complete::buildCurrentRoute(), NIImporter_VISUM::buildDistrictNode(), NIVissimConnection::buildEdgeConnections(), NBEdge::buildInnerEdges(), NIVissimEdge::buildNBEdge(), NBNodeCont::buildOffRamp(), NBNodeCont::buildOnRamp(), ODDistrictHandler::closeDistrict(), NBTrafficLightDefinition::collectEdges(), NBOwnTLDef::collectLinks(), NBNode::computeInternalLaneShape(), NBEdge::computeLaneShapes(), NBNode::computeLogic(), NBNode::computeNodeShape(), NBTrafficLightLogicCont::computeSingleLogic(), NBEdge::connections_sorter(), MSLane::detectCollisions(), NIVissimDistrictConnection::dict_BuildDistricts(), MSVTypeProbe::execute(), Command_SaveTLSSwitches::execute(), NBTrafficLightLogicCont::extract(), NBEdgeCont::extract(), MSNet::getBusStopID(), NIImporter_VISUM::getNamedEdgeContinuating(), NLTriggerBuilder::getPosition(), NBNode::getPossiblySplittedIncoming(), NBNode::getPossiblySplittedOutgoing(), NIImporter_VISUM::getReversedContinuating(), MSUnboundActuatedTrafficLightLogic::init(), MSAgentbasedTrafficLightLogic::init(), MSActuatedTrafficLightLogic::init(), NIXMLTrafficLightsHandler::initTrafficLightLogic(), NIImporter_SUMO::initTrafficLightLogic(), NBNodeCont::joinJunctions(), NBEdgeCont::joinSameNodeConnectingEdges(), NIImporter_OpenDrive::loadNetwork(), MSLane::moveCritical(), MSVehicle::MSVehicle(), NBLoadedTLDef::myCompute(), NIXMLEdgesHandler::myEndElement(), NIXMLConnectionsHandler::myStartElement(), MSLaneSpeedTrigger::myStartElement(), NBConnection::NBConnection(), NBRequest::NBRequest(), NBOwnTLDef::edge_by_incoming_priority_sorter::operator()(), NBNode::nodes_by_id_sorter::operator()(), NBNetBuilder::by_id_sorter::operator()(), NBContHelper::same_connection_edge_sorter::operator()(), Named::ComparatorIdLess::operator()(), NIImporter_VISUM::parse_EdgePolys(), NIImporter_VISUM::parse_Lanes(), NIImporter_VISUM::parse_LanesConnections(), NIImporter_VISUM::parse_Turns(), NIImporter_VISUM::parse_TurnsToSignalGroups(), NIXMLConnectionsHandler::parseDeprecatedLaneDefinition(), NIXMLConnectionsHandler::parseLaneBound(), NBLoadedTLDef::SignalGroup::patchTYellow(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_TLS::processGet(), TraCIServerAPI_Lane::processGet(), TraCIServerAPI_InductionLoop::processGet(), NWWriter_SUMO::prohibitionConnection(), NBNodeCont::remapEdge(), NBLoadedSUMOTLDef::removeConnection(), NBNode::removeDummyEdges(), NBEdgeCont::removeUnwishedEdges(), NBNodeCont::removeUnwishedNodes(), NBConnection::replaceFrom(), NBConnection::replaceTo(), NIXMLTrafficLightsHandler::retrieveLaneIndex(), NBNodeCont::setAsTLControlled(), NBEdge::setControllingTLInformation(), MSLane::setCritical(), NBOwnTLDef::setTLControllingInformation(), NBLoadedTLDef::setTLControllingInformation(), NBLoadedSUMOTLDef::setTLControllingInformation(), NBEdgeCont::splitAt(), RORDLoader_SUMOBase::startRoute(), NIXMLConnectionsHandler::validateLaneInfo(), MSInstantInductLoop::write(), NWWriter_SUMO::writeConnection(), NWWriter_SUMO::writeDistrict(), NWWriter_SUMO::writeEdge(), writeEdge(), NWWriter_XML::writeEdgesAndConnections(), NWWriter_SUMO::writeInternalConnections(), NWWriter_SUMO::writeJunction(), NWWriter_OpenDrive::writeNetwork(), NWWriter_XML::writeNodes(), and MSRouteProbe::writeXMLOutput().

void MSMeanData::init ( ) throw ()
MSMeanData& MSMeanData::operator= ( const MSMeanData &  ) [private]

Invalidated assignment operator.

virtual void MSDetectorFileOutput::reset ( ) throw () [inline, virtual, inherited]

Resets collected values.

Please note that this is only a "hack" for coupled-tls-outputs.

See also:
Command_SaveTLCoupledLaneDet
Todo:
Reckeck/refactor

Reimplemented in GUIInductLoop, MSE2Collector, MSE3Collector, and MSInductLoop.

Definition at line 102 of file MSDetectorFileOutput.h.

Referenced by Command_SaveTLCoupledLaneDet::execute().

void MSMeanData::resetOnly ( SUMOTime  stopTime) throw () [protected]

Resets network value in order to allow processing of the next interval.

Goes through the lists of edges and starts "resetOnly" for each edge.

Parameters:
[in]edgeThe last time step that is reported

Reimplemented in MSMeanData_Net.

Definition at line 312 of file MSMeanData.cpp.

References myEdges, myMeasures, MSMeanData::MeanDataValues::reset(), and UNUSED_PARAMETER.

Referenced by writeXMLOutput().

void Named::setID ( const std::string &  newID) [inline, inherited]

resets the id

Definition at line 65 of file Named.h.

References Named::myID.

void MSMeanData::writeEdge ( OutputDevice &  dev,
const std::vector< MeanDataValues * > &  edgeValues,
MSEdge *  edge,
SUMOTime  startTime,
SUMOTime  stopTime 
) throw (IOError) [protected]

Writes edge values into the given stream.

microsim: It is checked whether the dump shall be generated edge- or lane-wise. In the first case, the lane-data are collected and aggregated and written directly. In the second case, "writeLane" is used to write each lane's state.

Parameters:
[in]devThe output device to write the data into
[in]edgeValuesList of this edge's value collectors
[in]edgeThe edge to write the dump of
[in]startTimeFirst time step the data were gathered
[in]stopTimeLast time step the data were gathered
Exceptions:
IOErrorIf an error on writing occurs (!!! not yet implemented)

Definition at line 338 of file MSMeanData.cpp.

References MSMeanData::MeanDataValues::addTo(), createValues(), Named::getID(), MSMoveReminder::getLane(), myAmEdgeBased, myDumpEmpty, myTrackVehicles, MSMeanData::MeanDataValues::reset(), SUMOReal, MSMeanData::MeanDataValues::write(), and writePrefix().

Referenced by writeXMLOutput().

bool MSMeanData::writePrefix ( OutputDevice &  dev,
const MeanDataValues &  values,
const std::string  prefix 
) const throw (IOError) [protected]

Checks for emptiness and writes prefix into the given stream.

Parameters:
[in]devThe output device to write the data into
[in]valuesThe values to check for emptiness
[in]prefixThe xml prefix to write (mostly the lane / edge id)
Returns:
whether further output should be generated
Exceptions:
IOErrorIf an error on writing occurs (!!! not yet implemented)

Definition at line 405 of file MSMeanData.cpp.

References myDumpEmpty.

Referenced by writeEdge().

void MSMeanData::writeXMLDetectorProlog ( OutputDevice &  dev) const throw (IOError) [virtual]

Opens the XML-output using "netstats" as root element.

Parameters:
[in]devThe output device to write the root into
See also:
MSDetectorFileOutput::writeXMLDetectorProlog
Exceptions:
IOErrorIf an error on writing occurs (!!! not yet implemented)

Implements MSDetectorFileOutput.

Definition at line 455 of file MSMeanData.cpp.

void MSMeanData::writeXMLOutput ( OutputDevice &  dev,
SUMOTime  startTime,
SUMOTime  stopTime 
) throw (IOError) [virtual]

Writes collected values into the given stream.

At first, it is checked whether the values for the current interval shall be written. If not, a reset is performed, only, using "resetOnly". Otherwise, both the list of single-lane edges and the list of multi-lane edges are gone through and each edge is written using "writeEdge".

Parameters:
[in]devThe output device to write the data into
[in]startTimeFirst time step the data were gathered
[in]stopTimeLast time step the data were gathered
See also:
MSDetectorFileOutput::writeXMLOutput
write
Exceptions:
IOErrorIf an error on writing occurs (!!! not yet implemented)

Implements MSDetectorFileOutput.

Definition at line 415 of file MSMeanData.cpp.

References DELTA_T, MIN2(), myDumpBegin, myDumpEnd, myEdges, Named::myID, myMeasures, myPendingIntervals, myTrackVehicles, resetOnly(), time2string(), and writeEdge().


Field Documentation

Information whether the output shall be edge-based (not lane-based)

Definition at line 423 of file MSMeanData.h.

Referenced by init(), and writeEdge().

The first and the last time step to write information (-1 indicates always)

Definition at line 426 of file MSMeanData.h.

Referenced by detectorUpdate(), and writeXMLOutput().

const bool MSMeanData::myDumpEmpty [private]

Whether empty lanes/edges shall be written.

Definition at line 432 of file MSMeanData.h.

Referenced by writeEdge(), and writePrefix().

Definition at line 426 of file MSMeanData.h.

Referenced by writeXMLOutput().

Whether internal lanes/edges shall be written.

Definition at line 435 of file MSMeanData.h.

Referenced by init().

std::vector<MSEdge*> MSMeanData::myEdges [private]

The corresponding first edges.

Definition at line 429 of file MSMeanData.h.

Referenced by init(), resetOnly(), and writeXMLOutput().

const SUMOReal MSMeanData::myMaxTravelTime [protected]

the maximum travel time to write

Definition at line 413 of file MSMeanData.h.

std::vector<std::vector<MeanDataValues*> > MSMeanData::myMeasures [protected]

Value collectors; sorted by edge, then by lane.

Definition at line 419 of file MSMeanData.h.

Referenced by MSMeanData_Harmonoise::detectorUpdate(), init(), resetOnly(), writeXMLOutput(), and ~MSMeanData().

const SUMOReal MSMeanData::myMinSamples [protected]

the minimum sample seconds

Definition at line 410 of file MSMeanData.h.

std::list< std::pair<SUMOTime, SUMOTime> > MSMeanData::myPendingIntervals [private]

The intervals for which output still has to be generated (only in the tracking case)

Definition at line 441 of file MSMeanData.h.

Referenced by writeXMLOutput().

Whether vehicles are tracked.

Definition at line 438 of file MSMeanData.h.

Referenced by init(), writeEdge(), and writeXMLOutput().

const std::set<std::string> MSMeanData::myVehicleTypes [protected]

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