GUIInductLoop Class Reference

#include <GUIInductLoop.h>

Inheritance diagram for GUIInductLoop:

MSInductLoop MSMoveReminder MSDetectorFileOutput MSVehicleQuitReminded Named

Detailed Description

The gui-version of the MSInductLoop. Allows the building of a wrapper (also declared herein) which draws the detector on the gl-canvas.

Definition at line 53 of file GUIInductLoop.h.


Public Member Functions

virtual GUIDetectorWrapperbuildDetectorWrapper (GUIGlObjectStorage &idStorage, GUILaneWrapper &lane)
 Returns this detector's visualisation-wrapper valid for gui-version only.
const std::string & getID () const throw ()
 Returns the id.
const MSLane *const getLane () const throw ()
 Returns the lane the reminder works on.
 GUIInductLoop (const std::string &id, MSLane *const lane, SUMOReal position) throw ()
 Constructor.
void reset () throw ()
 Resets all generated values to allow computation of next interval.
 ~GUIInductLoop () throw ()
 Destructor.
Methods returning current values
SUMOReal getCurrentLength () const throw ()
 Returns the length of the vehicle on the detector.
SUMOReal getCurrentOccupancy () const throw ()
 Returns the current occupancy.
SUMOReal getCurrentPassedNumber () const throw ()
 Returns the number of vehicles that have passed the detector.
SUMOReal getCurrentSpeed () const throw ()
 Returns the speed of the vehicle on the detector.
std::vector< std::string > getCurrentVehicleIDs () const throw ()
 Returns the ids of vehicles that have passed the detector.
SUMOReal getTimestepsSinceLastDetection () const throw ()
 Returns the time since the last vehicle left the detector.
Methods returning aggregated values
unsigned getNVehContributed () const throw ()
Methods inherited from MSMoveReminder
bool isStillActive (MSVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed) throw ()
 Checks whether the vehicle shall be counted and/or shall still touch this MSMoveReminder.
bool notifyEnter (MSVehicle &veh, bool isEmit, bool isLaneChange) throw ()
 Returns whether the detector may has to be concerned during the vehicle's further movement.
void notifyLeave (MSVehicle &veh, bool isArrival, bool isLaneChange) throw ()
 Dismisses the vehicle if it is on the detector due to a lane change.
Methods inherited from MSVehicleQuitReminded.
void removeOnTripEnd (MSVehicle *veh) throw ()
 Removes the information that the vehicle is on the detector.
Methods inherited from MSDetectorFileOutput.
void writeXMLDetectorProlog (OutputDevice &dev) const throw (IOError)
 Opens the XML-output using "detector" as root element.
void writeXMLOutput (OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime) throw (IOError)
 Writes collected values into the given stream.

Protected Types

typedef std::deque< VehicleDataVehicleDataCont
 Type of myVehicleDataCont.
typedef std::map< MSVehicle
*, SUMOReal > 
VehicleMap
 Type of myVehiclesOnDet.

Protected Member Functions

std::vector< VehicleDatacollectVehiclesOnDet (SUMOTime t) const throw ()
 Returns vehicle data for vehicles that have been on the detector starting at the given time.
Methods that add and remove vehicles from internal container
void enterDetectorByMove (MSVehicle &veh, SUMOReal entryTimestep) throw ()
 Introduces a vehicle to the detector's map myVehiclesOnDet.
void leaveDetectorByLaneChange (MSVehicle &veh) throw ()
 Removes a vehicle from the detector's map myVehiclesOnDet.
void leaveDetectorByMove (MSVehicle &veh, SUMOReal leaveTimestep) throw ()
 Processes a vehicle that leaves the detector.

Static Protected Member Functions

Function for summing up values
static SUMOReal lengthSum (SUMOReal sumSoFar, const MSInductLoop::VehicleData &data) throw ()
 Adds up VehicleData::lengthM.
static SUMOReal speedSum (SUMOReal sumSoFar, const MSInductLoop::VehicleData &data) throw ()
 Adds up VehicleData::speedM.

Protected Attributes

MSVehiclemyCurrentVehicle
 The vehicle that is currently on the detector.
unsigned myDismissedVehicleNumber
 The number of dismissed vehicles.
std::string myID
 The name of the object.
MSLane *const myLane
 Lane on which the reminder works.
SUMOReal myLastLeaveTime
 Leave-time of the last vehicle detected [s].
