|
SUMO - Simulation of Urban MObility
|
The class responsible for building and deletion of vehicles (gui-version) More...
#include <GUIVehicleControl.h>
Public Types | |
| typedef std::map< std::string, SUMOVehicle * > ::const_iterator | constVehIt |
| Definition of the internal vehicles map iterator. | |
Public Member Functions | |
| void | abortWaiting () throw () |
| removes any vehicles that are still waiting | |
| bool | addVehicle (const std::string &id, SUMOVehicle *v) throw () |
| Tries to insert the vehicle into the internal vehicle container. | |
| void | addWaiting (const MSEdge *const edge, SUMOVehicle *vehicle) throw () |
| void | deleteVehicle (SUMOVehicle *v) throw () |
| Deletes the vehicle. | |
| SUMOVehicle * | getWaitingVehicle (const MSEdge *const edge, const std::set< std::string > &lines) throw () |
| GUIVehicleControl () throw () | |
| Constructor. | |
| void | insertVehicleIDs (std::vector< GUIGlID > &into) throw () |
| Returns the list of all known vehicles by gl-id. | |
| void | registerOneWaitingForPerson () |
| increases the count of vehicles waiting for a person to allow recogniztion of person related deadlocks | |
| void | removeWaiting (const MSEdge *const edge, SUMOVehicle *vehicle) throw () |
| void | unregisterOneWaitingForPerson () |
| decreases the count of vehicles waiting for a person to allow recogniztion of person related deadlocks | |
| ~GUIVehicleControl () throw () | |
| Destructor. | |
Vehicle creation | |
| SUMOVehicle * | buildVehicle (SUMOVehicleParameter *defs, const MSRoute *route, const MSVehicleType *type) throw (ProcessError) |
| Builds a vehicle, increases the number of built vehicles. | |
Insertion, deletion and retrieval of vehicles | |
| SUMOVehicle * | getVehicle (const std::string &id) const throw () |
| Returns the vehicle with the given id. | |
| void | scheduleVehicleRemoval (SUMOVehicle *veh) throw () |
| Removes a vehicle after it has ended. | |
| constVehIt | loadedVehBegin () const throw () |
| Returns the begin of the internal vehicle map. | |
| constVehIt | loadedVehEnd () const throw () |
| Returns the end of the internal vehicle map. | |
Setting vehicle statistics | |
| void | vehicleDeparted (const SUMOVehicle &v) throw () |
| Informs this control about a vehicle's departure. | |
Retrieval of vehicle statistics (always accessable) | |
| unsigned int | getLoadedVehicleNo () const throw () |
| Returns the number of build vehicles. | |
| unsigned int | getEndedVehicleNo () const throw () |
| Returns the number of removed vehicles. | |
| unsigned int | getRunningVehicleNo () const throw () |
| Returns the number of build and inserted, but not yet deleted vehicles. | |
| unsigned int | getDepartedVehicleNo () const throw () |
| Returns the number of inserted vehicles. | |
| bool | isInQuota (const SUMOReal frac) const throw () |
| Returns the information whether the currently vehicle number is still in the given range. | |
| int | getActiveVehicleCount () const throw () |
| Returns the number of build vehicles that have not been removed or need to wait for a passenger. | |
Retrieval of vehicle statistics (availability depends on simulation settings) | |
| void | printMeanWaitingTime (OutputDevice &od) const throw () |
| Prints the mean waiting time of vehicles. The mean time vehicles had to wait for being inserted (-1 if no vehicle was inserted, yet) | |
| void | printMeanTravelTime (OutputDevice &od) const throw () |
| Returns the mean travel time of vehicles The mean travel time of ended vehicles (-1 if no vehicle has ended, yet) | |
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. | |
| bool | hasVTypeDistribution (const std::string &id) const throw () |
| Asks for a vehicle type distribution. | |
| MSVehicleType * | getVType (const std::string &id=DEFAULT_VTYPE_ID) throw () |
| Returns the named vehicle type or a sample from the named 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. | |
State I/O (mesosim only) | |
| virtual void | saveState (std::ostream &os) throw () |
| Loads the state of this control from the given stream. | |
| virtual void | loadState (BinaryInputDevice &bis, const SUMOTime offset) throw () |
| Saves the current state into the given stream. | |
Protected Attributes | |
Vehicle statistics (always accessable) | |
| unsigned int | myLoadedVehNo |
| The number of build vehicles. | |
| unsigned int | myRunningVehNo |
| The number of vehicles within the network (build and inserted but not removed) | |
| unsigned int | myEndedVehNo |
| The number of removed vehicles. | |
Vehicle statistics | |
| SUMOReal | myTotalDepartureDelay |
| The aggregated time vehicles had to wait for departure (in seconds) | |
| SUMOReal | myTotalTravelTime |
| The aggregated time vehicles needed to aacomplish their route (in seconds) | |
Private Member Functions | |
| GUIVehicleControl (const GUIVehicleControl &s) | |
| invalidated copy constructor | |
| GUIVehicleControl & | operator= (const GUIVehicleControl &s) |
| invalidated assignment operator | |
Private Attributes | |
| MFXMutex | myLock |
| The mutex used to avoid concurrent updates of the vehicle buffer. | |
Vehicle container | |
| typedef std::map< std::string, SUMOVehicle * > | VehicleDictType |
| Vehicle dictionary type. | |
| VehicleDictType | myVehicleDict |
| Dictionary of vehicles. | |
Vehicle type container | |
| typedef std::map< std::string, MSVehicleType * > | VTypeDictType |
| Vehicle type dictionary type. | |
| typedef std::map< std::string, RandomDistributor < MSVehicleType * > * > | VTypeDistDictType |
| Vehicle type distribution dictionary type. | |
| VTypeDictType | myVTypeDict |
| Dictionary of vehicle types. | |
| VTypeDistDictType | myVTypeDistDict |
| A distribution of vehicle types (probability->vehicle type) | |
| bool | myDefaultVTypeMayBeDeleted |
| Whether no vehicle type was loaded. | |
| std::map< const MSEdge *const, std::vector< SUMOVehicle * > > | myWaiting |
| the lists of waiting vehicles | |
| unsigned int | myWaitingForPerson |
| the number of vehicles contained in myWaiting which can only continue by being triggered | |
The class responsible for building and deletion of vehicles (gui-version)
Builds GUIVehicle instances instead of MSVehicle.
This is partially unsecure due to concurrent access...
Recheck vehicle deletion
Definition at line 56 of file GUIVehicleControl.h.
typedef std::map<std::string, SUMOVehicle*>::const_iterator MSVehicleControl::constVehIt [inherited] |
Definition of the internal vehicles map iterator.
Definition at line 73 of file MSVehicleControl.h.
typedef std::map< std::string, SUMOVehicle* > MSVehicleControl::VehicleDictType [protected, inherited] |
Vehicle dictionary type.
Definition at line 399 of file MSVehicleControl.h.
typedef std::map< std::string, MSVehicleType* > MSVehicleControl::VTypeDictType [protected, inherited] |
Vehicle type dictionary type.
Definition at line 409 of file MSVehicleControl.h.
typedef std::map< std::string, RandomDistributor<MSVehicleType*>* > MSVehicleControl::VTypeDistDictType [protected, inherited] |
Vehicle type distribution dictionary type.
Definition at line 414 of file MSVehicleControl.h.
| GUIVehicleControl::GUIVehicleControl | ( | ) | throw () |
Constructor.
Definition at line 44 of file GUIVehicleControl.cpp.
| GUIVehicleControl::~GUIVehicleControl | ( | ) | throw () |
Destructor.
Definition at line 48 of file GUIVehicleControl.cpp.
References MFXMutex::locked(), myLock, and MFXMutex::unlock().
| GUIVehicleControl::GUIVehicleControl | ( | const GUIVehicleControl & | s | ) | [private] |
invalidated copy constructor
| void MSVehicleControl::abortWaiting | ( | ) | throw () [inherited] |
removes any vehicles that are still waiting
Definition at line 296 of file MSVehicleControl.cpp.
References MSVehicleControl::myVehicleDict, and WRITE_WARNING.
Referenced by MSNet::simulationState().
| bool GUIVehicleControl::addVehicle | ( | const std::string & | id, |
| SUMOVehicle * | v | ||
| ) | throw () [virtual] |
Tries to insert the vehicle into the internal vehicle container.
Identical to the MSVehicleControl implementation except for locking.
| [in] | id | The id of the vehicle |
| [in] | v | The vehicle |
Reimplemented from MSVehicleControl.
Definition at line 67 of file GUIVehicleControl.cpp.
References MSVehicleControl::addVehicle().
| 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.
| [in] | vehType | The vehicle type to add |
Definition at line 207 of file MSVehicleControl.cpp.
| 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.
| [in] | id | The id of the distribution to add |
| [in] | vehTypeDistribution | The vehicle type distribution to add |
Definition at line 217 of file MSVehicleControl.cpp.
| void MSVehicleControl::addWaiting | ( | const MSEdge *const | edge, |
| SUMOVehicle * | vehicle | ||
| ) | throw () [inherited] |
Definition at line 262 of file MSVehicleControl.cpp.
Referenced by MSRouteHandler::closeVehicle(), and MSVehicle::processNextStop().
| SUMOVehicle * 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
| [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 |
Reimplemented from MSVehicleControl.
Definition at line 57 of file GUIVehicleControl.cpp.
References MSNet::getInstance(), MSNet::informVehicleStateListener(), and MSNet::VEHICLE_STATE_BUILT.
| void GUIVehicleControl::deleteVehicle | ( | SUMOVehicle * | v | ) | throw () [virtual] |
Deletes the vehicle.
Identical to the MSVehicleControl implementation except for locking.
| [in] | v | The vehicle to delete |
Reimplemented from MSVehicleControl.
Definition at line 76 of file GUIVehicleControl.cpp.
References MSVehicleControl::deleteVehicle().
| int MSVehicleControl::getActiveVehicleCount | ( | ) | const throw () [inline, inherited] |
Returns the number of build vehicles that have not been removed or need to wait for a passenger.
Definition at line 238 of file MSVehicleControl.h.
References MSVehicleControl::myEndedVehNo, MSVehicleControl::myLoadedVehNo, and MSVehicleControl::myWaitingForPerson.
Referenced by MSNet::simulationState().
| unsigned int MSVehicleControl::getDepartedVehicleNo | ( | ) | const throw () [inline, inherited] |
Returns the number of inserted vehicles.
Definition at line 218 of file MSVehicleControl.h.
References MSVehicleControl::myEndedVehNo, and MSVehicleControl::myRunningVehNo.
Referenced by MSNet::closeSimulation(), GUINet::getParameterWindow(), MSNet::postSimStepOutput(), and MSNet::writeOutput().
| unsigned int MSVehicleControl::getEndedVehicleNo | ( | ) | const throw () [inline, inherited] |
Returns the number of removed vehicles.
Definition at line 202 of file MSVehicleControl.h.
References MSVehicleControl::myEndedVehNo.
Referenced by GUINet::getParameterWindow(), and MSNet::writeOutput().
| unsigned int MSVehicleControl::getLoadedVehicleNo | ( | ) | const throw () [inline, inherited] |
Returns the number of build vehicles.
Definition at line 194 of file MSVehicleControl.h.
References MSVehicleControl::myLoadedVehNo.
Referenced by GUINet::getParameterWindow(), and MSNet::writeOutput().
| unsigned int MSVehicleControl::getRunningVehicleNo | ( | ) | const throw () [inline, inherited] |
Returns the number of build and inserted, but not yet deleted vehicles.
Definition at line 210 of file MSVehicleControl.h.
References MSVehicleControl::myRunningVehNo.
Referenced by MSNet::closeSimulation(), GUINet::getParameterWindow(), MSNet::postSimStepOutput(), GUINet::setSimDuration(), MSNet::simulationState(), MSNet::simulationStep(), and MSNet::writeOutput().
| SUMOVehicle * MSVehicleControl::getVehicle | ( | const std::string & | id | ) | const throw () [inherited] |
Returns the vehicle with the given id.
If no vehicle with the given id is store din "myVehicleDict", 0 is returned.
| [in] | id | The id of the vehicle to retrieve |
Definition at line 159 of file MSVehicleControl.cpp.
Referenced by MSInsertionControl::checkFlows(), MSRouteHandler::closeVehicle(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_GUI::processSet(), and GUINet::vehicleExists().
| MSVehicleType * MSVehicleControl::getVType | ( | const std::string & | id = DEFAULT_VTYPE_ID | ) | throw () [inherited] |
Returns the named vehicle type or a sample from the named distribution.
| [in] | id | The id of the vehicle type to return. If left out, the default type is returned. |
Definition at line 233 of file MSVehicleControl.cpp.
References DEFAULT_VTYPE_ID, and MSVehicleType::get().
Referenced by MSInsertionControl::checkFlows(), MSRouteHandler::closeVehicle(), MSRouteHandler::openVehicleTypeDistribution(), TraCIServerAPI_VehicleType::processGet(), TraCIServerAPI_VehicleType::processSet(), and TraCIServerAPI_Vehicle::processSet().
| SUMOVehicle * MSVehicleControl::getWaitingVehicle | ( | const MSEdge *const | edge, |
| const std::set< std::string > & | lines | ||
| ) | throw () [inherited] |
Definition at line 282 of file MSVehicleControl.cpp.
References SUMOVehicle::getParameter(), and SUMOVehicleParameter::line.
Referenced by MSPerson::MSPersonStage_Driving::proceed().
| 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.
| [in] | id | The id of the distribution |
Definition at line 227 of file MSVehicleControl.cpp.
Referenced by MSInsertionControl::add().
| void GUIVehicleControl::insertVehicleIDs | ( | std::vector< GUIGlID > & | into | ) | throw () |
Returns the list of all known vehicles by gl-id.
| fill] | into The list to fill with vehicle ids |
Definition at line 84 of file GUIVehicleControl.cpp.
References SUMOVehicle::isOnRoad().
| 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.
| [in] | into | The vector to fill with ids |
Definition at line 250 of file MSVehicleControl.cpp.
Referenced by TraCIServerAPI_VehicleType::processGet().
| bool MSVehicleControl::isInQuota | ( | const SUMOReal | frac | ) | const throw () [inline, inherited] |
Returns the information whether the currently vehicle number is still in the given range.
Definition at line 226 of file MSVehicleControl.h.
References MSGlobals::gFractions, and MSVehicleControl::myLoadedVehNo.
Referenced by MSDevice_Routing::buildVehicleDevices(), MSDevice_HBEFA::buildVehicleDevices(), and MSRouteHandler::closeVehicle().
| MSVehicleControl::constVehIt MSVehicleControl::loadedVehBegin | ( | ) | const throw () [inherited] |
Returns the begin of the internal vehicle map.
Definition at line 177 of file MSVehicleControl.cpp.
References MSVehicleControl::myVehicleDict.
Referenced by MSVTypeProbe::execute(), and TraCIServerAPI_Vehicle::processGet().
| MSVehicleControl::constVehIt MSVehicleControl::loadedVehEnd | ( | ) | const throw () [inherited] |
Returns the end of the internal vehicle map.
Definition at line 183 of file MSVehicleControl.cpp.
References MSVehicleControl::myVehicleDict.
Referenced by MSVTypeProbe::execute(), and TraCIServerAPI_Vehicle::processGet().
| void MSVehicleControl::loadState | ( | BinaryInputDevice & | bis, |
| const SUMOTime | offset | ||
| ) | throw () [virtual, inherited] |
Saves the current state into the given stream.
Definition at line 142 of file MSVehicleControl.cpp.
| GUIVehicleControl& GUIVehicleControl::operator= | ( | const GUIVehicleControl & | s | ) | [private] |
invalidated assignment operator
| void MSVehicleControl::printMeanTravelTime | ( | OutputDevice & | od | ) | const throw () [inherited] |
Returns the mean travel time of vehicles The mean travel time of ended vehicles (-1 if no vehicle has ended, yet)
Definition at line 119 of file MSVehicleControl.cpp.
References SUMOReal.
Referenced by MSNet::writeOutput().
| void MSVehicleControl::printMeanWaitingTime | ( | OutputDevice & | od | ) | const throw () [inherited] |
Prints the mean waiting time of vehicles. The mean time vehicles had to wait for being inserted (-1 if no vehicle was inserted, yet)
Definition at line 109 of file MSVehicleControl.cpp.
References SUMOReal.
Referenced by MSNet::writeOutput().
| void MSVehicleControl::registerOneWaitingForPerson | ( | ) | [inline, inherited] |
increases the count of vehicles waiting for a person to allow recogniztion of person related deadlocks
Definition at line 329 of file MSVehicleControl.h.
References MSVehicleControl::myWaitingForPerson.
Referenced by MSRouteHandler::closeVehicle(), and MSVehicle::processNextStop().
| void MSVehicleControl::removeWaiting | ( | const MSEdge *const | edge, |
| SUMOVehicle * | vehicle | ||
| ) | throw () [inherited] |
Definition at line 271 of file MSVehicleControl.cpp.
Referenced by MSPerson::MSPersonStage_Driving::proceed(), and MSVehicle::processNextStop().
| void MSVehicleControl::saveState | ( | std::ostream & | os | ) | throw () [virtual, inherited] |
Loads the state of this control from the given stream.
Definition at line 137 of file MSVehicleControl.cpp.
| void MSVehicleControl::scheduleVehicleRemoval | ( | SUMOVehicle * | veh | ) | 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.
| [in] | veh | The vehicle to remove |
Definition at line 93 of file MSVehicleControl.cpp.
References OutputDevice::closeTag(), OutputDevice::getDeviceByOption(), MSNet::getInstance(), OptionsCont::getOptions(), MSNet::informVehicleStateListener(), STEPS2TIME, and MSNet::VEHICLE_STATE_ARRIVED.
Referenced by MSVehicleTransfer::addVeh(), MSVehicleTransfer::checkInsertions(), TraCIServerAPI_Vehicle::processSet(), and MSLane::setCritical().
| void MSVehicleControl::unregisterOneWaitingForPerson | ( | ) | [inline, inherited] |
decreases the count of vehicles waiting for a person to allow recogniztion of person related deadlocks
Definition at line 335 of file MSVehicleControl.h.
References MSVehicleControl::myWaitingForPerson.
Referenced by MSPerson::MSPersonStage_Driving::proceed(), and MSVehicle::processNextStop().
| void MSVehicleControl::vehicleDeparted | ( | const SUMOVehicle & | v | ) | throw () [inherited] |
Informs this control about a vehicle's departure.
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.
| [in] | v | The inserted vehicle |
Definition at line 129 of file MSVehicleControl.cpp.
References MSNet::getInstance(), MSNet::informVehicleStateListener(), STEPFLOOR, STEPS2TIME, and MSNet::VEHICLE_STATE_DEPARTED.
Referenced by MSBaseVehicle::onDepart().
bool MSVehicleControl::myDefaultVTypeMayBeDeleted [protected, inherited] |
Whether no vehicle type was loaded.
Definition at line 419 of file MSVehicleControl.h.
unsigned int MSVehicleControl::myEndedVehNo [protected, inherited] |
The number of removed vehicles.
Definition at line 380 of file MSVehicleControl.h.
Referenced by MSVehicleControl::getActiveVehicleCount(), MSVehicleControl::getDepartedVehicleNo(), and MSVehicleControl::getEndedVehicleNo().
unsigned int MSVehicleControl::myLoadedVehNo [protected, inherited] |
The number of build vehicles.
Definition at line 374 of file MSVehicleControl.h.
Referenced by MSVehicleControl::getActiveVehicleCount(), MSVehicleControl::getLoadedVehicleNo(), and MSVehicleControl::isInQuota().
MFXMutex GUIVehicleControl::myLock [mutable, private] |
The mutex used to avoid concurrent updates of the vehicle buffer.
Definition at line 117 of file GUIVehicleControl.h.
Referenced by ~GUIVehicleControl().
unsigned int MSVehicleControl::myRunningVehNo [protected, inherited] |
The number of vehicles within the network (build and inserted but not removed)
Definition at line 377 of file MSVehicleControl.h.
Referenced by MSVehicleControl::getDepartedVehicleNo(), and MSVehicleControl::getRunningVehicleNo().
SUMOReal MSVehicleControl::myTotalDepartureDelay [protected, inherited] |
The aggregated time vehicles had to wait for departure (in seconds)
Definition at line 388 of file MSVehicleControl.h.
SUMOReal MSVehicleControl::myTotalTravelTime [protected, inherited] |
The aggregated time vehicles needed to aacomplish their route (in seconds)
Definition at line 391 of file MSVehicleControl.h.
VehicleDictType MSVehicleControl::myVehicleDict [protected, inherited] |
Dictionary of vehicles.
Definition at line 401 of file MSVehicleControl.h.
Referenced by MSVehicleControl::abortWaiting(), MSVehicleControl::loadedVehBegin(), MSVehicleControl::loadedVehEnd(), and MSVehicleControl::~MSVehicleControl().
VTypeDictType MSVehicleControl::myVTypeDict [protected, inherited] |
Dictionary of vehicle types.
Definition at line 411 of file MSVehicleControl.h.
Referenced by MSVehicleControl::MSVehicleControl(), and MSVehicleControl::~MSVehicleControl().
VTypeDistDictType MSVehicleControl::myVTypeDistDict [protected, inherited] |
A distribution of vehicle types (probability->vehicle type)
Definition at line 416 of file MSVehicleControl.h.
Referenced by MSVehicleControl::~MSVehicleControl().
std::map<const MSEdge* const, std::vector<SUMOVehicle*> > MSVehicleControl::myWaiting [protected, inherited] |
the lists of waiting vehicles
Definition at line 422 of file MSVehicleControl.h.
unsigned int MSVehicleControl::myWaitingForPerson [protected, inherited] |
the number of vehicles contained in myWaiting which can only continue by being triggered
Definition at line 425 of file MSVehicleControl.h.
Referenced by MSVehicleControl::getActiveVehicleCount(), MSVehicleControl::registerOneWaitingForPerson(), and MSVehicleControl::unregisterOneWaitingForPerson().