GUIVehicleControl Class Reference

#include <GUIVehicleControl.h>

Inheritance diagram for GUIVehicleControl:

MSVehicleControl

Detailed Description

The class responsible for building and deletion of vehicles (gui-version).

Builds GUIVehicle instances instead of MSVehicle.

See also:
MSVehicleControl
Todo:
This is partially unsecure due to concurrent access...
Todo:
Recheck vehicle deletion

Definition at line 56 of file GUIVehicleControl.h.


Vehicle type container

bool myDefaultVTypeMayBeDeleted
 Whether no vehicle type was loaded.
VTypeDictType myVTypeDict
 Dictionary of vehicle types.
VTypeDistDictType myVTypeDistDict
 A distribution of vehicle types (probability->vehicle type).
std::map< const MSEdge *const,
std::vector< MSVehicle * > > 
myWaiting
 the lists of waiting vehicles
typedef std::map< std::string,
MSVehicleType * > 
VTypeDictType
 Vehicle type dictionary type.
typedef std::map< std::string,
RandomDistributor
< MSVehicleType * > * > 
VTypeDistDictType
 Vehicle type distribution dictionary type.

Vehicle container

VehicleDictType myVehicleDict
 Dictionary of vehicles.
typedef std::map< std::string,
MSVehicle * > 
VehicleDictType
 Vehicle dictionary type.

Public Types

typedef std::map< std::string,
MSVehicle * >::const_iterator 
constVehIt
 Definition of the internal vehicles map iterator.

Public Member Functions

void addWaiting (const MSEdge *const edge, MSVehicle *vehicle) throw ()
MSVehiclegetWaitingVehicle (const MSEdge *const edge, const std::set< std::string > &lines) throw ()
 GUIVehicleControl () throw ()
 Constructor.
void insertVehicleIDs (std::vector< GLuint > &into) throw ()
 Returns the list of all known vehicles by gl-id.
void removeWaiting (const MSEdge *const edge, MSVehicle *vehicle) throw ()
 ~GUIVehicleControl () throw ()
 Destructor.
Insertion, deletion and retrieal of vehicles
virtual bool addVehicle (const std::string &id, MSVehicle *v) throw ()
 Tries to insert the vehicle into the internal vehicle container.
virtual MSVehiclegetVehicle (const std::string &id) const throw ()
 Returns the vehicle with the given id.
constVehIt loadedVehBegin () const throw ()
 Returns the begin of the internal vehicle map.
constVehIt loadedVehEnd () const throw ()
 Returns the end of the internal vehicle map.
void scheduleVehicleRemoval (MSVehicle *v) throw ()
 Removes a vehicle after it has ended.
Insertion and retrieval of vehicle types
bool addVType (MSVehicleType *vehType) throw ()
 Adds a vehicle type.
bool addVTypeDistribution (const std::string &id, RandomDistributor< MSVehicleType * > *vehTypeDistribution) throw ()
 Adds a vehicle type distribution.
MSVehicleTypegetVType (const std::string &id=DEFAULT_VTYPE_ID) throw ()
 Returns the named vehicle type or a sample from the named distribution.
bool hasVTypeDistribution (const std::string &id) const throw ()
 Asks for a vehicle type distribution.
void insertVTypeIDs (std::vector< std::string > &into) const throw ()
 Inserts ids of all known vehicle types and vehicle type distributions to the given vector.
Vehicle creation
MSVehiclebuildVehicle (SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type) throw (ProcessError)
 Builds a vehicle, increases the number of built vehicles.
Insertion, deletion and retrieal of vehicles
virtual void deleteVehicle (MSVehicle *v) throw ()
 Deletes the vehicle.
Retrieval of vehicle statistics (always accessable)
unsigned int getEmittedVehicleNo () const throw ()
 Returns the number of emitted vehicles.
unsigned int getEndedVehicleNo () const throw ()
 Returns the number of removed vehicles.
unsigned int getLoadedVehicleNo () const throw ()
 Returns the number of build vehicles.
unsigned int getRunningVehicleNo () const throw ()
 Returns the number of build and emitted, but not yet deleted vehicles.
bool haveAllVehiclesQuit () const throw ()
 Returns the information whether all build vehicles have been removed.
Retrieval of vehicle statistics (availability depends on simulation settings)
SUMOReal getMeanTravelTime () const throw ()
 Returns the mean travel time of vehicles (corn-dependent value).
SUMOReal getMeanWaitingTime () const throw ()
 Returns the mean waiting time of vehicles (corn-dependent value).
Setting vehicle statistics
virtual void vehicleEmitted (const MSVehicle &v) throw ()
 Informs this control about a vehicle's emission.

Protected Attributes

