SUMO - Simulation of Urban MObility
MSMeanData::MeanDataValueTracker Class Reference

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

#include <MSMeanData.h>

Inheritance diagram for MSMeanData::MeanDataValueTracker:
Inheritance graph
Collaboration diagram for MSMeanData::MeanDataValueTracker:
Collaboration graph

Data Structures

class  TrackerEntry
 

Public Types

enum  Notification {
  NOTIFICATION_DEPARTED, NOTIFICATION_JUNCTION, NOTIFICATION_SEGMENT, NOTIFICATION_LANE_CHANGE,
  NOTIFICATION_TELEPORT, NOTIFICATION_PARKING, NOTIFICATION_ARRIVED, NOTIFICATION_VAPORIZED,
  NOTIFICATION_TELEPORT_ARRIVED, NOTIFICATION_PARKING_REROUTE
}
 Definition of a vehicle state. More...
 

Public Member Functions

void addTo (MSMeanData::MeanDataValues &val) const
 Add the values of this to the given one and store them there. More...
 
void clearFirst ()
 
const std::string & getDescription () const
 
const MSLanegetLane () const
 Returns the lane the reminder works on. More...
 
int getNumReady () const
 
double getSamples () const
 Returns the number of collected sample seconds. More...
 
double getTravelledDistance () const
 Returns the total travelled distance. More...
 
bool isEmpty () const
 Returns whether any data was collected. More...
 
 MeanDataValueTracker (MSLane *const lane, const double length, const MSMeanData *const parent)
 Constructor. More...
 
bool notifyMove (SUMOVehicle &veh, double oldPos, double newPos, double newSpeed)
 Checks whether the reminder still has to be notified about the vehicle moves. More...
 
void reset (bool afterWrite)
 Resets values so they may be used for the next interval. More...
 
void setDescription (const std::string &description)
 
virtual void update ()
 Called if a per timestep update is needed. Default does nothing. More...
 
void write (OutputDevice &dev, const SUMOTime period, const double numLanes, const double defaultTravelTime, const int numVehicles=-1) const
 Writes output values into the given stream. More...
 
virtual ~MeanDataValueTracker ()
 Destructor. More...
 
Methods inherited from MSMoveReminder
void notifyMoveInternal (const SUMOVehicle &veh, const double frontOnLane, const double timeOnLane, const double meanSpeedFrontOnLane, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double meanLengthOnLane)
 Internal notification about the vehicle moves. More...
 
