GUI_E2_ZS_Collector Class Reference

#include <GUI_E2_ZS_Collector.h>

Inheritance diagram for GUI_E2_ZS_Collector:

MSE2Collector Named MSMoveReminder MSDetectorFileOutput MSVehicleQuitReminded

Detailed Description

The gui-version of the MS_E2_ZS_Collector.

Allows the building of a wrapper (also declared herein) which draws the detector on the gl-canvas. Beside this, the method "amVisible" is overridden to signalise that this detector is not used for simulation- -internal reasons, but is placed over the simulation by the user.

Definition at line 62 of file GUI_E2_ZS_Collector.h.


Public Member Functions

virtual GUIDetectorWrapperbuildDetectorWrapper (GUIGlObjectStorage &idStorage, GUILaneWrapper &wrapper, GUI_E2_ZS_CollectorOverLanes &p, GLuint glID)
virtual GUIDetectorWrapperbuildDetectorWrapper (GUIGlObjectStorage &idStorage, GUILaneWrapper &wrapper)
SUMOReal getEndPos () const throw ()
 Returns the end position of the detector.
const std::string & getID () const throw ()
 Returns the id.
const MSLane *const getLane () const throw ()
 Returns the lane the reminder works on.
SUMOReal getStartPos () const throw ()
 Returns the begin position of the detector.
virtual DetectorUsage getUsageType () const throw ()
 Returns the detector's usage type.
 GUI_E2_ZS_Collector (const std::string &id, DetectorUsage usage, MSLane *const lane, SUMOReal startPos, SUMOReal detLength, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold) throw ()
 Constructor.
void reset () throw ()
 Resets all values.
void update (SUMOTime currentTime) throw ()
 Computes the detector values in each time step.
 ~GUI_E2_ZS_Collector () throw ()
 Destructor.
Methods returning current values
SUMOReal getCurrentJamLengthInMeters () const throw ()
 Returns the length of all jams in meters.
unsigned getCurrentJamLengthInVehicles () const throw ()
 Returns the length of all jams in vehicles.
unsigned getCurrentJamNumber () const throw ()
 Returns the current number of jams.
SUMOReal getCurrentMaxJamLengthInMeters () const throw ()
 Returns the length in meters of the currently largest jam.
unsigned getCurrentMaxJamLengthInVehicles () const throw ()
 Returns the length in vehicles of the currently largest jam.
SUMOReal getCurrentMeanLength () const throw ()
 Returns the mean vehicle length of vehicles currently on the detector.
SUMOReal getCurrentMeanSpeed () const throw ()
 Returns the mean vehicle speed of vehicles currently on the detector.
SUMOReal getCurrentOccupancy () const throw ()
 Returns the curent detector occupancy.
unsigned getCurrentStartedHalts () const throw ()
 Returns the length of all jams in meters.
unsigned getCurrentVehicleNumber () const throw ()
 Returns the number of vehicles currently on the detector.
Methods inherited from MSMoveReminder
bool isStillActive (MSVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal newSpeed) throw ()
 Adds/removes vehicles from the list of vehicles to regard.
bool notifyEnter (MSVehicle &veh, bool isEmit, bool isLaneChange) throw ()
 Adds the vehicle to known vehicles if not beyond the dector.
void notifyLeave (MSVehicle &veh, bool isArrival, bool isLaneChange) throw ()
 Removes a known vehicle due to its 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 Attributes

std::string myID
 The name of the object.
MSLane *const myLane
 Lane on which the reminder works.

Data Structures

class  MyWrapper

Constructor & Destructor Documentation

GUI_E2_ZS_Collector::GUI_E2_ZS_Collector ( const std::string &  id,
DetectorUsage  usage,
MSLane *const   lane,
SUMOReal  startPos,
SUMOReal  detLength,
SUMOTime  haltingTimeThreshold,
SUMOReal  haltingSpeedThreshold,
SUMOReal  jamDistThreshold 
) throw ()

Constructor.

Parameters:
[in] id The detector's unique id.
[in] usage Information how the detector is used
[in] lane The lane to place the detector at
[in] startPos Begin position of the detector
[in] detLength Length of the detector
[in] haltingTimeThreshold The time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed
[in] haltingSpeedThreshold The speed a vehicle's speed must be below to be assigned as jammed
[in] jamDistThreshold The distance between two vehicles in order to not count them to one jam
Todo:
The lane should not be given as a pointer