SUMOReal myLastOccupancy
 Occupancy by the last vehicle detected.
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].
VehicleDataCont myVehicleDataCont
 Data of vehicles that have completely passed the detector.
VehicleMap myVehiclesOnDet
 Data for vehicles that have entered the detector (vehicle -> enter time).

Data Structures

class  MyWrapper

Member Typedef Documentation

typedef std::deque< VehicleData > MSInductLoop::VehicleDataCont [protected, inherited]

Type of myVehicleDataCont.

Definition at line 373 of file MSInductLoop.h.

typedef std::map< MSVehicle*, SUMOReal > MSInductLoop::VehicleMap [protected, inherited]

Type of myVehiclesOnDet.

Definition at line 383 of file MSInductLoop.h.


Constructor & Destructor Documentation

GUIInductLoop::GUIInductLoop ( const std::string &  id,
MSLane *const   lane,
SUMOReal  position 
) throw ()

Constructor.

Adds reminder to MSLane.

Parameters:
id Unique id.
lane Lane where detector woks on.
position Position of the detector within the lane.

Definition at line 58 of file GUIInductLoop.cpp.

00060         : MSInductLoop(id, lane, position) {}

GUIInductLoop::~GUIInductLoop (  )  throw ()

Destructor.

Definition at line 63 of file GUIInductLoop.cpp.

00063 {}


Member Function Documentation

GUIDetectorWrapper * GUIInductLoop::buildDetectorWrapper ( GUIGlObjectStorage idStorage,
GUILaneWrapper lane 
) [virtual]

Returns this detector's visualisation-wrapper valid for gui-version only.

Definition at line 67 of file GUIInductLoop.cpp.

References MSInductLoop::myPosition.

00068                                                              {
00069     return new MyWrapper(*this, idStorage, wrapper, myPosition);
00070 }

std::vector< MSInductLoop::VehicleData > MSInductLoop::collectVehiclesOnDet ( SUMOTime  t  )  const throw () [protected, inherited]

Returns vehicle data for vehicles that have been on the detector starting at the given time.

Parameters:
[in] t The time from which vehicles shall be counted
Returns:
The list of vehicles

Definition at line 298 of file MSInductLoop.cpp.

References MSNet::getCurrentTimeStep(), MSVehicle::getID(), MSNet::getInstance(), MSVehicleType::getLength(), MSVehicle::getSpeed(), MSVehicle::getVehicleType(), MSInductLoop::myLastVehicleDataCont, MSInductLoop::myVehicleDataCont, MSInductLoop::myVehiclesOnDet, STEPS2TIME, and SUMOReal.

Referenced by MSInductLoop::getCurrentLength(), MSInductLoop::getCurrentOccupancy(), MSInductLoop::getCurrentPassedNumber(), MSInductLoop::getCurrentSpeed(), MSInductLoop::getCurrentVehicleIDs(), and MSInductLoop::getNVehContributed().

00298                                                              {
00299     SUMOReal t = STEPS2TIME(tMS);
00300     std::vector<VehicleData> ret;
00301     for (VehicleDataCont::const_iterator i=myVehicleDataCont.begin(); i!=myVehicleDataCont.end(); ++i) {
00302         if ((*i).leaveTimeM>=t) {
00303             ret.push_back(*i);
00304         }
00305     }
00306     for (VehicleDataCont::const_iterator i=myLastVehicleDataCont.begin(); i!=myLastVehicleDataCont.end(); ++i) {
00307         if ((*i).leaveTimeM>=t) {
00308             ret.push_back(*i);
00309         }
00310     }
00311     SUMOTime ct = MSNet::getInstance()->getCurrentTimeStep();
00312     for (VehicleMap::const_iterator i=myVehiclesOnDet.begin(); i!=myVehiclesOnDet.end(); ++i) {
00313         MSVehicle *v = (*i).first;
00314         VehicleData d(v->getID(), v->getVehicleType().getLength(), (*i).second, STEPS2TIME(ct));
00315         d.speedM = v->getSpeed();
00316         ret.push_back(d);
00317     }
00318     return ret;
00319 }

void MSInductLoop::enterDetectorByMove ( MSVehicle veh,
SUMOReal  entryTimestep 
) throw () [protected, inherited]

Introduces a vehicle to the detector's map myVehiclesOnDet.