Vehicle statistics (availability depends on simulation settings)
SUMOTime myAbsVehTravelTime
 The aggregated time vehicles needed to aacomplish their route.
SUMOTime myAbsVehWaitingTime
 The aggregated time vehicles had to wait for departure.
Vehicle statistics (always accessable)
unsigned int myEndedVehNo
 The number of removed vehicles.
unsigned int myLoadedVehNo
 The number of build vehicles.
unsigned int myRunningVehNo
 The number of vehicles within the network (build and emitted but not removed).

Private Member Functions

 GUIVehicleControl (const GUIVehicleControl &s)
 invalidated copy constructor
GUIVehicleControloperator= (const GUIVehicleControl &s)
 invalidated assignment operator

Member Typedef Documentation

typedef std::map<std::string, MSVehicle*>::const_iterator MSVehicleControl::constVehIt [inherited]

Definition of the internal vehicles map iterator.

Definition at line 71 of file MSVehicleControl.h.

typedef std::map< std::string, MSVehicle* > MSVehicleControl::VehicleDictType [protected, inherited]

Vehicle dictionary type.

Definition at line 383 of file MSVehicleControl.h.

typedef std::map< std::string, MSVehicleType* > MSVehicleControl::VTypeDictType [protected, inherited]

Vehicle type dictionary type.

Definition at line 393 of file MSVehicleControl.h.

typedef std::map< std::string, RandomDistributor<MSVehicleType*>* > MSVehicleControl::VTypeDistDictType [protected, inherited]

Vehicle type distribution dictionary type.

Definition at line 398 of file MSVehicleControl.h.


Constructor & Destructor Documentation

GUIVehicleControl::GUIVehicleControl (  )  throw ()

Constructor.

Definition at line 45 of file GUIVehicleControl.cpp.

00046         : MSVehicleControl() {}

GUIVehicleControl::~GUIVehicleControl (  )  throw ()

Destructor.

Definition at line 49 of file GUIVehicleControl.cpp.

00049 {}

GUIVehicleControl::GUIVehicleControl ( const GUIVehicleControl s  )  [private]

invalidated copy constructor


Member Function Documentation

bool MSVehicleControl::addVehicle ( const std::string &  id,
MSVehicle v 
) throw () [virtual, inherited]

Tries to insert the vehicle into the internal vehicle container.

Checks whether another vehicle with the same id exists; returns false if so. Otherwise, the vehicle is added to "myVehicleDict" and true is returned.

The vehicle control gets responsible for vehicle deletion.

Parameters:
[in] id The id of the vehicle
[in] v The vehicle
Returns:
Whether the vehicle could be inserted (no other vehicle with the same id was inserted before)

Definition at line 432 of file MSVehicleControl.cpp.

References MSVehicleControl::myVehicleDict.

Referenced by MSEmitControl::checkFlows(), MSEmitter::childCheckEmit(), MSCalibrator::childCheckEmit(), MSRouteHandler::closeVehicle(), and traci::TraCIServer::commandAddVehicle().

00432                                                                       {
00433     VehicleDictType::iterator it = myVehicleDict.find(id);
00434     if (it == myVehicleDict.end()) {
00435         // id not in myVehicleDict.
00436         myVehicleDict[id] = v;
00437         return true;
00438     }
00439     return false;
00440 }

bool MSVehicleControl::addVType ( MSVehicleType vehType  )  throw () [inherited]

Adds a vehicle type.

If another vehicle type (or distribution) with the same id exists, false is returned. Otherwise, the vehicle type is added to the internal vehicle type container "myVTypeDict".

This control get responsible for deletion of the added vehicle type.

Parameters:
[in] vehType The vehicle type to add
Returns:
Whether the vehicle type could be added

Definition at line 492 of file MSVehicleControl.cpp.

References MSVehicleControl::checkVType(), and MSVehicleControl::myVTypeDict.

00492                                                          {
00493     if (checkVType(vehType->getID())) {
00494         myVTypeDict[vehType->getID()] = vehType;
00495         return true;
00496     }
00497     return false;
00498 }

bool MSVehicleControl::addVTypeDistribution ( const std::string &  id,
RandomDistributor< MSVehicleType * > *  vehTypeDistribution 
) throw () [inherited]

Adds a vehicle type distribution.

If another vehicle type (or distribution) with the same id exists, false is returned. Otherwise, the vehicle type distribution is added to the internal vehicle type distribution container "myVTypeDistDict".

This control get responsible for deletion of the added vehicle type distribution.

Parameters:
[in] id The id of the distribution to add
[in] vehTypeDistribution The vehicle type distribution to add
Returns:
Whether the vehicle type could be added

Definition at line 502 of file MSVehicleControl.cpp.

References MSVehicleControl::checkVType(), and MSVehicleControl::myVTypeDistDict.

