SUMO - Simulation of Urban MObility
MSMeanData.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // Data collector for edges/lanes
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <limits>
35 #include <microsim/MSEdgeControl.h>
36 #include <microsim/MSEdge.h>
37 #include <microsim/MSLane.h>
38 #include <microsim/MSVehicle.h>
39 #include <microsim/MSNet.h>
40 #include <utils/common/SUMOTime.h>
41 #include <utils/common/ToString.h>
43 #include "MSMeanData_Amitran.h"
44 #include "MSMeanData.h"
45 
46 #include <microsim/MSGlobals.h>
47 #include <mesosim/MESegment.h>
48 #include <mesosim/MELoop.h>
49 
50 #ifdef CHECK_MEMORY_LEAKS
51 #include <foreign/nvwa/debug_new.h>
52 #endif // CHECK_MEMORY_LEAKS
53 
54 
55 // ===========================================================================
56 // method definitions
57 // ===========================================================================
58 // ---------------------------------------------------------------------------
59 // MSMeanData::MeanDataValues - methods
60 // ---------------------------------------------------------------------------
62  MSLane* const lane, const SUMOReal length, const bool doAdd,
63  const std::set<std::string>* const vTypes) :
64  MSMoveReminder("meandata_" + (lane == 0 ? "NULL" : lane->getID()), lane, doAdd),
65  myLaneLength(length),
66  sampleSeconds(0),
67  travelledDistance(0),
68  myVehicleTypes(vTypes) {}
69 
70 
72 }
73 
74 
75 bool
77  UNUSED_PARAMETER(reason);
78  return vehicleApplies(veh);
79 }
80 
81 
82 bool
84  // if the vehicle has arrived, the reminder must be kept so it can be
85  // notified of the arrival subsequently
86  SUMOReal timeOnLane = TS;
87  bool ret = true;
88  if (oldPos < 0 && newSpeed != 0) {
89  timeOnLane = newPos / newSpeed;
90  }
91  if (newPos - veh.getVehicleType().getLength() > myLaneLength && newSpeed != 0) {
92  timeOnLane -= (newPos - veh.getVehicleType().getLength() - myLaneLength) / newSpeed;
93  if (fabs(timeOnLane) < 0.001) { // reduce rounding errors
94  timeOnLane = 0.;
95  }
96  ret = veh.hasArrived();
97  }
98  if (timeOnLane < 0) {
99  WRITE_ERROR("Negative vehicle step fraction for '" + veh.getID() + "' on lane '" + getLane()->getID() + "'.");
100  return veh.hasArrived();
101  }
102  if (timeOnLane == 0) {
103  return veh.hasArrived();
104  }
105  notifyMoveInternal(veh, timeOnLane, newSpeed);
106  return ret;
107 }
108 
109 
110 bool
113  return false; // reminder is re-added on every segment (@recheck for performance)
114  }
115  return reason == MSMoveReminder::NOTIFICATION_JUNCTION;
116 }
117 
118 
119 bool
121  return myVehicleTypes == 0 || myVehicleTypes->empty() ||
122  myVehicleTypes->find(veh.getVehicleType().getID()) != myVehicleTypes->end();
123 }
124 
125 
126 bool
128  return sampleSeconds == 0;
129 }
130 
131 
132 void
134 }
135 
136 
137 SUMOReal
139  return sampleSeconds;
140 }
141 
142 
143 // ---------------------------------------------------------------------------
144 // MSMeanData::MeanDataValueTracker - methods
145 // ---------------------------------------------------------------------------
147  const SUMOReal length,
148  const std::set<std::string>* const vTypes,
149  const MSMeanData* const parent)
150  : MSMeanData::MeanDataValues(lane, length, true, vTypes), myParent(parent) {
151  myCurrentData.push_back(new TrackerEntry(parent->createValues(lane, length, false)));
152 }
153 
154 
156  std::list<TrackerEntry*>::iterator i;
157  for (i = myCurrentData.begin(); i != myCurrentData.end(); i++) {
158  delete *i;
159  }
160 
161  // FIXME: myTrackedData may still hold some undeleted TrackerEntries. When to delete those? (Leo), refers to #2251
162  // code below fails
163 
164 // std::map<SUMOVehicle*, TrackerEntry*>::iterator j;
165 // for(j=myTrackedData.begin(); j!=myTrackedData.end();j++){
166 // delete j->second;
167 // }
168 }
169 
170 
171 void
173  if (afterWrite) {
174  if (myCurrentData.begin() != myCurrentData.end()) {
175  myCurrentData.pop_front();
176  }
177  } else {
179  }
180 }
181 
182 
183 void
185  myCurrentData.front()->myValues->addTo(val);
186 }
187 
188 
189 void
191  myTrackedData[&veh]->myValues->notifyMoveInternal(veh, timeOnLane, speed);
192 }
193 
194 
195 bool
197  if (myParent == 0 || reason != MSMoveReminder::NOTIFICATION_SEGMENT) {
198  myTrackedData[&veh]->myNumVehicleLeft++;
199  }
200  return myTrackedData[&veh]->myValues->notifyLeave(veh, lastPos, reason);
201 }
202 
203 
204 bool
206  if (reason == MSMoveReminder::NOTIFICATION_SEGMENT) {
207  return true;
208  }
209  if (vehicleApplies(veh) && myTrackedData.find(&veh) == myTrackedData.end()) {
210  myTrackedData[&veh] = myCurrentData.back();
211  myTrackedData[&veh]->myNumVehicleEntered++;
212  if (!myTrackedData[&veh]->myValues->notifyEnter(veh, reason)) {
213  myTrackedData[&veh]->myNumVehicleLeft++;
214  myTrackedData.erase(&veh);
215  return false;
216  }
217  return true;
218  }
219  return false;
220 }
221 
222 
223 bool
225  return myCurrentData.front()->myValues->isEmpty();
226 }
227 
228 
229 void
231  const SUMOTime period,
232  const SUMOReal numLanes,
233  const SUMOReal defaultTravelTime,
234  const int /*numVehicles*/) const {
235  myCurrentData.front()->myValues->write(dev, period, numLanes,
236  defaultTravelTime,
237  myCurrentData.front()->myNumVehicleEntered);
238 }
239 
240 
241 int
243  int result = 0;
244  for (std::list<TrackerEntry*>::const_iterator it = myCurrentData.begin(); it != myCurrentData.end(); ++it) {
245  if ((*it)->myNumVehicleEntered == (*it)->myNumVehicleLeft) {
246  result++;
247  } else {
248  break;
249  }
250  }
251  return result;
252 }
253 
254 
255 SUMOReal
257  return myCurrentData.front()->myValues->getSamples();
258 }
259 
260 
261 // ---------------------------------------------------------------------------
262 // MSMeanData - methods
263 // ---------------------------------------------------------------------------
264 MSMeanData::MSMeanData(const std::string& id,
265  const SUMOTime dumpBegin, const SUMOTime dumpEnd,
266  const bool useLanes, const bool withEmpty,
267  const bool printDefaults, const bool withInternal, const bool trackVehicles,
268  const SUMOReal maxTravelTime,
269  const SUMOReal minSamples,
270  const std::set<std::string> vTypes) :
272  myMinSamples(minSamples),
273  myMaxTravelTime(maxTravelTime),
274  myVehicleTypes(vTypes),
275  myDumpEmpty(withEmpty),
276  myAmEdgeBased(!useLanes),
277  myDumpBegin(dumpBegin),
278  myDumpEnd(dumpEnd),
279  myPrintDefaults(printDefaults),
280  myDumpInternal(withInternal),
281  myTrackVehicles(trackVehicles) {
282 }
283 
284 
285 void
288  for (MSEdgeVector::const_iterator e = edges.begin(); e != edges.end(); ++e) {
289  const MSEdge::EdgeBasicFunction efun = (*e)->getPurpose();
292  myEdges.push_back(*e);
293  myMeasures.push_back(std::vector<MeanDataValues*>());
294  const std::vector<MSLane*>& lanes = (*e)->getLanes();
296  MeanDataValues* data;
297  if (myTrackVehicles) {
298  data = new MeanDataValueTracker(0, lanes[0]->getLength(), &myVehicleTypes, this);
299  } else {
300  data = createValues(0, lanes[0]->getLength(), false);
301  }
302  data->setDescription("meandata_" + (*e)->getID());
303  myMeasures.back().push_back(data);
305  while (s != 0) {
306  s->addDetector(data);
307  s->prepareDetectorForWriting(*data);
308  s = s->getNextSegment();
309  }
310  data->reset();
311  data->reset(true);
312  continue;
313  }
315  myMeasures.back().push_back(new MeanDataValueTracker(0, lanes[0]->getLength(), &myVehicleTypes, this));
316  }
317  for (std::vector<MSLane*>::const_iterator lane = lanes.begin(); lane != lanes.end(); ++lane) {
318  if (myTrackVehicles) {
319  if (myAmEdgeBased) {
320  (*lane)->addMoveReminder(myMeasures.back().back());
321  } else {
322  myMeasures.back().push_back(new MeanDataValueTracker(*lane, (*lane)->getLength(), &myVehicleTypes, this));
323  }
324  } else {
325  myMeasures.back().push_back(createValues(*lane, (*lane)->getLength(), true));
326  }
327  }
328  }
329  }
330 }
331 
332 
334  for (std::vector<std::vector<MeanDataValues*> >::const_iterator i = myMeasures.begin(); i != myMeasures.end(); ++i) {
335  for (std::vector<MeanDataValues*>::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
336  delete *j;
337  }
338  }
339 }
340 
341 
342 void
344  UNUSED_PARAMETER(stopTime);
346  MSEdgeVector::iterator edge = myEdges.begin();
347  for (std::vector<std::vector<MeanDataValues*> >::const_iterator i = myMeasures.begin(); i != myMeasures.end(); ++i, ++edge) {
349  MeanDataValues* data = i->front();
350  while (s != 0) {
351  s->prepareDetectorForWriting(*data);
352  s = s->getNextSegment();
353  }
354  data->reset();
355  }
356  return;
357  }
358  for (std::vector<std::vector<MeanDataValues*> >::const_iterator i = myMeasures.begin(); i != myMeasures.end(); ++i) {
359  for (std::vector<MeanDataValues*>::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
360  (*j)->reset();
361  }
362  }
363 }
364 
365 
366 std::string
367 MSMeanData::getEdgeID(const MSEdge* const edge) {
368  return edge->getID();
369 }
370 
371 
372 void
374  const std::vector<MeanDataValues*>& edgeValues,
375  MSEdge* edge, SUMOTime startTime, SUMOTime stopTime) {
378  MeanDataValues* data = edgeValues.front();
379  while (s != 0) {
380  s->prepareDetectorForWriting(*data);
381  s = s->getNextSegment();
382  }
383  if (writePrefix(dev, *data, SUMO_TAG_EDGE, getEdgeID(edge))) {
384  data->write(dev, stopTime - startTime,
385  (SUMOReal)edge->getLanes().size(),
386  myPrintDefaults ? edge->getLength() / edge->getSpeedLimit() : -1.);
387  }
388  data->reset(true);
389  return;
390  }
391  std::vector<MeanDataValues*>::const_iterator lane;
392  if (!myAmEdgeBased) {
393  bool writeCheck = myDumpEmpty;
394  if (!writeCheck) {
395  for (lane = edgeValues.begin(); lane != edgeValues.end(); ++lane) {
396  if (!(*lane)->isEmpty()) {
397  writeCheck = true;
398  break;
399  }
400  }
401  }
402  if (writeCheck) {
404  }
405  for (lane = edgeValues.begin(); lane != edgeValues.end(); ++lane) {
406  MeanDataValues& meanData = **lane;
407  if (writePrefix(dev, meanData, SUMO_TAG_LANE, meanData.getLane()->getID())) {
408  meanData.write(dev, stopTime - startTime, 1.f, myPrintDefaults ? meanData.getLane()->getLength() / meanData.getLane()->getSpeedLimit() : -1.);
409  }
410  meanData.reset(true);
411  }
412  if (writeCheck) {
413  dev.closeTag();
414  }
415  } else {
416  if (myTrackVehicles) {
417  MeanDataValues& meanData = **edgeValues.begin();
418  if (writePrefix(dev, meanData, SUMO_TAG_EDGE, edge->getID())) {
419  meanData.write(dev, stopTime - startTime, (SUMOReal)edge->getLanes().size(), myPrintDefaults ? edge->getLength() / edge->getSpeedLimit() : -1.);
420  }
421  meanData.reset(true);
422  } else {
423  MeanDataValues* sumData = createValues(0, edge->getLength(), false);
424  for (lane = edgeValues.begin(); lane != edgeValues.end(); ++lane) {
425  MeanDataValues& meanData = **lane;
426  meanData.addTo(*sumData);
427  meanData.reset();
428  }
429  if (writePrefix(dev, *sumData, SUMO_TAG_EDGE, getEdgeID(edge))) {
430  sumData->write(dev, stopTime - startTime, (SUMOReal)edge->getLanes().size(), myPrintDefaults ? edge->getLength() / edge->getSpeedLimit() : -1.);
431  }
432  delete sumData;
433  }
434  }
435 }
436 
437 
438 void
439 MSMeanData::openInterval(OutputDevice& dev, const SUMOTime startTime, const SUMOTime stopTime) {
442 }
443 
444 
445 bool
446 MSMeanData::writePrefix(OutputDevice& dev, const MeanDataValues& values, const SumoXMLTag tag, const std::string id) const {
447  if (myDumpEmpty || !values.isEmpty()) {
448  dev.openTag(tag).writeAttr(SUMO_ATTR_ID, id).writeAttr("sampledSeconds", values.getSamples());
449  return true;
450  }
451  return false;
452 }
453 
454 
455 void
457  SUMOTime startTime, SUMOTime stopTime) {
458  // check whether this dump shall be written for the current time
459  int numReady = myDumpBegin < stopTime && myDumpEnd - DELTA_T >= startTime ? 1 : 0;
460  if (myTrackVehicles && myDumpBegin < stopTime) {
461  myPendingIntervals.push_back(std::make_pair(startTime, stopTime));
462  numReady = (int)myPendingIntervals.size();
463  for (std::vector<std::vector<MeanDataValues*> >::const_iterator i = myMeasures.begin(); i != myMeasures.end(); ++i) {
464  for (std::vector<MeanDataValues*>::const_iterator j = (*i).begin(); j != (*i).end(); ++j) {
465  numReady = MIN2(numReady, ((MeanDataValueTracker*)*j)->getNumReady());
466  if (numReady == 0) {
467  break;
468  }
469  }
470  if (numReady == 0) {
471  break;
472  }
473  }
474  }
475  if (numReady == 0 || myTrackVehicles) {
476  resetOnly(stopTime);
477  }
478  while (numReady-- > 0) {
479  if (!myPendingIntervals.empty()) {
480  startTime = myPendingIntervals.front().first;
481  stopTime = myPendingIntervals.front().second;
482  myPendingIntervals.pop_front();
483  }
484  openInterval(dev, startTime, stopTime);
485  MSEdgeVector::iterator edge = myEdges.begin();
486  for (std::vector<std::vector<MeanDataValues*> >::const_iterator i = myMeasures.begin(); i != myMeasures.end(); ++i, ++edge) {
487  writeEdge(dev, (*i), *edge, startTime, stopTime);
488  }
489  dev.closeTag();
490  }
491 }
492 
493 
494 void
496  dev.writeXMLHeader("meandata", "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/meandata_file.xsd\"");
497 }
498 
499 
500 void
502  if (step + DELTA_T == myDumpBegin) {
503  init();
504  }
505 }
506 
507 
508 /****************************************************************************/
509 
Data collector for edges/lanes.
Definition: MSMeanData.h:67
virtual ~MeanDataValueTracker()
Destructor.
Definition: MSMeanData.cpp:155
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:257
virtual MSMeanData::MeanDataValues * createValues(MSLane *const lane, const SUMOReal length, const bool doAdd) const =0
Create an instance of MeanDataValues.
SumoXMLTag
Numbers representing SUMO-XML - element names.
const SUMOReal myLaneLength
The length of the lane / edge the data collector is on.
Definition: MSMeanData.h:173
long long int SUMOTime
Definition: SUMOTime.h:43
std::vector< std::vector< MeanDataValues * > > myMeasures
Value collectors; sorted by edge, then by lane.
Definition: MSMeanData.h:443
MeanDataValues(MSLane *const lane, const SUMOReal length, const bool doAdd, const std::set< std::string > *const vTypes=0)
Constructor.
Definition: MSMeanData.cpp:61
const bool myDumpInternal
Whether internal lanes/edges shall be written.
Definition: MSMeanData.h:462
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:192
const SUMOTime myDumpEnd
Definition: MSMeanData.h:453
const std::set< std::string > *const myVehicleTypes
The vehicle types to look for (0 or empty means all)
Definition: MSMeanData.h:186
The vehicle arrived at a junction.
SUMOReal getLength() const
Returns the lane&#39;s length.
Definition: MSLane.h:475
MSLane *const myLane
Lane on which the reminder works.
const SUMOReal myMaxTravelTime
the maximum travel time to write
Definition: MSMeanData.h:437
Notification
Definition of a vehicle state.
SUMOReal getLength() const
Get vehicle&#39;s length [m].
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:159
SUMOTime DELTA_T
Definition: SUMOTime.cpp:39
The vehicle changes the segment (meso only)
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Computes current values and adds them to their sums.
Definition: MSMeanData.cpp:205
const std::set< std::string > myVehicleTypes
The vehicle types to look for (empty means all)
Definition: MSMeanData.h:440
#define TS
Definition: SUMOTime.h:52
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.
Definition: MSMeanData.cpp:446
EdgeBasicFunction
Defines possible edge types.
Definition: MSEdge.h:89
const MSMeanData * myParent
The meandata parent.
Definition: MSMeanData.h:305
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:39
const MSLane * getLane() const
Returns the lane the reminder works on.
std::list< TrackerEntry * > myCurrentData
The currently active meandata "intervals".
Definition: MSMeanData.h:302
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
const std::string & getID() const
Returns the id.
Definition: Named.h:66
A road/street connecting two junctions.
Definition: MSEdge.h:80
const bool myPrintDefaults
Whether empty lanes/edges shall be written.
Definition: MSMeanData.h:459
MeanDataValueTracker(MSLane *const lane, const SUMOReal length, const std::set< std::string > *const vTypes=0, const MSMeanData *const parent=0)
Constructor.
Definition: MSMeanData.cpp:146
SUMOReal getLength() const
return the length of the edge
Definition: MSEdge.h:585
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
Definition: MESegment.h:158
virtual bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Called if the vehicle leaves the reminder&#39;s lane.
Definition: MSMeanData.cpp:111
Representation of a vehicle.
Definition: SUMOVehicle.h:66
Data structure for mean (aggregated) edge/lane values.
Definition: MSMeanData.h:76
Definition: MSMeanData.h:277
MSEdgeVector myEdges
The corresponding first edges.
Definition: MSMeanData.h:456
const bool myAmEdgeBased
Information whether the output shall be edge-based (not lane-based)
Definition: MSMeanData.h:450
virtual bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason)
Called if the vehicle enters the reminder&#39;s lane.
Definition: MSMeanData.cpp:76
virtual bool isEmpty() const
Returns whether any data was collected.
Definition: MSMeanData.cpp:127
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
T MIN2(T a, T b)
Definition: StdDefs.h:69
void addDetector(MSMoveReminder *data)
Adds a data collector for a detector to this segment.
Definition: MESegment.cpp:194
virtual void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "netstats" as root element.
Definition: MSMeanData.cpp:495
SUMOReal getSpeedLimit() const
Returns the lane&#39;s maximum allowed speed.
Definition: MSLane.h:467
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)
Definition: MSMeanData.h:453
virtual void notifyMoveInternal(SUMOVehicle &veh, SUMOReal timeOnLane, SUMOReal speed)
Internal notification about the vehicle moves.
virtual ~MSMeanData()
Destructor.
Definition: MSMeanData.cpp:333
SUMOReal getSpeedLimit() const
Returns the speed limit of the edge The speed limit of the first lane is retured; should probably be...
Definition: MSEdge.cpp:762
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
Definition: MSMeanData.cpp:83
const SUMOReal myMinSamples
the minimum sample seconds
Definition: MSMeanData.h:434
void notifyMoveInternal(SUMOVehicle &veh, SUMOReal timeOnLane, SUMOReal speed)
Internal notification about the vehicle moves.
Definition: MSMeanData.cpp:190
bool isEmpty() const
Returns whether any data was collected.
Definition: MSMeanData.cpp:224
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.
Definition: MSMeanData.cpp:439
void setDescription(const std::string &description)
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:206
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::set< std::string > vTypes)
Constructor.
Definition: MSMeanData.cpp:264
The edge is a pedestrian walking area (a special type of internal edge)
Definition: MSEdge.h:103
void addTo(MSMeanData::MeanDataValues &val) const
Add the values of this to the given one and store them there.
Definition: MSMeanData.cpp:184
virtual ~MeanDataValues()
Destructor.
Definition: MSMeanData.cpp:71
std::string myID
The name of the object.
Definition: Named.h:136
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
Definition: MSMeanData.cpp:456
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) ...
Definition: MSMeanData.h:468
virtual bool hasArrived() const =0
Returns whether this vehicle has arrived.
void writeEdge(OutputDevice &dev, const std::vector< MeanDataValues * > &edgeValues, MSEdge *edge, SUMOTime startTime, SUMOTime stopTime)
Writes edge values into the given stream.
Definition: MSMeanData.cpp:373
A single mesoscopic segment (cell)
Definition: MESegment.h:57
virtual void update()
Called if a per timestep update is needed. Default does nothing.
Definition: MSMeanData.cpp:133
The edge is a pedestrian crossing (a special type of internal edge)
Definition: MSEdge.h:101
MESegment * getSegmentForEdge(const MSEdge &e, SUMOReal pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:295
const std::string & getID() const
Returns the name of the vehicle type.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:102
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.
Definition: MSMeanData.cpp:230
std::map< SUMOVehicle *, TrackerEntry * > myTrackedData
The map of vehicles to data entries.
Definition: MSMeanData.h:299
virtual void detectorUpdate(const SUMOTime step)
Updates the detector.
Definition: MSMeanData.cpp:501
SUMOReal getSamples() const
Returns the number of collected sample seconds.
Definition: MSMeanData.cpp:256
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
bool closeTag()
Closes the most recently opened tag.
#define SUMOReal
Definition: config.h:213
virtual SUMOReal getSamples() const
Returns the number of collected sample seconds.
Definition: MSMeanData.cpp:138
MSEdgeControl & getEdgeControl()
Returns the edge control.
Definition: MSNet.h:350
bool vehicleApplies(const SUMOVehicle &veh) const
Tests whether the vehicles type is to be regarded.
Definition: MSMeanData.cpp:120
void prepareDetectorForWriting(MSMoveReminder &data)
Updates data of a detector for all vehicle queues.
Definition: MESegment.cpp:236
std::vector< MSEdge * > MSEdgeVector
Definition: MSEdge.h:77
void resetOnly(SUMOTime stopTime)
Resets network value in order to allow processing of the next interval.
Definition: MSMeanData.cpp:343
const bool myDumpEmpty
Whether empty lanes/edges shall be written.
Definition: MSMeanData.h:446
The edge is an internal edge.
Definition: MSEdge.h:97
Data structure for mean (aggregated) edge/lane values for tracked vehicles.
Definition: MSMeanData.h:195
const bool myTrackVehicles
Whether vehicles are tracked.
Definition: MSMeanData.h:465
static bool gUseMesoSim
Definition: MSGlobals.h:90
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
virtual const std::string & getID() const =0
Get the vehicle&#39;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.
Definition: MSMeanData.cpp:367
Base of value-generating classes (detectors)
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Called if the vehicle leaves the reminder&#39;s lane.
Definition: MSMeanData.cpp:196
const MSEdgeVector & getEdges() const
Returns loaded edges.
void init()
Adds the value collectors to all relevant edges.
Definition: MSMeanData.cpp:286
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.
void reset(bool afterWrite)
Resets values so they may be used for the next interval.
Definition: MSMeanData.cpp:172