47 #ifdef CHECK_MEMORY_LEAKS
49 #endif // CHECK_MEMORY_LEAKS
56 std::set<std::string> MSBaseVehicle::myShallTraceMoveReminders;
66 myCurrEdge(route->begin()),
67 myChosenSpeedFactor(speedFactor),
69 myDeparture(NOT_YET_DEPARTED),
73 , myTraceMoveReminders(myShallTraceMoveReminders.count(pars->id) > 0)
79 for (std::vector< MSDevice* >::iterator dev =
myDevices.begin(); dev !=
myDevices.end(); ++dev) {
89 for (std::vector< MSDevice* >::iterator dev =
myDevices.begin(); dev !=
myDevices.end(); ++dev) {
132 std::vector<const MSEdge*> edges;
135 if (edges.size() >= 2) {
136 edges.erase(edges.begin());
153 std::string
id =
getID();
157 if (
myRoute->
getID().find(
"!var#") != std::string::npos) {
212 msg =
"No connection between '" + (*e)->getID() +
"' and '" + (*(e + 1))->getID() +
"'.";
219 if ((*e)->prohibits(
this)) {
220 msg =
"Edge '" + (*e)->getID() +
"' prohibits.";
231 if (myTraceMoveReminders) {
232 traceMoveReminder(
"add", rem, 0,
true);
242 if (r->first == rem) {
244 if (myTraceMoveReminders) {
245 traceMoveReminder(
"remove", rem, 0,
false);
258 if (rem->first->notifyEnter(*
this, reason)) {
260 if (myTraceMoveReminders) {
261 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
true);
267 if (myTraceMoveReminders) {
268 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
false);
283 WRITE_WARNING(
"Vehicle '" +
getID() +
"' will not be able to arrive at the given position!");
303 for (std::vector<MSDevice*>::const_iterator dev =
myDevices.begin(); dev !=
myDevices.end(); ++dev) {
304 if (
typeid(**dev) == type) {
325 MSBaseVehicle::initMoveReminderOutput(
const OptionsCont& oc) {
326 if (oc.
isSet(
"movereminder-output.vehicles")) {
327 const std::vector<std::string> vehicles = oc.
getStringVector(
"movereminder-output.vehicles");
328 myShallTraceMoveReminders.insert(vehicles.begin(), vehicles.end());
334 MSBaseVehicle::traceMoveReminder(
const std::string& type,
MSMoveReminder* rem,
SUMOReal pos,
bool keep)
const {
void removeReminder(MSMoveReminder *rem)
Removes a MoveReminder dynamically.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
const MSVehicleType * myType
This Vehicle's type.
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
SUMOReal getMaxSpeed() const
Get vehicle's maximum speed [m/s].
void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, bool withTaz=false)
Performs a rerouting using the given router.
unsigned int getNumberReroutes() const
Returns the number of new routes this vehicle got.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type's vehicle class.
const std::string & getDescription() const
SUMOReal myArrivalPos
the position on the destination lane where the vehicle stops
MoveReminderCont myMoveReminders
Current lane's move reminder.
SUMOReal getMaxSpeed() const
Returns the maximum speed.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
virtual void addPerson(MSPerson *person)
Adds a person to this vehicle.
MSEdgeVector::const_iterator MSRouteIterator
virtual bool replaceRoute(const MSRoute *route, bool onInit=false)=0
Replaces the current route by the given one.
const MSEdge * getLastEdge() const
returns the destination edge
Notification
Definition of a vehicle state.
static SUMOReal rand()
Returns a random real number in [0, 1)
bool replaceRouteEdges(const MSEdgeVector &edges, bool onInit=false)
Replaces the current route by the given edges.
SUMOReal arrivalPos
(optional) The position the vehicle shall arrive on
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
virtual ~MSBaseVehicle()
Destructor.
const MSRoute * myRoute
This Vehicle's route.
bool hasDeparted() const
Returns whether this vehicle has already departed.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
const SUMOVehicleParameter * myParameter
This Vehicle's parameter.
The arrival position is given.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step (in s)
MSBaseVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, const SUMOReal speedFactor)
Constructor.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice * > &into)
Build devices for the given vehicle, if needed.
#define WRITE_WARNING(msg)
The car-following model and parameter.
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
std::string toTaz
The vehicle's destination zone (district)
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
virtual SUMOReal getAcceleration() const
Returns the vehicle's acceleration.
std::vector< const MSEdge * > MSEdgeVector
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
const MSEdge * succEdge(unsigned int nSuccs) const
Returns the nSuccs'th successor of edge the vehicle is currently at.
SUMOTime depart
The vehicle's departure time.
std::string fromTaz
The vehicle's origin zone (district)
Something on a lane to be noticed about vehicle movement.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
void addReference() const
increments the reference counter for the route
Abstract in-vehicle device.
Structure representing possible vehicle parameter.
MSRouteIterator end() const
Returns the end of the list of edges to pass.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
virtual void activateReminders(const MSMoveReminder::Notification reason)
"Activates" all current move reminder
void onDepart()
Called when the vehicle is inserted into the network.
A storage for options typed value containers)
virtual bool hasArrived() const
Returns whether this vehicle has already arived (by default this is true if the vehicle has reached i...
void calculateArrivalPos()
(Re-)Calculates the arrival position from the vehicle parameters
const std::string & getID() const
Returns the name of the vehicle type.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
bool hasValidRoute(std::string &msg) const
Validates the current route.
Static storage of an output device and its base (abstract) implementation.
const RGBColor & getColor() const
Returns the color.
bool closeTag()
Closes the most recently opened tag.
virtual void compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
MSRouteIterator myCurrEdge
Iterator to current route-edge.
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle's departure.
void release() const
deletes the route if there are no further references to it
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
std::vector< MSDevice * > myDevices
The devices this vehicle has.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOTime myDeparture
The real departure time.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static const SUMOTime NOT_YET_DEPARTED
std::string id
The vehicle's id.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
const std::string & getID() const
Returns the name of the vehicle.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
The arrival position is chosen randomly.