00502                                                                                                                           {
00503     if (checkVType(id)) {
00504         myVTypeDistDict[id] = vehTypeDistribution;
00505         return true;
00506     }
00507     return false;
00508 }

void MSVehicleControl::addWaiting ( const MSEdge *const   edge,
MSVehicle vehicle 
) throw () [inherited]

Definition at line 547 of file MSVehicleControl.cpp.

References MSVehicleControl::myWaiting.

Referenced by MSRouteHandler::closeVehicle(), and MSVehicle::processNextStop().

00547                                                                                  {
00548     if (myWaiting.find(edge) == myWaiting.end()) {
00549         myWaiting[edge] = std::vector<MSVehicle*>();
00550     }
00551     myWaiting[edge].push_back(vehicle);
00552 }

MSVehicle * GUIVehicleControl::buildVehicle ( SUMOVehicleParameter defs,
const MSRoute route,
const MSVehicleType type 
) throw (ProcessError) [virtual]

Builds a vehicle, increases the number of built vehicles.

Instead of a MSVehicle, a GUIVehicle is built

Parameters:
[in] id The id of the vehicle to build
[in] route The route of this vehicle
[in] departTime The departure time of this vehicle
[in] type The type of this vehicle
[in] repNo The number of repetitions
[in] repOffset The repetition offset
Returns:
The built vehicle (GUIVehicle instance)
See also:
MSVehicleControl::buildVehicle

Reimplemented from MSVehicleControl.

Definition at line 53 of file GUIVehicleControl.cpp.

References MSNet::getInstance(), GUIGlObjectStorage::gIDStorage, MSNet::informVehicleStateListener(), MSVehicleControl::myLoadedVehNo, and MSNet::VEHICLE_STATE_BUILT.

00054                                                                                                      {
00055     myLoadedVehNo++;
00056     MSVehicle *built = new GUIVehicle(GUIGlObjectStorage::gIDStorage, defs, route, type, myLoadedVehNo-1);
00057     MSNet::getInstance()->informVehicleStateListener(built, MSNet::VEHICLE_STATE_BUILT);
00058     return built;
00059 }

void GUIVehicleControl::deleteVehicle ( MSVehicle v  )  throw () [virtual]

Deletes the vehicle.

We are destroying this vehicle only if it is not in use with the visualization.

Parameters:
[in] v The vehicle to delete
Todo:
Isn't this quite insecure?
See also:
MSVehicleControl::deleteVehicle

Reimplemented from MSVehicleControl.

Definition at line 63 of file GUIVehicleControl.cpp.

References MSVehicleControl::deleteVehicle(), and GUIGlObjectStorage::gIDStorage.

00063                                                        {
00064     static_cast<GUIVehicle*>(veh)->setRemoved();
00065     if (GUIGlObjectStorage::gIDStorage.remove(static_cast<GUIVehicle*>(veh)->getGlID())) {
00066         MSVehicleControl::deleteVehicle(veh);
00067     }
00068 }

unsigned int MSVehicleControl::getEmittedVehicleNo (  )  const throw () [inline, inherited]

Returns the number of emitted vehicles.

Returns:
The number of vehicles that have entered the simulation so far

Definition at line 217 of file MSVehicleControl.h.

References MSVehicleControl::myEndedVehNo, and MSVehicleControl::myRunningVehNo.

Referenced by MSNet::closeSimulation(), MSVehicleControl::getMeanWaitingTime(), GUINet::getParameterWindow(), MSNet::postSimStepOutput(), and MSNet::writeOutput().

00217                                                      {
00218         return myRunningVehNo + myEndedVehNo;
00219     }

unsigned int MSVehicleControl::getEndedVehicleNo (  )  const throw () [inline, inherited]

Returns the number of removed vehicles.

Returns:
The number of vehicles that have left the simulation

Definition at line 201 of file MSVehicleControl.h.

References MSVehicleControl::myEndedVehNo.

Referenced by GUINet::getParameterWindow(), and MSNet::writeOutput().

00201                                                    {
00202         return myEndedVehNo;
00203     }

unsigned int MSVehicleControl::getLoadedVehicleNo (  )  const throw () [inline, inherited]

Returns the number of build vehicles.

Returns:
The number of loaded (build) vehicles

Definition at line 193 of file MSVehicleControl.h.

References MSVehicleControl::myLoadedVehNo.

Referenced by GUINet::getParameterWindow(), and MSNet::writeOutput().

00193                                                     {
00194         return myLoadedVehNo;
00195     }

SUMOReal MSVehicleControl::getMeanTravelTime (  )  const throw () [inherited]

Returns the mean travel time of vehicles (corn-dependent value).

This value is only available if MSCORN::CORN_MEAN_VEH_TRAVELTIME is "wished". This is the case if the emissions-output shall be generated.

