SUMO - Simulation of Urban MObility

MSBaseVehicle Class Reference

The base class for microscopic and mesoscopic vehicles. More...

#include <MSBaseVehicle.h>

Inheritance diagram for MSBaseVehicle:
SUMOVehicle MSVehicle GUIVehicle

Public Member Functions

virtual void activateReminders (const MSMoveReminder::Notification reason) throw ()
 "Activates" all current move reminder
SUMOReal adaptMaxSpeed (SUMOReal referenceSpeed)
 Adapts the current maximum speed using the distribution given in the type.
virtual void addPerson (MSPerson *person) throw ()
 Adds a person to this vehicle.
void addReminder (MSMoveReminder *rem) throw ()
 Adds a MoveReminder dynamically.
SUMOTime getDeparture () const throw ()
 Returns this vehicle's real departure time.
const std::vector< MSDevice * > & getDevices () const
 Returns this vehicle's devices.
const MSEdge * getEdge () const
 Returns the edge the vehicle is currently at.
const std::string & getID () const throw ()
 Returns the name of the vehicle.
SUMOReal getMaxSpeed () const
 Returns the current maximum speed.
unsigned int getNumberReroutes () const throw ()
 Returns the number of new routes this vehicle got.
const SUMOVehicleParameter & getParameter () const throw ()
 Returns the vehicle's parameter (including departure definition)
virtual SUMOReal getPositionOnLane () const =0 throw ()
 Get the vehicle's position along the lane.
virtual SUMOReal getPreDawdleAcceleration () const throw ()
 Returns the vehicle's acceleration before dawdling.
const MSRoute & getRoute () const throw ()
 Returns the current route.
virtual SUMOReal getSpeed () const =0 throw ()
 Returns the vehicle's current speed.
const MSVehicleType & getVehicleType () const throw ()
 Returns the vehicle's type definition.
bool hasValidRoute (std::string &msg) const throw ()
 Validates the current route.
virtual bool isOnRoad () const throw ()
 Returns the information whether the vehicle is on a road (is simulated)
virtual bool isStopped () const
 Returns whether the vehicle is at a stop.
 MSBaseVehicle (SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type) throw (ProcessError)
 Constructor.
void onDepart () throw ()
 Called when the vehicle is inserted into the network.
void removeReminder (MSMoveReminder *rem) throw ()
 Removes a MoveReminder dynamically.
virtual bool replaceRoute (const MSRoute *route, bool onInit=false)=0
 Replaces the current route by the given one.
bool replaceRouteEdges (const MSEdgeVector &edges, bool onInit=false) throw ()
 Replaces the current route by the given edges.
void reroute (SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, bool withTaz=false) throw ()
 Performs a rerouting using the given router.
const MSEdge * succEdge (unsigned int nSuccs) const throw ()
 Returns the nSuccs'th successor of edge the vehicle is currently at.
virtual ~MSBaseVehicle () throw ()
 Destructor.

Protected Member Functions

void calculateArrivalPos () throw ()
 (Re-)Calculates the arrival position from the vehicle parameters

Protected Attributes

SUMOReal myArrivalPos
 the position on the destination lane where the vehicle stops
MSRouteIterator myCurrEdge
 Iterator to current route-edge.
SUMOTime myDeparture
 The real departure time.
std::vector< MSDevice * > myDevices
 The devices this vehicle has.
bool myHasIndividualMaxSpeed
 is true if there has an individual speed been set
SUMOReal myIndividualMaxSpeed
unsigned int myNumberReroutes
 The number of reroutings.
const SUMOVehicleParameter * myParameter
 This Vehicle's parameter.
SUMOReal myReferenceSpeed
 the speed which served as reference when calculating the individual maxspeed
const MSRoute * myRoute
 This Vehicle's route.
const MSVehicleType * myType
 This Vehicle's type.

Move reminder structures

typedef std::vector< std::pair
< MSMoveReminder *, SUMOReal > > 
MoveReminderCont
 Definition of a move reminder container.
MoveReminderCont myMoveReminders
 Current lane's move reminder.

Detailed Description

The base class for microscopic and mesoscopic vehicles.

Definition at line 55 of file MSBaseVehicle.h.


Member Typedef Documentation