Parameters:
veh The entering vehicle.
entryTimestep Timestep (not necessary integer) of entrance.

Definition at line 247 of file MSInductLoop.cpp.

References MSVehicle::getID(), Named::getID(), MsgHandler::getWarningInstance(), MsgHandler::inform(), MSInductLoop::leaveDetectorByMove(), MSInductLoop::myCurrentVehicle, and MSInductLoop::myVehiclesOnDet.

Referenced by MSInductLoop::isStillActive().

00248                                                                   {
00249     myVehiclesOnDet.insert(std::make_pair(&veh, entryTimestep));
00250     veh.quitRemindedEntered(this);
00251     if (myCurrentVehicle!=0&&myCurrentVehicle!=&veh) {
00252         // in fact, this is an error - a second vehicle is on the detector
00253         //  before the first one leaves... (collision)
00254         // Still, this seems to happen, but should not be handled herein.
00255         //  we will inform the user, etc., but continue as nothing had happened
00256         MsgHandler::getWarningInstance()->inform("Collision on e1-detector '" + getID() + "'.\n Vehicle '" + myCurrentVehicle->getID() +
00257                 "' was aready at detector as '" + veh.getID() + "' entered.");
00258         leaveDetectorByMove(*myCurrentVehicle, entryTimestep);
00259     }
00260     myCurrentVehicle = &veh;
00261 }

SUMOReal MSInductLoop::getCurrentLength (  )  const throw () [inherited]

Returns the length of the vehicle on the detector.

If no vehicle is on the detector, -1 is returned, otherwise this vehicle's length.

Returns:
The length [m] of the vehicle if one is on the detector, -1 otherwise

Definition at line 148 of file MSInductLoop.cpp.

References MSInductLoop::collectVehiclesOnDet(), DELTA_T, MSNet::getInstance(), MSInductLoop::lengthSum(), and SUMOReal.

Referenced by GUIInductLoop::MyWrapper::getParameterWindow(), and TraCIServerAPI_InductionLoop::processGet().

00148                                              {
00149     std::vector<VehicleData> d = collectVehiclesOnDet(MSNet::getInstance()->getCurrentTimeStep()-DELTA_T);
00150     return d.size()!=0
00151            ? accumulate(d.begin(), d.end(), (SUMOReal) 0.0, lengthSum) / (SUMOReal) d.size()
00152            : -1;
00153 }

SUMOReal MSInductLoop::getCurrentOccupancy (  )  const throw () [inherited]

Returns the current occupancy.

If a vehicle is on the detector, 1 is returned. If a vehicle has passed the detector in this timestep, its occupancy value is returned. If no vehicle has passed, 0 is returned.

Returns:
This detector's current occupancy
Todo:
recheck (especially if more than one vehicle has passed)

Definition at line 157 of file MSInductLoop.cpp.

References MSInductLoop::collectVehiclesOnDet(), DELTA_T, MSNet::getCurrentTimeStep(), MSNet::getInstance(), MAX2(), MIN2(), STEPS2TIME, SUMOReal, and TS.

Referenced by GUIInductLoop::MyWrapper::getParameterWindow(), and TraCIServerAPI_InductionLoop::processGet().

00157                                                 {
00158     SUMOTime tbeg = MSNet::getInstance()->getCurrentTimeStep()-DELTA_T;
00159     std::vector<VehicleData> d = collectVehiclesOnDet(tbeg);
00160     if(d.size()==0) {
00161         return -1;
00162     }
00163     SUMOReal occupancy = 0;
00164     for(std::vector< VehicleData >::const_iterator i=d.begin(); i!=d.end(); ++i) {
00165         SUMOReal timeOnDetDuringInterval = (*i).leaveTimeM - MAX2(STEPS2TIME(tbeg), (*i).entryTimeM);
00166         timeOnDetDuringInterval = MIN2(timeOnDetDuringInterval, TS);
00167         occupancy += timeOnDetDuringInterval;
00168     }
00169     return occupancy / TS * (SUMOReal) 100.;
00170 }

SUMOReal MSInductLoop::getCurrentPassedNumber (  )  const throw () [inherited]

Returns the number of vehicles that have passed the detector.

If a vehicle is on the detector, 1 is returned. If a vehicle has passed the detector in this timestep, 1 is returned. If no vehicle has passed, 0 is returned.

Returns:
The number of vehicles that have passed the detector
Todo:
recheck (especially if more than one vehicle has passed)