Returns:
The mean travel time of ended vehicles (-1 if no vehicle has ended, yet)
See also:
MSCORN
Todo:
Enable this for guisim?

Definition at line 247 of file MSVehicleControl.cpp.

References MSVehicleControl::myAbsVehTravelTime, MSVehicleControl::myEndedVehNo, and SUMOReal.

Referenced by MSNet::writeOutput().

00247                                                   {
00248     if (myEndedVehNo==0) {
00249         return -1;
00250     }
00251     return (SUMOReal) myAbsVehTravelTime / (SUMOReal) myEndedVehNo;
00252 }

SUMOReal MSVehicleControl::getMeanWaitingTime (  )  const throw () [inherited]

Returns the mean waiting time of vehicles (corn-dependent value).

This value is only available if MSCORN::CORN_MEAN_VEH_WAITINGTIME is "wished". This is the case if the emissions-output shall be generated.

Returns:
The mean time vehicles had to wait for being emitted (-1 if no vehicle was emitted, yet)
See also:
MSCORN
Todo:
Enable this for guisim?

Definition at line 238 of file MSVehicleControl.cpp.

References MSVehicleControl::getEmittedVehicleNo(), MSVehicleControl::myAbsVehWaitingTime, and SUMOReal.

Referenced by MSNet::writeOutput().

00238                                                    {
00239     if (getEmittedVehicleNo()==0) {
00240         return -1;
00241     }
00242     return (SUMOReal) myAbsVehWaitingTime / (SUMOReal) getEmittedVehicleNo();
00243 }

unsigned int MSVehicleControl::getRunningVehicleNo (  )  const throw () [inline, inherited]

Returns the number of build and emitted, but not yet deleted vehicles.

Returns:
The number simulated vehicles (including those in teleporter)

Definition at line 209 of file MSVehicleControl.h.

References MSVehicleControl::myRunningVehNo.

Referenced by MSNet::closeSimulation(), GUINet::getParameterWindow(), MSNet::postSimStepOutput(), GUINet::setSimDuration(), MSNet::simulationState(), MSNet::simulationStep(), and MSNet::writeOutput().

00209                                                      {
00210         return myRunningVehNo;
00211     }

MSVehicle * MSVehicleControl::getVehicle ( const std::string &  id  )  const throw () [virtual, inherited]

Returns the vehicle with the given id.

If no vehicle with the given id is store din "myVehicleDict", 0 is returned.

Parameters:
[in] id The id of the vehicle to retrieve
Returns:
The vehicle with the given id, 0 if no such vehicle exists

Definition at line 444 of file MSVehicleControl.cpp.

References MSVehicleControl::myVehicleDict.