typedef std::vector< std::pair<MSMoveReminder*, SUMOReal> > MSBaseVehicle::MoveReminderCont [protected]

Definition of a move reminder container.

Definition at line 260 of file MSBaseVehicle.h.


Constructor & Destructor Documentation

MSBaseVehicle::MSBaseVehicle ( SUMOVehicleParameter *  pars,
const MSRoute *  route,
const MSVehicleType *  type 
) throw (ProcessError)
MSBaseVehicle::~MSBaseVehicle ( ) throw () [virtual]

Destructor.

Definition at line 77 of file MSBaseVehicle.cpp.

References myDevices, myParameter, myRoute, and MSRoute::release().


Member Function Documentation

void MSBaseVehicle::activateReminders ( const MSMoveReminder::Notification  reason) throw () [virtual]

"Activates" all current move reminder

For all move reminder stored in "myMoveReminders", their method "MSMoveReminder::notifyEnter" is called.

Parameters:
[in]reasonThe reason for changing the reminders' states
See also:
MSMoveReminder
MSMoveReminder::notifyEnter
MSMoveReminder::Notification

Reimplemented in MSVehicle.

Definition at line 271 of file MSBaseVehicle.cpp.

SUMOReal MSBaseVehicle::adaptMaxSpeed ( SUMOReal  referenceSpeed) [virtual]

Adapts the current maximum speed using the distribution given in the type.

Returns:
The vehicle's new maximum speed

Implements SUMOVehicle.

Definition at line 120 of file MSBaseVehicle.cpp.

References MSVehicleType::getMaxSpeed(), MSVehicleType::getMaxSpeedWithDeviation(), MSVehicleType::hasSpeedDeviation(), MIN2(), myHasIndividualMaxSpeed, myIndividualMaxSpeed, myReferenceSpeed, and myType.

void MSBaseVehicle::addPerson ( MSPerson *  person) throw () [virtual]

Adds a person to this vehicle.

The default implementation does nothing since persons are not supported by default

Parameters:
[in]personThe person to add

Implements SUMOVehicle.

Reimplemented in MSVehicle.

Definition at line 222 of file MSBaseVehicle.cpp.

void MSBaseVehicle::addReminder ( MSMoveReminder *  rem) throw ()

Adds a MoveReminder dynamically.

Parameters:
[in]remthe reminder to add
See also:
MSMoveReminder

Definition at line 254 of file MSBaseVehicle.cpp.

Referenced by MSVehicle::adaptLaneEntering2MoveReminder(), MSVehicle::enterLaneAtInsertion(), and MSVehicle::enterLaneAtLaneChange().

void MSBaseVehicle::calculateArrivalPos ( ) throw () [protected]
SUMOTime MSBaseVehicle::getDeparture ( ) const throw () [virtual]

Returns this vehicle's real departure time.

Returns:
This vehicle's real departure time

Implements SUMOVehicle.

Definition at line 210 of file MSBaseVehicle.cpp.

References myDeparture.

const std::vector<MSDevice*>& MSBaseVehicle::getDevices ( ) const [inline, virtual]

Returns this vehicle's devices.

Returns:
This vehicle's devices

Implements SUMOVehicle.

Definition at line 177 of file MSBaseVehicle.h.

References myDevices.

const MSEdge * MSBaseVehicle::getEdge ( ) const [virtual]

Returns the edge the vehicle is currently at.

Returns:
The current edge in the vehicle's route

Implements SUMOVehicle.

Definition at line 144 of file MSBaseVehicle.cpp.

References myCurrEdge.

Referenced by MSVehicleTransfer::checkInsertions(), and TraCIServerAPI_Vehicle::commandDistanceRequest().

SUMOReal MSBaseVehicle::getMaxSpeed ( ) const [virtual]

Returns the current maximum speed.

Returns:
The vehicle's maximum speed

Implements SUMOVehicle.

Definition at line 111 of file MSBaseVehicle.cpp.

References MSVehicleType::getMaxSpeed(), myHasIndividualMaxSpeed, myIndividualMaxSpeed, and myType.

Referenced by MSCFModel_Wiedemann::_v(), MSVehicleTransfer::checkInsertions(), GUIVehicle::getColorValue(), and MSVehicle::moveChecked().

