68 if (oc.
isSet(
"vehroute-output")) {
96 if (maxRoutes < std::numeric_limits<int>::max()) {
121 const auto& deviceEntry =
myDevices.find(vehicle);
123 deviceEntry->second->addRoute(info);
205 double priorEdgesLength = 0;
262 for (
int i = routesToSkip; i < index; i++) {
276 const double routeLength = route->getDistanceBetween(
myHolder.
getDepartPos(), route->getEdges().back()->getLength(),
277 route->begin(), route->end(), includeInternalLengths);
278 os.
writeAttr(
"routeLength", routeLength);
306 std::vector<std::string> exits;
310 assert(numWritten >= (
int)
myExits.size());
311 std::vector<std::string> missing(numWritten - (
int)
myExits.size(),
"-1");
312 exits.insert(exits.end(), missing.begin(), missing.end());
359 if (oc.
getBool(
"vehroute-output.speedfactor") ||
375 od.
writeAttr(
"routeLength", routeLength);
379 if (routeDist !=
nullptr) {
380 const std::vector<ConstMSRoutePtr>& routes = routeDist->
getVals();
382 while (index < routes.size() && routes[index] !=
myCurrentRoute) {
386 const std::vector<double>& probs = routeDist->
getProbs();
387 for (
int i = 0; i < (int)routes.size(); ++i) {
409 std::string dummyMsg;
469 if (!includeUnfinished) {
472 for (
const auto& rouXML : routeInfo.second) {
479 for (
const auto& routeInfo : personRouteInfos.
routeXML) {
480 for (
const auto& rouXML : routeInfo.second) {
481 (*personRouteInfos.
routeOut) << rouXML.second;
490 if (it.first->hasDeparted()) {
491 if (it.first->isStopped()) {
492 it.second->notifyStopEnded();
494 it.second->writeOutput(
false);
518 routeInfo->
routeXML[depart][id] = xmlOutput;
520 std::map<const SUMOTime, int>::iterator it = routeInfo->
departureCounts.begin();
522 for (
const auto& rouXML : routeInfo->
routeXML[it->first]) {
523 (*routeInfo->
routeOut) << rouXML.second;
525 routeInfo->
routeXML.erase(it->first);
535 std::vector<std::string> internals;
545 internals.push_back(replacedOnEdge);
572 for (
int i = 0; i < size; ++i) {
587 if (route !=
nullptr) {
std::shared_ptr< const MSRoute > ConstMSRoutePtr
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
const std::string DEFAULT_VTYPE_ID
const long long int VEHPARS_DEPARTPOSLAT_SET
const long long int VEHPARS_DEPARTSPEED_SET
const long long int VEHPARS_FORCE_REROUTE
@ GIVEN
The lane is given.
@ RANDOM
The lateral position is chosen randomly.
@ GIVEN
The position is given.
@ GIVEN_VEHROUTE
The position is set by the vehroute device.
@ GIVEN
The position is given.
@ GIVEN_VEHROUTE
The position is set by the vehroute device.
@ STOP
depart position is endPos of first stop
@ GIVEN
The speed is given.
@ GIVEN_VEHROUTE
The speed is set by the vehroute device.
@ LIMIT
The maximum lane speed is used (speedLimit)
const long long int VEHPARS_DEPARTLANE_SET
const long long int VEHPARS_DEPARTPOS_SET
const long long int VEHPARS_SPEEDFACTOR_SET
const int STOP_STARTED_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_REPLACED_AT_TIME
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_REPLACED_ON_INDEX
@ SUMO_ATTR_STATE
The state of a link.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
The base class for microscopic and mesoscopic vehicles.
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 writeSortedOutput(SortedRouteInfo *routeInfo, SUMOTime depart, const std::string &id, const std::string &xmlOutput)
static void init()
Static intialization.
std::vector< SUMOTime > myExits
The times at which the vehicle exits 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".
void addRoute(const std::string &info)
Called on route change.
int myLastRouteIndex
The route index of the last edge that the vehicle left.
static bool myIncludeIncomplete
A shortcut for the Option "vehroute-output.incomplete".
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.
ConstMSRoutePtr getRoute(int index) const
Called on route retrieval.
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.
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.
static void writePendingOutput(const bool includeUnfinished)
generate vehroute output for pending vehicles at sim end, either due to sorting or because they are s...
static bool myLastRouteOnly
A shortcut for the Option "vehroute-output.last-route".
ConstMSRoutePtr myCurrentRoute
The currently used route.
double myDepartSpeed
The speed on departure.
int myDepartLane
The lane the vehicle departed at.
static SortedRouteInfo myRouteInfos
Information needed to sort vehicles by departure time.
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 myWriteInternal
A shortcut for the Option "vehroute-output.internal".
static bool mySkipPTLines
A shortcut for the Option "vehroute-output.skip-ptlines".
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing vehroutes output.
void notifyStopEnded()
called to update state for stopped vehicles
static bool myDUAStyle
A shortcut for the Option "vehroute-output.dua".
static bool mySaveExits
A shortcut for the Option "vehroute-output.exit-times".
static void registerTransportableDepart(SUMOTime depart)
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_SEGMENT
The vehicle changes the segment (meso only)
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
@ NOTIFICATION_PARKING
The vehicle starts or ends parking.
The simulated network and simulation perfomer.
VehicleState
Definition of a 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
double getSavings() const
Returns the estimated savings due to using this route (compare to the route before rerouting)
static bool dictionary(const std::string &id, ConstMSRoutePtr route)
Adds a route to the dictionary.
static RandomDistributor< ConstMSRoutePtr > * distDictionary(const std::string &id)
Returns the named route distribution.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
double getDistanceBetween(double fromPos, double toPos, const MSLane *fromLane, const MSLane *toLane, int routePosition=0) const
Compute the distance between 2 given edges on this route, optionally including the length of internal...
double getCosts() const
Returns the costs of the route.
const MSDevice_Vehroutes::SortedRouteInfo & getRouteInfo()
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.
const MSLane * getLane() const
Returns the lane the vehicle is on.
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
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.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
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 & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
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.
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 precision or resets it to default.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
Represents a generic random distribution.
const std::vector< T > & getVals() const
Returns the members of the distribution.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
Representation of a vehicle, person, or container.
virtual NumericalID getNumericalID() const =0
return the numerical ID which is only for internal usage
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual double getChosenSpeedFactor() const =0
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual int getRoutePosition() const =0
return index of edge within route
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 std::list< MSStop > & getStops() const =0
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 double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
virtual ConstMSRoutePtr getRoutePtr() const =0
Returns the current route.
virtual bool hasValidRoute(std::string &msg, ConstMSRoutePtr route=0) const =0
Validates the current or given route.
virtual double getDepartPos() const =0
Returns this vehicle's real departure position.
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual const MSRoute & getRoute() const =0
Returns the current route.
Definition of vehicle stop (position and duration)
SUMOTime started
the time at which this stop was reached
int parametersSet
Information for the output which parameter were set.
void write(OutputDevice &dev, const bool close=true, const bool writeTagAndParents=true) const
Writes the stop as XML.
SUMOTime ended
the time at which this stop was ended
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
double speedFactor
individual speedFactor (overriding distribution from vType)
long long int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
bool wasSet(long long int what) const
Returns whether the given parameter was set.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
static long long int toLong(const std::string &sData)
converts a string into the long value described by it by calling the char-type converter,...
Information needed to sort vehicle / transportable output by departure time.
std::map< const SUMOTime, int > departureCounts
Map needed to sort vehicles by departure time.
std::map< const SUMOTime, std::map< const std::string, std::string > > routeXML
pregenerated route output sorted by time
OutputDevice * routeOut
route output device