85 if (maxRoutes < std::numeric_limits<int>::max()) {
106 myDevices[vehicle]->addRoute();
130 (*i).route->release();
187 os <<
" replacedOnEdge=\"";
198 const MSEdge* lastEdge = 0;
199 for (; i < index; ++i) {
206 const MSEdge* lastEdge = 0;
221 int remainingWithExitTime = (int)
myExits.size() - numWritten;
222 assert(remainingWithExitTime >= 0);
230 os <<
"\" exitTimes=\"";
231 for (std::vector<SUMOTime>::const_iterator it =
myExits.begin(); it !=
myExits.end(); ++it) {
239 (os <<
"\"").closeTag();
284 od.writeAttr(
"routeLength", routeLength);
289 if (routeDist != 0) {
290 const std::vector<const MSRoute*>& routes = routeDist->
getVals();
292 while (index < routes.size() && routes[index] !=
myCurrentRoute) {
296 const std::vector<double>& probs = routeDist->
getProbs();
297 for (
int i = 0; i < (int)routes.size(); ++i) {
304 routes[i]->writeEdgeIDs(od, *routes[i]->begin());
305 (od <<
"\"").closeTag();
341 std::map<const std::string, std::string>& infos =
myRouteInfos[it->first];
342 for (std::map<const std::string, std::string>::const_iterator it2 = infos.begin(); it2 != infos.end(); ++it2) {
343 routeOut << it2->second;
350 routeOut << od.getString();
389 if (it->first->hasDeparted()) {
390 it->second->writeOutput(
false);
400 std::vector<std::string> internals;
410 internals.push_back(replacedOnEdge);
430 for (
int i = 0; i < size; ++i) {
static std::map< const SUMOTime, int > myDepartureCounts
Map needed to sort vehicles by departure time.
const MSLane * getLane() const
Returns the lane the reminder works on.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
const int myMaxRoutes
The maximum number of routes to report.
Representation of a vehicle in the micro simulation.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute) ...
const MSRoute * myCurrentRoute
The currently used route.
static StateListener myStateListener
A class that is notified about reroutings.
void release() const
deletes the route if there are no further references to it
Function-object for stable sorting of objects acting like Named without being derived (SUMOVehicle) ...
virtual const MSRoute & getRoute() const =0
Returns the current route.
Represents a generic random distribution.
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to)
Called if a vehicle changes its state.
SUMOVehicle & myHolder
The vehicle that stores the device.
static bool myDUAStyle
A shortcut for the Option "vehroute-output.dua".
const SUMOVehicleParameter::Stop pars
The stop parameter.
std::string getString() const
Returns the current content as a string.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
Notification
Definition of a vehicle state.
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true) const
Compute the distance between 2 given edges on this route, including the length of internal lanes...
std::string time2string(SUMOTime t)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
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 std::vector< T > & getVals() const
Returns the members of the distribution.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Does nothing, returns true only if exit times should be collected.
std::vector< SUMOTime > myExits
The times the vehicle exites an edge.
static bool mySorted
A shortcut for the Option "vehroute-output.sorted".
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
const std::string & getID() const
Returns the id.
int size() const
Returns the number of edges to pass.
const std::string DEFAULT_VTYPE_ID
static bool mySaveExits
A shortcut for the Option "vehroute-output.exit-times".
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
void writeXMLRoute(OutputDevice &os, int index=-1) const
Called on route output.
begin/end of the description of a route
static bool myIntendedDepart
A shortcut for the Option "vehroute-output.intended-depart".
static OptionsCont & getOptions()
Retrieves the options.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
std::map< const SUMOVehicle *, MSDevice_Vehroutes *, SUMOVehicle::ComparatorIdLess > myDevices
A map for internal notification.
void writeParams(OutputDevice &out) const
void generateOutput() const
Called on writing vehroutes output.
static void init()
Static intialization.
A road/street connecting two junctions.
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
The vehicle changes lanes (micro only)
int myDepartLane
The lane the vehicle departed at.
static bool myLastRouteOnly
A shortcut for the Option "vehroute-output.last-route".
int getIndex() const
Returns the lane's index.
The vehicle got a new route.
void addRoute()
Called on route change.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
Representation of a vehicle.
Encapsulated SAX-Attributes.
const int VEHPARS_DEPARTSPEED_SET
virtual int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
double myDepartPosLat
The lateral depart position.
std::vector< RouteReplaceInfo > myReplacedRoutes
Prior routes.
const int VEHPARS_DEPARTPOSLAT_SET
SUMOTime depart
The vehicle's departure time.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
bool hasInternalLinks() const
return whether the network contains internal links
A class that is notified about reroutings.
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
int writeEdgeIDs(OutputDevice &os, const MSEdge *const from, const MSEdge *const upTo=0) const
Output the edge ids up to but not including the id of the given edge.
static void generateOutputForUnfinished()
generate vehroute output for vehicles which are still in the network
static bool mySkipPTLines
A shortcut for the Option "vehroute-output.skip-ptlines".
void writeOutput(const bool hasArrived) const
Called on writing vehroutes output.
std::string line
The vehicle's line (mainly for public transport)
static bool myRouteLength
A shortcut for the Option "vehroute-output.route-length".
VehicleState
Definition of a vehicle state.
void saveState(OutputDevice &out) const
Saves the state of the device.
bool notifyLeave(SUMOVehicle &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Saves exit times if needed.
Abstract in-vehicle device.
void write(OutputDevice &dev) const
Writes the stop as XML.
virtual double getDepartPos() const =0
Returns this vehicle's real departure position.
The vehicle has departed (was inserted into the network)
Structure representing possible vehicle parameter.
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
double myDepartSpeed
The speed on departure.
virtual double getPositionOnLane() const =0
Get the vehicle's position along the lane.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
MSDevice_Vehroutes(SUMOVehicle &holder, const std::string &id, int maxRoutes)
Constructor.
const std::string & getID() const
Returns the name of the vehicle type.
const int VEHPARS_DEPARTLANE_SET
OutputDevice_String myStopOut
void addReference() const
increments the reference counter for the route
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into, int maxRoutes=std::numeric_limits< int >::max())
Build devices for the given vehicle, if needed.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
const MSRoute * getRoute(int index) const
Called on route retrieval.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
static std::map< const SUMOTime, std::map< const std::string, std::string > > myRouteInfos
const int VEHPARS_DEPARTPOS_SET
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual double getSpeed() const =0
Returns the vehicle's current speed.
bool isBinary() const
Returns whether we have a binary output.
double myDepartPos
The lane the vehicle departed at.
Representation of a lane in the micro simulation.
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
virtual const std::string & getID() const =0
Get the vehicle's ID.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
An output device that encapsulates an ofstream.
The vehicle is being teleported.
void stopEnded(const MSVehicle::Stop &stop)
Definition of vehicle stop (position and duration)
const MSEdge * myLastSavedAt
The last edge the exit time was saved for.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
~MSDevice_Vehroutes()
Destructor.
Information about a replaced route.