Definition at line 57 of file GUI_E2_ZS_Collector.cpp.

00061         : MSE2Collector(id, usage, lane, startPos, detLength, haltingTimeThreshold,
00062                         haltingSpeedThreshold, jamDistThreshold) {}

GUI_E2_ZS_Collector::~GUI_E2_ZS_Collector (  )  throw ()

Destructor.

Definition at line 66 of file GUI_E2_ZS_Collector.cpp.

00066 {}


Member Function Documentation

GUIDetectorWrapper * GUI_E2_ZS_Collector::buildDetectorWrapper ( GUIGlObjectStorage idStorage,
GUILaneWrapper wrapper,
GUI_E2_ZS_CollectorOverLanes p,
GLuint  glID 
) [virtual]

Definition at line 76 of file GUI_E2_ZS_Collector.cpp.

00079                      {
00080     return new MyWrapper(*this, idStorage, glID, p, wrapper);
00081 }

GUIDetectorWrapper * GUI_E2_ZS_Collector::buildDetectorWrapper ( GUIGlObjectStorage idStorage,
GUILaneWrapper wrapper 
) [virtual]

Definition at line 70 of file GUI_E2_ZS_Collector.cpp.

Referenced by GUI_E2_ZS_CollectorOverLanes::MyWrapper::MyWrapper().

00071                                  {
00072     return new MyWrapper(*this, idStorage, wrapper);
00073 }

SUMOReal MSE2Collector::getCurrentJamLengthInMeters (  )  const throw () [inherited]

Returns the length of all jams in meters.

Definition at line 434 of file MSE2Collector.cpp.

References MSE2Collector::myCurrentJamLengthInMeters.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow().

00434                                                          {
00435     return myCurrentJamLengthInMeters;
00436 }

unsigned MSE2Collector::getCurrentJamLengthInVehicles (  )  const throw () [inherited]

Returns the length of all jams in vehicles.

Definition at line 428 of file MSE2Collector.cpp.

References MSE2Collector::myCurrentJamLengthInVehicles.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow().

00428                                                            {
00429     return myCurrentJamLengthInVehicles;
00430 }

unsigned MSE2Collector::getCurrentJamNumber (  )  const throw () [inherited]

Returns the current number of jams.

Definition at line 410 of file MSE2Collector.cpp.

References MSE2Collector::myCurrentJamNo.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow().

00410                                                  {
00411     return myCurrentJamNo;
00412 }

SUMOReal MSE2Collector::getCurrentMaxJamLengthInMeters (  )  const throw () [inherited]

Returns the length in meters of the currently largest jam.

Definition at line 422 of file MSE2Collector.cpp.

References MSE2Collector::myCurrentMaxJamLengthInMeters.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow().

00422                                                             {
00423     return myCurrentMaxJamLengthInMeters;
00424 }

unsigned MSE2Collector::getCurrentMaxJamLengthInVehicles (  )  const throw () [inherited]

Returns the length in vehicles of the currently largest jam.

Definition at line 416 of file MSE2Collector.cpp.

References MSE2Collector::myCurrentMaxJamLengthInVehicles.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow().

00416                                                               {
00417     return myCurrentMaxJamLengthInVehicles;
00418 }

SUMOReal MSE2Collector::getCurrentMeanLength (  )  const throw () [inherited]

Returns the mean vehicle length of vehicles currently on the detector.

Definition at line 404 of file MSE2Collector.cpp.

References MSE2Collector::myCurrentMeanLength.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow().

00404                                                   {
00405     return myCurrentMeanLength;
00406 }

SUMOReal MSE2Collector::getCurrentMeanSpeed (  )  const throw () [inherited]

Returns the mean vehicle speed of vehicles currently on the detector.

Definition at line 398 of file MSE2Collector.cpp.

References MSE2Collector::myCurrentMeanSpeed.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow().

00398                                                  {
00399     return myCurrentMeanSpeed;
00400 }

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

Returns the curent detector occupancy.

Definition at line 392 of file MSE2Collector.cpp.

References MSE2Collector::myCurrentOccupancy, and SUMOReal.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow().

00392                                                  {
00393     return myCurrentOccupancy *(SUMOReal) 100.;
00394 }

unsigned MSE2Collector::getCurrentStartedHalts (  )  const throw () [inherited]

Returns the length of all jams in meters.

