40 #ifdef CHECK_MEMORY_LEAKS
42 #endif // CHECK_MEMORY_LEAKS
54 myCollector(collector), myPosition(crossSection.myPosition) {}
60 if (myCollector.myEnteredContainer.find(&veh) == myCollector.myEnteredContainer.end() && newPos >= myPosition) {
61 if (oldPos > myPosition) {
67 if (myPosition > oldPos) {
68 entryTime += (myPosition - oldPos) / newSpeed;
71 myCollector.enter(veh, entryTime);
82 myCollector.myEnteredContainer.erase(&veh);
95 myCollector(collector), myPosition(crossSection.myPosition) {}
101 if (newPos <= myPosition) {
105 if (oldPos > myPosition) {
111 if (myPosition > oldPos) {
112 leaveTime += (myPosition - oldPos) / newSpeed;
114 myCollector.leave(veh, leaveTime);
201 SUMOReal leaveTimestepFraction = leaveTimestep - (
SUMOReal)((
int) leaveTimestep);
202 leaveTimestepFraction = fmod(leaveTimestep * 1000., 1000.) / (
SUMOReal)
DELTA_T;
225 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
myID <<
"\" ";
232 meanHaltsPerVehicle += (
SUMOReal)(*i).second.haltings;
233 SUMOReal steps = (*i).second.leaveTime - (*i).second.entryTime;
234 meanTravelTime += steps;
235 meanSpeed += ((*i).second.speedSum / steps);
237 meanTravelTime = vehicleSum != 0 ? meanTravelTime / (
SUMOReal) vehicleSum : -1;
238 meanSpeed = vehicleSum != 0 ? meanSpeed / (
SUMOReal) vehicleSum : -1;
239 meanHaltsPerVehicle = vehicleSum != 0 ? meanHaltsPerVehicle / (
SUMOReal) vehicleSum : -1;
247 SUMOReal meanHaltsPerVehicleWithin = 0.;
248 SUMOReal meanIntervalSpeedWithin = 0.;
249 SUMOReal meanIntervalHaltsPerVehicleWithin = 0.;
250 SUMOReal meanIntervalDurationWithin = 0.;
252 meanHaltsPerVehicleWithin += (
SUMOReal)(*i).second.haltings;
253 meanIntervalHaltsPerVehicleWithin += (
SUMOReal)(*i).second.intervalHaltings;
256 if (i->second.speedSum > 0.) {
257 meanSpeedWithin += i->second.speedSum / time;
259 if (i->second.intervalSpeedSum > 0.) {
260 meanIntervalSpeedWithin += i->second.intervalSpeedSum / timeWithin;
262 meanDurationWithin += time;
263 meanIntervalDurationWithin += timeWithin;
265 (*i).second.intervalHaltings = 0;
266 (*i).second.intervalSpeedSum = 0;
269 meanSpeedWithin = vehicleSumWithin != 0 ? meanSpeedWithin / (
SUMOReal) vehicleSumWithin : -1;
270 meanHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanHaltsPerVehicleWithin / (
SUMOReal) vehicleSumWithin : -1;
271 meanDurationWithin = vehicleSumWithin != 0 ? meanDurationWithin / (
SUMOReal) vehicleSumWithin : -1;
272 meanIntervalSpeedWithin = vehicleSumWithin != 0 ? meanIntervalSpeedWithin / (
SUMOReal) vehicleSumWithin : -1;
273 meanIntervalHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanIntervalHaltsPerVehicleWithin / (
SUMOReal) vehicleSumWithin : -1;
274 meanIntervalDurationWithin = vehicleSumWithin != 0 ? meanIntervalDurationWithin / (
SUMOReal) vehicleSumWithin : -1;
277 dev <<
"meanTravelTime=\"" << meanTravelTime
278 <<
"\" meanSpeed=\"" << meanSpeed
279 <<
"\" meanHaltsPerVehicle=\"" << meanHaltsPerVehicle
280 <<
"\" vehicleSum=\"" << vehicleSum
281 <<
"\" meanSpeedWithin=\"" << meanSpeedWithin
282 <<
"\" meanHaltsPerVehicleWithin=\"" << meanHaltsPerVehicleWithin
283 <<
"\" meanDurationWithin=\"" << meanDurationWithin
284 <<
"\" vehicleSumWithin=\"" << vehicleSumWithin
285 <<
"\" meanIntervalSpeedWithin=\"" << meanIntervalSpeedWithin
286 <<
"\" meanIntervalHaltsPerVehicleWithin=\"" << meanIntervalHaltsPerVehicleWithin
287 <<
"\" meanIntervalDurationWithin=\"" << meanIntervalDurationWithin
345 ret += (*pair).first->getSpeed();
363 std::vector<std::string>
365 std::vector<std::string> ret;
367 ret.push_back((*pair).first->getID());
369 std::sort(ret.begin(), ret.end());
SUMOReal getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
std::map< SUMOVehicle *, E3Values > myLeftContainer
Container for vehicles that have left 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.
SUMOReal myCurrentHaltingsNumber
The current number of haltings (inside)
Notification
Definition of a vehicle state.
std::string time2string(SUMOTime t)
std::vector< MSCrossSection > CrossSectionVector
CrossSectionVector::const_iterator CrossSectionVectorConstIt
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
void enter(SUMOVehicle &veh, SUMOReal entryTimestep)
Called if a vehicle touches an entry-cross-section.
SUMOTime myLastResetTime
Information when the last reset has been done.
std::vector< MSE3LeaveReminder * > myLeaveReminders
The detector's built exit reminder.
#define WRITE_WARNING(msg)
SUMOReal haltingBegin
Begin time of last halt begin.
SUMOReal leaveTime
The vehicle's leaving time.
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
const std::string & getID() const
Returns the id.
The vehicle changes lanes (micro only)
Representation of a vehicle.
Internal storage for values from a vehicle.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "e3Detector" as root element.
SUMOTime myHaltingTimeThreshold
The vehicle arrived at its destination (is deleted)
void leave(SUMOVehicle &veh, SUMOReal leaveTimestep)
Called if a vehicle passes a leave-cross-section.
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.
SUMOReal myCurrentTouchedVehicles
The current number of vehicles inside;.
std::string myID
The name of the object.
virtual SUMOReal getSpeed() const =0
Returns the vehicle's current speed.
unsigned haltings
The sum of haltings the vehicle has/had within the area.
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.
Static storage of an output device and its base (abstract) implementation.
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.
SUMOReal getCurrentMeanSpeed() const
Returns the mean speed within the area.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal)
Checks whether the vehicle leaves.
SUMOReal getVehiclesWithin() const
Returns the number of vehicles within the area.
unsigned intervalHaltings
The sum of haltings the vehicle has/had within the area during the current interval.
void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
std::map< SUMOVehicle *, E3Values > myEnteredContainer
Container for vehicles that have entered the area.
MSE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold)
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.
Base of value-generating classes (detectors)
std::vector< std::string > getCurrentVehicleIDs() const
Returns the number of vehicles within the area.
CrossSectionVector myExits
The detector's exits.
SUMOReal myCurrentMeanSpeed
The current mean speed of known vehicles (inside)