Definition at line 174 of file MSInductLoop.cpp.

References MSInductLoop::collectVehiclesOnDet(), DELTA_T, MSNet::getInstance(), and SUMOReal.

Referenced by GUIInductLoop::MyWrapper::getParameterWindow(), and TraCIServerAPI_InductionLoop::processGet().

00174                                                    {
00175     std::vector<VehicleData> d = collectVehiclesOnDet(MSNet::getInstance()->getCurrentTimeStep()-DELTA_T);
00176     return (SUMOReal) d.size();
00177 }

SUMOReal MSInductLoop::getCurrentSpeed (  )  const throw () [inherited]

Returns the speed of the vehicle on the detector.

If no vehicle is on the detector, -1 is returned, otherwise this vehicle's current speed.

Returns:
The speed [m/s] of the vehicle if one is on the detector, -1 otherwise

Definition at line 139 of file MSInductLoop.cpp.

References MSInductLoop::collectVehiclesOnDet(), DELTA_T, MSNet::getInstance(), MSInductLoop::speedSum(), and SUMOReal.

Referenced by MSCalibrator::execute(), GUIInductLoop::MyWrapper::getParameterWindow(), and TraCIServerAPI_InductionLoop::processGet().

00139                                             {
00140     std::vector<VehicleData> d = collectVehiclesOnDet(MSNet::getInstance()->getCurrentTimeStep()-DELTA_T);
00141     return d.size()!=0
00142            ? accumulate(d.begin(), d.end(), (SUMOReal) 0.0, speedSum) / (SUMOReal) d.size()
00143            : -1;
00144 }

std::vector< std::string > MSInductLoop::getCurrentVehicleIDs (  )  const throw () [inherited]

Returns the ids of vehicles that have passed the detector.

Returns:
The ids of vehicles that have passed the detector
Todo:
recheck (especially if more than one vehicle has passed)

Definition at line 181 of file MSInductLoop.cpp.

References MSInductLoop::collectVehiclesOnDet(), DELTA_T, and MSNet::getInstance().

Referenced by TraCIServerAPI_InductionLoop::processGet().

00181                                                  {
00182     std::vector<VehicleData> d = collectVehiclesOnDet(MSNet::getInstance()->getCurrentTimeStep()-DELTA_T);
00183     std::vector<std::string> ret;
00184     for (std::vector<VehicleData>::iterator i=d.begin(); i!=d.end(); ++i) {
00185         ret.push_back((*i).idM);
00186     }
00187     return ret;
00188 }

const std::string& Named::getID (  )  const throw () [inline, inherited]

Returns the id.

Returns:
The stored id

Definition at line 59 of file Named.h.

References Named::myID.

Referenced by RORouteDef_Alternatives::addAlternative(), MSRouteProbe::addRoute(), MSEmitter::MSEmitter_FileTriggeredChild::buildAndScheduleFlowVehicle(), MSCalibrator::MSCalibrator_FileTriggeredChild::buildAndScheduleFlowVehicle(), RORouteDef_Complete::buildCurrentRoute(), ODDistrictHandler::closeDistrict(), NBTrafficLightDefinition::collectLinks(), NBTrafficLightDefinition::compute(), GUIPointOfInterest::drawGL(), MSInductLoop::enterDetectorByMove(), MSVTypeProbe::execute(), MSNet::getBusStopID(), GUITriggeredRerouter::getMicrosimID(), GUIPointOfInterest::getMicrosimID(), GUILaneSpeedTrigger::getMicrosimID(), GUIInductLoop::MyWrapper::getMicrosimID(), GUIEmitter::getMicrosimID(), GUIBusStop::getMicrosimID(), GUI_E2_ZS_Collector::MyWrapper::getMicrosimID(), traci::TraCIServer::handlePoiDomain(), RORDLoader_SUMOBase::myCharacters(), NBOwnTLDef::myCompute(), NBLoadedTLDef::myCompute(), MSTriggeredRerouter::myStartElement(), MSLaneSpeedTrigger::myStartElement(), MSEmitter::MSEmitter_FileTriggeredChild::myStartElement(), MSCalibrator::MSCalibrator_FileTriggeredChild::myStartElement(), NBLoadedTLDef::SignalGroup::patchTYellow(), TraCIServerAPI_Vehicle::processGet(), MSVehicle::replaceRoute(), MSVehicle::saveState(), NBOwnTLDef::setTLControllingInformation(), NBLoadedTLDef::setTLControllingInformation(), RORDLoader_SUMOBase::startRoute(), GUIEmitter::GUIEmitterChild_UserTriggeredChild::wrappedExecute(), NBTrafficLightLogic::writeXML(), MSRouteProbe::writeXMLOutput(), MSInductLoop::writeXMLOutput(), MSE2Collector::writeXMLOutput(), and MSVehicle::~MSVehicle().