Referenced by MSEmitControl::checkFlows(), traci::TraCIServer::getVehicleByExtId(), traci::TraCIServer::handleVehicleDomain(), MSEmitter::MSEmitter_FileTriggeredChild::myStartElement(), MSCalibrator::MSCalibrator_FileTriggeredChild::myStartElement(), traci::TraCIServer::postProcessSimulationStep(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Vehicle::processSet(), and GUINet::vehicleExists().

00444                                                               {
00445     VehicleDictType::const_iterator it = myVehicleDict.find(id);
00446     if (it == myVehicleDict.end()) {
00447         return 0;
00448     }
00449     return it->second;
00450 }

MSVehicleType * MSVehicleControl::getVType ( const std::string &  id = DEFAULT_VTYPE_ID  )  throw () [inherited]

Returns the named vehicle type or a sample from the named distribution.

Parameters:
[in] id The id of the vehicle type to return. If left out, the default type is returned.
Returns:
The named vehicle type, or 0 if no such type exists

Definition at line 518 of file MSVehicleControl.cpp.

References DEFAULT_VTYPE_ID, MSVehicleControl::myDefaultVTypeMayBeDeleted, MSVehicleControl::myVTypeDict, and MSVehicleControl::myVTypeDistDict.

Referenced by MSEmitter::MSEmitter_FileTriggeredChild::buildAndScheduleFlowVehicle(), MSCalibrator::MSCalibrator_FileTriggeredChild::buildAndScheduleFlowVehicle(), MSEmitControl::checkFlows(), MSRouteHandler::closeVehicle(), traci::TraCIServer::commandAddVehicle(), MSEmitter::MSEmitter_FileTriggeredChild::myStartElement(), MSCalibrator::MSCalibrator_FileTriggeredChild::myStartElement(), MSRouteHandler::openVehicleTypeDistribution(), TraCIServerAPI_VehicleType::processGet(), and GUIEmitter::GUIEmitterChild_UserTriggeredChild::wrappedExecute().

00518                                                       {
00519     VTypeDictType::iterator it = myVTypeDict.find(id);
00520     if (it == myVTypeDict.end()) {
00521         VTypeDistDictType::iterator it2 = myVTypeDistDict.find(id);
00522         if (it2 == myVTypeDistDict.end()) {
00523             return 0;
00524         }
00525         return it2->second->get();
00526     }
00527     if (id == DEFAULT_VTYPE_ID) {
00528         myDefaultVTypeMayBeDeleted = false;
00529     }
00530     return it->second;
00531 }

MSVehicle * MSVehicleControl::getWaitingVehicle ( const MSEdge *const   edge,
const std::set< std::string > &  lines 
) throw () [inherited]

Definition at line 567 of file MSVehicleControl.cpp.

References MSVehicle::getParameter(), SUMOVehicleParameter::line, and MSVehicleControl::myWaiting.

Referenced by MSPerson::MSPersonStage_Driving::proceed().

00567                                                                                                     {
00568     if (myWaiting.find(edge) != myWaiting.end()) {
00569         for (std::vector<MSVehicle*>::const_iterator it = myWaiting[edge].begin(); it != myWaiting[edge].end(); ++it) {
00570             const std::string &line = (*it)->getParameter().line == "" ? (*it)->getParameter().id : (*it)->getParameter().line;
00571             if (lines.count(line)) {
00572                 return (*it);
00573             }
00574         }
00575     }
00576     return 0;
00577 }

bool MSVehicleControl::hasVTypeDistribution ( const std::string &  id  )  const throw () [inherited]

Asks for a vehicle type distribution.

If vehicle type distribution with the id exists, true is returned, false otherwise.

Parameters:
[in] id The id of the distribution
Returns:
Whether the vehicle type distribution exists

Definition at line 512 of file MSVehicleControl.cpp.

References MSVehicleControl::myVTypeDistDict.

Referenced by MSEmitControl::add().

00512                                                                         {
00513     return myVTypeDistDict.find(id) != myVTypeDistDict.end();
00514 }

bool MSVehicleControl::haveAllVehiclesQuit (  )  const throw () [inline, inherited]

Returns the information whether all build vehicles have been removed.

Returns:
Whether all loaded vehicles have ended

Definition at line 225 of file MSVehicleControl.h.

References MSVehicleControl::myEndedVehNo, and MSVehicleControl::myLoadedVehNo.

Referenced by MSNet::simulationState().

00225                                              {
00226         return myLoadedVehNo==myEndedVehNo;
00227     }

void GUIVehicleControl::insertVehicleIDs ( std::vector< GLuint > &  into  )  throw ()

Returns the list of all known vehicles by gl-id.

Parameters:
fill] into The list to fill with vehicle ids
Todo:
Well, what about concurrent modifications?

Definition at line 72 of file GUIVehicleControl.cpp.

References MSVehicle::isOnRoad(), and MSVehicleControl::myVehicleDict.

00072                                                                    {
00073     into.reserve(myVehicleDict.size());
00074     for (VehicleDictType::iterator i=myVehicleDict.begin(); i!=myVehicleDict.end(); ++i) {
00075         MSVehicle *veh = (*i).second;
00076         if (veh->isOnRoad()) {
00077             into.push_back(static_cast<GUIVehicle*>((*i).second)->getGlID());
00078         }
00079     }
00080 }

void MSVehicleControl::insertVTypeIDs ( std::vector< std::string > &  into  )  const throw () [inherited]

Inserts ids of all known vehicle types and vehicle type distributions to the given vector.

Parameters:
[in] into The vector to fill with ids

Definition at line 535 of file MSVehicleControl.cpp.

References MSVehicleControl::myVTypeDict, and MSVehicleControl::myVTypeDistDict.

Referenced by TraCIServerAPI_VehicleType::processGet().

00535                                                                          {
00536     into.reserve(into.size()+myVTypeDict.size()+myVTypeDistDict.size());
00537     for (VTypeDictType::const_iterator i=myVTypeDict.begin(); i!=myVTypeDict.end(); ++i) {
00538         into.push_back((*i).first);
00539     }
00540     for (VTypeDistDictType::const_iterator i=myVTypeDistDict.begin(); i!=myVTypeDistDict.end(); ++i) {
00541         into.push_back((*i).first);
00542     }
00543 }

MSVehicleControl::constVehIt MSVehicleControl::loadedVehBegin (  )  const throw () [inherited]

Returns the begin of the internal vehicle map.

Returns:
The begin of the internal vehicle map

Definition at line 462 of file MSVehicleControl.cpp.

References MSVehicleControl::myVehicleDict.

Referenced by MSVTypeProbe::execute(), traci::TraCIServer::handleVehicleDomain(), traci::TraCIServer::postProcessSimulationStep(), and TraCIServerAPI_Vehicle::processGet().

