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);
81 myCollector.myEnteredContainer.erase(&veh);
94 myCollector(collector), myPosition(crossSection.myPosition) {}
100 if (newPos <= myPosition) {
104 if (oldPos > myPosition) {
110 if (myPosition > oldPos) {
111 leaveTime += (myPosition - oldPos) / newSpeed;
113 myCollector.leave(veh, leaveTime);
200 SUMOReal leaveTimestepFraction = leaveTimestep - (
SUMOReal)((
int) leaveTimestep);
201 leaveTimestepFraction = fmod(leaveTimestep * 1000., 1000.) / (
SUMOReal)
DELTA_T;
224 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
myID <<
"\" ";
231 meanHaltsPerVehicle += (
SUMOReal)(*i).second.haltings;
232 SUMOReal steps = (*i).second.leaveTime - (*i).second.entryTime;
233 meanTravelTime += steps;
234 meanSpeed += ((*i).second.speedSum / steps);
236 meanTravelTime = vehicleSum != 0 ? meanTravelTime / (
SUMOReal) vehicleSum : -1;
237 meanSpeed = vehicleSum != 0 ? meanSpeed / (
SUMOReal) vehicleSum : -1;
238 meanHaltsPerVehicle = vehicleSum != 0 ? meanHaltsPerVehicle / (
SUMOReal) vehicleSum : -1;
246 SUMOReal meanHaltsPerVehicleWithin = 0.;
247 SUMOReal meanIntervalSpeedWithin = 0.;
248 SUMOReal meanIntervalHaltsPerVehicleWithin = 0.;
249 SUMOReal meanIntervalDurationWithin = 0.;
251 meanHaltsPerVehicleWithin += (
SUMOReal)(*i).second.haltings;
252 meanIntervalHaltsPerVehicleWithin += (
SUMOReal)(*i).second.intervalHaltings;
256 meanSpeedWithin += ((*i).second.speedSum / time);
257 meanIntervalSpeedWithin += ((*i).second.intervalSpeedSum / timeWithin);
258 meanDurationWithin += time;
259 meanIntervalDurationWithin += timeWithin;
261 (*i).second.intervalHaltings = 0;
262 (*i).second.intervalSpeedSum = 0;
265 meanSpeedWithin = vehicleSumWithin != 0 ? meanSpeedWithin / (
SUMOReal) vehicleSumWithin : -1;
266 meanHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanHaltsPerVehicleWithin / (
SUMOReal) vehicleSumWithin : -1;
267 meanDurationWithin = vehicleSumWithin != 0 ? meanDurationWithin / (
SUMOReal) vehicleSumWithin : -1;
268 meanIntervalSpeedWithin = vehicleSumWithin != 0 ? meanIntervalSpeedWithin / (
SUMOReal) vehicleSumWithin : -1;
269 meanIntervalHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanIntervalHaltsPerVehicleWithin / (
SUMOReal) vehicleSumWithin : -1;
270 meanIntervalDurationWithin = vehicleSumWithin != 0 ? meanIntervalDurationWithin / (
SUMOReal) vehicleSumWithin : -1;
273 dev <<
"meanTravelTime=\"" << meanTravelTime
274 <<
"\" meanSpeed=\"" << meanSpeed
275 <<
"\" meanHaltsPerVehicle=\"" << meanHaltsPerVehicle
276 <<
"\" vehicleSum=\"" << vehicleSum
277 <<
"\" meanSpeedWithin=\"" << meanSpeedWithin
278 <<
"\" meanHaltsPerVehicleWithin=\"" << meanHaltsPerVehicleWithin
279 <<
"\" meanDurationWithin=\"" << meanDurationWithin
280 <<
"\" vehicleSumWithin=\"" << vehicleSumWithin
281 <<
"\" meanIntervalSpeedWithin=\"" << meanIntervalSpeedWithin
282 <<
"\" meanIntervalHaltsPerVehicleWithin=\"" << meanIntervalHaltsPerVehicleWithin
283 <<
"\" meanIntervalDurationWithin=\"" << meanIntervalDurationWithin
341 ret += (*pair).first->getSpeed();
359 std::vector<std::string>
361 std::vector<std::string> ret;
363 ret.push_back((*pair).first->getID());
365 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)