MSMeanData::MeanDataValueTracker Class Reference

#include <MSMeanData.h>

Inheritance diagram for MSMeanData::MeanDataValueTracker:

MSMeanData::MeanDataValues MSMoveReminder

Detailed Description

Data structure for mean (aggregated) edge/lane values for tracked vehicles.

Definition at line 151 of file MSMeanData.h.


Collected values

The number of sampled vehicle movements (in s)

SUMOReal sampleSeconds
SUMOReal travelledDistance
 The sum of the distances the vehicles travelled.

Public Member Functions

void addTo (MSMeanData::MeanDataValues &val) const throw ()
 Add the values of this to the given one and store them there.
void clearFirst () throw ()
const MSLane *const getLane () const throw ()
 Returns the lane the reminder works on.
size_t getNumReady () const throw ()
SUMOReal getSamples () const throw ()
bool isEmpty () const throw ()
 Returns whether any data was collected.
 MeanDataValueTracker (MSLane *const lane, const std::set< std::string > *const vTypes=0, const MSMeanData *const parent=0) throw ()
 Constructor.
void reset () throw ()
 Resets values so they may be used for the next interval.
virtual void update () throw ()
 Called if a per timestep update is needed. Default does nothing.
void write (OutputDevice &dev, const SUMOTime period, const SUMOReal numLanes, const SUMOReal length, const int numVehicles=-1) const throw (IOError)
 Writes output values into the given stream.
virtual ~MeanDataValueTracker () throw ()
 Destructor.
Methods inherited from MSMoveReminder
bool isStillActive (MSVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed) throw ()
 Computes current values and adds them to their sums.
bool notifyEnter (MSVehicle &veh, bool isEmit, bool isLaneChange) throw ()
 Computes current values and adds them to their sums.
void notifyLeave (MSVehicle &veh, bool isArrival, bool isLaneChange) throw ()
 Called if the vehicle leaves the reminder's lane.
Methods inherited from MSMoveReminder.
bool vehicleApplies (const SUMOVehicle &veh) const throw ()
 Tests whether the vehicles type is to be regarded.

Protected Attributes

MSLane *const myLane
 Lane on which the reminder works.

Private Attributes

std::list< TrackerEntry * > myCurrentData
 The currently active meandata "intervals".
const MSMeanDatamyParent
 The meandata parent.
std::map< MSVehicle
*, TrackerEntry * > 
myTrackedData
 The map of vehicles to data entries.

Data Structures

class  TrackerEntry

Constructor & Destructor Documentation

MSMeanData::MeanDataValueTracker::MeanDataValueTracker ( MSLane *const   lane,
const std::set< std::string > *const   vTypes = 0,
const MSMeanData *const   parent = 0 
) throw ()

Constructor.

Definition at line 92 of file MSMeanData.cpp.

Referenced by MSMeanData::init().

00095         : MSMeanData::MeanDataValues(lane, true, vTypes), myParent(parent) {
00096     myCurrentData.push_back(new TrackerEntry(parent->createValues(lane, false)));
00097 }

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

Destructor.

Definition at line 100 of file MSMeanData.cpp.

00100                                                               {
00101 }


Member Function Documentation

void MSMeanData::MeanDataValueTracker::addTo ( MSMeanData::MeanDataValues val  )  const throw () [virtual]

Add the values of this to the given one and store them there.

Parameters:
[in] val The meandata to add to

Implements MSMeanData::MeanDataValues.

Definition at line 111 of file MSMeanData.cpp.

References myCurrentData.

00111                                                                                  {
00112     myCurrentData.front()->myValues->addTo(val);
00113 }

void MSMeanData::MeanDataValueTracker::clearFirst (  )  throw ()

Definition at line 173 of file MSMeanData.cpp.

References myCurrentData.

00173                                                    {
00174     if (myCurrentData.size() == 1) {
00175         myCurrentData.front()->reset();
00176     } else {
00177         myCurrentData.pop_front();
00178     }
00179 }

const MSLane* const MSMoveReminder::getLane (  )  const throw () [inline, inherited]

size_t MSMeanData::MeanDataValueTracker::getNumReady (  )  const throw ()

Definition at line 159 of file MSMeanData.cpp.

References myCurrentData.

00159                                                           {
00160     size_t result = 0;
00161     for (std::list<TrackerEntry*>::const_iterator it = myCurrentData.begin(); it != myCurrentData.end(); ++it) {
00162         if ((*it)->myNumVehicleEntered == (*it)->myNumVehicleLeft) {
00163             result++;
00164         } else {
00165             break;
00166         }
00167     }
00168     return result;
00169 }

SUMOReal MSMeanData::MeanDataValueTracker::getSamples (  )  const throw () [virtual]

Reimplemented from MSMeanData::MeanDataValues.

Definition at line 183 of file MSMeanData.cpp.

References myCurrentData.

00183                                                          {
00184     return myCurrentData.front()->myValues->getSamples();
00185 }

bool MSMeanData::MeanDataValueTracker::isEmpty (  )  const throw () [virtual]

Returns whether any data was collected.

Returns:
whether no data was collected

Reimplemented from MSMeanData::MeanDataValues.

Definition at line 146 of file MSMeanData.cpp.

References myCurrentData.

00146                                                       {
00147     return myCurrentData.front()->myValues->isEmpty();
00148 }

bool MSMeanData::MeanDataValueTracker::isStillActive ( MSVehicle veh,
SUMOReal  oldPos,
SUMOReal  newPos,
SUMOReal  newSpeed 
) throw () [virtual]