00462                                                {
00463     return myVehicleDict.begin();
00464 }

MSVehicleControl::constVehIt MSVehicleControl::loadedVehEnd (  )  const throw () [inherited]

Returns the end of the internal vehicle map.

Returns:
The end of the internal vehicle map

Definition at line 468 of file MSVehicleControl.cpp.

References MSVehicleControl::myVehicleDict.

Referenced by MSVTypeProbe::execute(), traci::TraCIServer::handleVehicleDomain(), traci::TraCIServer::postProcessSimulationStep(), and TraCIServerAPI_Vehicle::processGet().

00468                                              {
00469     return myVehicleDict.end();
00470 }

GUIVehicleControl& GUIVehicleControl::operator= ( const GUIVehicleControl s  )  [private]

invalidated assignment operator

void MSVehicleControl::removeWaiting ( const MSEdge *const   edge,
MSVehicle vehicle 
) throw () [inherited]

Definition at line 556 of file MSVehicleControl.cpp.

References MSVehicleControl::myWaiting.

Referenced by MSPerson::MSPersonStage_Driving::proceed(), and MSVehicle::processNextStop().

00556                                                                                     {
00557     if (myWaiting.find(edge) != myWaiting.end()) {
00558         std::vector<MSVehicle*>::iterator it = std::find(myWaiting[edge].begin(), myWaiting[edge].end(), vehicle);
00559         if (it != myWaiting[edge].end()) {
00560             myWaiting[edge].erase(it);
00561         }
00562     }
00563 }

void MSVehicleControl::scheduleVehicleRemoval ( MSVehicle v  )  throw () [inherited]

Removes a vehicle after it has ended.

Writes output to tripinfos and vehroutes if wished; decrements the number of running vehicles and increments the number of ended vehicles. Then deletes the vehicle using "deleteVehicle".

This method should be called for each vehicle that was inserted into the network and quits its ride.

Parameters:
[in] v The vehicle to remove

Definition at line 95 of file MSVehicleControl.cpp.

References OutputDevice::closeTag(), MSCORN::CORN_MEAN_VEH_TRAVELTIME, MSCORN::CORN_OUT_OLDROUTES, MSCORN::CORN_OUT_TAZ, MSCORN::CORN_OUT_TRIPDURATIONS, MSCORN::CORN_OUT_VEHROUTES, MSCORN::CORN_P_VEH_ARRIVAL_INFO, MSCORN::CORN_P_VEH_DEPART_INFO, MSCORN::CORN_VEH_DEPART_TIME, MSCORN::CORN_VEH_NUMBERROUTE, MSCORN::CORN_VEH_VAPORIZED, MSCORN::CORN_VEH_WAITINGTIME, MSVehicleControl::deleteVehicle(), MSNet::getCurrentTimeStep(), OutputDevice::getDeviceByOption(), MSLane::getID(), MSNet::getInstance(), MSLane::getLength(), MSNet::informVehicleStateListener(), MSVehicle::DepartArrivalInformation::lane, MSVehicleControl::myAbsVehTravelTime, MSVehicleControl::myRunningVehNo, OutputDevice::openTag(), MSVehicle::DepartArrivalInformation::pos, MSVehicle::DepartArrivalInformation::speed, SUMOReal, MSVehicle::DepartArrivalInformation::time, time2string(), MSNet::VEHICLE_STATE_ARRIVED, and MSCORN::wished().

Referenced by MSVehicleTransfer::addVeh(), MSVehicleTransfer::checkEmissions(), MSCalibrator::execute(), MSLane::push(), and MSLane::setCritical().

