51 #ifdef CHECK_MEMORY_LEAKS 53 #endif // CHECK_MEMORY_LEAKS 65 MSMoveReminder(
"meandata_" + (lane == 0 ?
"NULL" : lane->getID()), lane, doAdd),
69 travelledDistance(0) {}
89 SUMOReal leaveSpeed = newSpeed, leaveSpeedFront = newSpeed;
97 if (oldPos < 0 && newPos >= 0) {
100 timeOnLane =
TS - timeBeforeEnter;
101 frontOnLane = timeOnLane;
114 const SUMOReal timeAfterLeave =
TS - timeBeforeLeave;
115 timeOnLane -= timeAfterLeave;
130 const SUMOReal timeAfterLeave =
TS - timeBeforeLeave;
131 frontOnLane -= timeAfterLeave;
139 if (timeOnLane < 0) {
143 if (timeOnLane == 0) {
159 notifyMoveInternal(veh, frontOnLane, timeOnLane, (enterSpeed + leaveSpeedFront) / 2., (enterSpeed + leaveSpeed) / 2., travelledDistanceFrontOnLane, travelledDistanceVehicleOnLane);
203 std::list<TrackerEntry*>::iterator i;
238 myTrackedData[&veh]->myValues->notifyMoveInternal(veh, frontOnLane, timeOnLane, meanSpeedFrontOnLane, meanSpeedVehicleOnLane, travelledDistanceFrontOnLane, travelledDistanceVehicleOnLane);
247 return myTrackedData[&veh]->myValues->notifyLeave(veh, lastPos, reason);
259 if (!
myTrackedData[&veh]->myValues->notifyEnter(veh, reason)) {
282 myCurrentData.front()->myValues->write(dev, period, numLanes,
292 if ((*it)->myNumVehicleEntered == (*it)->myNumVehicleLeft) {
313 const bool useLanes,
const bool withEmpty,
314 const bool printDefaults,
const bool withInternal,
const bool trackVehicles,
317 const std::string& vTypes) :
334 for (MSEdgeVector::const_iterator e = edges.begin(); e != edges.end(); ++e) {
339 myMeasures.push_back(std::vector<MeanDataValues*>());
340 const std::vector<MSLane*>& lanes = (*e)->getLanes();
363 for (std::vector<MSLane*>::const_iterator lane = lanes.begin(); lane != lanes.end(); ++lane) {
366 (*lane)->addMoveReminder(
myMeasures.back().back());
380 for (std::vector<std::vector<MeanDataValues*> >::const_iterator i =
myMeasures.begin(); i !=
myMeasures.end(); ++i) {
381 for (std::vector<MeanDataValues*>::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
392 MSEdgeVector::iterator edge =
myEdges.begin();
393 for (std::vector<std::vector<MeanDataValues*> >::const_iterator i =
myMeasures.begin(); i !=
myMeasures.end(); ++i, ++edge) {
404 for (std::vector<std::vector<MeanDataValues*> >::const_iterator i =
myMeasures.begin(); i !=
myMeasures.end(); ++i) {
405 for (std::vector<MeanDataValues*>::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
414 return edge->
getID();
420 const std::vector<MeanDataValues*>& edgeValues,
430 data->
write(dev, stopTime - startTime,
437 std::vector<MeanDataValues*>::const_iterator lane;
441 for (lane = edgeValues.begin(); lane != edgeValues.end(); ++lane) {
442 if (!(*lane)->isEmpty()) {
451 for (lane = edgeValues.begin(); lane != edgeValues.end(); ++lane) {
456 meanData.
reset(
true);
467 meanData.
reset(
true);
470 for (lane = edgeValues.begin(); lane != edgeValues.end(); ++lane) {
472 meanData.
addTo(*sumData);
509 for (std::vector<std::vector<MeanDataValues*> >::const_iterator i =
myMeasures.begin(); i !=
myMeasures.end(); ++i) {
510 for (std::vector<MeanDataValues*>::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
524 while (numReady-- > 0) {
531 MSEdgeVector::iterator edge =
myEdges.begin();
532 for (std::vector<std::vector<MeanDataValues*> >::const_iterator i =
myMeasures.begin(); i !=
myMeasures.end(); ++i, ++edge) {
533 writeEdge(dev, (*i), *edge, startTime, stopTime);
542 dev.
writeXMLHeader(
"meandata",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/meandata_file.xsd\"");
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
Data collector for edges/lanes.
virtual ~MeanDataValueTracker()
Destructor.
const MSLane * getLane() const
Returns the lane the reminder works on.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
virtual MSMeanData::MeanDataValues * createValues(MSLane *const lane, const SUMOReal length, const bool doAdd) const =0
Create an instance of MeanDataValues.
SUMOReal getLength() const
Returns the lane's length.
SumoXMLTag
Numbers representing SUMO-XML - element names.
const SUMOReal myLaneLength
The length of the lane / edge the data collector is on.
std::vector< std::vector< MeanDataValues * > > myMeasures
Value collectors; sorted by edge, then by lane.
const bool myDumpInternal
Whether internal lanes/edges shall be written.
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
The vehicle arrived at a junction.
MSLane *const myLane
Lane on which the reminder works.
bool isEmpty() const
Returns whether any data was collected.
const SUMOReal myMaxTravelTime
the maximum travel time to write
Notification
Definition of a vehicle state.
SUMOReal getLength() const
Get vehicle's length [m].
virtual SUMOReal getPreviousSpeed() const =0
Returns the vehicle's previous speed.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
std::map< const SUMOVehicle *, TrackerEntry * > myTrackedData
The map of vehicles to data entries.
SUMOReal getSpeedLimit() const
Returns the lane's maximum allowed speed.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual bool isEmpty() const
Returns whether any data was collected.
void write(OutputDevice &dev, const SUMOTime period, const SUMOReal numLanes, const SUMOReal defaultTravelTime, const int numVehicles=-1) const
Writes output values into the given stream.
The vehicle changes the segment (meso only)
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Computes current values and adds them to their sums.
const std::string & getID() const
Returns the id.
virtual void notifyMoveInternal(const SUMOVehicle &veh, const SUMOReal frontOnLane, const SUMOReal timeOnLane, const SUMOReal meanSpeedFrontOnLane, const SUMOReal meanSpeedVehicleOnLane, const SUMOReal travelledDistanceFrontOnLane, const SUMOReal travelledDistanceVehicleOnLane)
Internal notification about the vehicle moves.
EdgeBasicFunction
Defines possible edge types.
#define UNUSED_PARAMETER(x)
std::list< TrackerEntry * > myCurrentData
The currently active meandata "intervals".
MeanDataValues(MSLane *const lane, const SUMOReal length, const bool doAdd, const MSMeanData *const parent)
Constructor.
SUMOReal getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
void addTo(MSMeanData::MeanDataValues &val) const
Add the values of this to the given one and store them there.
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
A road/street connecting two junctions.
const bool myPrintDefaults
Whether empty lanes/edges shall be written.
static SUMOReal speedAfterTime(const SUMOReal t, const SUMOReal oldSpeed, const SUMOReal dist)
Calculates the speed after a time t [0,TS] given the initial speed and the distance traveled in an i...
virtual bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Called if the vehicle leaves the reminder's lane.
Representation of a vehicle.
Data structure for mean (aggregated) edge/lane values.
MSEdgeVector myEdges
The corresponding first edges.
const bool myAmEdgeBased
Information whether the output shall be edge-based (not lane-based)
virtual bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Called if the vehicle enters the reminder's lane.
virtual SUMOReal getSamples() const
Returns the number of collected sample seconds.
MSMeanData(const std::string &id, const SUMOTime dumpBegin, const SUMOTime dumpEnd, const bool useLanes, const bool withEmpty, const bool printDefaults, const bool withInternal, const bool trackVehicles, const SUMOReal minSamples, const SUMOReal maxTravelTime, const std::string &vTypes)
Constructor.
void addDetector(MSMoveReminder *data)
Adds a data collector for a detector to this segment.
static SUMOReal passingTime(const SUMOReal lastPos, const SUMOReal passedPos, const SUMOReal currentPos, const SUMOReal lastSpeed, const SUMOReal currentSpeed)
Calculates the time at which the position passedPosition has been passed In case of a ballistic updat...
virtual void write(OutputDevice &dev, const SUMOTime period, const SUMOReal numLanes, const SUMOReal defaultTravelTime, const int numVehicles=-1) const =0
Writes output values into the given stream.
Something on a lane to be noticed about vehicle movement.
const SUMOTime myDumpBegin
The first and the last time step to write information (-1 indicates always)
virtual ~MSMeanData()
Destructor.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
void notifyMoveInternal(const SUMOVehicle &veh, const SUMOReal frontOnLane, const SUMOReal timeOnLane, const SUMOReal meanSpeedFrontOnLane, const SUMOReal meanSpeedVehicleOnLane, const SUMOReal travelledDistanceFrontOnLane, const SUMOReal travelledDistanceVehicleOnLane)
Internal notification about the vehicle moves.
const SUMOReal myMinSamples
the minimum sample seconds
virtual void addTo(MeanDataValues &val) const =0
Add the values of this to the given one and store them there.
virtual void openInterval(OutputDevice &dev, const SUMOTime startTime, const SUMOTime stopTime)
Writes the interval opener.
void setDescription(const std::string &description)
The edge is a pedestrian walking area (a special type of internal edge)
virtual ~MeanDataValues()
Destructor.
std::string myID
The name of the object.
const MSMeanData *const myParent
The meandata parent.
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
virtual void reset(bool afterWrite=false)=0
Resets values so they may be used for the next interval.
std::list< std::pair< SUMOTime, SUMOTime > > myPendingIntervals
The intervals for which output still has to be generated (only in the tracking case) ...
virtual bool hasArrived() const =0
Returns whether this vehicle has arrived.
virtual void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "netstats" as root element.
A single mesoscopic segment (cell)
virtual void update()
Called if a per timestep update is needed. Default does nothing.
The edge is a pedestrian crossing (a special type of internal edge)
SUMOReal getLength() const
return the length of the edge
MESegment * getSegmentForEdge(const MSEdge &e, SUMOReal pos=0)
Get the segment for a given edge at a given position.
virtual bool writePrefix(OutputDevice &dev, const MeanDataValues &values, const SumoXMLTag tag, const std::string id) const
Checks for emptiness and writes prefix into the given stream.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
const MSEdgeVector & getEdges() const
Returns loaded edges.
virtual void detectorUpdate(const SUMOTime step)
Updates the detector.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
static bool gSemiImplicitEulerUpdate
MSEdgeControl & getEdgeControl()
Returns the edge control.
SUMOReal getSamples() const
Returns the number of collected sample seconds.
void prepareDetectorForWriting(MSMoveReminder &data)
Updates data of a detector for all vehicle queues.
std::vector< MSEdge * > MSEdgeVector
void resetOnly(SUMOTime stopTime)
Resets network value in order to allow processing of the next interval.
const bool myDumpEmpty
Whether empty lanes/edges shall be written.
The edge is an internal edge.
Data structure for mean (aggregated) edge/lane values for tracked vehicles.
const bool myTrackVehicles
Whether vehicles are tracked.
Representation of a lane in the micro simulation.
void writeEdge(OutputDevice &dev, const std::vector< MeanDataValues *> &edgeValues, MSEdge *edge, SUMOTime startTime, SUMOTime stopTime)
Writes edge values into the given stream.
virtual const std::string & getID() const =0
Get the vehicle's ID.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
virtual std::string getEdgeID(const MSEdge *const edge)
Return the relevant edge id.
Base of value-generating classes (detectors)
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Called if the vehicle leaves the reminder's lane.
MeanDataValueTracker(MSLane *const lane, const SUMOReal length, const MSMeanData *const parent)
Constructor.
void init()
Adds the value collectors to all relevant edges.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
void reset(bool afterWrite)
Resets values so they may be used for the next interval.