bool notifyLeave (SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
 Called if the vehicle leaves the reminder's lane. More...
 
bool notifyEnter (SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
 Computes current values and adds them to their sums. More...
 
Interface methods, to be derived by subclasses
void updateDetector (SUMOVehicle &veh, double entryPos, double leavePos, SUMOTime entryTime, SUMOTime currentTime, SUMOTime leaveTime, bool cleanUp)
 

Protected Member Functions

void removeFromVehicleUpdateValues (SUMOVehicle &veh)
 

Protected Attributes

std::string myDescription
 a description of this moveReminder More...
 
MSLane *const myLane
 Lane on which the reminder works. More...
 
const double myLaneLength
 The length of the lane / edge the data collector is on. More...
 
const MSMeanData *const myParent
 The meandata parent. More...
 
Collected values

The number of sampled vehicle movements (in s)

double sampleSeconds
 
double travelledDistance
 The sum of the distances the vehicles travelled. More...
 

Private Attributes

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

Detailed Description

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

Definition at line 192 of file MSMeanData.h.

Member Enumeration Documentation

◆ Notification

Definition of a vehicle state.

Enumerator
NOTIFICATION_DEPARTED 

The vehicle has departed (was inserted into the network)

NOTIFICATION_JUNCTION 

The vehicle arrived at a junction.

NOTIFICATION_SEGMENT 

The vehicle changes the segment (meso only)

NOTIFICATION_LANE_CHANGE 

The vehicle changes lanes (micro only)

NOTIFICATION_TELEPORT 

The vehicle is being teleported.

NOTIFICATION_PARKING 

The vehicle starts or ends parking.

NOTIFICATION_ARRIVED 

The vehicle arrived at its destination (is deleted)

NOTIFICATION_VAPORIZED 

The vehicle got vaporized.

NOTIFICATION_TELEPORT_ARRIVED 

The vehicle was teleported out of the net.

NOTIFICATION_PARKING_REROUTE 

The vehicle needs another parking area.

Definition at line 95 of file MSMoveReminder.h.

Constructor & Destructor Documentation

◆ MeanDataValueTracker()

MSMeanData::MeanDataValueTracker::MeanDataValueTracker ( MSLane *const  lane,
const double  length,
const MSMeanData *const  parent 
)

Constructor.

Definition at line 289 of file MSMeanData.cpp.

References MSMeanData::createValues(), and myCurrentData.

◆ ~MeanDataValueTracker()

MSMeanData::MeanDataValueTracker::~MeanDataValueTracker ( )
virtual

Destructor.

Definition at line 297 of file MSMeanData.cpp.

References myCurrentData.

Member Function Documentation

◆ addTo()

void MSMeanData::MeanDataValueTracker::addTo ( MSMeanData::MeanDataValues val) const
virtual

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

Parameters
[in]valThe meandata to add to

Implements MSMeanData::MeanDataValues.

Definition at line 326 of file MSMeanData.cpp.

References myCurrentData.

◆ clearFirst()

void MSMeanData::MeanDataValueTracker::clearFirst ( )

◆ getDescription()

◆ getLane()

◆ getNumReady()

int MSMeanData::MeanDataValueTracker::getNumReady ( ) const

Definition at line 389 of file MSMeanData.cpp.

References myCurrentData.

◆ getSamples()

double MSMeanData::MeanDataValueTracker::getSamples ( ) const
virtual

Returns the number of collected sample seconds.

Returns
the number of collected sample seconds

Reimplemented from MSMeanData::MeanDataValues.

Definition at line 403 of file MSMeanData.cpp.

References myCurrentData.

◆ getTravelledDistance()

double MSMeanData::MeanDataValues::getTravelledDistance ( ) const
inlineinherited

Returns the total travelled distance.

Returns
the total travelled distance

Definition at line 165 of file MSMeanData.h.

References MSMeanData::MeanDataValues::travelledDistance.

Referenced by MSCalibrator::currentSpeed(), and MSCalibrator::writeXMLOutput().

◆ isEmpty()

bool MSMeanData::MeanDataValueTracker::isEmpty ( ) const
virtual

Returns whether any data was collected.

Returns
whether no data was collected

Reimplemented from MSMeanData::MeanDataValues.

Definition at line 371 of file MSMeanData.cpp.

References myCurrentData.

◆ notifyEnter()

bool MSMeanData::MeanDataValueTracker::notifyEnter ( SUMOVehicle veh,
MSMoveReminder::Notification  reason,
const MSLane enteredLane = 0 
)
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]vehThe entering vehicle.
[in]reasonhow the vehicle enters the lane
See also
MSMoveReminder::notifyEnter
Returns
Always true

Reimplemented from MSMeanData::MeanDataValues.

Definition at line 347 of file MSMeanData.cpp.

References Named::getID(), SUMOVehicle::getID(), myCurrentData, MSMeanData::MeanDataValues::myParent, myTrackedData, MSMoveReminder::NOTIFICATION_SEGMENT, SIMTIME, UNUSED_PARAMETER, and MSDetectorFileOutput::vehicleApplies().

◆ notifyLeave()

bool MSMeanData::MeanDataValueTracker::notifyLeave ( SUMOVehicle veh,
double  lastPos,
MSMoveReminder::Notification  reason,
const MSLane enteredLane = 0 
)
virtual

Called if the vehicle leaves the reminder's lane.

Parameters
vehThe leaving vehicle.
[in]lastPosPosition on the lane when leaving.
[in]isArrivalwhether the vehicle arrived at its destination
[in]isLaneChangewhether the vehicle changed from the lane
See also
MSMoveReminder
MSMoveReminder::notifyLeave

Reimplemented from MSMeanData::MeanDataValues.

Definition at line 338 of file MSMeanData.cpp.

References MSMeanData::MeanDataValues::myParent, myTrackedData, and MSMoveReminder::NOTIFICATION_SEGMENT.

◆ notifyMove()

bool MSMeanData::MeanDataValues::notifyMove ( SUMOVehicle veh,
double  oldPos,
double  newPos,
double  newSpeed 
)
virtualinherited

Checks whether the reminder still has to be notified about the vehicle moves.

Indicator if the reminders is still active for the passed vehicle/parameters. If false, the vehicle will erase this reminder from it's reminder-container.

Parameters
[in]vehVehicle that asks this reminder.
[in]oldPosPosition before move.
[in]newPosPosition after move with newSpeed.
[in]newSpeedMoving speed.
Returns
True if vehicle hasn't passed the reminder completely.

Reimplemented from MSMoveReminder.

Definition at line 91 of file MSMeanData.cpp.

References Named::getID(), SUMOVehicle::getID(), MSMoveReminder::getLane(), MSVehicleType::getLength(), SUMOVehicle::getPreviousSpeed(), SUMOVehicle::getVehicleType(), MSGlobals::gSemiImplicitEulerUpdate, SUMOVehicle::hasArrived(), MAX2(), MIN2(), MIN4(), MSMoveReminder::myLane, MSMeanData::MeanDataValues::myLaneLength, MSMoveReminder::notifyMoveInternal(), NUMERICAL_EPS, MSCFModel::passingTime(), MSCFModel::speedAfterTime(), TS, and WRITE_ERROR.

◆ notifyMoveInternal()

void MSMeanData::MeanDataValueTracker::notifyMoveInternal ( const SUMOVehicle veh,
const double  frontOnLane,
const double  timeOnLane,
const double  meanSpeedFrontOnLane,
const double  meanSpeedVehicleOnLane,
const double  travelledDistanceFrontOnLane,
const double  travelledDistanceVehicleOnLane,
const double  meanLengthOnLane 
)
virtual

Internal notification about the vehicle moves.

See also
MSMoveReminder::notifyMoveInternal().

Reimplemented from MSMoveReminder.

Definition at line 332 of file MSMeanData.cpp.

References myTrackedData.

◆ removeFromVehicleUpdateValues()

void MSMoveReminder::removeFromVehicleUpdateValues ( SUMOVehicle veh)
protectedinherited

◆ reset()

void MSMeanData::MeanDataValueTracker::reset ( bool  afterWrite)
virtual

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

Implements MSMeanData::MeanDataValues.

Definition at line 314 of file MSMeanData.cpp.

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

◆ setDescription()

void MSMoveReminder::setDescription ( const std::string &  description)
inlineinherited

◆ update()

void MSMeanData::MeanDataValues::update ( )
virtualinherited

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

Reimplemented in MSMeanData_Harmonoise::MSLaneMeanDataValues.

Definition at line 276 of file MSMeanData.cpp.

◆ updateDetector()

void MSMoveReminder::updateDetector ( SUMOVehicle veh,
double  entryPos,
double  leavePos,
SUMOTime  entryTime,
SUMOTime  currentTime,
SUMOTime  leaveTime,
bool  cleanUp 
)
inherited

◆ write()

void MSMeanData::MeanDataValueTracker::write ( OutputDevice dev,
const SUMOTime  period,
const double  numLanes,
const double  defaultTravelTime,
const int  numVehicles = -1 
) const
virtual

Writes output values into the given stream.

Parameters
[in]devThe output device to write the data into
[in]periodLength of the period the data were gathered
[in]numLanesThe total number of lanes for which the data was collected
Exceptions
IOErrorIf an error on writing occurs (!!! not yet implemented)

Implements MSMeanData::MeanDataValues.

Definition at line 377 of file MSMeanData.cpp.

References myCurrentData.

Field Documentation

◆ myCurrentData

std::list<TrackerEntry*> MSMeanData::MeanDataValueTracker::myCurrentData
private

The currently active meandata "intervals".

Definition at line 291 of file MSMeanData.h.

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

◆ myDescription

std::string MSMoveReminder::myDescription
protectedinherited

a description of this moveReminder

Definition at line 246 of file MSMoveReminder.h.

Referenced by MSMoveReminder::getDescription(), and MSMoveReminder::setDescription().

◆ myLane

◆ myLaneLength

const double MSMeanData::MeanDataValues::myLaneLength
protectedinherited

◆ myParent

◆ myTrackedData

std::map<const SUMOVehicle*, TrackerEntry*> MSMeanData::MeanDataValueTracker::myTrackedData
private

The map of vehicles to data entries.

Definition at line 288 of file MSMeanData.h.

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

◆ sampleSeconds

◆ travelledDistance


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