00095                                                              {
00096     assert(myRunningVehNo>0);
00097     // check whether to generate the information about the vehicle's trip
00098     if (MSCORN::wished(MSCORN::CORN_OUT_TRIPDURATIONS)) {
00099         OutputDevice& od = OutputDevice::getDeviceByOption("tripinfo-output");
00100         // obtain and generate vehicle's trip information
00101         MSVehicle::DepartArrivalInformation *departInfo = v->hasCORNPointerValue(MSCORN::CORN_P_VEH_DEPART_INFO)
00102                 ? (MSVehicle::DepartArrivalInformation*) v->getCORNPointerValue(MSCORN::CORN_P_VEH_DEPART_INFO)
00103                 : 0;
00104         MSVehicle::DepartArrivalInformation *arrivalInfo = v->hasCORNPointerValue(MSCORN::CORN_P_VEH_ARRIVAL_INFO)
00105                 ? (MSVehicle::DepartArrivalInformation*) v->getCORNPointerValue(MSCORN::CORN_P_VEH_ARRIVAL_INFO)
00106                 : 0;
00107         SUMOReal routeLength = v->getRoute().getLength();
00108         // write
00109         od.openTag("tripinfo") << " id=\"" << v->getID() << "\" ";
00110         SUMOTime departTime = -1;
00111         if (departInfo!=0) {
00112             routeLength -= departInfo->pos;
00113             std::string laneID = departInfo->lane!=0 ? departInfo->lane->getID() : "";
00114             od << "depart=\"" << time2string(departInfo->time) << "\" "
00115             << "departLane=\"" << laneID << "\" "
00116             << "departPos=\"" << departInfo->pos << "\" "
00117             << "departSpeed=\"" << departInfo->speed << "\" "
00118             << "departDelay=\"" << time2string(departInfo->time - v->getDesiredDepart()) << "\" ";
00119             departTime = departInfo->time;
00120         } else {
00121             if (v->hasCORNIntValue(MSCORN::CORN_VEH_DEPART_TIME)) {
00122                 departTime = v->getCORNIntValue(MSCORN::CORN_VEH_DEPART_TIME);
00123                 od << "depart=\"" << time2string(departTime) << "\" ";
00124             } else {
00125                 od << "depart=\"\" ";
00126             }
00127             od << "departLane=\"\" "
00128             << "departPos=\"\" "
00129             << "departSpeed=\"\" "
00130             << "departDelay=\"\" ";
00131         }
00132         SUMOTime arrivalTime = -1;
00133         if (arrivalInfo!=0) {
00134             std::string laneID = "";
00135             if (arrivalInfo->lane!=0) {
00136                 routeLength -= arrivalInfo->lane->getLength() - arrivalInfo->pos;
00137                 laneID = arrivalInfo->lane->getID();
00138             }
00139             od << "arrival=\"" << time2string(arrivalInfo->time) << "\" "
00140             << "arrivalLane=\"" << laneID << "\" "
00141             << "arrivalPos=\"" << arrivalInfo->pos << "\" "
00142             << "arrivalSpeed=\"" << arrivalInfo->speed << "\" ";
00143             arrivalTime = arrivalInfo->time;
00144         } else {
00145             arrivalTime = MSNet::getInstance()->getCurrentTimeStep();
00146             od << "arrival=\"" << time2string(arrivalTime) << "\" "
00147             << "arrivalLane=\"\" "
00148             << "arrivalPos=\"\" "
00149             << "arrivalSpeed=\"\" ";
00150         }
00151         if (departTime!=-1&&arrivalTime!=-1) {
00152             od << "duration=\"" << time2string(arrivalTime - departTime) << "\" ";
00153         } else {
00154             od << "duration=\"\" ";
00155         }
00156         od << "routeLength=\"" << routeLength << "\" "
00157         << "waitSteps=\"" << v->getCORNIntValue(MSCORN::CORN_VEH_WAITINGTIME) << "\" "
00158         << "rerouteNo=\"";
00159         if (v->hasCORNIntValue(MSCORN::CORN_VEH_NUMBERROUTE)) {
00160             od << v->getCORNIntValue(MSCORN::CORN_VEH_NUMBERROUTE);
00161         } else {
00162             od << '0';
00163         }
00164         // compute device id list
00165         const std::vector<MSDevice*> &devices = v->getDevices();
00166         std::string deviceIDs;
00167         if (devices.size()!=0) {
00168             std::ostringstream str;
00169             bool addSem = false;
00170             for (std::vector<MSDevice*>::const_iterator i=devices.begin(); i!=devices.end(); ++i) {
00171                 if (addSem) {
00172                     str << ' ';
00173                 }
00174                 addSem = true;
00175                 str << (*i)->getID();
00176             }
00177             deviceIDs = str.str();
00178         }
00179         //
00180         od << "\" devices=\"" << deviceIDs
00181         << "\" vtype=\"" << v->getVehicleType().getID()
00182         << "\" vaporized=\"";
00183         if (v->hasCORNIntValue(MSCORN::CORN_VEH_VAPORIZED)) {
00184             od << v->getCORNIntValue(MSCORN::CORN_VEH_VAPORIZED);
00185         }
00186         od << "\"";
00187         // write device information
00188         if (devices.size()!=0) {
00189             od << ">\n";
00190             for (std::vector<MSDevice*>::const_iterator i=devices.begin(); i!=devices.end(); ++i) {
00191                 (*i)->tripInfoOutput(od);
00192             }
00193         }
00194         od.closeTag(devices.size()==0);
00195     }
00196 
00197     // check whether to generate the information about the vehicle's routes
00198     if (MSCORN::wished(MSCORN::CORN_OUT_VEHROUTES)) {
00199         // generate vehicle's trip routes
00200         MSNet *net = MSNet::getInstance();
00201         OutputDevice& od = OutputDevice::getDeviceByOption("vehroute-output");
00202         SUMOTime realDepart = (SUMOTime) v->getCORNIntValue(MSCORN::CORN_VEH_DEPART_TIME);
00203         SUMOTime time = net->getCurrentTimeStep();
00204         od.openTag("vehicle") << " id=\"" << v->getID() << "\" depart=\""
00205         << time2string(v->getCORNIntValue(MSCORN::CORN_VEH_DEPART_TIME))
00206         << "\" arrival=\"" << time2string(MSNet::getInstance()->getCurrentTimeStep());
00207         if (MSCORN::wished(MSCORN::CORN_OUT_TAZ)) {
00208             od << "\" fromtaz=\"" << v->getParameter().fromTaz << "\" totaz=\"" << v->getParameter().toTaz;
00209         }
00210         od << "\">\n";
00211         if (MSCORN::wished(MSCORN::CORN_OUT_OLDROUTES) && v->hasCORNIntValue(MSCORN::CORN_VEH_NUMBERROUTE)) {
00212             od.openTag("routeDistribution") << ">\n";
00213             int noReroutes = v->getCORNIntValue(MSCORN::CORN_VEH_NUMBERROUTE);
00214             for (int i=0; i<noReroutes; ++i) {
00215                 v->writeXMLRoute(od, i);
00216             }
00217         }
00218         v->writeXMLRoute(od);
00219         if (MSCORN::wished(MSCORN::CORN_OUT_OLDROUTES) && v->hasCORNIntValue(MSCORN::CORN_VEH_NUMBERROUTE)) {
00220             od.closeTag();
00221         }
00222         od.closeTag();
00223         od << "\n";
00224     }
00225     // check whether to save information about the vehicle's trip
00226     if (MSCORN::wished(MSCORN::CORN_MEAN_VEH_TRAVELTIME)) {
00227         myAbsVehTravelTime +=
00228             (MSNet::getInstance()->getCurrentTimeStep()
00229              - v->getCORNIntValue(MSCORN::CORN_VEH_DEPART_TIME));
00230     }
00231     myRunningVehNo--;
00232     MSNet::getInstance()->informVehicleStateListener(v, MSNet::VEHICLE_STATE_ARRIVED);
00233     deleteVehicle(v);
00234 }