Definition at line 440 of file MSE2Collector.cpp.

References MSE2Collector::myCurrentStartedHalts.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow().

00440                                                     {
00441     return myCurrentStartedHalts;
00442 }

unsigned MSE2Collector::getCurrentVehicleNumber (  )  const throw () [inherited]

Returns the number of vehicles currently on the detector.

Definition at line 386 of file MSE2Collector.cpp.

References MSE2Collector::myKnownVehicles.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow().

00386                                                      {
00387     return (unsigned) myKnownVehicles.size();
00388 }

SUMOReal MSE2Collector::getEndPos (  )  const throw () [inline, inherited]

Returns the end position of the detector.

Returns:
The detector's end position

Definition at line 221 of file MSE2Collector.h.

References MSE2Collector::myEndPos.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow(), and GUI_E2_ZS_Collector::MyWrapper::myConstruct().

00221                                        {
00222         return myEndPos;
00223     }

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]

SUMOReal MSE2Collector::getStartPos (  )  const throw () [inline, inherited]

Returns the begin position of the detector.

Returns:
The detector's begin position

Definition at line 212 of file MSE2Collector.h.

References MSE2Collector::myStartPos.

Referenced by GUI_E2_ZS_Collector::MyWrapper::getParameterWindow(), and GUI_E2_ZS_Collector::MyWrapper::myConstruct().

00212                                          {
00213         return myStartPos;
00214     }

virtual DetectorUsage MSE2Collector::getUsageType (  )  const throw () [inline, virtual, inherited]

Returns the detector's usage type.

See also:
DetectorUsage
Returns:
How the detector is used.

Definition at line 102 of file MSE2Collector.h.

References MSE2Collector::myUsage.

Referenced by GUI_E2_ZS_Collector::MyWrapper::drawGL().

00102                                                        {
00103         return myUsage;
00104     }

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

Adds/removes vehicles from the list of vehicles to regard.

As soon as the reported vehicle enters the detector area (position>myStartPos) it is added to the list of vehicles to regard (myKnownVehicles). It is removed from this list if it leaves the detector (position<lengt>myEndPos). The method returns true as long as the vehicle is not beyond the detector.

Parameters:
[in] veh The vehicle in question.
[in] oldPos Position before the move-micro-timestep.
[in] newPos Position after the move-micro-timestep.
[in] newSpeed Unused here.
Returns:
False, if vehicle passed the detector entierly, else true.
See also:
MSMoveReminder

MSMoveReminder::isStillActive

Reimplemented from MSMoveReminder.

Definition at line 72 of file MSE2Collector.cpp.

References MSVehicleType::getLength(), MSVehicle::getVehicleType(), MSE2Collector::myEndPos, MSE2Collector::myKnownVehicles, MSE2Collector::myStartPos, MSVehicle::quitRemindedEntered(), and MSVehicle::quitRemindedLeft().

00073                                                                 {
00074     if (newPos <= myStartPos) {
00075         // detector not yet reached
00076         return true;
00077     }
00078     if (oldPos <= myStartPos && newPos > myStartPos) {
00079         if (find(myKnownVehicles.begin(), myKnownVehicles.end(), &veh)==myKnownVehicles.end()) {
00080             myKnownVehicles.push_back(&veh);
00081             veh.quitRemindedEntered(this);
00082         }
00083     }
00084     if (newPos - veh.getVehicleType().getLength() > myEndPos) {
00085         veh.quitRemindedLeft(this);
00086         std::list<MSVehicle*>::iterator i = find(myKnownVehicles.begin(), myKnownVehicles.end(), &veh);
00087         if (i!=myKnownVehicles.end()) {
00088             myKnownVehicles.erase(i);
00089         }
00090         return false;
00091     }
00092     return true;
00093 }

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

Adds the vehicle to known vehicles if not beyond the dector.

If the vehicles is within the detector are, it is added to the list of known vehicles. The method returns true as long as the vehicle is not beyond the detector.

Parameters:
[in] veh The vehicle that enters the lane
[in] isEmit whether the vehicle was just emitted into the net
[in] isLaneChange whether the vehicle changed to the lane
See also:
MSMoveReminder::notifyEnter
Returns:
False, if vehicle passed the detector entirely, else true.

Reimplemented from MSMoveReminder.

Definition at line 109 of file MSE2Collector.cpp.

