 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
54 myCollector(collector), myPosition(crossSection.myPosition) {
60 #ifdef DEBUG_E3_NOTIFY_ENTER
61 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
63 <<
" MSE3EntryReminder::notifyEnter() (" << getDescription() <<
"on lane '" << myLane->getID() <<
"')"
64 <<
" vehicle '" << veh.
getID() <<
"'"
65 <<
" enteredLane=" << enteredLane->
getID()
66 <<
" reason=" << reason
70 if (reason != NOTIFICATION_JUNCTION) {
72 if (myLane == enteredLane && posOnLane > myPosition) {
73 const auto& itVeh = myCollector.myEnteredContainer.find(&veh);
74 if (itVeh == myCollector.myEnteredContainer.end() ||
75 itVeh->second.entryReminder !=
this) {
76 #ifdef DEBUG_E3_NOTIFY_ENTER
77 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
78 std::cout <<
" assume already known\n";
92 double newPos,
double newSpeed) {
93 #ifdef DEBUG_E3_NOTIFY_MOVE
94 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
96 <<
" MSE3EntryReminder::notifyMove() (" << getDescription() <<
"on lane '" << myLane->getID() <<
"')"
97 <<
" vehicle '" << veh.
getID() <<
"'"
98 <<
" entered. oldPos=" << oldPos <<
" newPos=" << newPos <<
" newSpeed=" << newSpeed
99 <<
" myPosition=" << myPosition
103 if (myCollector.myEnteredContainer.find(&veh) == myCollector.myEnteredContainer.end() && newPos > myPosition) {
104 if (oldPos > myPosition) {
106 #ifdef DEBUG_E3_NOTIFY_MOVE
107 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
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
121 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
122 std::cout <<
" enter\n";
133 #ifdef DEBUG_E3_NOTIFY_LEAVE
134 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
136 <<
" MSE3EntryReminder::notifyLeave() (" << getDescription() <<
"on lane '" << myLane->getID() <<
"')"
137 <<
" vehicle '" << veh.
getID() <<
"'"
138 <<
" reason=" << reason
143 if (myCollector.myEnteredContainer.erase(&veh) > 0) {
158 myCollector(collector), myPosition(crossSection.myPosition) {}
163 #ifdef DEBUG_E3_NOTIFY_ENTER
164 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
166 <<
" MSE3LeaveReminder::notifyEnter() (" << getDescription() <<
"on lane '" << myLane->getID() <<
"')"
167 <<
" vehicle '" << veh.
getID() <<
"'"
168 <<
" enteredLane=" << enteredLane->
getID()
169 <<
" reason=" << reason
173 if (reason != NOTIFICATION_JUNCTION) {
175 if (backPosOnLane > myPosition) {
178 #ifdef DEBUG_E3_NOTIFY_ENTER
179 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
180 std::cout <<
" assume already known\n";
192 double newPos,
double newSpeed) {
193 #ifdef DEBUG_E3_NOTIFY_MOVE
194 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
196 <<
" MSE3LeaveReminder::notifyMove() (" << getDescription() <<
" on lane '" << myLane->getID() <<
"')"
197 <<
" vehicle '" << veh.
getID() <<
"'"
198 <<
" entered. oldPos=" << oldPos <<
" newPos=" << newPos <<
" newSpeed=" << newSpeed
199 <<
" myPosition=" << myPosition
203 if (newPos < myPosition) {
208 if (oldPos < myPosition) {
212 const double leaveTimeFront =
SIMTIME -
TS + timeBeforeLeave;
213 myCollector.leaveFront(veh, leaveTimeFront);
214 #ifdef DEBUG_E3_NOTIFY_MOVE
215 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
216 std::cout <<
" leaveFront\n";
221 if (backPos < myPosition) {
227 const double leaveStep =
SIMTIME;
229 const double timeBeforeLeave =
MSCFModel::passingTime(oldBackPos, myPosition, backPos, oldSpeed, newSpeed);
230 myCollector.leave(veh, leaveStep -
TS + timeBeforeLeave, timeBeforeLeave);
231 #ifdef DEBUG_E3_NOTIFY_MOVE
232 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
233 std::cout <<
" leave\n";
242 #ifdef DEBUG_E3_NOTIFY_LEAVE
243 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
245 <<
" MSE3LeaveReminder::notifyLeave() (" << getDescription() <<
"on lane '" << myLane->getID() <<
"')"
246 <<
" vehicle '" << veh.
getID() <<
"'"
247 <<
" reason=" << reason
253 #ifdef DEBUG_E3_NOTIFY_LEAVE
254 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
255 std::cout <<
" remove reminder, keep in container\n";
262 myCollector.myEnteredContainer.erase(&veh);
266 if (myCollector.myEnteredContainer.erase(&veh) > 0) {
280 double haltingSpeedThreshold,
282 const std::string& vTypes,
325 const double speedFraction = veh.
getSpeed() * fractionTimeOnDet;
343 v.
timeLoss = static_cast<const MSVehicle&>(veh).getTimeLoss();
378 const double speedFraction = veh.
getSpeed() * (
TS - fractionTimeOnDet);
386 values.
timeLoss = static_cast<const MSVehicle&>(veh).getTimeLoss() - values.
timeLoss;
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;
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());
The vehicle changes lanes (micro only)
Representation of a vehicle or person.
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
int getVehiclesWithin() const
Returns the number of vehicles within the area.
CrossSectionVector myExits
The detector's exits.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "e3Detector" as root element.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double)
Checks whether the vehicle leaves.
double entryTime
The vehicle's entry time.
double myCurrentMeanSpeed
The current mean speed of known vehicles (inside)
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane)
Checks whether the reminder is activated by a vehicle entering the lane.
#define WRITE_WARNING(msg)
Base of value-generating classes (detectors)
Representation of a lane in the micro simulation.
A detector of vehicles passing an area between entry/exit points.
Static storage of an output device and its base (abstract) implementation.
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
MSE3LeaveReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
virtual ~MSE3Collector()
Destructor.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
void enter(const SUMOTrafficObject &veh, const double entryTimestep, const double fractionTimeOnDet, MSE3EntryReminder *entryReminder)
Called if a vehicle touches an entry-cross-section.
virtual const std::string & getID() const =0
Get the vehicle's ID.
bool hadUpdate
An internal information whether the update step was performed.
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane)
Checks whether the reminder is activated by a vehicle entering the lane.
double intervalSpeedSum
The sum of registered speeds the vehicle has/had inside the area during the current interval.
void leaveFront(const SUMOTrafficObject &veh, const double leaveTimestep)
Called if a vehicle front passes a leave-cross-section.
CrossSectionVector::const_iterator CrossSectionVectorConstIt
MSE3EntryReminder * entryReminder
the reminder on which the vehicle entered the detector
SUMOTime myLastResetTime
Information when the last reset has been done.
std::vector< MSE3LeaveReminder * > myLeaveReminders
The detector's built exit reminder.
A simple description of a position on a lane (crossing of a lane)
std::vector< MSE3EntryReminder * > myEntryReminders
The detector's built entry reminder.
double frontLeaveTime
The time the vehicle's front was crossing the leave line.
int intervalHaltings
The sum of haltings the vehicle has/had within the area during the current interval.
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.
std::vector< std::string > getCurrentVehicleIDs() const
Returns the number of vehicles within the area.
int myCurrentHaltingsNumber
The current number of haltings (inside)
Something on a lane to be noticed about vehicle movement.
double myHaltingSpeedThreshold
Speed-threshold to determine if a vehicle is halting.
bool notifyMove(SUMOTrafficObject &veh, double, double newPos, double)
Checks whether the vehicle enters.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Processes state changes of a vehicle.
MSE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes, bool openEntry)
Constructor.
double speedSum
The sum of registered speeds the vehicle has/had inside the area.
std::string time2string(SUMOTime t)
double getCurrentMeanSpeed() const
Returns the mean speed within the area.
SUMOTime myHaltingTimeThreshold
std::map< const SUMOTrafficObject *, E3Values > myEnteredContainer
Container for vehicles that have entered the area.
const bool myOpenEntry
whether this dector is declared as having incomplete entry detectors
SUMOTime haltingBegin
Begin time of last halt begin.
void leave(const SUMOTrafficObject &veh, const double leaveTimestep, const double fractionTimeOnDet)
Called if a vehicle back passes a leave-cross-section.
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 ends.
MSEdge & getEdge() const
Returns the lane's edge.
A place on the road net (at a certain lane and position on it) where the E3 area begins.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
std::vector< E3Values > myLeftContainer
Container for vehicles that have left the area.
int haltings
The sum of haltings the vehicle has/had within the area.
SUMOTime intervalTimeLoss
The timeLoss of the vehicle when entering. Updated to the current timeLoss at interval write.
The vehicle arrived at its destination (is deleted)
virtual double getPreviousSpeed() const =0
Returns the vehicle's previous speed.
CrossSectionVector myEntries
The detector's entries.
double getLength() const
Get vehicle's length [m].
Internal storage for values from a vehicle.
SUMOTime timeLoss
The timeLoss of the vehicle when entering. Updated to the actual time loss within the area when leavi...
bool vehicleApplies(const SUMOTrafficObject &veh) const
Checks whether the detector measures vehicles of the given type.
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...
void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
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.
static bool gSemiImplicitEulerUpdate
std::string myID
The name of the object.
const std::string & getID() const
Returns the id.
Notification
Definition of a vehicle state.
std::vector< MSCrossSection > CrossSectionVector
void reset()
Resets all generated values to allow computation of next interval.
The vehicle is being teleported.
virtual double getSpeed() const =0
Returns the vehicle's current speed.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Processes state changes of a vehicle.