void MSVehicleControl::vehicleEmitted ( const MSVehicle v  )  throw () [virtual, inherited]

Informs this control about a vehicle's emission.

If the mean waiting time shall be computed (f.e. for emissions-output), the absolut waiting time is increased by the waiting time of the given vehicle.

Parameters:
[in] v The emitted vehicle
Todo:
Consolidate with vehiclesEmitted

Definition at line 256 of file MSVehicleControl.cpp.

References MSCORN::CORN_MEAN_VEH_WAITINGTIME, MSCORN::CORN_VEH_DEPART_TIME, MSNet::getInstance(), MSNet::informVehicleStateListener(), MAX2(), MSVehicleControl::myAbsVehWaitingTime, MSVehicleControl::myRunningVehNo, MSNet::VEHICLE_STATE_DEPARTED, and MSCORN::wished().

Referenced by MSVehicle::onDepart().


Field Documentation

The aggregated time vehicles needed to aacomplish their route.

Definition at line 375 of file MSVehicleControl.h.

Referenced by MSVehicleControl::getMeanTravelTime(), and MSVehicleControl::scheduleVehicleRemoval().

The aggregated time vehicles had to wait for departure.

Definition at line 372 of file MSVehicleControl.h.

Referenced by MSVehicleControl::getMeanWaitingTime(), and MSVehicleControl::vehicleEmitted().

Whether no vehicle type was loaded.

Definition at line 403 of file MSVehicleControl.h.

Referenced by MSVehicleControl::checkVType(), and MSVehicleControl::getVType().

unsigned int MSVehicleControl::myEndedVehNo [protected, inherited]

unsigned int MSVehicleControl::myLoadedVehNo [protected, inherited]

unsigned int MSVehicleControl::myRunningVehNo [protected, inherited]

The number of vehicles within the network (build and emitted but not removed).

Definition at line 361 of file MSVehicleControl.h.

Referenced by MSVehicleControl::getEmittedVehicleNo(), MSVehicleControl::getRunningVehicleNo(), MSVehicleControl::scheduleVehicleRemoval(), and MSVehicleControl::vehicleEmitted().

std::map<const MSEdge* const, std::vector<MSVehicle*> > MSVehicleControl::myWaiting [protected, inherited]

the lists of waiting vehicles

Definition at line 406 of file MSVehicleControl.h.

Referenced by MSVehicleControl::addWaiting(), MSVehicleControl::getWaitingVehicle(), and MSVehicleControl::removeWaiting().


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

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