References MSVehicleType::getLength(), MSVehicle::getPositionOnLane(), MSVehicle::getVehicleType(), MSE2Collector::myEndPos, MSE2Collector::myKnownVehicles, MSE2Collector::myStartPos, and MSVehicle::quitRemindedEntered().

00109                                                              {
00110     if (veh.getPositionOnLane() >= myStartPos && veh.getPositionOnLane() - veh.getVehicleType().getLength() < myEndPos) {
00111         // vehicle is on detector
00112         veh.quitRemindedEntered(this);
00113         myKnownVehicles.push_back(&veh);
00114         return true;
00115     }
00116     if (veh.getPositionOnLane() - veh.getVehicleType().getLength() > myEndPos) {
00117         // vehicle is beyond detector
00118         return false;
00119     }
00120     // vehicle is in front of detector
00121     return true;
00122 }

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

Removes a known vehicle due to its lane-change.

If the reported vehicle is known, it is removed from the list of vehicles to regard (myKnownVehicles).

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:
MSMoveReminder::notifyLeave

Reimplemented from MSMoveReminder.

Definition at line 97 of file MSE2Collector.cpp.

References MSE2Collector::myEndPos, MSE2Collector::myKnownVehicles, and MSE2Collector::myStartPos.

00097                                                                                     {
00098     if (veh.getPositionOnLane() >= myStartPos && veh.getPositionOnLane() - veh.getVehicleType().getLength() < myEndPos) {
00099         std::list<MSVehicle*>::iterator i = find(myKnownVehicles.begin(), myKnownVehicles.end(), &veh);
00100         if (i!=myKnownVehicles.end()) {
00101             myKnownVehicles.erase(i);
00102         }
00103         veh.quitRemindedLeft(this);
00104     }
00105 }

void MSE2Collector::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 446 of file MSE2Collector.cpp.

References MSE2Collector::myKnownVehicles.

00446                                                      {
00447     myKnownVehicles.erase(find(myKnownVehicles.begin(), myKnownVehicles.end(), veh));
00448 }

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

Resets all values.

This method is called on initialisation and as soon as the values were written. Values for the next interval may be collected, then. The list of known vehicles stays untouched.

Reimplemented from MSDetectorFileOutput.

Definition at line 126 of file MSE2Collector.cpp.

References MSE2Collector::myIntervalHaltingVehicleDurations, MSE2Collector::myJamLengthInMetersSum, MSE2Collector::myJamLengthInVehiclesSum, MSE2Collector::myMaxJamInMeters, MSE2Collector::myMaxJamInVehicles, MSE2Collector::myMaxOccupancy, MSE2Collector::myMaxVehicleNumber, MSE2Collector::myMeanMaxJamInMeters, MSE2Collector::myMeanMaxJamInVehicles, MSE2Collector::myMeanVehicleNumber, MSE2Collector::myOccupancySum, MSE2Collector::myPastIntervalStandingDurations, MSE2Collector::myPastStandingDurations, MSE2Collector::mySpeedSum, MSE2Collector::myStartedHalts, MSE2Collector::myTimeSamples, and MSE2Collector::myVehicleSamples.

Referenced by MSE2Collector::writeXMLOutput().

00126                              {
00127     mySpeedSum = 0;
00128     myStartedHalts = 0;
00129     myJamLengthInMetersSum = 0;
00130     myJamLengthInVehiclesSum = 0;
00131     myVehicleSamples = 0;
00132     myOccupancySum = 0;
00133     myMaxOccupancy = 0;
00134     myMeanMaxJamInVehicles = 0;
00135     myMeanMaxJamInMeters = 0;
00136     myMaxJamInVehicles = 0;
00137     myMaxJamInMeters = 0;
00138     myTimeSamples = 0;
00139     myMeanVehicleNumber = 0;
00140     myMaxVehicleNumber = 0;
00141     for (std::map<MSVehicle*, SUMOReal>::iterator i=myIntervalHaltingVehicleDurations.begin(); i!=myIntervalHaltingVehicleDurations.end(); ++i) {
00142         (*i).second = 0;
00143     }
00144     myPastStandingDurations.clear();
00145     myPastIntervalStandingDurations.clear();
00146 }

void MSE2Collector::update ( SUMOTime  currentTime  )  throw () [inherited]

Computes the detector values in each time step.

This method should be called at the end of a simulation step, when all vehicles have moved. The current values are computed and summed up with the previous.