00059                                            {
00060         return myID;
00061     }

const MSLane* const MSMoveReminder::getLane (  )  const throw () [inline, inherited]

unsigned MSInductLoop::getNVehContributed (  )  const throw () [inherited]

Definition at line 192 of file MSInductLoop.cpp.

References MSInductLoop::collectVehiclesOnDet(), DELTA_T, and MSNet::getInstance().

Referenced by MSCalibrator::execute().

00192                                                {
00193     return (unsigned int) collectVehiclesOnDet(MSNet::getInstance()->getCurrentTimeStep()-DELTA_T).size();
00194 }

SUMOReal MSInductLoop::getTimestepsSinceLastDetection (  )  const throw () [inherited]

Returns the time since the last vehicle left the detector.

Returns:
Timesteps from last leaving (detection) of the detector

Definition at line 198 of file MSInductLoop.cpp.

References MSNet::getInstance(), MSInductLoop::myLastLeaveTime, MSInductLoop::myVehiclesOnDet, and STEPS2TIME.

Referenced by GUIInductLoop::MyWrapper::getParameterWindow(), and TraCIServerAPI_InductionLoop::processGet().

00198                                                            {
00199     if (myVehiclesOnDet.size() != 0) {
00200         // detector is occupied
00201         return 0;
00202     }
00203     return STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()) - myLastLeaveTime;
00204 }

bool MSInductLoop::isStillActive ( MSVehicle veh,
SUMOReal  oldPos,
SUMOReal  newPos,
SUMOReal  newSpeed 
) throw () [virtual, inherited]

Checks whether the vehicle shall be counted and/or shall still touch this MSMoveReminder.

As soon a vehicle enters the detector, its entry time is computed and stored in myVehiclesOnDet via enterDetectorByMove. If it passes the detector, the according leaving time is computed and stored, too, using leaveDetectorByMove.

Parameters:
[in] veh Vehicle that asks this remider.
[in] oldPos Position before move.
[in] newPos Position after move with newSpeed.
[in] newSpeed Moving speed.
Returns:
True if vehicle hasn't passed the detector completely.
See also:
MSMoveReminder

MSMoveReminder::isStillActive

enterDetectorByMove

leaveDetectorByMove

Reimplemented from MSMoveReminder.

Definition at line 80 of file MSInductLoop.cpp.

References MSInductLoop::enterDetectorByMove(), MSNet::getInstance(), MSInductLoop::leaveDetectorByMove(), MSInductLoop::myPosition, MSInductLoop::myVehiclesOnDet, STEPS2TIME, and SUMOReal.

00081                                                                         {
00082     if (newPos < myPosition) {
00083         // detector not reached yet
00084         return true;
00085     }
00086     if (myVehiclesOnDet.find(&veh) == myVehiclesOnDet.end()) {
00087         // entered the detector by move
00088         SUMOReal entryTime = STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep());
00089         if (newSpeed!=0) {
00090             entryTime += (myPosition - oldPos) / newSpeed;
00091         }
00092         if (newPos - veh.getVehicleType().getLength() > myPosition) {
00093             // entered and passed detector in a single timestep
00094             SUMOReal leaveTime = STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep());
00095             leaveTime += (myPosition - oldPos + veh.getVehicleType().getLength()) / newSpeed;
00096             enterDetectorByMove(veh, entryTime);
00097             leaveDetectorByMove(veh, leaveTime);
00098             return false;
00099         }
00100         // entered detector, but not passed
00101         enterDetectorByMove(veh, entryTime);
00102         return true;
00103     } else {
00104         // vehicle has been on the detector the previous timestep
00105         if (newPos - veh.getVehicleType().getLength() >= myPosition) {
00106             // vehicle passed the detector
00107             SUMOReal leaveTime = STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep());
00108             leaveTime += (myPosition - oldPos + veh.getVehicleType().getLength()) / newSpeed;
00109             leaveDetectorByMove(veh, leaveTime);
00110             return false;
00111         }
00112         // vehicle stays on the detector
00113         return true;
00114     }
00115 }