unsigned int MSBaseVehicle::getNumberReroutes ( ) const throw () [virtual]

Returns the number of new routes this vehicle got.

Returns:
the number of new routes this vehicle got

Implements SUMOVehicle.

Definition at line 216 of file MSBaseVehicle.cpp.

References myNumberReroutes.

Referenced by GUIVehicle::drawGLAdditional(), and GUIVehicle::getColorValue().

const SUMOVehicleParameter & MSBaseVehicle::getParameter ( ) const throw () [virtual]

Returns the vehicle's parameter (including departure definition)

Returns:
The vehicle's parameter

Implements SUMOVehicle.

Definition at line 93 of file MSBaseVehicle.cpp.

References myParameter.

Referenced by GUIVehicle::getParameterWindow(), TraCIServerAPI_Vehicle::processGet(), and GUIVehicle::setFunctionalColor().

virtual SUMOReal SUMOVehicle::getPositionOnLane ( ) const throw () [pure virtual, inherited]

Get the vehicle's position along the lane.

Returns:
The position of the vehicle (in m from the lane's begin)

Implemented in MSVehicle.

Referenced by MSInstantInductLoop::notifyEnter(), MSInductLoop::notifyEnter(), and MSE2Collector::notifyEnter().

SUMOReal MSBaseVehicle::getPreDawdleAcceleration ( ) const throw () [virtual]

Returns the vehicle's acceleration before dawdling.

This default implementation returns always 0.

Returns:
The acceleration before dawdling

Implements SUMOVehicle.

Reimplemented in MSVehicle.

Definition at line 197 of file MSBaseVehicle.cpp.

const MSRoute & MSBaseVehicle::getRoute ( ) const throw () [virtual]

Returns the current route.

Returns:
The route the vehicle uses

Implements SUMOVehicle.

Definition at line 99 of file MSBaseVehicle.cpp.

References myRoute.

Referenced by TraCIServerAPI_Vehicle::commandDistanceRequest(), MSVehicle::enterLaneAtLaneChange(), getMaxSpeedRegardingNextLanes(), TraCIServerAPI_Vehicle::processGet(), and GUIVehicle::setFunctionalColor().

virtual SUMOReal SUMOVehicle::getSpeed ( ) const throw () [pure virtual, inherited]

Returns the vehicle's current speed.

Returns:
The vehicle's speed

Implemented in MSVehicle.

Referenced by MSInductLoop::collectVehiclesOnDet(), MSE3Collector::detectorUpdate(), and TraCIServerAPI_Vehicle::processSet().

bool MSBaseVehicle::hasValidRoute ( std::string &  msg) const throw ()

Validates the current route.

Parameters:
[out]msgDescription why the route is not valid (if it is the case)
Returns:
Whether the vehicle's current route is valid

Definition at line 232 of file MSBaseVehicle.cpp.

Referenced by MSVehicle::enterLaneAtInsertion(), and TraCIServerAPI_Vehicle::processGet().

virtual bool MSBaseVehicle::isOnRoad ( ) const throw () [inline, virtual]

Returns the information whether the vehicle is on a road (is simulated)

Returns:
Whether the vehicle is simulated

Implements SUMOVehicle.

Reimplemented in MSVehicle.

Definition at line 119 of file MSBaseVehicle.h.

bool MSBaseVehicle::isStopped ( ) const [virtual]

Returns whether the vehicle is at a stop.

Returns:
Whether it has stopped

Implements SUMOVehicle.

Reimplemented in MSVehicle.

Definition at line 226 of file MSBaseVehicle.cpp.

void MSBaseVehicle::onDepart ( ) throw () [virtual]

Called when the vehicle is inserted into the network.

Sets optional information about departure time, informs the vehicle control about a further running vehicle.

Implements SUMOVehicle.

Definition at line 203 of file MSBaseVehicle.cpp.

References MSNet::getCurrentTimeStep(), MSNet::getInstance(), MSNet::getVehicleControl(), myDeparture, and MSVehicleControl::vehicleDeparted().

void MSBaseVehicle::removeReminder ( MSMoveReminder *  rem) throw ()

Removes a MoveReminder dynamically.

Parameters:
[in]remthe reminder to remove
See also:
MSMoveReminder

Definition at line 260 of file MSBaseVehicle.cpp.

virtual bool SUMOVehicle::replaceRoute ( const MSRoute *  route,
bool  onInit = false 
) [pure virtual, inherited]

Replaces the current route by the given one.

Implemented in MSVehicle.

Referenced by TraCIServerAPI_Vehicle::processSet().

bool MSBaseVehicle::replaceRouteEdges ( const MSEdgeVector &  edges,
bool  onInit = false 
) throw () [virtual]

Replaces the current route by the given edges.

It is possible that the new route is not accepted, if a) it does not contain the vehicle's current edge, or b) something fails on insertion into the routes container (see in-line comments).

