 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
43 #define HAS_NOT_LEFT_DETECTOR -1
49 double positionInMeters,
50 const std::string& vTypes) :
53 myPosition(positionInMeters),
57 assert(
myPosition >= 0 && myPosition <= myLane->getLength());
94 double newPos,
double newSpeed) {
106 double entryTime =
SIMTIME + timeBeforeEnter;
117 const double leaveTime =
SIMTIME + timeBeforeLeave;
152 return d.empty() ? -1. : std::accumulate(d.begin(), d.end(), 0.0,
speedSum) / (double) d.size();
159 return d.empty() ? -1. : std::accumulate(d.begin(), d.end(), 0.0,
lengthSum) / (double)d.size();
166 double occupancy = 0;
167 const double csecond =
SIMTIME;
171 occupancy +=
MIN2(leaveTime - entryTime,
TS);
173 return occupancy /
TS * 100.;
183 std::vector<std::string>
186 std::vector<std::string> ret;
188 ret.push_back(i.idM);
222 const double t(
STEPS2TIME(stopTime - startTime));
224 double occupancy = 0.;
228 double inverseSpeedSum = 0.;
230 const double timeOnDetDuringInterval = i->leaveTimeM -
MAX2(
STEPS2TIME(startTime), i->entryTimeM);
231 occupancy +=
MIN2(timeOnDetDuringInterval, t);
233 assert(i->speedM > 0);
234 inverseSpeedSum += 1. / i->speedM;
240 occupancy = occupancy / t * (double) 100.;
261 std::map<SUMOTrafficObject*, double>::iterator it =
myVehiclesOnDet.find(&veh);
263 const double entryTimestep = it->second;
265 assert(entryTimestep < leaveTimestep);
280 std::vector<MSInductLoop::VehicleData>
283 std::vector<VehicleData> ret;
285 if (i.entryTimeM >= t || (leaveTime && i.leaveTimeM >= t)) {
290 if (i.entryTimeM >= t || (leaveTime && i.leaveTimeM >= t)) {
295 if (i.second >= t || leaveTime) {
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
Representation of a vehicle or person.
const std::string & getID() const
Returns the name of the vehicle type.
Base of value-generating classes (detectors)
double myLastLeaveTime
Leave-time of the last vehicle detected [s].
Representation of a lane in the micro simulation.
Struct to store the data of the counted vehicle internally.
double getVehicleLength(const int offset) const
Returns the length of the vehicle on the detector.
virtual void enterDetectorByMove(SUMOTrafficObject &veh, double entryTimestep)
Introduces a vehicle to the detector's map myVehiclesOnDet.
static double lengthSum(double sumSoFar, const MSInductLoop::VehicleData &data)
Adds up VehicleData::lengthM.
Static storage of an output device and its base (abstract) implementation.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
virtual const std::string & getID() const =0
Get the vehicle's ID.
static int gNumSimThreads
how many threads to use for simulation
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane=0)
Checks whether the reminder is activated by a vehicle entering the lane.
double getTimeSinceLastDetection() const
Returns the time since the last vehicle left the detector.
virtual void leaveDetectorByLaneChange(SUMOTrafficObject &veh, double lastPos)
Removes a vehicle from the detector's map myVehiclesOnDet.
virtual double getBackPositionOnLane(const MSLane *lane) const =0
Get the vehicle's back position along the given lane.
Something on a lane to be noticed about vehicle movement.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
@ SUMO_ATTR_BEGIN
weights: time range begin
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
double speedM
Speed of the vehicle in [m/s].
virtual void leaveDetectorByMove(SUMOTrafficObject &veh, double leaveTimestep)
Processes a vehicle that leaves the detector.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
A scoped lock which only triggers on condition.
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
std::vector< std::string > getVehicleIDs(const int offset) const
Returns the ids of vehicles that have passed the detector.
static double speedSum(double sumSoFar, const MSInductLoop::VehicleData &data)
Adds up VehicleData::speedM.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
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.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the vehicle shall be counted and/or shall still touch this MSMoveReminder.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
double getPassedNumber(const int offset) const
Returns the number of vehicles that have passed the detector.
@ NOTIFICATION_PARKING
The vehicle starts or ends parking.
std::map< SUMOTrafficObject *, double > myVehiclesOnDet
Data for vehicles that have entered the detector (vehicle -> enter time)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual double getPreviousSpeed() const =0
Returns the vehicle's previous speed.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Dismisses the vehicle if it is on the detector due to a lane change.
double getLength() const
Get vehicle's length [m].
VehicleDataCont myLastVehicleDataCont
Data of vehicles that have completely passed the detector in the last time interval.
double getSpeed(const int offset) const
Returns the speed of the vehicle on the detector.
bool vehicleApplies(const SUMOTrafficObject &veh) const
Checks whether the detector measures vehicles of the given type.
~MSInductLoop()
Destructor.
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...
const double myPosition
Detector's position on lane [m].
@ SUMO_ATTR_END
weights: time range end
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
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 getOccupancy() const
Returns the current occupancy.
virtual double getPositionOnLane() const =0
Get the vehicle's position along the lane.
#define HAS_NOT_LEFT_DETECTOR
SUMOTime getLastDetectionTime() const
return last time a vehicle was on the detector
MSInductLoop(const std::string &id, MSLane *const lane, double positionInMeters, const std::string &vTypes)
Constructor.
VehicleDataCont myVehicleDataCont
Data of vehicles that have completely passed the detector.
int myEnteredVehicleNumber
The number of entered vehicles.
const std::string & getID() const
Returns the id.
Notification
Definition of a vehicle state.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
virtual void reset()
Resets all generated values to allow computation of next interval.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
MSLane *const myLane
Lane on which the reminder works.
virtual double getSpeed() const =0
Returns the vehicle's current speed.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "detector" as root element.