void MSInductLoop::leaveDetectorByLaneChange ( MSVehicle veh  )  throw () [protected, inherited]

Removes a vehicle from the detector's map myVehiclesOnDet.

Parameters:
veh The leaving vehicle.

Definition at line 281 of file MSInductLoop.cpp.

References MSInductLoop::myCurrentVehicle, MSInductLoop::myDismissedVehicleNumber, MSInductLoop::myVehiclesOnDet, and MSVehicle::quitRemindedLeft().

Referenced by MSInductLoop::notifyLeave().

00281                                                               {
00282     // Discard entry data
00283     myVehiclesOnDet.erase(&veh);
00284     myDismissedVehicleNumber++;
00285     myCurrentVehicle = 0;
00286     veh.quitRemindedLeft(this);
00287 }

void MSInductLoop::leaveDetectorByMove ( MSVehicle veh,
SUMOReal  leaveTimestep 
) throw () [protected, inherited]

Processes a vehicle that leaves the detector.

Removes a vehicle from the detector's map myVehiclesOnDet and adds the vehicle data to the internal myVehicleDataCont.

Parameters:
veh The leaving vehicle.
leaveTimestep Timestep (not necessary integer) of leaving.

Definition at line 265 of file MSInductLoop.cpp.

References MSInductLoop::myCurrentVehicle, MSInductLoop::myLastLeaveTime, MSInductLoop::myLastOccupancy, MSInductLoop::myVehicleDataCont, MSInductLoop::myVehiclesOnDet, MSVehicle::quitRemindedLeft(), and SUMOReal.

Referenced by MSInductLoop::enterDetectorByMove(), and MSInductLoop::isStillActive().

00266                                                                   {
00267     VehicleMap::iterator it = myVehiclesOnDet.find(&veh);
00268     assert(it != myVehiclesOnDet.end());
00269     SUMOReal entryTimestep = it->second;
00270     myVehiclesOnDet.erase(it);
00271     assert(entryTimestep < leaveTimestep);
00272     myVehicleDataCont.push_back(VehicleData(veh.getID(), veh.getVehicleType().getLength(), entryTimestep, leaveTimestep));
00273     myLastOccupancy = leaveTimestep - entryTimestep;
00274     myLastLeaveTime = leaveTimestep;
00275     myCurrentVehicle = 0;
00276     veh.quitRemindedLeft(this);
00277 }

static SUMOReal MSInductLoop::lengthSum ( SUMOReal  sumSoFar,
const MSInductLoop::VehicleData data 
) throw () [inline, static, protected, inherited]

Adds up VehicleData::lengthM.

Definition at line 338 of file MSInductLoop.h.

Referenced by MSInductLoop::getCurrentLength(), and MSInductLoop::writeXMLOutput().

00338                                                                                                      {
00339         return sumSoFar + data.lengthM;
00340     }

bool MSInductLoop::notifyEnter ( MSVehicle veh,
bool  isEmit,
bool  isLaneChange 
) throw () [virtual, inherited]

Returns whether the detector may has to be concerned during the vehicle's further movement.

If the detector is in front of the vehicle, true is returned. If the vehicle's front has passed the detector, false, because the vehicle is no longer relevant for the detector.

Parameters:
[in] veh The entering vehicle.
[in] isEmit whether the vehicle was just emitted into the net
[in] isLaneChange whether the vehicle changed to the lane
Returns:
True if vehicle is on or in front of the detector.
See also:
MSMoveReminder

MSMoveReminder::notifyEnter

Reimplemented from MSMoveReminder.

Definition at line 128 of file MSInductLoop.cpp.

References MSVehicleType::getLength(), MSVehicle::getPositionOnLane(), MSVehicle::getVehicleType(), and MSInductLoop::myPosition.

00128                                                             {
00129     if (veh.getPositionOnLane() - veh.getVehicleType().getLength() > myPosition) {
00130         // vehicle-front is beyond detector. Ignore
00131         return false;
00132     }
00133     // vehicle is in front of detector
00134     return true;
00135 }

void MSInductLoop::notifyLeave ( MSVehicle veh,
bool  isArrival,
bool  isLaneChange 
) throw () [virtual, inherited]