Computes current values and adds them to their sums.

The fraction of time the vehicle is on the lane is computed and used as a weight for the vehicle's current values.

Additionally, if the vehicle has entered this lane, "nVehEnteredLane" is incremented, and if the vehicle has left the lane, "nVehLeftLane".

Parameters:
[in] veh The regarded vehicle
[in] oldPos Position before the move-micro-timestep.
[in] newPos Position after the move-micro-timestep.
[in] newSpeed The vehicle's current speed
Returns:
false, if the vehicle is beyond the lane, true otherwise
See also:
MSMoveReminder

MSMoveReminder::isStillActive

Reimplemented from MSMoveReminder.

Definition at line 117 of file MSMeanData.cpp.

References myTrackedData, and MSMeanData::MeanDataValues::vehicleApplies().

00117                                                                                                                          {
00118     if (vehicleApplies(veh)) {
00119         return myTrackedData[&veh]->myValues->isStillActive(veh, oldPos, newPos, newSpeed);
00120     }
00121     return false;
00122 }

bool MSMeanData::MeanDataValueTracker::notifyEnter ( MSVehicle veh,
bool  isEmit,
bool  isLaneChange 
) throw () [virtual]

Computes current values and adds them to their sums.

The fraction of time the vehicle is on the lane is computed and used as a weight for the vehicle's current values. The "emitted" field is incremented, additionally.

Parameters:
[in] veh The vehicle that enters the lane
[in] isEmit whether the vehicle was just emitted into the net
[in] isLaneChange whether the vehicle changed to the lane
See also:
MSMoveReminder::notifyEnter
Returns:
Always true

Reimplemented from MSMoveReminder.

Definition at line 135 of file MSMeanData.cpp.

References myCurrentData, myTrackedData, and MSMeanData::MeanDataValues::vehicleApplies().

00135                                                                                                   {
00136     if (vehicleApplies(veh)) {
00137         myTrackedData[&veh] = myCurrentData.back();
00138         myTrackedData[&veh]->myNumVehicleEntered++;
00139         return myTrackedData[&veh]->myValues->notifyEnter(veh, isEmit, isLaneChange);
00140     }
00141     return false;
00142 }

void MSMeanData::MeanDataValueTracker::notifyLeave ( MSVehicle veh,
bool  isArrival,
bool  isLaneChange 
) throw () [virtual]

Called if the vehicle leaves the reminder's lane.

Parameters:
veh The leaving vehicle.
See also:
MSMoveReminder

MSMoveReminder::notifyLeave

Reimplemented from MSMoveReminder.

Definition at line 126 of file MSMeanData.cpp.

References myTrackedData, and MSMeanData::MeanDataValues::vehicleApplies().

00126                                                                                                      {
00127     if (vehicleApplies(veh)) {
00128         myTrackedData[&veh]->myNumVehicleLeft++;
00129         myTrackedData[&veh]->myValues->notifyLeave(veh, isArrival, isLaneChange);
00130     }
00131 }

void MSMeanData::MeanDataValueTracker::reset (  )  throw () [virtual]

Resets values so they may be used for the next interval.

Implements MSMeanData::MeanDataValues.

Definition at line 105 of file MSMeanData.cpp.

References MSMeanData::createValues(), myCurrentData, MSMoveReminder::myLane, and myParent.

00105                                               {
00106     myCurrentData.push_back(new TrackerEntry(myParent->createValues(myLane, false)));
00107 }

void MSMeanData::MeanDataValues::update (  )  throw () [virtual, inherited]

Called if a per timestep update is needed. Default does nothing.

Reimplemented in MSMeanData_Harmonoise::MSLaneMeanDataValues.

Definition at line 79 of file MSMeanData.cpp.

00079                                          {
00080 }

bool MSMeanData::MeanDataValues::vehicleApplies ( const SUMOVehicle veh  )  const throw () [inherited]

void MSMeanData::MeanDataValueTracker::write ( OutputDevice dev,
const SUMOTime  period,
const SUMOReal  numLanes,
const SUMOReal  length,
const int  numVehicles = -1 
) const throw (IOError) [virtual]

Writes output values into the given stream.

Parameters:
[in] dev The output device to write the data into
[in] period Length of the period the data were gathered
[in] numLanes The total number of lanes for which the data was collected
[in] length The length of the object for which the data was collected
Exceptions:
IOError If an error on writing occurs (!!! not yet implemented)

Implements MSMeanData::MeanDataValues.

Definition at line 152 of file MSMeanData.cpp.

References myCurrentData.

00153                                                                                                                                     {
00154     myCurrentData.front()->myValues->write(dev, period, numLanes, length, myCurrentData.front()->myNumVehicleEntered);
00155 }


Field Documentation

The currently active meandata "intervals".

Definition at line 263 of file MSMeanData.h.

Referenced by addTo(), clearFirst(), getNumReady(), getSamples(), isEmpty(), notifyEnter(), reset(), and write().

MSLane* const MSMoveReminder::myLane [protected, inherited]

The meandata parent.

Definition at line 266 of file MSMeanData.h.

Referenced by reset().

The map of vehicles to data entries.

Definition at line 260 of file MSMeanData.h.

Referenced by isStillActive(), notifyEnter(), and notifyLeave().

SUMOReal MSMeanData::MeanDataValues::sampleSeconds [protected, inherited]


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

Generated on Wed May 5 00:06:48 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6