Parameters:
[in]edgesThe new list of edges to pass
[in]simTimeThe time at which the route was replaced
Returns:
Whether the new route was accepted

Implements SUMOVehicle.

Definition at line 171 of file MSBaseVehicle.cpp.

References MSRoute::addReference(), MSRoute::dictionary(), MSRoute::release(), and toString().

Referenced by TraCIServerAPI_Vehicle::processSet().

void MSBaseVehicle::reroute ( SUMOTime  t,
SUMOAbstractRouter< MSEdge, SUMOVehicle > &  router,
bool  withTaz = false 
) throw () [virtual]

Performs a rerouting using the given router.

Tries to find a new route between the current edge and the destination edge, first. Tries to replace the current route by the new one using replaceRoute.

Parameters:
[in]tThe time for which the route is computed
[in]routerThe router to use
See also:
replaceRoute

Implements SUMOVehicle.

Definition at line 150 of file MSBaseVehicle.cpp.

References MSEdge::dictionary(), and WRITE_WARNING.

const MSEdge * MSBaseVehicle::succEdge ( unsigned int  nSuccs) const throw () [virtual]

Returns the nSuccs'th successor of edge the vehicle is currently at.

If the rest of the route (counted from the current edge) has less than nSuccs edges, 0 is returned.

Parameters:
[in]nSuccsThe number of edge to look forward
Returns:
The nSuccs'th following edge in the vehicle's route

Implements SUMOVehicle.

Definition at line 134 of file MSBaseVehicle.cpp.

Referenced by MSVehicleTransfer::checkInsertions().


Field Documentation

SUMOReal MSBaseVehicle::myArrivalPos [protected]

the position on the destination lane where the vehicle stops

Definition at line 273 of file MSBaseVehicle.h.

Referenced by calculateArrivalPos(), MSVehicle::ends(), MSVehicle::getBestLanes(), MSVehicle::moveRegardingCritical(), and MSVehicle::vsafeCriticalCont().

The real departure time.

Definition at line 270 of file MSBaseVehicle.h.

Referenced by getDeparture(), and onDepart().

std::vector<MSDevice*> MSBaseVehicle::myDevices [protected]

The devices this vehicle has.

Definition at line 267 of file MSBaseVehicle.h.

Referenced by MSVehicle::addPerson(), getDevices(), GUIVehicle::GUIVehicle(), and ~MSBaseVehicle().

is true if there has an individual speed been set

Definition at line 251 of file MSBaseVehicle.h.

Referenced by adaptMaxSpeed(), getMaxSpeed(), MSVehicle::setIndividualMaxSpeed(), and MSVehicle::unsetIndividualMaxSpeed().

An individual speed for an vehicle that is used (iff set) instead of the maximal speed of the vehicle class. NOTE: This is just a little workaround for allowing an external influence on the actual speed

Definition at line 248 of file MSBaseVehicle.h.

Referenced by adaptMaxSpeed(), getMaxSpeed(), and MSVehicle::setIndividualMaxSpeed().

unsigned int MSBaseVehicle::myNumberReroutes [protected]

The number of reroutings.

Definition at line 276 of file MSBaseVehicle.h.

Referenced by getNumberReroutes(), and MSVehicle::replaceRoute().

SUMOReal MSBaseVehicle::myReferenceSpeed [protected]

the speed which served as reference when calculating the individual maxspeed

Definition at line 254 of file MSBaseVehicle.h.

Referenced by adaptMaxSpeed().


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines