51 #ifdef CHECK_MEMORY_LEAKS
53 #endif // CHECK_MEMORY_LEAKS
55 #define HAS_NOT_LEFT_DETECTOR -1
62 const std::string& vTypes) :
65 myPosition(positionInMeters),
69 assert(
myPosition >= 0 && myPosition <= myLane->getLength());
184 for (std::vector< VehicleData >::const_iterator i = d.begin(); i != d.end(); ++i) {
187 occupancy +=
MIN2(timeOnDetDuringInterval,
TS);
196 return (
int) d.size();
200 std::vector<std::string>
203 std::vector<std::string> ret;
204 for (std::vector<VehicleData>::iterator i = d.begin(); i != d.end(); ++i) {
205 ret.push_back((*i).idM);
223 dev.
writeXMLHeader(
"detector",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/det_e1_file.xsd\"");
237 occupancy +=
MIN2(timeOnDetDuringInterval, t);
238 speedSum += i->speedM;
239 lengthSum += i->lengthM;
244 occupancy = occupancy / t * (
SUMOReal) 100.;
275 SUMOReal entryTimestep = it->second;
277 assert(entryTimestep < leaveTimestep);
297 std::vector<MSInductLoop::VehicleData>
300 std::vector<VehicleData> ret;
302 if ((*i).entryTimeM >= t || (leaveTime && (*i).leaveTimeM >= t)) {
307 if ((*i).entryTimeM >= t || (leaveTime && (*i).leaveTimeM >= t)) {
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
The vehicle arrived at a junction.
MSLane *const myLane
Lane on which the reminder works.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle's position along the lane.
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
virtual void reset()
Resets all generated values to allow computation of next interval.
static std::string escapeXML(const std::string &orig)
Replaces the standard escapes by their XML entities.
Notification
Definition of a vehicle state.
SUMOReal getLength() const
Get vehicle's length [m].
virtual SUMOReal getPreviousSpeed() const =0
Returns the vehicle's previous speed.
int getCurrentPassedNumber() const
Returns the number of vehicles that have passed the detector.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual std::vector< VehicleData > collectVehiclesOnDet(SUMOTime t, bool leaveTime=false) const
Returns vehicle data for vehicles that have been on the detector starting at the given time...
SUMOReal getCurrentOccupancy() const
Returns the current occupancy.
VehicleMap myVehiclesOnDet
Data for vehicles that have entered the detector (vehicle -> enter time)
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
VehicleDataCont myLastVehicleDataCont
Data of vehicles that have completely passed the detector in the last time interval.
const SUMOReal myPosition
Detector's position on lane [m].
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.
VehicleDataCont myVehicleDataCont
Data of vehicles that have completely passed the detector.
SUMOReal speedM
Speed of the vehicle in [m/s].
bool writeXMLHeader(const std::string &rootElement, const std::string &attrs="", const std::string &comment="")
Writes an XML header with optional configuration.
static SUMOReal lengthSum(SUMOReal sumSoFar, const MSInductLoop::VehicleData &data)
Adds up VehicleData::lengthM.
std::vector< std::string > getCurrentVehicleIDs() const
Returns the ids of vehicles that have passed the detector.
const std::string & getID() const
Returns the id.
The vehicle changes lanes (micro only) XXX: What if a vehicle changes lanes and passes a junction sim...
Representation of a vehicle.
~MSInductLoop()
Destructor.
virtual void enterDetectorByMove(SUMOVehicle &veh, SUMOReal entryTimestep)
Introduces a vehicle to the detector's map myVehiclesOnDet.
static SUMOReal speedSum(SUMOReal sumSoFar, const MSInductLoop::VehicleData &data)
Adds up VehicleData::speedM.
MSInductLoop(const std::string &id, MSLane *const lane, SUMOReal positionInMeters, const std::string &vTypes)
Constructor.
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...
Something on a lane to be noticed about vehicle movement.
SUMOReal getCurrentSpeed() const
Returns the speed of the vehicle on the detector.
int myEnteredVehicleNumber
The number of entered vehicles.
#define HAS_NOT_LEFT_DETECTOR
The vehicle starts or ends parking.
The vehicle has departed (was inserted into the network)
SUMOReal myLastOccupancy
Occupancy by the last vehicle detected.
virtual SUMOReal getSpeed() const =0
Returns the vehicle's current speed.
Struct to store the data of the counted vehicle internally.
bool notifyEnter(SUMOVehicle &veh, Notification reason)
Checks whether the reminder is activated by a vehicle entering the lane.
virtual void leaveDetectorByLaneChange(SUMOVehicle &veh, SUMOReal lastPos)
Removes a vehicle from the detector's map myVehiclesOnDet.
const std::string & getID() const
Returns the name of the vehicle type.
virtual SUMOReal getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle's back position along the given lane.
SUMOReal getTimestepsSinceLastDetection() const
Returns the time since the last vehicle left the detector.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
static bool gSemiImplicitEulerUpdate
SUMOReal myLastLeaveTime
Leave-time of the last vehicle detected [s].
SUMOReal getCurrentLength() const
Returns the length of the vehicle on the detector.
virtual void leaveDetectorByMove(SUMOVehicle &veh, SUMOReal leaveTimestep)
Processes a vehicle that leaves the detector.
Representation of a lane in the micro simulation.
virtual const std::string & getID() const =0
Get the vehicle's ID.
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Dismisses the vehicle if it is on the detector due to a lane change.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Base of value-generating classes (detectors)
The vehicle is being teleported.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed)
Checks whether the vehicle shall be counted and/or shall still touch this MSMoveReminder.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.