40 #ifdef CHECK_MEMORY_LEAKS 42 #endif // CHECK_MEMORY_LEAKS 54 myCollector(collector), myPosition(crossSection.myPosition) {}
70 const SUMOReal fractionTimeOnDet =
TS - timeBeforeEnter;
144 const std::string& vTypes)
244 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
myID <<
"\" ";
248 SUMOReal meanOverlapTravelTime = 0.;
253 meanHaltsPerVehicle += (
SUMOReal)(*i).second.haltings;
254 meanTravelTime += (*i).second.frontLeaveTime - (*i).second.entryTime;
255 const SUMOReal steps = (*i).second.backLeaveTime - (*i).second.entryTime;
256 meanOverlapTravelTime += steps;
257 meanSpeed += ((*i).second.speedSum / steps);
258 meanTimeLoss +=
STEPS2TIME((*i).second.timeLoss);
260 meanTravelTime = vehicleSum != 0 ? meanTravelTime / (
SUMOReal)vehicleSum : -1;
261 meanOverlapTravelTime = vehicleSum != 0 ? meanOverlapTravelTime / (
SUMOReal)vehicleSum : -1;
262 meanSpeed = vehicleSum != 0 ? meanSpeed / (
SUMOReal)vehicleSum : -1;
263 meanHaltsPerVehicle = vehicleSum != 0 ? meanHaltsPerVehicle / (
SUMOReal) vehicleSum : -1;
264 meanTimeLoss = vehicleSum != 0 ? meanTimeLoss / (
SUMOReal) vehicleSum : -1;
272 SUMOReal meanHaltsPerVehicleWithin = 0.;
273 SUMOReal meanIntervalSpeedWithin = 0.;
274 SUMOReal meanIntervalHaltsPerVehicleWithin = 0.;
275 SUMOReal meanIntervalDurationWithin = 0.;
278 meanHaltsPerVehicleWithin += (
SUMOReal)(*i).second.haltings;
279 meanIntervalHaltsPerVehicleWithin += (
SUMOReal)(*i).second.intervalHaltings;
280 const SUMOReal end = (*i).second.backLeaveTime == 0 ?
STEPS2TIME(stopTime) : (*i).second.backLeaveTime;
281 const SUMOReal time = end - (*i).second.entryTime;
283 if (i->second.speedSum > 0.) {
284 meanSpeedWithin += i->second.speedSum / time;
286 if (i->second.intervalSpeedSum > 0.) {
287 meanIntervalSpeedWithin += i->second.intervalSpeedSum / timeWithin;
289 meanDurationWithin += time;
290 meanIntervalDurationWithin += timeWithin;
292 (*i).second.intervalHaltings = 0;
293 (*i).second.intervalSpeedSum = 0;
296 const SUMOTime currentTimeLoss =
static_cast<const MSVehicle*
>(i->first)->getTimeLoss();
297 meanTimeLossWithin +=
STEPS2TIME(currentTimeLoss - (*i).second.intervalTimeLoss);
298 (*i).second.intervalTimeLoss = currentTimeLoss;
302 meanSpeedWithin = vehicleSumWithin != 0 ? meanSpeedWithin / (
SUMOReal) vehicleSumWithin : -1;
303 meanHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanHaltsPerVehicleWithin / (
SUMOReal) vehicleSumWithin : -1;
304 meanDurationWithin = vehicleSumWithin != 0 ? meanDurationWithin / (
SUMOReal) vehicleSumWithin : -1;
305 meanIntervalSpeedWithin = vehicleSumWithin != 0 ? meanIntervalSpeedWithin / (
SUMOReal) vehicleSumWithin : -1;
306 meanIntervalHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanIntervalHaltsPerVehicleWithin / (
SUMOReal) vehicleSumWithin : -1;
307 meanIntervalDurationWithin = vehicleSumWithin != 0 ? meanIntervalDurationWithin / (
SUMOReal) vehicleSumWithin : -1;
308 meanTimeLossWithin = vehicleSumWithin != 0 ? meanTimeLossWithin / (
SUMOReal) vehicleSumWithin : -1;
311 dev <<
"meanTravelTime=\"" << meanTravelTime
312 <<
"\" meanOverlapTravelTime=\"" << meanOverlapTravelTime
313 <<
"\" meanSpeed=\"" << meanSpeed
314 <<
"\" meanHaltsPerVehicle=\"" << meanHaltsPerVehicle
315 <<
"\" meanTimeLoss=\"" << meanTimeLoss
316 <<
"\" vehicleSum=\"" << vehicleSum
317 <<
"\" meanSpeedWithin=\"" << meanSpeedWithin
318 <<
"\" meanHaltsPerVehicleWithin=\"" << meanHaltsPerVehicleWithin
319 <<
"\" meanDurationWithin=\"" << meanDurationWithin
320 <<
"\" vehicleSumWithin=\"" << vehicleSumWithin
321 <<
"\" meanIntervalSpeedWithin=\"" << meanIntervalSpeedWithin
322 <<
"\" meanIntervalHaltsPerVehicleWithin=\"" << meanIntervalHaltsPerVehicleWithin
323 <<
"\" meanIntervalDurationWithin=\"" << meanIntervalDurationWithin
324 <<
"\" meanTimeLossWithin=\"" << meanTimeLossWithin
385 std::vector<std::string>
387 std::vector<std::string> ret;
389 ret.push_back((*pair).first->getID());
391 std::sort(ret.begin(), ret.end());
Representation of a vehicle in the micro simulation.
int haltings
The sum of haltings the vehicle has/had within the area.
virtual ~MSE3Collector()
Destructor.
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Processes state changes of a vehicle.
A simple description of a position on a lane (crossing of a lane)
std::vector< MSE3EntryReminder * > myEntryReminders
The detector's built entry reminder.
SUMOReal entryTime
The vehicle's entry time.
bool hadUpdate
An internal information whether the update step was performed.
A place on the road net (at a certain lane and position on it) where the E3 area ends.
MSE3EntryReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
A place on the road net (at a certain lane and position on it) where the E3 area begins.
MSLane *const myLane
Lane on which the reminder works.
SUMOReal myPosition
The position on the lane.
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
void enter(const SUMOVehicle &veh, const SUMOReal entryTimestep, const SUMOReal fractionTimeOnDet)
Called if a vehicle touches an entry-cross-section.
std::vector< MSCrossSection > CrossSectionVector
SUMOReal getLength() const
Get vehicle's length [m].
SUMOReal backLeaveTime
The time the vehicle's back was crossing the leave line.
CrossSectionVector::const_iterator CrossSectionVectorConstIt
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime myLastResetTime
Information when the last reset has been done.
std::vector< MSE3LeaveReminder * > myLeaveReminders
The detector's built exit reminder.
#define WRITE_WARNING(msg)
SUMOReal haltingBegin
Begin time of last halt begin.
SUMOReal myPosition
The position on the lane.
int myCurrentHaltingsNumber
The current number of haltings (inside)
const std::string & getID() const
Returns the id.
The vehicle changes lanes (micro only) XXX: What if a vehicle changes lanes and passes a junction sim...
SUMOReal frontLeaveTime
The time the vehicle's front was crossing the leave line.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Representation of a vehicle.
std::map< const SUMOVehicle *, E3Values > myEnteredContainer
Container for vehicles that have entered the area.
Internal storage for values from a vehicle.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
virtual SUMOReal getSpeed() const =0
Returns the vehicle's current speed.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "e3Detector" as root element.
SUMOTime myHaltingTimeThreshold
The vehicle arrived at its destination (is deleted)
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...
MSE3Collector & myCollector
The parent collector.
SUMOReal myHaltingSpeedThreshold
Speed-threshold to determine if a vehicle is halting.
Something on a lane to be noticed about vehicle movement.
int getVehiclesWithin() const
Returns the number of vehicles within the area.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
MSE3LeaveReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
SUMOTime intervalTimeLoss
The timeLoss of the vehicle when entering. Updated to the current timeLoss at interval write...
CrossSectionVector myEntries
The detector's entries.
std::string myID
The name of the object.
void leaveFront(const SUMOVehicle &veh, const SUMOReal leaveTimestep)
Called if a vehicle front passes a leave-cross-section.
virtual const std::string & getID() const =0
Get the vehicle's ID.
void reset()
Resets all generated values to allow computation of next interval.
A detector of vehicles passing an area between entry/exit points.
bool notifyMove(SUMOVehicle &veh, SUMOReal, SUMOReal newPos, SUMOReal)
Checks whether the vehicle enters.
int intervalHaltings
The sum of haltings the vehicle has/had within the area during the current interval.
Static storage of an output device and its base (abstract) implementation.
static bool gSemiImplicitEulerUpdate
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Processes state changes of a vehicle.
SUMOReal speedSum
The sum of registered speeds the vehicle has/had inside the area.
SUMOReal getCurrentMeanSpeed() const
Returns the mean speed within the area.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal)
Checks whether the vehicle leaves.
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
virtual SUMOReal getPreviousSpeed() const =0
Returns the vehicle's previous speed.
void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
void leave(const SUMOVehicle &veh, const SUMOReal leaveTimestep, const SUMOReal fractionTimeOnDet)
Called if a vehicle back passes a leave-cross-section.
MSE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes)
Constructor.
SUMOReal intervalSpeedSum
The sum of registered speeds the vehicle has/had inside the area during the current interval...
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
MSE3Collector & myCollector
The parent collector.
SUMOTime timeLoss
The timeLoss of the vehicle when entering. Updated to the actual time loss within the area when leavi...
Base of value-generating classes (detectors)
std::vector< std::string > getCurrentVehicleIDs() const
Returns the number of vehicles within the area.
CrossSectionVector myExits
The detector's exits.
std::map< const SUMOVehicle *, E3Values > myLeftContainer
Container for vehicles that have left the area.
SUMOReal myCurrentMeanSpeed
The current mean speed of known vehicles (inside)