67 if (oc.
isSet(
"vehroute-output")) {
93 if (maxRoutes < std::numeric_limits<int>::max()) {
118 const auto& deviceEntry =
myDevices.find(vehicle);
120 deviceEntry->second->addRoute(info);
145 rri.route->release();
231 const MSEdge* lastEdge =
nullptr;
232 for (; i < index; ++i) {
246 const MSEdge* lastEdge =
nullptr;
263 std::vector<std::string> exits;
267 assert(numWritten >= (
int)
myExits.size());
268 std::vector<std::string> missing(numWritten - (
int)
myExits.size(),
"-1");
269 exits.insert(exits.end(), missing.begin(), missing.end());
315 od.
writeAttr(
"routeLength", routeLength);
320 if (routeDist !=
nullptr) {
321 const std::vector<const MSRoute*>& routes = routeDist->
getVals();
323 while (index < routes.size() && routes[index] !=
myCurrentRoute) {
327 const std::vector<double>& probs = routeDist->
getProbs();
328 for (
int i = 0; i < (int)routes.size(); ++i) {
339 routes[i]->writeEdgeIDs(od, *routes[i]->begin());
340 (od <<
"\"").closeTag();
368 std::map<const std::string, std::string>& infos =
myRouteInfos[it->first];
369 for (std::map<const std::string, std::string>::const_iterator it2 = infos.begin(); it2 != infos.end(); ++it2) {
370 routeOut << it2->second;
415 if (it.first->hasDeparted()) {
416 it.second->writeOutput(
false);
434 std::vector<std::string> internals;
444 internals.push_back(replacedOnEdge);
465 for (
int i = 0; i < size; ++i) {
std::string time2string(SUMOTime t)
convert SUMOTime to string
const std::string DEFAULT_VTYPE_ID
@ GIVEN
The lane is given.
@ GIVEN
The position is given.
@ GIVEN
The position is given.
const int VEHPARS_DEPARTPOS_SET
@ GIVEN
The speed is given.
const int VEHPARS_DEPARTLANE_SET
const int VEHPARS_FORCE_REROUTE
const int VEHPARS_DEPARTSPEED_SET
const int VEHPARS_DEPARTPOSLAT_SET
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_ATTR_STATE
The state of a link.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Information about a replaced route.
A class that is notified about reroutings.
std::map< const SUMOVehicle *, MSDevice_Vehroutes *, ComparatorNumericalIdLess > myDevices
A map for internal notification.
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
A device which collects info on the vehicle trip (mainly on departure and arrival)
static bool myWriteCosts
A shortcut for the Option "vehroute-output.costs".
static void init()
Static intialization.
std::vector< SUMOTime > myExits
The times the vehicle exites an edge.
static bool mySorted
A shortcut for the Option "vehroute-output.sorted".
static bool myIntendedDepart
A shortcut for the Option "vehroute-output.intended-depart".
static std::map< const SUMOTime, std::map< const std::string, std::string > > myRouteInfos
void addRoute(const std::string &info)
Called on route change.
static bool myIncludeIncomplete
A shortcut for the Option "vehroute-output.incomplete".
void stopEnded(const SUMOVehicleParameter::Stop &stop)
MSDevice_Vehroutes(SUMOVehicle &holder, const std::string &id, int maxRoutes)
Constructor.
static bool myRouteLength
A shortcut for the Option "vehroute-output.route-length".
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_FCD-options.
void writeXMLRoute(OutputDevice &os, int index=-1) const
Called on route output.
static std::map< const SUMOTime, int > myDepartureCounts
Map needed to sort vehicles by departure time.
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, int maxRoutes=std::numeric_limits< int >::max())
Build devices for the given vehicle, if needed.
static void generateOutputForUnfinished()
generate vehroute output for vehicles which are still in the network
std::vector< RouteReplaceInfo > myReplacedRoutes
Prior routes.
std::vector< const MSEdge * > myPriorEdges
the edges that were passed before the current stop
const int myMaxRoutes
The maximum number of routes to report.
static bool myWriteStopPriorEdges
A shortcut for the Option "vehroute-output.stop-edges".
double myDepartPosLat
The lateral depart position.
const MSEdge * myLastSavedAt
The last edge the exit time was saved for.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
OutputDevice_String myStopOut
double myDepartPos
The lane the vehicle departed at.
const MSRoute * getRoute(int index) const
Called on route retrieval.
static bool myLastRouteOnly
A shortcut for the Option "vehroute-output.last-route".
double myDepartSpeed
The speed on departure.
int myDepartLane
The lane the vehicle departed at.
void writeOutput(const bool hasArrived) const
Called on writing vehroutes output.
~MSDevice_Vehroutes()
Destructor.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Saves exit times if needed.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Does nothing, returns true only if exit times should be collected.
static bool mySkipPTLines
A shortcut for the Option "vehroute-output.skip-ptlines".
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing vehroutes output.
const MSRoute * myCurrentRoute
The currently used route.
static bool myDUAStyle
A shortcut for the Option "vehroute-output.dua".
static bool mySaveExits
A shortcut for the Option "vehroute-output.exit-times".
void saveState(OutputDevice &out) const
Saves the state of the device.
static StateListener myStateListener
A class that is notified about reroutings.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
A road/street connecting two junctions.
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....
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Representation of a lane in the micro simulation.
int getIndex() const
Returns the lane's index.
MSEdge & getEdge() const
Returns the lane's edge.
Notification
Definition of a vehicle state.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
The simulated network and simulation perfomer.
VehicleState
Definition of a vehicle state.
@ VEHICLE_STATE_NEWROUTE
The vehicle got a new route.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
bool hasPersons() const
Returns whether persons are simulated.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
bool hasInternalLinks() const
return whether the network contains internal links
void addReference() const
increments the reference counter for the route
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
double getSavings() const
Returns the estimated savings due to using this route (compare to the route before rerouting)
void release() const
deletes the route if there are no further references to it
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of 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.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
double getCosts() const
Returns the costs of the route.
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
virtual void erase(MSTransportable *transportable)
removes a single transportable
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
Representation of a vehicle in the micro simulation.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
const MSLane * getLane() const
Returns the lane the vehicle is on.
const std::string & getID() const
Returns the name of the vehicle type.
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
An output device that encapsulates an ofstream.
std::string getString() const
Returns the current content as a string.
Static storage of an output device and its base (abstract) implementation.
void lf()
writes a line feed if applicable
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
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.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precison or resets it to default.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
const std::vector< T > & getVals() const
Returns the members of the distribution.
Encapsulated SAX-Attributes.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
Representation of a vehicle, person, or container.
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
virtual const MSRoute & getRoute() const =0
Returns the current route.
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
virtual double getDepartPos() const =0
Returns this vehicle's real departure position.
Definition of vehicle stop (position and duration)
void write(OutputDevice &dev, bool close=true) const
Writes the stop as XML.
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
double departSpeed
(optional) The initial speed of the vehicle
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag tag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
bool wasSet(int what) const
Returns whether the given parameter was set.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)