Parameters:
[in] currentTime The current simulation time

Definition at line 151 of file MSE2Collector.cpp.

References MSE2Collector::JamInfo::firstStandingVehicle, MSVehicle::getLane(), MSMoveReminder::getLane(), MSVehicleType::getLength(), MSVehicle::getPositionOnActiveMoveReminderLane(), MSVehicle::getPositionOnLane(), MSVehicle::getSpeed(), MSVehicle::getVehicleType(), MSE2Collector::JamInfo::lastStandingVehicle, MAX2(), MSE2Collector::myCurrentJamLengthInMeters, MSE2Collector::myCurrentJamLengthInVehicles, MSE2Collector::myCurrentJamNo, MSE2Collector::myCurrentMaxJamLengthInMeters, MSE2Collector::myCurrentMaxJamLengthInVehicles, MSE2Collector::myCurrentMeanLength, MSE2Collector::myCurrentMeanSpeed, MSE2Collector::myCurrentOccupancy, MSE2Collector::myCurrentStartedHalts, MSE2Collector::myEndPos, MSE2Collector::myHaltingVehicleDurations, MSE2Collector::myIntervalHaltingVehicleDurations, MSE2Collector::myJamDistanceThreshold, MSE2Collector::myJamHaltingSpeedThreshold, MSE2Collector::myJamHaltingTimeThreshold, MSE2Collector::myJamLengthInMetersSum, MSE2Collector::myJamLengthInVehiclesSum, MSE2Collector::myKnownVehicles, MSE2Collector::myMaxJamInMeters, MSE2Collector::myMaxJamInVehicles, MSE2Collector::myMaxOccupancy, MSE2Collector::myMaxVehicleNumber, MSE2Collector::myMeanMaxJamInMeters, MSE2Collector::myMeanMaxJamInVehicles, MSE2Collector::myMeanVehicleNumber, MSE2Collector::myOccupancySum, MSE2Collector::myPastIntervalStandingDurations, MSE2Collector::myPastStandingDurations, MSE2Collector::mySpeedSum, MSE2Collector::myStartedHalts, MSE2Collector::myStartPos, MSE2Collector::myTimeSamples, MSE2Collector::myVehicleSamples, and SUMOReal.

