51 #ifdef CHECK_MEMORY_LEAKS 53 #endif // CHECK_MEMORY_LEAKS 55 #define HAS_NOT_LEFT_DETECTOR -1 61 SUMOReal positionInMeters,
bool splitByType) :
64 myPosition(positionInMeters), mySplitByType(splitByType),
65 myLastLeaveTime(
STEPS2TIME(
MSNet::getInstance()->getCurrentTimeStep())),
68 assert(
myPosition >= 0 && myPosition <= myLane->getLength());
113 entryTime += (
myPosition - oldPos) / newSpeed;
171 for (std::vector< VehicleData >::const_iterator i = d.begin(); i != d.end(); ++i) {
174 timeOnDetDuringInterval =
MIN2(timeOnDetDuringInterval,
TS);
175 occupancy += timeOnDetDuringInterval;
184 return (
int) d.size();
188 std::vector<std::string>
191 std::vector<std::string> ret;
192 for (std::vector<VehicleData>::iterator i = d.begin(); i != d.end(); ++i) {
193 ret.push_back((*i).idM);
211 dev.
writeXMLHeader(
"detector",
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://sumo.dlr.de/xsd/det_e1_file.xsd\"");
221 std::map<std::string, std::pair<VehicleDataCont, VehicleMap> > types;
224 if (types.find((*i).typeIDM) == types.end()) {
227 types[(*i).typeIDM].first.push_back(*i);
230 const std::string& type = (*i).first->getVehicleType().getID();
231 if (types.find(type) == types.end()) {
234 types[type].second[(*i).first] = (*i).second;
237 for (std::map<std::string, std::pair<VehicleDataCont, VehicleMap> >::const_iterator i = types.begin(); i != types.end(); ++i) {
238 writeTypedXMLOutput(dev, startTime, stopTime, (*i).first, (*i).second.first, (*i).second.second);
241 dev <<
" </interval>\n";
252 int nVehCrossed = (int) vdc.size();
258 for (std::deque< VehicleData >::const_iterator i = vdc.begin(); i != vdc.end(); ++i) {
260 timeOnDetDuringInterval =
MIN2(timeOnDetDuringInterval, t);
261 occupancy += timeOnDetDuringInterval;
263 for (std::map< SUMOVehicle*, SUMOReal >::const_iterator i = vm.begin(); i != vm.end(); ++i) {
265 occupancy += timeOnDetDuringInterval;
267 occupancy = occupancy / t * (
SUMOReal) 100.;
268 SUMOReal meanSpeed = vdc.size() != 0
271 SUMOReal meanLength = vdc.size() != 0
275 dev <<
" <typedInterval type=\"" + type +
"\" ";
277 dev <<
" <interval ";
279 dev <<
"begin=\"" <<
time2string(startTime) <<
"\" end=\"" <<
281 dev <<
"nVehContrib=\"" << vdc.size() <<
"\" flow=\"" << flow <<
282 "\" occupancy=\"" << occupancy <<
"\" speed=\"" << meanSpeed <<
283 "\" length=\"" << meanLength <<
284 "\" nVehEntered=\"" << nVehCrossed <<
"\"";
300 SUMOReal entryTimestep = it->second;
302 assert(entryTimestep < leaveTimestep);
321 std::vector<MSInductLoop::VehicleData>
324 std::vector<VehicleData> ret;
326 if ((*i).entryTimeM >= t || (leaveTime && (*i).leaveTimeM >= t)) {
331 if ((*i).entryTimeM >= t || (leaveTime && (*i).leaveTimeM >= t)) {
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
MSInductLoop(const std::string &id, MSLane *const lane, SUMOReal positionInMeters, bool splitByType)
Constructor.
The vehicle arrived at a junction.
virtual SUMOReal getPositionOnLane() const =0
Get the vehicle's position along the lane.
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.
std::string time2string(SUMOTime t)
SUMOReal getLength() const
Get vehicle's length [m].
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].
The simulated network and simulation perfomer.
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].
std::deque< VehicleData > VehicleDataCont
Type of myVehicleDataCont.
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)
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.
bool mySplitByType
Whether additional information split by vehicle classes shall be generated.
Something on a lane to be noticed about vehicle movement.
SUMOReal getCurrentSpeed() const
Returns the speed of the vehicle on the detector.
#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.
int myDismissedVehicleNumber
The number of dismissed vehicles.
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.
SUMOReal getTimestepsSinceLastDetection() const
Returns the time since the last vehicle left the detector.
Static storage of an output device and its base (abstract) implementation.
SUMOReal myLastLeaveTime
Leave-time of the last vehicle detected [s].
void writeTypedXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime, const std::string &type, const VehicleDataCont &vdc, const VehicleMap &vm)
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.
std::map< SUMOVehicle *, SUMOReal > VehicleMap
Type of myVehiclesOnDet.
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.