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 78 std::cout <<
" assume already known\n";
92 double newPos,
double newSpeed) {
93 #ifdef DEBUG_E3_NOTIFY_MOVE 97 <<
" vehicle '" << veh.
getID() <<
"'" 98 <<
" entered. oldPos=" << oldPos <<
" newPos=" << newPos <<
" newSpeed=" << newSpeed
106 #ifdef DEBUG_E3_NOTIFY_MOVE 108 std::cout <<
" already behind\n";
118 const double fractionTimeOnDet =
TS - timeBeforeEnter;
119 myCollector.
enter(veh, entryTime - fractionTimeOnDet, fractionTimeOnDet,
this);
120 #ifdef DEBUG_E3_NOTIFY_MOVE 122 std::cout <<
" enter\n";
133 #ifdef DEBUG_E3_NOTIFY_LEAVE 137 <<
" vehicle '" << veh.
getID() <<
"'" 138 <<
" reason=" << reason
163 #ifdef DEBUG_E3_NOTIFY_ENTER 167 <<
" vehicle '" << veh.
getID() <<
"'" 168 <<
" enteredLane=" << enteredLane->
getID()
169 <<
" reason=" << reason
178 #ifdef DEBUG_E3_NOTIFY_ENTER 180 std::cout <<
" assume already known\n";
192 double newPos,
double newSpeed) {
193 #ifdef DEBUG_E3_NOTIFY_MOVE 197 <<
" vehicle '" << veh.
getID() <<
"'" 198 <<
" entered. oldPos=" << oldPos <<
" newPos=" << newPos <<
" newSpeed=" << newSpeed
212 const double leaveTimeFront =
SIMTIME -
TS + timeBeforeLeave;
214 #ifdef DEBUG_E3_NOTIFY_MOVE 216 std::cout <<
" leaveFront\n";
227 const double leaveStep =
SIMTIME;
231 #ifdef DEBUG_E3_NOTIFY_MOVE 233 std::cout <<
" leave\n";
242 #ifdef DEBUG_E3_NOTIFY_LEAVE 246 <<
" vehicle '" << veh.
getID() <<
"'" 247 <<
" reason=" << reason
253 #ifdef DEBUG_E3_NOTIFY_LEAVE 255 std::cout <<
" remove reminder, keep in container\n";
280 double haltingSpeedThreshold,
282 const std::string& vTypes,
325 const double speedFraction = veh.
getSpeed() * fractionTimeOnDet;
378 const double speedFraction = veh.
getSpeed() * (
TS - fractionTimeOnDet);
397 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
myID <<
"\" ";
400 double meanTravelTime = 0.;
401 double meanOverlapTravelTime = 0.;
402 double meanSpeed = 0.;
403 double meanHaltsPerVehicle = 0.;
404 double meanTimeLoss = 0.;
406 meanHaltsPerVehicle += (double)values.haltings;
407 meanTravelTime += values.frontLeaveTime - values.entryTime;
408 const double steps = values.backLeaveTime - values.entryTime;
409 meanOverlapTravelTime += steps;
410 meanSpeed += (values.speedSum / steps);
413 meanTravelTime = vehicleSum != 0 ? meanTravelTime / (double)vehicleSum : -1;
414 meanOverlapTravelTime = vehicleSum != 0 ? meanOverlapTravelTime / (double)vehicleSum : -1;
415 meanSpeed = vehicleSum != 0 ? meanSpeed / (double)vehicleSum : -1;
416 meanHaltsPerVehicle = vehicleSum != 0 ? meanHaltsPerVehicle / (double) vehicleSum : -1;
417 meanTimeLoss = vehicleSum != 0 ? meanTimeLoss / (double) vehicleSum : -1;
419 myLeftContainer.clear();
423 double meanSpeedWithin = 0.;
424 double meanDurationWithin = 0.;
425 double meanHaltsPerVehicleWithin = 0.;
426 double meanIntervalSpeedWithin = 0.;
427 double meanIntervalHaltsPerVehicleWithin = 0.;
428 double meanIntervalDurationWithin = 0.;
429 double meanTimeLossWithin = 0.;
431 meanHaltsPerVehicleWithin += (double)(*i).second.haltings;
432 meanIntervalHaltsPerVehicleWithin += (
double)(*i).second.intervalHaltings;
433 const double end = (*i).second.backLeaveTime == 0 ?
STEPS2TIME(stopTime) : (*i).second.backLeaveTime;
434 const double time = end - (*i).second.entryTime;
435 const double timeWithin =
MIN2(time, end -
STEPS2TIME(startTime));
436 if (i->second.speedSum > 0.) {
437 meanSpeedWithin += i->second.speedSum / time;
439 if (i->second.intervalSpeedSum > 0.) {
440 meanIntervalSpeedWithin += i->second.intervalSpeedSum / timeWithin;
442 meanDurationWithin += time;
443 meanIntervalDurationWithin += timeWithin;
445 (*i).second.intervalHaltings = 0;
446 (*i).second.intervalSpeedSum = 0;
449 const SUMOTime currentTimeLoss =
static_cast<const MSVehicle*
>(i->first)->getTimeLoss();
450 meanTimeLossWithin +=
STEPS2TIME(currentTimeLoss - (*i).second.intervalTimeLoss);
451 (*i).second.intervalTimeLoss = currentTimeLoss;
455 meanSpeedWithin = vehicleSumWithin != 0 ? meanSpeedWithin / (double) vehicleSumWithin : -1;
456 meanHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanHaltsPerVehicleWithin / (double) vehicleSumWithin : -1;
457 meanDurationWithin = vehicleSumWithin != 0 ? meanDurationWithin / (double) vehicleSumWithin : -1;
458 meanIntervalSpeedWithin = vehicleSumWithin != 0 ? meanIntervalSpeedWithin / (double) vehicleSumWithin : -1;
459 meanIntervalHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanIntervalHaltsPerVehicleWithin / (double) vehicleSumWithin : -1;
460 meanIntervalDurationWithin = vehicleSumWithin != 0 ? meanIntervalDurationWithin / (double) vehicleSumWithin : -1;
461 meanTimeLossWithin = vehicleSumWithin != 0 ? meanTimeLossWithin / (double) vehicleSumWithin : -1;
464 dev <<
"meanTravelTime=\"" << meanTravelTime
465 <<
"\" meanOverlapTravelTime=\"" << meanOverlapTravelTime
466 <<
"\" meanSpeed=\"" << meanSpeed
467 <<
"\" meanHaltsPerVehicle=\"" << meanHaltsPerVehicle
468 <<
"\" meanTimeLoss=\"" << meanTimeLoss
469 <<
"\" vehicleSum=\"" << vehicleSum
470 <<
"\" meanSpeedWithin=\"" << meanSpeedWithin
471 <<
"\" meanHaltsPerVehicleWithin=\"" << meanHaltsPerVehicleWithin
472 <<
"\" meanDurationWithin=\"" << meanDurationWithin
473 <<
"\" vehicleSumWithin=\"" << vehicleSumWithin
474 <<
"\" meanIntervalSpeedWithin=\"" << meanIntervalSpeedWithin
475 <<
"\" meanIntervalHaltsPerVehicleWithin=\"" << meanIntervalHaltsPerVehicleWithin
476 <<
"\" meanIntervalDurationWithin=\"" << meanIntervalDurationWithin
477 <<
"\" meanTimeLossWithin=\"" << meanTimeLossWithin
494 #ifdef DEBUG_E3_DETECTORUPDATE 497 std::cout <<
SIMTIME <<
" vehPtr=" << veh <<
"\n";
498 std::cout <<
" veh=" << veh->
getID() <<
"\n";
547 std::vector<std::string>
549 std::vector<std::string> ret;
551 ret.push_back((*pair).first->getID());
553 std::sort(ret.begin(), ret.end());
double intervalSpeedSum
The sum of registered speeds the vehicle has/had inside the area during the current interval...
bool vehicleApplies(const SUMOTrafficObject &veh) const
Checks whether the detector measures vehicles of the given type.
MSEdge & getEdge() const
Returns the lane's edge.
Representation of a vehicle in the micro simulation.
bool notifyMove(SUMOTrafficObject &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.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Processes state changes of a vehicle.
A simple description of a position on a lane (crossing of a lane)
virtual const std::string & getID() const =0
Get the vehicle's ID.
std::vector< MSE3EntryReminder * > myEntryReminders
The detector's built entry reminder.
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.
void leaveFront(const SUMOTrafficObject &veh, const double leaveTimestep)
Called if a vehicle front passes a leave-cross-section.
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.
#define WRITE_WARNING(msg)
double backLeaveTime
The time the vehicle's back was crossing the leave line.
virtual double getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle's back position along the given lane.
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)
Internal storage for values from a vehicle.
void leave(const SUMOTrafficObject &veh, const double leaveTimestep, const double fractionTimeOnDet)
Called if a vehicle back passes a leave-cross-section.
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.
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
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane)
Checks whether the reminder is activated by a vehicle entering the lane.
MSE3Collector & myCollector
The parent collector.
Something on a lane to be noticed about vehicle movement.
MSE3LeaveReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
std::vector< E3Values > myLeftContainer
Container for vehicles that have left the area.
virtual double getPreviousSpeed() const =0
Returns the vehicle's previous speed.
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.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Processes state changes of a vehicle.
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane)
Checks whether the reminder is activated by a vehicle entering 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...
std::string myID
The name of the object.
Representation of a vehicle or person.
double speedSum
The sum of registered speeds the vehicle has/had inside the area.
const std::string & getDescription() const
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double)
Checks whether the vehicle leaves.
std::map< const SUMOTrafficObject *, E3Values > myEnteredContainer
Container for vehicles that have entered the area.
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.
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.
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.
void enter(const SUMOTrafficObject &veh, const double entryTimestep, const double fractionTimeOnDet, MSE3EntryReminder *entryReminder)
Called if a vehicle touches an entry-cross-section.