Dismisses the vehicle if it is on the detector due to a lane change.

If the vehicle is on the detector, it will be dismissed by incrementing myDismissedVehicleNumber and removing this vehicle's entering time from myVehiclesOnDet.

Parameters:
[in] veh The leaving vehicle.
[in] isArrival whether the vehicle arrived at its destination
[in] isLaneChange whether the vehicle changed from the lane
See also:
leaveDetectorByLaneChange

MSMoveReminder

MSMoveReminder::notifyLeave

Reimplemented from MSMoveReminder.

Definition at line 119 of file MSInductLoop.cpp.

References MSInductLoop::leaveDetectorByLaneChange(), and MSInductLoop::myPosition.

00119                                                                                    {
00120     if (veh.getPositionOnLane() > myPosition && veh.getPositionOnLane() - veh.getVehicleType().getLength() <= myPosition) {
00121         // vehicle is on detector during lane change
00122         leaveDetectorByLaneChange(veh);
00123     }
00124 }

void MSInductLoop::removeOnTripEnd ( MSVehicle veh  )  throw () [virtual, inherited]

Removes the information that the vehicle is on the detector.

Parameters:
[in] veh The vehicle that was on the detector and leaves the simuation

Implements MSVehicleQuitReminded.

Definition at line 291 of file MSInductLoop.cpp.

References MSInductLoop::myCurrentVehicle, and MSInductLoop::myVehiclesOnDet.

00291                                                     {
00292     myCurrentVehicle = 0;
00293     myVehiclesOnDet.erase(veh);
00294 }

void MSInductLoop::reset (  )  throw () [virtual, inherited]

Resets all generated values to allow computation of next interval.

Reimplemented from MSDetectorFileOutput.

Definition at line 72 of file MSInductLoop.cpp.

References MSInductLoop::myDismissedVehicleNumber, MSInductLoop::myLastVehicleDataCont, and MSInductLoop::myVehicleDataCont.

Referenced by MSInductLoop::writeXMLOutput().

00072                             {
00073     myDismissedVehicleNumber = 0;
00074     myLastVehicleDataCont = myVehicleDataCont;
00075     myVehicleDataCont.clear();
00076 }

static SUMOReal MSInductLoop::speedSum ( SUMOReal  sumSoFar,
const MSInductLoop::VehicleData data 
) throw () [inline, static, protected, inherited]

Adds up VehicleData::speedM.

Definition at line 333 of file MSInductLoop.h.

Referenced by MSInductLoop::getCurrentSpeed(), and MSInductLoop::writeXMLOutput().

00333                                                                                                     {
00334         return sumSoFar + data.speedM;
00335     }

void MSInductLoop::writeXMLDetectorProlog ( OutputDevice dev  )  const throw (IOError) [virtual, inherited]

Opens the XML-output using "detector" as root element.

Parameters:
[in] dev The output device to write the root into
See also:
MSDetectorFileOutput::writeXMLDetectorProlog
Exceptions:
IOError If an error on writing occurs (!!! not yet implemented)

Implements MSDetectorFileOutput.

Definition at line 208 of file MSInductLoop.cpp.

00208                                                                            {
00209     dev.writeXMLHeader("detector");
00210 }

void MSInductLoop::writeXMLOutput ( OutputDevice dev,
SUMOTime  startTime,
SUMOTime  stopTime 
) throw (IOError) [virtual, inherited]

Writes collected values into the given stream.

Parameters:
[in] dev The output device to write the data into
[in] startTime First time step the data were gathered
[in] stopTime Last time step the data were gathered
See also:
MSDetectorFileOutput::writeXMLOutput
Exceptions:
IOError If an error on writing occurs (!!! not yet implemented)

Implements MSDetectorFileOutput.

Definition at line 214 of file MSInductLoop.cpp.

References StringUtils::escapeXML(), Named::getID(), MSInductLoop::lengthSum(), MAX2(), MIN2(), MSInductLoop::myDismissedVehicleNumber, MSInductLoop::myVehicleDataCont, MSInductLoop::myVehiclesOnDet, MSInductLoop::reset(), MSInductLoop::speedSum(), STEPS2TIME, SUMOReal, and time2string().

