 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
53 myCollector(collector), myPosition(crossSection.myPosition) {
59 #ifdef DEBUG_E3_NOTIFY_ENTER
60 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
62 <<
" MSE3EntryReminder::notifyEnter() (" << getDescription() <<
"on lane '" << myLane->getID() <<
"')"
63 <<
" vehicle '" << veh.
getID() <<
"'"
64 <<
" enteredLane=" << enteredLane->
getID()
65 <<
" reason=" << reason
69 if (reason != NOTIFICATION_JUNCTION) {
71 if (myLane == enteredLane && posOnLane > myPosition) {
75 const auto& itVeh = myCollector.myEnteredContainer.find(&veh);
76 if (itVeh == myCollector.myEnteredContainer.end() ||
77 itVeh->second.entryReminder !=
this) {
78 #ifdef DEBUG_E3_NOTIFY_ENTER
79 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
80 std::cout <<
" assume already known\n";
94 double newPos,
double newSpeed) {
95 #ifdef DEBUG_E3_NOTIFY_MOVE
96 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
98 <<
" MSE3EntryReminder::notifyMove() (" << getDescription() <<
"on lane '" << myLane->getID() <<
"')"
99 <<
" vehicle '" << veh.
getID() <<
"'"
100 <<
" entered. oldPos=" << oldPos <<
" newPos=" << newPos <<
" newSpeed=" << newSpeed
101 <<
" myPosition=" << myPosition
108 if (myCollector.myEnteredContainer.find(&veh) == myCollector.myEnteredContainer.end() && newPos > myPosition) {
109 if (oldPos > myPosition) {
111 #ifdef DEBUG_E3_NOTIFY_MOVE
112 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
113 std::cout <<
" already behind\n";
123 const double fractionTimeOnDet =
TS - timeBeforeEnter;
124 myCollector.enter(veh, entryTime - fractionTimeOnDet, fractionTimeOnDet,
this);
125 #ifdef DEBUG_E3_NOTIFY_MOVE
126 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
127 std::cout <<
" enter\n";
138 #ifdef DEBUG_E3_NOTIFY_LEAVE
139 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
141 <<
" MSE3EntryReminder::notifyLeave() (" << getDescription() <<
"on lane '" << myLane->getID() <<
"')"
142 <<
" vehicle '" << veh.
getID() <<
"'"
143 <<
" reason=" << reason
151 if (myCollector.myEnteredContainer.erase(&veh) > 0) {
166 myCollector(collector), myPosition(crossSection.myPosition) {}
171 #ifdef DEBUG_E3_NOTIFY_ENTER
172 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
174 <<
" MSE3LeaveReminder::notifyEnter() (" << getDescription() <<
"on lane '" << myLane->getID() <<
"')"
175 <<
" vehicle '" << veh.
getID() <<
"'"
176 <<
" enteredLane=" << enteredLane->
getID()
177 <<
" reason=" << reason
182 if (reason != NOTIFICATION_JUNCTION) {
184 if (backPosOnLane > myPosition) {
187 #ifdef DEBUG_E3_NOTIFY_ENTER
188 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
189 std::cout <<
" assume already known\n";
201 double newPos,
double newSpeed) {
202 #ifdef DEBUG_E3_NOTIFY_MOVE
203 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
205 <<
" MSE3LeaveReminder::notifyMove() (" << getDescription() <<
" on lane '" << myLane->getID() <<
"')"
206 <<
" vehicle '" << veh.
getID() <<
"'"
207 <<
" entered. oldPos=" << oldPos <<
" newPos=" << newPos <<
" newSpeed=" << newSpeed
208 <<
" myPosition=" << myPosition
212 if (newPos < myPosition) {
220 if (oldPos < myPosition) {
224 const double leaveTimeFront =
SIMTIME -
TS + timeBeforeLeave;
225 myCollector.leaveFront(veh, leaveTimeFront);
226 #ifdef DEBUG_E3_NOTIFY_MOVE
227 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
228 std::cout <<
" leaveFront\n";
233 if (backPos < myPosition) {
239 const double leaveStep =
SIMTIME;
241 const double timeBeforeLeave =
MSCFModel::passingTime(oldBackPos, myPosition, backPos, oldSpeed, newSpeed);
242 myCollector.leave(veh, leaveStep -
TS + timeBeforeLeave, timeBeforeLeave);
243 #ifdef DEBUG_E3_NOTIFY_MOVE
244 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
245 std::cout <<
" leave\n";
254 #ifdef DEBUG_E3_NOTIFY_LEAVE
255 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
257 <<
" MSE3LeaveReminder::notifyLeave() (" << getDescription() <<
"on lane '" << myLane->getID() <<
"')"
258 <<
" vehicle '" << veh.
getID() <<
"'"
259 <<
" reason=" << reason
265 #ifdef DEBUG_E3_NOTIFY_LEAVE
266 if (
DEBUG_COND(myCollector) && DEBUG_COND_VEH(veh)) {
267 std::cout <<
" remove reminder, keep in container\n";
277 myCollector.myEnteredContainer.erase(&veh);
281 if (myCollector.myEnteredContainer.erase(&veh) > 0) {
295 double haltingSpeedThreshold,
297 const std::string& vTypes,
340 const double speedFraction = veh.
getSpeed() * fractionTimeOnDet;
358 v.
timeLoss = static_cast<const MSVehicle&>(veh).getTimeLoss();
393 const double speedFraction = veh.
getSpeed() * (
TS - fractionTimeOnDet);
401 values.
timeLoss = static_cast<const MSVehicle&>(veh).getTimeLoss() - values.
timeLoss;
412 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
myID <<
"\" ";
415 double meanTravelTime = 0.;
416 double meanOverlapTravelTime = 0.;
417 double meanSpeed = 0.;
418 double meanHaltsPerVehicle = 0.;
419 double meanTimeLoss = 0.;
421 meanHaltsPerVehicle += (double)values.haltings;
422 meanTravelTime += values.frontLeaveTime - values.entryTime;
423 const double steps = values.backLeaveTime - values.entryTime;
424 meanOverlapTravelTime += steps;
425 meanSpeed += (values.speedSum / steps);
428 meanTravelTime = vehicleSum != 0 ? meanTravelTime / (double)vehicleSum : -1;
429 meanOverlapTravelTime = vehicleSum != 0 ? meanOverlapTravelTime / (double)vehicleSum : -1;
430 meanSpeed = vehicleSum != 0 ? meanSpeed / (double)vehicleSum : -1;
431 meanHaltsPerVehicle = vehicleSum != 0 ? meanHaltsPerVehicle / (double) vehicleSum : -1;
432 meanTimeLoss = vehicleSum != 0 ? meanTimeLoss / (double) vehicleSum : -1;
438 double meanSpeedWithin = 0.;
439 double meanDurationWithin = 0.;
440 double meanHaltsPerVehicleWithin = 0.;
441 double meanIntervalSpeedWithin = 0.;
442 double meanIntervalHaltsPerVehicleWithin = 0.;
443 double meanIntervalDurationWithin = 0.;
444 double meanTimeLossWithin = 0.;
446 meanHaltsPerVehicleWithin += (double)(*i).second.haltings;
447 meanIntervalHaltsPerVehicleWithin += (
double)(*i).second.intervalHaltings;
448 const double end = (*i).second.backLeaveTime == 0 ?
STEPS2TIME(stopTime) : (*i).second.backLeaveTime;
449 const double time = end - (*i).second.entryTime;
450 const double timeWithin =
MIN2(time, end -
STEPS2TIME(startTime));
451 if (i->second.speedSum > 0.) {
452 meanSpeedWithin += i->second.speedSum / time;
454 if (i->second.intervalSpeedSum > 0.) {
455 meanIntervalSpeedWithin += i->second.intervalSpeedSum / timeWithin;
457 meanDurationWithin += time;
458 meanIntervalDurationWithin += timeWithin;
460 (*i).second.intervalHaltings = 0;
461 (*i).second.intervalSpeedSum = 0;
464 const SUMOTime currentTimeLoss = static_cast<const MSVehicle*>(i->first)->getTimeLoss();
465 meanTimeLossWithin +=
STEPS2TIME(currentTimeLoss - (*i).second.intervalTimeLoss);
466 (*i).second.intervalTimeLoss = currentTimeLoss;
470 meanSpeedWithin = vehicleSumWithin != 0 ? meanSpeedWithin / (double) vehicleSumWithin : -1;
471 meanHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanHaltsPerVehicleWithin / (double) vehicleSumWithin : -1;
472 meanDurationWithin = vehicleSumWithin != 0 ? meanDurationWithin / (double) vehicleSumWithin : -1;
473 meanIntervalSpeedWithin = vehicleSumWithin != 0 ? meanIntervalSpeedWithin / (double) vehicleSumWithin : -1;
474 meanIntervalHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanIntervalHaltsPerVehicleWithin / (double) vehicleSumWithin : -1;
475 meanIntervalDurationWithin = vehicleSumWithin != 0 ? meanIntervalDurationWithin / (double) vehicleSumWithin : -1;
476 meanTimeLossWithin = vehicleSumWithin != 0 ? meanTimeLossWithin / (double) vehicleSumWithin : -1;
479 dev <<
"meanTravelTime=\"" << meanTravelTime
480 <<
"\" meanOverlapTravelTime=\"" << meanOverlapTravelTime
481 <<
"\" meanSpeed=\"" << meanSpeed
482 <<
"\" meanHaltsPerVehicle=\"" << meanHaltsPerVehicle
483 <<
"\" meanTimeLoss=\"" << meanTimeLoss
484 <<
"\" vehicleSum=\"" << vehicleSum
485 <<
"\" meanSpeedWithin=\"" << meanSpeedWithin
486 <<
"\" meanHaltsPerVehicleWithin=\"" << meanHaltsPerVehicleWithin
487 <<
"\" meanDurationWithin=\"" << meanDurationWithin
488 <<
"\" vehicleSumWithin=\"" << vehicleSumWithin
489 <<
"\" meanIntervalSpeedWithin=\"" << meanIntervalSpeedWithin
490 <<
"\" meanIntervalHaltsPerVehicleWithin=\"" << meanIntervalHaltsPerVehicleWithin
491 <<
"\" meanIntervalDurationWithin=\"" << meanIntervalDurationWithin
492 <<
"\" meanTimeLossWithin=\"" << meanTimeLossWithin
509 #ifdef DEBUG_E3_DETECTORUPDATE
512 std::cout <<
SIMTIME <<
" vehPtr=" << veh <<
"\n";
513 std::cout <<
" veh=" << veh->
getID() <<
"\n";
562 std::vector<std::string>
564 std::vector<std::string> ret;
566 ret.push_back((*pair).first->getID());
568 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.
static int gNumSimThreads
how many threads to use for simulation
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.
A scoped lock which only triggers on condition.
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.