00151                                       {
00152     JamInfo *currentJam = 0;
00153     std::map<MSVehicle*, SUMOReal> haltingVehicles;
00154     std::map<MSVehicle*, SUMOReal> intervalHaltingVehicles;
00155     std::vector<JamInfo*> jams;
00156 
00157     SUMOReal lengthSum = 0;
00158     myCurrentMeanSpeed = 0;
00159     myCurrentMeanLength = 0;
00160     myCurrentStartedHalts = 0;
00161 
00162     // go through the (sorted) list of vehicles positioned on the detector
00163     //  sum up values and prepare the list of jams
00164     myKnownVehicles.sort(by_vehicle_position_sorter(getLane()));
00165     for (std::list<MSVehicle*>::const_iterator i=myKnownVehicles.begin(); i!=myKnownVehicles.end(); ++i) {
00166         MSVehicle *veh = *i;
00167 
00168         SUMOReal length = veh->getVehicleType().getLength();
00169         if (&(veh->getLane())==getLane()) {
00170             if (veh->getPositionOnLane() - veh->getVehicleType().getLength() < myStartPos) {
00171                 // vehicle entered detector partially
00172                 length -= (veh->getVehicleType().getLength() - (veh->getPositionOnLane()-myStartPos));
00173             }
00174             if (veh->getPositionOnLane()>myEndPos && veh->getPositionOnLane()-veh->getVehicleType().getLength()<=myEndPos) {
00175                 // vehicle left detector partially
00176                 length -= (veh->getPositionOnLane()-myEndPos);
00177             }
00178         } else {
00179             // ok, the vehicle is only partially still on the detector, has already moved to the
00180             //  next lane; still, we do not know how far away it is
00181             assert(veh->getPositionOnActiveMoveReminderLane(getLane())>0);
00182             length -= (veh->getPositionOnActiveMoveReminderLane(getLane())-myEndPos);
00183         }
00184         assert(length>=0);
00185 
00186         mySpeedSum += veh->getSpeed();
00187         myCurrentMeanSpeed += veh->getSpeed();
00188         lengthSum += length;
00189         myCurrentMeanLength += length;
00190 
00191         // jam-checking begins
00192         bool isInJam = false;
00193         // first, check whether the vehicle is slow enough to be states as halting
00194         if (veh->getSpeed()<myJamHaltingSpeedThreshold) {
00195             // we have to track the time it was halting;
00196             //  so let's look up whether it was halting before and compute the overall halting time
00197             bool wasHalting = myHaltingVehicleDurations.find(veh)!=myHaltingVehicleDurations.end();
00198             if (wasHalting) {
00199                 haltingVehicles[veh] = myHaltingVehicleDurations[veh] + 1;
00200                 intervalHaltingVehicles[veh] = myIntervalHaltingVehicleDurations[veh] + 1;
00201             } else {
00202                 haltingVehicles[veh] = 1;
00203                 intervalHaltingVehicles[veh] = 1;
00204                 myCurrentStartedHalts++;
00205                 myStartedHalts++;
00206             }
00207             // we now check whether the halting time is large enough
00208             if (haltingVehicles[veh]>myJamHaltingTimeThreshold) {
00209                 // yep --> the vehicle is a part of a jam
00210                 isInJam = true;
00211             }
00212         } else {
00213             // is not standing anymore; keep duration information
00214             std::map<MSVehicle*, SUMOReal>::iterator v = myHaltingVehicleDurations.find(veh);
00215             if (v!=myHaltingVehicleDurations.end()) {
00216                 myPastStandingDurations.push_back((*v).second);
00217                 myHaltingVehicleDurations.erase(v);
00218             }
00219             v = myIntervalHaltingVehicleDurations.find(veh);
00220             if (v!=myIntervalHaltingVehicleDurations.end()) {
00221                 myPastIntervalStandingDurations.push_back((*v).second);
00222                 myIntervalHaltingVehicleDurations.erase(v);
00223             }
00224         }
00225 
00226         // jam-building
00227         if (isInJam) {
00228             // the vehicle is in a jam;
00229             //  it may be a new one or already an existing one
00230             if (currentJam==0) {
00231                 // the vehicle is the first vehicle in a jam
00232                 currentJam = new JamInfo;
00233                 currentJam->firstStandingVehicle = i;
00234             } else {
00235                 // ok, we have a jam already. But - maybe it is too far away
00236                 //  ... honestly, I can hardly find a reason for doing this,
00237                 //  but jams were defined this way in an earlier version...
00238                 if (veh->getPositionOnLane()-(*currentJam->lastStandingVehicle)->getPositionOnLane()>myJamDistanceThreshold) {
00239                     // yep, yep, yep - it's a new one...
00240                     //  close the frist, build a new
00241                     jams.push_back(currentJam);
00242                     currentJam = new JamInfo;
00243                     currentJam->firstStandingVehicle = i;
00244                 }
00245             }
00246             currentJam->lastStandingVehicle = i;
00247         } else {
00248             // the vehicle is not part of a jam...
00249             //  maybe we have to close an already computed jam
00250             if (currentJam!=0) {
00251                 jams.push_back(currentJam);
00252                 currentJam = 0;
00253             }
00254         }
00255     }
00256     if (currentJam!=0) {
00257         jams.push_back(currentJam);
00258         currentJam = 0;
00259     }
00260 
00261     myCurrentMaxJamLengthInMeters = 0;
00262     myCurrentMaxJamLengthInVehicles = 0;
00263     myCurrentJamLengthInMeters = 0;
00264     myCurrentJamLengthInVehicles = 0;
00265     // process jam information
00266     for (std::vector<JamInfo*>::iterator i=jams.begin(); i!=jams.end(); ++i) {
00267         // compute current jam's values
00268         SUMOReal jamLengthInMeters =
00269             (*(*i)->firstStandingVehicle)->getPositionOnActiveMoveReminderLane(getLane())
00270             - (*(*i)->lastStandingVehicle)->getPositionOnActiveMoveReminderLane(getLane())
00271             + (*(*i)->lastStandingVehicle)->getVehicleType().getLength();
00272         unsigned jamLengthInVehicles = (unsigned) distance((*i)->firstStandingVehicle, (*i)->lastStandingVehicle) + 1;
00273         // apply them to the statistics
00274         myCurrentMaxJamLengthInMeters = MAX2(myCurrentMaxJamLengthInMeters, jamLengthInMeters);
00275         myCurrentMaxJamLengthInVehicles = MAX2(myCurrentMaxJamLengthInVehicles, jamLengthInVehicles);
00276         myJamLengthInMetersSum += jamLengthInMeters;
00277         myJamLengthInVehiclesSum += jamLengthInVehicles;
00278         myCurrentJamLengthInMeters += jamLengthInMeters;
00279         myCurrentJamLengthInVehicles += jamLengthInVehicles;
00280     }
00281     myCurrentJamNo = (unsigned) jams.size();
00282 
00283     unsigned noVehicles = (unsigned) myKnownVehicles.size();
00284     myVehicleSamples += noVehicles;
00285     myTimeSamples += 1;
00286     // compute occupancy values
00287     SUMOReal currentOccupancy = lengthSum / (myEndPos-myStartPos) * (SUMOReal) 100.;
00288     myCurrentOccupancy = currentOccupancy;
00289     myOccupancySum += currentOccupancy;
00290     myMaxOccupancy = MAX2(myMaxOccupancy, currentOccupancy);
00291     // compute jam values
00292     myMeanMaxJamInVehicles += myCurrentMaxJamLengthInVehicles;
00293     myMeanMaxJamInMeters += myCurrentMaxJamLengthInMeters;
00294     myMaxJamInVehicles = MAX2(myMaxJamInVehicles, myCurrentMaxJamLengthInVehicles);
00295     myMaxJamInMeters = MAX2(myMaxJamInMeters, myCurrentMaxJamLengthInMeters);
00296     // save information about halting vehicles
00297     myHaltingVehicleDurations = haltingVehicles;
00298     myIntervalHaltingVehicleDurations = intervalHaltingVehicles;
00299     // compute information about vehicle numbers
00300     myMeanVehicleNumber += (unsigned) myKnownVehicles.size();
00301     myMaxVehicleNumber = MAX2((unsigned) myKnownVehicles.size(), myMaxVehicleNumber);
00302     // norm current values
00303     myCurrentMeanSpeed = noVehicles!=0 ? myCurrentMeanSpeed / (SUMOReal) noVehicles : -1;
00304     myCurrentMeanLength = noVehicles!=0 ? myCurrentMeanLength / (SUMOReal) noVehicles : -1;
00305 
00306     // clean up
00307     for (std::vector<JamInfo*>::iterator i=jams.begin(); i!=jams.end(); ++i) {
00308         delete *i;
00309     }
00310     jams.clear();
00311 }

