40 #ifdef CHECK_MEMORY_LEAKS 42 #endif // CHECK_MEMORY_LEAKS 54 myCollector(collector), myPosition(crossSection.myPosition) {}
66 assert(newSpeed != 0);
108 assert(newSpeed != 0);
207 dev <<
" <interval begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
time2string(stopTime) <<
"\" " <<
"id=\"" <<
myID <<
"\" ";
214 meanHaltsPerVehicle += (
SUMOReal)(*i).second.haltings;
215 SUMOReal steps = (*i).second.leaveTime - (*i).second.entryTime;
216 meanTravelTime += steps;
217 meanSpeed += ((*i).second.speedSum / steps);
219 meanTravelTime = vehicleSum != 0 ? meanTravelTime / (
SUMOReal) vehicleSum : -1;
220 meanSpeed = vehicleSum != 0 ? meanSpeed / (
SUMOReal) vehicleSum : -1;
221 meanHaltsPerVehicle = vehicleSum != 0 ? meanHaltsPerVehicle / (
SUMOReal) vehicleSum : -1;
229 SUMOReal meanHaltsPerVehicleWithin = 0.;
230 SUMOReal meanIntervalSpeedWithin = 0.;
231 SUMOReal meanIntervalHaltsPerVehicleWithin = 0.;
232 SUMOReal meanIntervalDurationWithin = 0.;
234 meanHaltsPerVehicleWithin += (
SUMOReal)(*i).second.haltings;
235 meanIntervalHaltsPerVehicleWithin += (
SUMOReal)(*i).second.intervalHaltings;
236 const SUMOReal end = (*i).second.leaveTime == 0 ?
STEPS2TIME(stopTime) : (*i).second.leaveTime;
237 const SUMOReal time = end - (*i).second.entryTime;
239 if (i->second.speedSum > 0.) {
240 meanSpeedWithin += i->second.speedSum / time;
242 if (i->second.intervalSpeedSum > 0.) {
243 meanIntervalSpeedWithin += i->second.intervalSpeedSum / timeWithin;
245 meanDurationWithin += time;
246 meanIntervalDurationWithin += timeWithin;
248 (*i).second.intervalHaltings = 0;
249 (*i).second.intervalSpeedSum = 0;
252 meanSpeedWithin = vehicleSumWithin != 0 ? meanSpeedWithin / (
SUMOReal) vehicleSumWithin : -1;
253 meanHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanHaltsPerVehicleWithin / (
SUMOReal) vehicleSumWithin : -1;
254 meanDurationWithin = vehicleSumWithin != 0 ? meanDurationWithin / (
SUMOReal) vehicleSumWithin : -1;
255 meanIntervalSpeedWithin = vehicleSumWithin != 0 ? meanIntervalSpeedWithin / (
SUMOReal) vehicleSumWithin : -1;
256 meanIntervalHaltsPerVehicleWithin = vehicleSumWithin != 0 ? meanIntervalHaltsPerVehicleWithin / (
SUMOReal) vehicleSumWithin : -1;
257 meanIntervalDurationWithin = vehicleSumWithin != 0 ? meanIntervalDurationWithin / (
SUMOReal) vehicleSumWithin : -1;
260 dev <<
"meanTravelTime=\"" << meanTravelTime
261 <<
"\" meanSpeed=\"" << meanSpeed
262 <<
"\" meanHaltsPerVehicle=\"" << meanHaltsPerVehicle
263 <<
"\" vehicleSum=\"" << vehicleSum
264 <<
"\" meanSpeedWithin=\"" << meanSpeedWithin
265 <<
"\" meanHaltsPerVehicleWithin=\"" << meanHaltsPerVehicleWithin
266 <<
"\" meanDurationWithin=\"" << meanDurationWithin
267 <<
"\" vehicleSumWithin=\"" << vehicleSumWithin
268 <<
"\" meanIntervalSpeedWithin=\"" << meanIntervalSpeedWithin
269 <<
"\" meanIntervalHaltsPerVehicleWithin=\"" << meanIntervalHaltsPerVehicleWithin
270 <<
"\" meanIntervalDurationWithin=\"" << meanIntervalDurationWithin
331 std::vector<std::string>
333 std::vector<std::string> ret;
335 ret.push_back((*pair).first->getID());
337 std::sort(ret.begin(), ret.end());
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
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< 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.
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.
int myCurrentHaltingsNumber
The current number of haltings (inside)
const std::string & getID() const
Returns the id.
The vehicle changes lanes (micro only)
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.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "e3Detector" as root element.
SUMOTime myHaltingTimeThreshold
The vehicle arrived at its destination (is deleted)
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.
int getVehiclesWithin() const
Returns the number of vehicles within the area.
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.
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.
int getCurrentHaltingNumber() const
Returns the number of current haltings 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.
MSE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold)
Constructor.
void leave(const SUMOVehicle &veh, const SUMOReal leaveTimestep, const SUMOReal fractionTimeOnDet)
Called if a vehicle passes a leave-cross-section.
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)
std::vector< std::string > getCurrentVehicleIDs() const
Returns the number of vehicles within the area.
CrossSectionVector myExits
The detector's exits.
std::map< const SUMOVehicle *, E3Values > myLeftContainer
Container for vehicles that have left the area.
SUMOReal myCurrentMeanSpeed
The current mean speed of known vehicles (inside)