54 myCollector(collector), myPosition(crossSection.myPosition) {
60 #ifdef DEBUG_E3_NOTIFY_ENTER 64 <<
" vehicle '" << veh.
getID() <<
"'" 65 <<
" enteredLane=" << enteredLane->
getID()
66 <<
" reason=" << reason
75 itVeh->second.entryReminder !=
this) {
76 #ifdef DEBUG_E3_NOTIFY_ENTER 90 double newPos,
double newSpeed) {
91 #ifdef DEBUG_E3_NOTIFY_MOVE 95 <<
" vehicle '" << veh.
getID() <<
"'" 96 <<
" entered. oldPos=" << oldPos <<
" newPos=" << newPos <<
" newSpeed=" << newSpeed
104 #ifdef DEBUG_E3_NOTIFY_MOVE 114 const double fractionTimeOnDet =
TS - timeBeforeEnter;
115 myCollector.
enter(veh, entryTime - fractionTimeOnDet, fractionTimeOnDet,
this);
116 #ifdef DEBUG_E3_NOTIFY_MOVE 127 #ifdef DEBUG_E3_NOTIFY_LEAVE 131 <<
" vehicle '" << veh.
getID() <<
"'" 132 <<
" reason=" << reason
157 #ifdef DEBUG_E3_NOTIFY_ENTER 161 <<
" vehicle '" << veh.
getID() <<
"'" 162 <<
" enteredLane=" << enteredLane->
getID()
163 <<
" reason=" << reason
172 #ifdef DEBUG_E3_NOTIFY_ENTER 184 double newPos,
double newSpeed) {
185 #ifdef DEBUG_E3_NOTIFY_MOVE 189 <<
" vehicle '" << veh.
getID() <<
"'" 190 <<
" entered. oldPos=" << oldPos <<
" newPos=" << newPos <<
" newSpeed=" << newSpeed
204 const double leaveTimeFront =
SIMTIME -
TS + timeBeforeLeave;
206 #ifdef DEBUG_E3_NOTIFY_MOVE 217 const double leaveStep =
SIMTIME;
221 #ifdef DEBUG_E3_NOTIFY_MOVE 230 #ifdef DEBUG_E3_NOTIFY_LEAVE 234 <<
" vehicle '" << veh.
getID() <<
"'" 235 <<
" reason=" << reason
241 #ifdef DEBUG_E3_NOTIFY_LEAVE 242 if (
DEBUG_COND(
myCollector) && DEBUG_COND_VEH(veh)) std::cout <<
" remove reminder, keep in container\n";
266 double haltingSpeedThreshold,
268 const std::string& vTypes,
311 const double speedFraction = veh.
getSpeed() * fractionTimeOnDet;
364 const double speedFraction = veh.
getSpeed() * (
TS - fractionTimeOnDet);
383 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
myID <<
"\" ";
386 double meanTravelTime = 0.;
387 double meanOverlapTravelTime = 0.;
388 double meanSpeed = 0.;
389 double meanHaltsPerVehicle = 0.;
390 double meanTimeLoss = 0.;
392 meanHaltsPerVehicle += (double)values.haltings;
393 meanTravelTime += values.frontLeaveTime - values.entryTime;
394 const double steps = values.backLeaveTime - values.entryTime;
395 meanOverlapTravelTime += steps;
396 meanSpeed += (values.speedSum / steps);
399 meanTravelTime = vehicleSum != 0 ? meanTravelTime / (double)vehicleSum : -1;
400 meanOverlapTravelTime = vehicleSum != 0 ? meanOverlapTravelTime / (double)vehicleSum : -1;
401 meanSpeed = vehicleSum != 0 ? meanSpeed / (double)vehicleSum : -1;
402 meanHaltsPerVehicle = vehicleSum != 0 ? meanHaltsPerVehicle / (double) vehicleSum : -1;
403 meanTimeLoss = vehicleSum != 0 ? meanTimeLoss / (double) vehicleSum : -1;
405 myLeftContainer.clear();
409 double meanSpeedWithin = 0.;
410 double meanDurationWithin = 0.;
411 double meanHaltsPerVehicleWithin = 0.;
412 double meanIntervalSpeedWithin = 0.;
413 double meanIntervalHaltsPerVehicleWithin = 0.;
414 double meanIntervalDurationWithin = 0.;
415 double meanTimeLossWithin = 0.;
417 meanHaltsPerVehicleWithin += (double)(*i).second.haltings;
418 meanIntervalHaltsPerVehicleWithin += (
double)(*i).second.intervalHaltings;
419 const double end = (*i).second.backLeaveTime == 0 ?
STEPS2TIME(stopTime) : (*i).second.backLeaveTime;
420 const double time = end - (*i).second.entryTime;
421 const double timeWithin =
MIN2(time, end -
STEPS2TIME(startTime));
422 if (i->second.speedSum > 0.) {
423 meanSpeedWithin += i->second.speedSum / time;
425 if (i->second.intervalSpeedSum > 0.) {
426 meanIntervalSpeedWithin += i->second.intervalSpeedSum / timeWithin;
428 meanDurationWithin += time;
429 meanIntervalDurationWithin += timeWithin;
431 (*i).second.intervalHaltings = 0;
432 (*i).second.intervalSpeedSum = 0;
435 const SUMOTime currentTimeLoss =
static_cast<const MSVehicle*
>(i->first)->getTimeLoss();
436 meanTimeLossWithin +=
STEPS2TIME(currentTimeLoss - (*i).second.intervalTimeLoss);
437 (*i).second.intervalTimeLoss = currentTimeLoss;
441 meanSpeedWithin = vehicleSumWithin != 0 ? meanSpeedWithin / (double) vehicleSumWithin : -1;
442 meanHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanHaltsPerVehicleWithin / (double) vehicleSumWithin : -1;
443 meanDurationWithin = vehicleSumWithin != 0 ? meanDurationWithin / (double) vehicleSumWithin : -1;
444 meanIntervalSpeedWithin = vehicleSumWithin != 0 ? meanIntervalSpeedWithin / (double) vehicleSumWithin : -1;
445 meanIntervalHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanIntervalHaltsPerVehicleWithin / (double) vehicleSumWithin : -1;
446 meanIntervalDurationWithin = vehicleSumWithin != 0 ? meanIntervalDurationWithin / (double) vehicleSumWithin : -1;
447 meanTimeLossWithin = vehicleSumWithin != 0 ? meanTimeLossWithin / (double) vehicleSumWithin : -1;
450 dev <<
"meanTravelTime=\"" << meanTravelTime
451 <<
"\" meanOverlapTravelTime=\"" << meanOverlapTravelTime
452 <<
"\" meanSpeed=\"" << meanSpeed
453 <<
"\" meanHaltsPerVehicle=\"" << meanHaltsPerVehicle
454 <<
"\" meanTimeLoss=\"" << meanTimeLoss
455 <<
"\" vehicleSum=\"" << vehicleSum
456 <<
"\" meanSpeedWithin=\"" << meanSpeedWithin
457 <<
"\" meanHaltsPerVehicleWithin=\"" << meanHaltsPerVehicleWithin
458 <<
"\" meanDurationWithin=\"" << meanDurationWithin
459 <<
"\" vehicleSumWithin=\"" << vehicleSumWithin
460 <<
"\" meanIntervalSpeedWithin=\"" << meanIntervalSpeedWithin
461 <<
"\" meanIntervalHaltsPerVehicleWithin=\"" << meanIntervalHaltsPerVehicleWithin
462 <<
"\" meanIntervalDurationWithin=\"" << meanIntervalDurationWithin
463 <<
"\" meanTimeLossWithin=\"" << meanTimeLossWithin
480 #ifdef DEBUG_E3_DETECTORUPDATE 483 std::cout <<
SIMTIME <<
" vehPtr=" << veh <<
"\n";
484 std::cout <<
" veh=" << veh->
getID() <<
"\n";
533 std::vector<std::string>
535 std::vector<std::string> ret;
537 ret.push_back((*pair).first->getID());
539 std::sort(ret.begin(), ret.end());
double intervalSpeedSum
The sum of registered speeds the vehicle has/had inside the area during the current interval...
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
bool notifyMove(SUMOVehicle &veh, double, double newPos, double)
Checks whether the vehicle enters.
int haltings
The sum of haltings the vehicle has/had within the area.
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
virtual ~MSE3Collector()
Destructor.
A simple description of a position on a lane (crossing of a lane)
std::vector< MSE3EntryReminder * > myEntryReminders
The detector's built entry reminder.
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
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.
The vehicle arrived at a junction.
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.
double myHaltingSpeedThreshold
Speed-threshold to determine if a vehicle is halting.
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
std::vector< MSCrossSection > CrossSectionVector
double frontLeaveTime
The time the vehicle's front was crossing the leave line.
double myCurrentMeanSpeed
The current mean speed of known vehicles (inside)
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< std::string > getCurrentVehicleIDs() const
Returns the number of vehicles within the area.
const std::string & getID() const
Returns the id.
std::vector< MSE3LeaveReminder * > myLeaveReminders
The detector's built exit reminder.
bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Processes state changes of a vehicle.
#define WRITE_WARNING(msg)
double backLeaveTime
The time the vehicle's back was crossing the leave line.
int myCurrentHaltingsNumber
The current number of haltings (inside)
The vehicle changes lanes (micro only)
MSE3EntryReminder * entryReminder
the reminder on which the vehicle entered the detector
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.
double entryTime
The vehicle's entry time.
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.
void enter(const SUMOVehicle &veh, const double entryTimestep, const double fractionTimeOnDet, MSE3EntryReminder *entryReminder)
Called if a vehicle touches an entry-cross-section.
bool notifyEnter(SUMOVehicle &veh, Notification reason, const MSLane *enteredLane)
Checks whether the reminder is activated by a vehicle entering the lane.
double getCurrentMeanSpeed() const
Returns the mean speed within the area.
SUMOTime myHaltingTimeThreshold
The vehicle arrived at its destination (is deleted)
MSE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes, bool openEntry)
Constructor.
const bool myOpenEntry
whether this dector is declared as having incomplete entry detectors
MSE3Collector & myCollector
The parent collector.
Something on a lane to be noticed about vehicle movement.
bool notifyMove(SUMOVehicle &veh, double oldPos, double newPos, double)
Checks whether the vehicle leaves.
MSE3LeaveReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
void leaveFront(const SUMOVehicle &veh, const double leaveTimestep)
Called if a vehicle front passes a leave-cross-section.
void leave(const SUMOVehicle &veh, const double leaveTimestep, const double fractionTimeOnDet)
Called if a vehicle back passes a leave-cross-section.
std::vector< E3Values > myLeftContainer
Container for vehicles that have left the area.
SUMOTime haltingBegin
Begin time of last halt begin.
SUMOTime intervalTimeLoss
The timeLoss of the vehicle when entering. Updated to the current timeLoss at interval write...
CrossSectionVector myEntries
The detector's entries.
double myPosition
The position on the lane.
static double passingTime(const double lastPos, const double passedPos, const double currentPos, const double lastSpeed, const double currentSpeed)
Calculates the time at which the position passedPosition has been passed In case of a ballistic updat...
virtual double getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle's back position along the given lane.
std::string myID
The name of the object.
double speedSum
The sum of registered speeds the vehicle has/had inside the area.
const std::string & getDescription() const
bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Processes state changes of a vehicle.
double getLength() const
Get vehicle's length [m].
void reset()
Resets all generated values to allow computation of next interval.
A detector of vehicles passing an area between entry/exit points.
bool notifyEnter(SUMOVehicle &veh, Notification reason, const MSLane *enteredLane)
Checks whether the reminder is activated by a vehicle entering the lane.
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
int getVehiclesWithin() const
Returns the number of vehicles within the area.
void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
virtual double getSpeed() const =0
Returns the vehicle's current speed.
Representation of a lane in the micro simulation.
virtual double getPreviousSpeed() const =0
Returns the vehicle's previous speed.
virtual const std::string & getID() const =0
Get the vehicle's ID.
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)
double myPosition
The position on the lane.
The vehicle is being teleported.
CrossSectionVector myExits
The detector's exits.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "e3Detector" as root element.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.