void MSE2Collector::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 380 of file MSE2Collector.cpp.

00380                                                                             {
00381     dev.writeXMLHeader("detector");
00382 }

void MSE2Collector::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 316 of file MSE2Collector.cpp.

References Named::getID(), MAX2(), MSE2Collector::myHaltingVehicleDurations, MSE2Collector::myIntervalHaltingVehicleDurations, MSE2Collector::myJamLengthInMetersSum, MSE2Collector::myJamLengthInVehiclesSum, MSE2Collector::myMaxJamInMeters, MSE2Collector::myMaxJamInVehicles, MSE2Collector::myMaxOccupancy, MSE2Collector::myMaxVehicleNumber, MSE2Collector::myMeanMaxJamInMeters, MSE2Collector::myMeanMaxJamInVehicles, MSE2Collector::myMeanVehicleNumber, MSE2Collector::myOccupancySum, MSE2Collector::myPastIntervalStandingDurations, MSE2Collector::myPastStandingDurations, MSE2Collector::mySpeedSum, MSE2Collector::myStartedHalts, MSE2Collector::myTimeSamples, MSE2Collector::myVehicleSamples, MSE2Collector::reset(), SUMOReal, and time2string().

00316                                                                                                      {
00317     dev<<"   <interval begin=\""<<time2string(startTime)<<"\" end=\""<< time2string(stopTime)<<"\" "<<"id=\""<<getID()<<"\" ";
00318 
00319     SUMOReal meanSpeed = myVehicleSamples!=0 ? mySpeedSum / (SUMOReal) myVehicleSamples : -1;
00320     SUMOReal meanOccupancy = myTimeSamples!=0 ? myOccupancySum / (SUMOReal) myTimeSamples : 0;
00321     SUMOReal meanJamLengthInMeters = myTimeSamples!=0 ? myMeanMaxJamInMeters / (SUMOReal) myTimeSamples : 0;
00322     SUMOReal meanJamLengthInVehicles = myTimeSamples!=0 ? myMeanMaxJamInVehicles / (SUMOReal) myTimeSamples : 0;
00323     SUMOReal meanVehicleNumber = myTimeSamples!=0 ? (SUMOReal) myMeanVehicleNumber / (SUMOReal) myTimeSamples : 0;
00324 
00325     SUMOReal haltingDurationSum = 0;
00326     SUMOReal maxHaltingDuration = 0;
00327     SUMOReal haltingNo = 0;
00328     for (std::vector<SUMOReal>::iterator i=myPastStandingDurations.begin(); i!=myPastStandingDurations.end(); ++i) {
00329         haltingDurationSum += (*i);
00330         maxHaltingDuration = MAX2(maxHaltingDuration, (*i));
00331         haltingNo = haltingNo + 1;
00332     }
00333     for (std::map<MSVehicle*, SUMOReal> ::iterator i=myHaltingVehicleDurations.begin(); i!=myHaltingVehicleDurations.end(); ++i) {
00334         haltingDurationSum += (*i).second;
00335         maxHaltingDuration = MAX2(maxHaltingDuration, (*i).second);
00336         haltingNo = haltingNo + 1;
00337     }
00338     SUMOReal meanHaltingDuration = haltingNo!=0 ? haltingDurationSum / (SUMOReal) haltingNo : 0;
00339 
00340     SUMOReal intervalHaltingDurationSum = 0;
00341     SUMOReal intervalMaxHaltingDuration = 0;
00342     SUMOReal intervalHaltingNo = 0;
00343     for (std::vector<SUMOReal>::iterator i=myPastIntervalStandingDurations.begin(); i!=myPastIntervalStandingDurations.end(); ++i) {
00344         intervalHaltingDurationSum += (*i);
00345         intervalMaxHaltingDuration = MAX2(intervalMaxHaltingDuration, (*i));
00346         intervalHaltingNo = intervalHaltingNo + 1;
00347     }
00348     for (std::map<MSVehicle*, SUMOReal> ::iterator i=myIntervalHaltingVehicleDurations.begin(); i!=myIntervalHaltingVehicleDurations.end(); ++i) {
00349         intervalHaltingDurationSum += (*i).second;
00350         intervalMaxHaltingDuration = MAX2(intervalMaxHaltingDuration, (*i).second);
00351         intervalHaltingNo = intervalHaltingNo + 1;
00352     }
00353     SUMOReal intervalMeanHaltingDuration = intervalHaltingNo!=0 ? intervalHaltingDurationSum / (SUMOReal) intervalHaltingNo : 0;
00354 
00355     dev << "nSamples=\"" << myVehicleSamples << "\" "
00356     << "meanSpeed=\"" << meanSpeed << "\" "
00357     << "meanOccupancy=\"" << meanOccupancy << "\" "
00358     << "maxOccupancy=\"" << myMaxOccupancy << "\" "
00359     << "meanMaxJamLengthInVehicles=\"" << meanJamLengthInVehicles << "\" "
00360     << "meanMaxJamLengthInMeters=\"" << meanJamLengthInMeters << "\" "
00361     << "maxJamLengthInVehicles=\"" << myMaxJamInVehicles << "\" "
00362     << "maxJamLengthInMeters=\"" << myMaxJamInMeters << "\" "
00363     << "jamLengthInVehiclesSum=\"" << myJamLengthInVehiclesSum << "\" "
00364     << "jamLengthInMetersSum=\"" << myJamLengthInMetersSum << "\" "
00365     << "meanHaltingDuration=\"" << meanHaltingDuration << "\" "
00366     << "maxHaltingDuration=\"" << maxHaltingDuration << "\" "
00367     << "haltingDurationSum=\"" << haltingDurationSum << "\" "
00368     << "meanIntervalHaltingDuration=\"" << intervalMeanHaltingDuration << "\" "
00369     << "maxIntervalHaltingDuration=\"" << intervalMaxHaltingDuration << "\" "
00370     << "intervalHaltingDurationSum=\"" << intervalHaltingDurationSum << "\" "
00371     << "startedHalts=\"" << myStartedHalts << "\" "
00372     << "meanVehicleNumber=\"" << meanVehicleNumber << "\" "
00373     << "maxVehicleNumber=\"" << myMaxVehicleNumber << "\" "
00374     << "/>\n";
00375     reset();
00376 }


Field Documentation

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

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


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

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