00215                                                                                    {
00216     SUMOReal t(STEPS2TIME(stopTime-startTime));
00217     unsigned nVehCrossed = (unsigned) myVehicleDataCont.size() + myDismissedVehicleNumber;
00218     SUMOReal flow = ((SUMOReal) myVehicleDataCont.size() / (SUMOReal) t) * (SUMOReal) 3600.0;
00219     SUMOReal occupancy = 0;
00220     for(std::deque< VehicleData >::const_iterator i=myVehicleDataCont.begin(); i!=myVehicleDataCont.end(); ++i) {
00221         SUMOReal timeOnDetDuringInterval = (*i).leaveTimeM - MAX2(STEPS2TIME(startTime), (*i).entryTimeM);
00222         timeOnDetDuringInterval = MIN2(timeOnDetDuringInterval, t);
00223         occupancy += timeOnDetDuringInterval;
00224     }
00225     for(std::map< MSVehicle*, SUMOReal >::const_iterator i=myVehiclesOnDet.begin(); i!=myVehiclesOnDet.end(); ++i) {
00226         SUMOReal timeOnDetDuringInterval = STEPS2TIME(stopTime) - MAX2(STEPS2TIME(startTime), (*i).second);
00227         occupancy += timeOnDetDuringInterval;
00228     }
00229     occupancy = occupancy / t * (SUMOReal) 100.;
00230     SUMOReal meanSpeed = myVehicleDataCont.size()!=0
00231                          ? accumulate(myVehicleDataCont.begin(), myVehicleDataCont.end(), (SUMOReal) 0.0, speedSum) / (SUMOReal) myVehicleDataCont.size()
00232                          : -1;
00233     SUMOReal meanLength = myVehicleDataCont.size()!=0
00234                           ? accumulate(myVehicleDataCont.begin(), myVehicleDataCont.end(), (SUMOReal) 0.0, lengthSum) / (SUMOReal) myVehicleDataCont.size()
00235                           : -1;
00236     dev<<"   <interval begin=\""<<time2string(startTime)<<"\" end=\""<<
00237     time2string(stopTime)<<"\" "<<"id=\""<<StringUtils::escapeXML(getID())<<"\" ";
00238     dev<<"nVehContrib=\""<<myVehicleDataCont.size()<<"\" flow=\""<<flow<<
00239     "\" occupancy=\""<<occupancy<<"\" speed=\""<<meanSpeed<<
00240     "\" length=\""<<meanLength<<
00241     "\" nVehEntered=\""<<nVehCrossed<<"\"/>\n";
00242     reset();
00243 }


Field Documentation

MSVehicle* MSInductLoop::myCurrentVehicle [protected, inherited]

unsigned MSInductLoop::myDismissedVehicleNumber [protected, inherited]

The number of dismissed vehicles.

Definition at line 369 of file MSInductLoop.h.

Referenced by MSInductLoop::leaveDetectorByLaneChange(), MSInductLoop::reset(), and MSInductLoop::writeXMLOutput().

std::string Named::myID [protected, inherited]

MSLane* const MSMoveReminder::myLane [protected, inherited]

SUMOReal MSInductLoop::myLastLeaveTime [protected, inherited]

Leave-time of the last vehicle detected [s].

Definition at line 363 of file MSInductLoop.h.

Referenced by MSInductLoop::getTimestepsSinceLastDetection(), and MSInductLoop::leaveDetectorByMove().

SUMOReal MSInductLoop::myLastOccupancy [protected, inherited]

Occupancy by the last vehicle detected.

Definition at line 366 of file MSInductLoop.h.

Referenced by MSInductLoop::leaveDetectorByMove().

Data of vehicles that have completely passed the detector in the last time interval.

Definition at line 379 of file MSInductLoop.h.

Referenced by MSInductLoop::collectVehiclesOnDet(), and MSInductLoop::reset().

const SUMOReal MSInductLoop::myPosition [protected, inherited]

Detector's position on lane [m].

Definition at line 360 of file MSInductLoop.h.

Referenced by buildDetectorWrapper(), MSInductLoop::isStillActive(), MSInductLoop::notifyEnter(), and MSInductLoop::notifyLeave().

Data of vehicles that have completely passed the detector.

Definition at line 376 of file MSInductLoop.h.

Referenced by MSInductLoop::collectVehiclesOnDet(), MSInductLoop::leaveDetectorByMove(), MSInductLoop::reset(), and MSInductLoop::writeXMLOutput().

VehicleMap MSInductLoop::myVehiclesOnDet [protected, inherited]


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:43 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6