49 #ifdef CHECK_MEMORY_LEAKS 51 #endif // CHECK_MEMORY_LEAKS 58 std::set<std::string> MSBaseVehicle::myShallTraceMoveReminders;
69 myCurrEdge(route->begin()),
70 myChosenSpeedFactor(speedFactor),
72 myDeparture(NOT_YET_DEPARTED),
77 , myTraceMoveReminders(myShallTraceMoveReminders.count(pars->id) > 0)
83 for (std::vector< MSDevice* >::iterator dev =
myDevices.begin(); dev !=
myDevices.end(); ++dev) {
97 for (std::vector< MSDevice* >::iterator dev =
myDevices.begin(); dev !=
myDevices.end(); ++dev) {
154 router.
compute(source, *s,
this, t, edges);
159 router.
compute(source, sink,
this, t, edges);
161 edges.erase(edges.begin());
177 std::string
id =
getID();
181 if (
myRoute->
getID().find(
"!var#") != std::string::npos) {
186 int oldSize = (int)edges.size();
189 if (origin != *
myCurrEdge && edges.front() == origin) {
191 oldSize = (int)edges.size();
205 MSDevice_Routing::lock();
209 MSDevice_Routing::unlock();
215 MSDevice_Routing::unlock();
220 MSDevice_Routing::lock();
224 MSDevice_Routing::unlock();
277 msg =
"No connection between edge '" + (*e)->getID() +
"' and edge '" + (*(e + 1))->getID() +
"'.";
284 if ((*e)->prohibits(
this)) {
285 msg =
"Edge '" + (*e)->getID() +
"' prohibits.";
296 if (myTraceMoveReminders) {
297 traceMoveReminder(
"add", rem, 0,
true);
307 if (r->first == rem) {
309 if (myTraceMoveReminders) {
310 traceMoveReminder(
"remove", rem, 0,
false);
323 if (rem->first->notifyEnter(*
this, reason)) {
325 if (myTraceMoveReminders) {
326 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
true);
332 if (myTraceMoveReminders) {
333 traceMoveReminder(
"notifyEnter", rem->first, rem->second,
false);
345 const SUMOReal lastLaneLength = lanes[0]->getLength();
349 WRITE_WARNING(
"Vehicle '" +
getID() +
"' will not be able to arrive at the given position!");
371 for (std::vector<MSLane*>::const_iterator l = lanes.begin(); l != lanes.end(); ++l) {
376 WRITE_WARNING(
"Vehicle '" +
getID() +
"' will not be able to arrive with the given speed!");
390 for (std::vector<MSDevice*>::const_iterator dev =
myDevices.begin(); dev !=
myDevices.end(); ++dev) {
391 if (
typeid(**dev) == type) {
413 std::string errorMsg;
414 if (!
addStop(*i, errorMsg) && !ignoreStopErrors) {
417 if (errorMsg !=
"") {
422 std::string errorMsg;
423 if (!
addStop(*i, errorMsg) && !ignoreStopErrors) {
426 if (errorMsg !=
"") {
435 MSBaseVehicle::initMoveReminderOutput(
const OptionsCont& oc) {
436 if (oc.
isSet(
"movereminder-output.vehicles")) {
437 const std::vector<std::string> vehicles = oc.
getStringVector(
"movereminder-output.vehicles");
438 myShallTraceMoveReminders.insert(vehicles.begin(), vehicles.end());
444 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].
const int VEHPARS_FORCE_REROUTE
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.
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
SUMOReal getMaxSpeed() const
Returns the maximum speed.
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
SUMOReal getImpatience() const
Returns this vehicles impatience.
const MSEdge * getLastEdge() const
returns the destination edge
SUMOReal arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
Notification
Definition of a vehicle state.
static SUMOReal rand()
Returns a random real number in [0, 1)
std::string time2string(SUMOTime t)
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...
std::vector< const MSEdge * > ConstMSEdgeVector
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle's end speed shall be chosen.
int myArrivalLane
the position on the destination lane where the vehicle stops
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.
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.
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0)=0
Adds a stop.
std::string toTaz
The vehicle's destination zone (district)
std::vector< Stop > stops
List of the stops the vehicle will make.
void calculateArrivalParams()
(Re-)Calculates the arrival position and lane from the vehicle parameters
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
virtual void addPerson(MSTransportable *person)
Adds a person to this vehicle.
The edge is a district edge.
std::string routeid
The vehicle's route id.
virtual SUMOReal getAcceleration() const
Returns the vehicle's acceleration.
bool wasSet(int what) const
Returns whether the given parameter was set.
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.
ConstMSEdgeVector::const_iterator MSRouteIterator
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
SUMOTime depart
The vehicle's departure time.
const ConstMSEdgeVector & getEdges() const
std::string fromTaz
The vehicle's origin zone (district)
virtual const ConstMSEdgeVector getStopEdges() const =0
Returns the list of still pending stop edges.
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
bool replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false)
Replaces the current route by the given edges.
Abstract in-vehicle device.
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
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 replaceRoute(const MSRoute *route, bool onInit=false, int offset=0)=0
Replaces the current route by the given one.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
virtual bool hasArrived() const
Returns whether this vehicle has already arived (by default this is true if the vehicle has reached i...
virtual const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
The arrival lane is given.
const std::string & getID() const
Returns the name of the vehicle type.
static SUMOTime gTimeToGridlock
const SUMOVehicleParameter & getParameter() const
Returns the vehicle's parameter (including departure definition)
virtual SUMOTime getWaitingTime() const =0
unsigned size() const
Returns the number of edges to pass.
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.
void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)
Performs a rerouting using the given router.
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
virtual SUMOReal getSlope() const
Returns the slope of the road at vehicle's position.
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
std::vector< MSDevice * > myDevices
The devices this vehicle has.
virtual void addContainer(MSTransportable *container)
Adds a container to this vehicle.
static void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
SUMOTime myDeparture
The real departure time.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
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.