51 #define HAS_NOT_LEFT_DETECTOR -1 57 double positionInMeters,
58 const std::string& vTypes) :
61 myPosition(positionInMeters),
65 assert(
myPosition >= 0 && myPosition <= myLane->getLength());
102 double newPos,
double newSpeed) {
111 double entryTime =
SIMTIME + timeBeforeEnter;
121 const double leaveTime =
SIMTIME + timeBeforeLeave;
157 ? accumulate(d.begin(), d.end(), (double) 0.0,
speedSum) / (double) d.size()
166 ? accumulate(d.begin(), d.end(), (double) 0.0,
lengthSum) / (double) d.size()
178 double occupancy = 0;
180 for (std::vector< VehicleData >::const_iterator i = d.begin(); i != d.end(); ++i) {
182 const double timeOnDetDuringInterval = leaveTime -
MAX2(
STEPS2TIME(tbeg), (*i).entryTimeM);
183 occupancy +=
MIN2(timeOnDetDuringInterval,
TS);
185 return occupancy /
TS * (double) 100.;
192 return (
int) d.size();
196 std::vector<std::string>
199 std::vector<std::string> ret;
200 for (std::vector<VehicleData>::iterator i = d.begin(); i != d.end(); ++i) {
201 ret.push_back((*i).idM);
226 const double t(
STEPS2TIME(stopTime - startTime));
228 double occupancy = 0.;
232 const double timeOnDetDuringInterval = i->leaveTimeM -
MAX2(
STEPS2TIME(startTime), i->entryTimeM);
233 occupancy +=
MIN2(timeOnDetDuringInterval, t);
234 speedSum += i->speedM;
235 lengthSum += i->lengthM;
240 occupancy = occupancy / t * (double) 100.;
253 double entryTimestep) {
264 double leaveTimestep) {
271 double entryTimestep = it->second;
273 assert(entryTimestep < leaveTimestep);
293 std::vector<MSInductLoop::VehicleData>
296 std::vector<VehicleData> ret;
298 if ((*i).entryTimeM >= t || (leaveTime && (*i).leaveTimeM >= t)) {
303 if ((*i).entryTimeM >= t || (leaveTime && (*i).leaveTimeM >= t)) {
const double myPosition
Detector's position on lane [m].
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.
bool vehicleApplies(const SUMOVehicle &veh) const
Checks whether the detector measures vehicles of the given type.
The vehicle arrived at a junction.
double myLastOccupancy
Occupancy by the last vehicle detected.
MSLane *const myLane
Lane on which the reminder works.
std::vector< std::string > getCurrentVehicleIDs() const
Returns the ids of vehicles that have passed the detector.
virtual void leaveDetectorByLaneChange(SUMOVehicle &veh, double lastPos)
Removes a vehicle from the detector's map myVehiclesOnDet.
virtual void reset()
Resets all generated values to allow computation of next interval.
bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Dismisses the vehicle if it is on the detector due to a lane change.
static double speedSum(double sumSoFar, const MSInductLoop::VehicleData &data)
Adds up VehicleData::speedM.
virtual void leaveDetectorByMove(SUMOVehicle &veh, double leaveTimestep)
Processes a vehicle that leaves the detector.
Notification
Definition of a vehicle state.
weights: time range begin
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
double getCurrentLength() const
Returns the length of the vehicle on the detector.
const std::string & getID() const
Returns the id.
VehicleMap myVehiclesOnDet
Data for vehicles that have entered the detector (vehicle -> enter time)
double speedM
Speed of the vehicle in [m/s].
VehicleDataCont myLastVehicleDataCont
Data of vehicles that have completely passed the detector in the last time interval.
VehicleDataCont myVehicleDataCont
Data of vehicles that have completely passed the detector.
The vehicle changes lanes (micro only)
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.
Representation of a vehicle.
~MSInductLoop()
Destructor.
virtual void enterDetectorByMove(SUMOVehicle &veh, double entryTimestep)
Introduces a vehicle to the detector's map myVehiclesOnDet.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
double getCurrentSpeed() const
Returns the speed of the vehicle on the detector.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Something on a lane to be noticed about vehicle movement.
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
double getTimeSinceLastDetection() const
Returns the time since the last vehicle left the detector.
MSInductLoop(const std::string &id, MSLane *const lane, double positionInMeters, const std::string &vTypes)
Constructor.
int myEnteredVehicleNumber
The number of entered vehicles.
#define HAS_NOT_LEFT_DETECTOR
bool notifyEnter(SUMOVehicle &veh, Notification reason, const MSLane *enteredLane=0)
Checks whether the reminder is activated by a vehicle entering the lane.
int getCurrentPassedNumber() const
Returns the number of vehicles that have passed the detector.
static double passingTime(const double lastPos, const double passedPos, const double currentPos, const double lastSpeed, const double currentSpeed)
Calculates the time at which the position passedPosition has been passed In case of a ballistic updat...
virtual double getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle's back position along the given lane.
The vehicle starts or ends parking.
The vehicle has departed (was inserted into the network)
Struct to store the data of the counted vehicle internally.
virtual double getPositionOnLane() const =0
Get the vehicle's position along the lane.
const std::string & getID() const
Returns the name of the vehicle type.
bool notifyMove(SUMOVehicle &veh, double oldPos, double newPos, double newSpeed)
Checks whether the vehicle shall be counted and/or shall still touch this MSMoveReminder.
double getLength() const
Get vehicle's length [m].
an aggreagated-output interval
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
static bool gSemiImplicitEulerUpdate
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...
double getCurrentOccupancy() const
Returns the current occupancy.
double myLastLeaveTime
Leave-time of the last vehicle detected [s].
virtual double getSpeed() const =0
Returns the vehicle's current speed.
Representation of a lane in the micro simulation.
static double lengthSum(double sumSoFar, const MSInductLoop::VehicleData &data)
Adds up VehicleData::lengthM.
virtual double getPreviousSpeed() const =0
Returns the vehicle's previous speed.
virtual const std::string & getID() const =0
Get the vehicle's ID.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Base of value-generating classes (detectors)
The vehicle is being teleported.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.