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)
232 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
myID <<
"\" ";
236 SUMOReal meanOverlapTravelTime = 0.;
240 meanHaltsPerVehicle += (
SUMOReal)(*i).second.haltings;
241 meanTravelTime += (*i).second.frontLeaveTime - (*i).second.entryTime;
242 const SUMOReal steps = (*i).second.backLeaveTime - (*i).second.entryTime;
243 meanOverlapTravelTime += steps;
244 meanSpeed += ((*i).second.speedSum / steps);
246 meanTravelTime = vehicleSum != 0 ? meanTravelTime / (
SUMOReal)vehicleSum : -1;
247 meanOverlapTravelTime = vehicleSum != 0 ? meanOverlapTravelTime / (
SUMOReal)vehicleSum : -1;
248 meanSpeed = vehicleSum != 0 ? meanSpeed / (
SUMOReal)vehicleSum : -1;
249 meanHaltsPerVehicle = vehicleSum != 0 ? meanHaltsPerVehicle / (
SUMOReal) vehicleSum : -1;
257 SUMOReal meanHaltsPerVehicleWithin = 0.;
258 SUMOReal meanIntervalSpeedWithin = 0.;
259 SUMOReal meanIntervalHaltsPerVehicleWithin = 0.;
260 SUMOReal meanIntervalDurationWithin = 0.;
262 meanHaltsPerVehicleWithin += (
SUMOReal)(*i).second.haltings;
263 meanIntervalHaltsPerVehicleWithin += (
SUMOReal)(*i).second.intervalHaltings;
264 const SUMOReal end = (*i).second.backLeaveTime == 0 ?
STEPS2TIME(stopTime) : (*i).second.backLeaveTime;
265 const SUMOReal time = end - (*i).second.entryTime;
267 if (i->second.speedSum > 0.) {
268 meanSpeedWithin += i->second.speedSum / time;
270 if (i->second.intervalSpeedSum > 0.) {
271 meanIntervalSpeedWithin += i->second.intervalSpeedSum / timeWithin;
273 meanDurationWithin += time;
274 meanIntervalDurationWithin += timeWithin;
276 (*i).second.intervalHaltings = 0;
277 (*i).second.intervalSpeedSum = 0;
280 meanSpeedWithin = vehicleSumWithin != 0 ? meanSpeedWithin / (
SUMOReal) vehicleSumWithin : -1;
281 meanHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanHaltsPerVehicleWithin / (
SUMOReal) vehicleSumWithin : -1;
282 meanDurationWithin = vehicleSumWithin != 0 ? meanDurationWithin / (
SUMOReal) vehicleSumWithin : -1;
283 meanIntervalSpeedWithin = vehicleSumWithin != 0 ? meanIntervalSpeedWithin / (
SUMOReal) vehicleSumWithin : -1;
284 meanIntervalHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanIntervalHaltsPerVehicleWithin / (
SUMOReal) vehicleSumWithin : -1;
285 meanIntervalDurationWithin = vehicleSumWithin != 0 ? meanIntervalDurationWithin / (
SUMOReal) vehicleSumWithin : -1;
288 dev <<
"meanTravelTime=\"" << meanTravelTime
289 <<
"\" meanOverlapTravelTime=\"" << meanOverlapTravelTime
290 <<
"\" meanSpeed=\"" << meanSpeed
291 <<
"\" meanHaltsPerVehicle=\"" << meanHaltsPerVehicle
292 <<
"\" vehicleSum=\"" << vehicleSum
293 <<
"\" meanSpeedWithin=\"" << meanSpeedWithin
294 <<
"\" meanHaltsPerVehicleWithin=\"" << meanHaltsPerVehicleWithin
295 <<
"\" meanDurationWithin=\"" << meanDurationWithin
296 <<
"\" vehicleSumWithin=\"" << vehicleSumWithin
297 <<
"\" meanIntervalSpeedWithin=\"" << meanIntervalSpeedWithin
298 <<
"\" meanIntervalHaltsPerVehicleWithin=\"" << meanIntervalHaltsPerVehicleWithin
299 <<
"\" meanIntervalDurationWithin=\"" << meanIntervalDurationWithin
306 dev.
writeXMLHeader(
"e3Detector",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/det_e3_file.xsd\"");
360 std::vector<std::string>
362 std::vector<std::string> ret;
364 ret.push_back((*pair).first->getID());
366 std::sort(ret.begin(), ret.end());
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.
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.
virtual SUMOReal getPreviousSpeed() const =0
Returns the vehicle's previous speed.
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)
SUMOReal haltingBegin
Begin time of last halt begin.
SUMOReal myPosition
The position on the lane.
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
int myCurrentHaltingsNumber
The current number of haltings (inside)
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.
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.
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.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
MSE3LeaveReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
CrossSectionVector myEntries
The detector's entries.
std::string myID
The name of the object.
virtual SUMOReal getSpeed() const =0
Returns the vehicle's current speed.
SUMOReal getCurrentMeanSpeed() const
Returns the mean speed within the area.
void leaveFront(const SUMOVehicle &veh, const SUMOReal leaveTimestep)
Called if a vehicle front passes a leave-cross-section.
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.
int getVehiclesWithin() const
Returns the number of vehicles within the area.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal)
Checks whether the vehicle leaves.
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.
virtual const std::string & getID() const =0
Get the vehicle's ID.
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.
Base of value-generating classes (detectors)
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.
std::map< const SUMOVehicle *, E3Values > myLeftContainer
Container for vehicles that have left the area.
SUMOReal myCurrentMeanSpeed
The current mean speed of known vehicles (inside)