28#pragma warning(disable: 4514 4820)
57#define LIBSUMO_NAMESPACE libtraci
59#define LIBSUMO_NAMESPACE libsumo
62#define LIBSUMO_SUBSCRIPTION_API \
63static void subscribe(const std::string& objectID, const std::vector<int>& varIDs = std::vector<int>({-1}), \
64 double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& params = libsumo::TraCIResults()); \
65static void unsubscribe(const std::string& objectID); \
66static void subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs = std::vector<int>({-1}), \
67 double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& params = libsumo::TraCIResults()); \
68static void unsubscribeContext(const std::string& objectID, int domain, double dist); \
69static const libsumo::SubscriptionResults getAllSubscriptionResults(); \
70static const libsumo::TraCIResults getSubscriptionResults(const std::string& objectID); \
71static const libsumo::ContextSubscriptionResults getAllContextSubscriptionResults(); \
72static const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string& objectID); \
73static void subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime = libsumo::INVALID_DOUBLE_VALUE, double endTime = libsumo::INVALID_DOUBLE_VALUE); \
74static const int DOMAIN_ID;
76#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM) \
77const int CLASS::DOMAIN_ID(libsumo::CMD_GET_##DOM##_VARIABLE); \
79CLASS::subscribe(const std::string& objectID, const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& params) { \
80 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, varIDs, begin, end, params); \
83CLASS::unsubscribe(const std::string& objectID) { \
84 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults()); \
87CLASS::subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs, double begin, double end, const TraCIResults& params) { \
88 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_CONTEXT, objectID, varIDs, begin, end, params, domain, dist); \
91CLASS::unsubscribeContext(const std::string& objectID, int domain, double dist) { \
92 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_CONTEXT, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults(), domain, dist); \
94const libsumo::SubscriptionResults \
95CLASS::getAllSubscriptionResults() { \
96 return mySubscriptionResults; \
98const libsumo::TraCIResults \
99CLASS::getSubscriptionResults(const std::string& objectID) { \
100 return mySubscriptionResults[objectID]; \
102const libsumo::ContextSubscriptionResults \
103CLASS::getAllContextSubscriptionResults() { \
104 return myContextSubscriptionResults; \
106const libsumo::SubscriptionResults \
107CLASS::getContextSubscriptionResults(const std::string& objectID) { \
108 return myContextSubscriptionResults[objectID]; \
111CLASS::subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime, double endTime) { \
112 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, std::vector<int>({libsumo::VAR_PARAMETER_WITH_KEY}), beginTime, endTime, libsumo::TraCIResults {{libsumo::VAR_PARAMETER_WITH_KEY, std::make_shared<libsumo::TraCIString>(key)}}); \
116#define LIBSUMO_ID_PARAMETER_API \
117static std::vector<std::string> getIDList(); \
118static int getIDCount(); \
119static std::string getParameter(const std::string& objectID, const std::string& key); \
120static const std::pair<std::string, std::string> getParameterWithKey(const std::string& objectID, const std::string& key); \
121static void setParameter(const std::string& objectID, const std::string& key, const std::string& value);
123#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS) \
124const std::pair<std::string, std::string> \
125CLASS::getParameterWithKey(const std::string& objectID, const std::string& key) { \
126 return std::make_pair(key, getParameter(objectID, key)); \
130#define SWIGJAVA_CAST(CLASS) \
131static std::shared_ptr<CLASS> cast(std::shared_ptr<TraCIResult> res) { \
132 return std::dynamic_pointer_cast<CLASS>(res); \
148 :
std::runtime_error(what) {}
159 :
std::runtime_error(what) {}
180 std::ostringstream os;
181 os <<
"TraCIPosition(" <<
x <<
"," <<
y;
201 std::ostringstream os;
220 std::ostringstream os;
221 os <<
"TraCIColor(" <<
r <<
"," <<
g <<
"," <<
b <<
"," <<
a <<
")";
236 std::ostringstream os;
239 os <<
"(" << v.x <<
"," << v.y <<
"," << v.z <<
")";
255 std::ostringstream os;
270 std::ostringstream os;
302 std::ostringstream os;
304 for (std::string v :
value) {
319 std::ostringstream os;
321 for (
double v :
value) {
335typedef std::map<int, std::shared_ptr<libsumo::TraCIResult> >
TraCIResults;
346 const std::vector<int>& _next = std::vector<int>(),
347 const std::string& _name =
"") :
361%
template(TraCIPhaseVector) std::vector<std::shared_ptr<libsumo::TraCIPhase> >;
369 TraCILogic(
const std::string& _programID,
const int _type,
const int _currentPhaseIndex,
370 const std::vector<std::shared_ptr<libsumo::TraCIPhase> >& _phases = std::vector<std::shared_ptr<libsumo::TraCIPhase> >())
371 : programID(_programID), type(_type), currentPhaseIndex(_currentPhaseIndex), phases(_phases) {}
377 std::vector<std::shared_ptr<libsumo::TraCIPhase> >
phases;
385 TraCILink(
const std::string& _from,
const std::string& _via,
const std::string& _to)
386 : fromLane(_from), viaLane(_via), toLane(_to) {}
398 TraCIConnection(
const std::string& _approachedLane,
const bool _hasPrio,
const bool _isOpen,
const bool _hasFoe,
399 const std::string _approachedInternal,
const std::string _state,
const std::string _direction,
const double _length)
400 : approachedLane(_approachedLane), hasPrio(_hasPrio), isOpen(_isOpen), hasFoe(_hasFoe),
401 approachedInternal(_approachedInternal), state(_state), direction(_direction), length(_length) {}
445 double startPos = INVALID_DOUBLE_VALUE,
446 double endPos = INVALID_DOUBLE_VALUE,
447 const std::string& stoppingPlaceID =
"",
449 double duration = INVALID_DOUBLE_VALUE,
450 double until = INVALID_DOUBLE_VALUE,
451 double intendedArrival = INVALID_DOUBLE_VALUE,
452 double arrival = INVALID_DOUBLE_VALUE,
453 double depart = INVALID_DOUBLE_VALUE,
454 const std::string&
split =
"",
455 const std::string& join =
"",
456 const std::string& actType =
"",
457 const std::string& tripId =
"",
458 const std::string& line =
"",
463 stoppingPlaceID(stoppingPlaceID),
464 stopFlags(stopFlags),
467 intendedArrival(intendedArrival),
479 std::ostringstream os;
480 os <<
"TraCINextStopData(" << lane <<
"," << endPos <<
"," << stoppingPlaceID
481 <<
"," << stopFlags <<
"," << duration <<
"," << until
482 <<
"," << arrival <<
")";
527 std::ostringstream os;
528 os <<
"TraCINextStopDataVector[";
530 os << v.getString() <<
",";
536 std::vector<TraCINextStopData>
value;
558 TraCIStage(
int type = INVALID_INT_VALUE,
const std::string& vType =
"",
const std::string& line =
"",
const std::string& destStop =
"",
559 const std::vector<std::string>& edges = std::vector<std::string>(),
560 double travelTime = INVALID_DOUBLE_VALUE,
double cost = INVALID_DOUBLE_VALUE,
double length = INVALID_DOUBLE_VALUE,
561 const std::string& intended =
"",
double depart = INVALID_DOUBLE_VALUE,
double departPos = INVALID_DOUBLE_VALUE,
562 double arrivalPos = INVALID_DOUBLE_VALUE,
const std::string& description =
"") :
563 type(type), vType(vType), line(line), destStop(destStop), edges(edges), travelTime(travelTime), cost(cost),
564 length(length), intended(intended), depart(depart), departPos(departPos), arrivalPos(arrivalPos), description(description) {}
599 const std::vector<std::string>& persons,
600 const std::string& group,
601 const std::string& fromEdge,
602 const std::string& toEdge,
606 double reservationTime,
608 id(id), persons(persons), group(group), fromEdge(fromEdge), toEdge(toEdge), departPos(departPos), arrivalPos(arrivalPos),
609 depart(depart), reservationTime(reservationTime), state(state) {}
667 std::map<std::string, std::string>
param;
670 std::ostringstream os;
671 os <<
"TraCISignalConstraint(signalId=" << signalId <<
", tripid=" << tripId <<
", foeSignal=" << foeSignal <<
", foeId=" << foeId <<
")";
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
#define SWIGJAVA_CAST(CLASS)
An error which is not recoverable.
FatalTraCIError(std::string what)
TraCIConnection(const std::string &_approachedLane, const bool _hasPrio, const bool _isOpen, const bool _hasFoe, const std::string _approachedInternal, const std::string _state, const std::string _direction, const double _length)
std::string approachedLane
std::string approachedInternal
An error which allows to continue.
TraCIException(std::string what)
TraCILink(const std::string &_from, const std::string &_via, const std::string &_to)
std::map< std::string, std::string > subParameter
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
TraCILogic(const std::string &_programID, const int _type, const int _currentPhaseIndex, const std::vector< std::shared_ptr< libsumo::TraCIPhase > > &_phases=std::vector< std::shared_ptr< libsumo::TraCIPhase > >())
TraCIPhase(const double _duration, const std::string &_state, const double _minDur=libsumo::INVALID_DOUBLE_VALUE, const double _maxDur=libsumo::INVALID_DOUBLE_VALUE, const std::vector< int > &_next=std::vector< int >(), const std::string &_name="")
double departPos
pickup position on the origin edge
double reservationTime
time when the reservation was made
double arrivalPos
drop-off position on the destination edge
std::vector< std::string > persons
The persons ids that are part of this reservation.
int state
the state of this reservation
std::string fromEdge
The origin edge id.
std::string group
The group id of this reservation.
std::string id
The id of the taxi reservation (usable for traci.vehicle.dispatchTaxi)
std::string toEdge
The destination edge id.
TraCIReservation(const std::string &id, const std::vector< std::string > &persons, const std::string &group, const std::string &fromEdge, const std::string &toEdge, double departPos, double arrivalPos, double depart, double reservationTime, int state)
std::string intended
id of the intended vehicle for public transport ride
int type
The type of stage (walking, driving, ...)
std::string destStop
The id of the destination stop.
double travelTime
duration of the stage in seconds
double departPos
position on the lane when starting the stage
std::string description
arbitrary description string
std::string line
The line or the id of the vehicle type.
TraCIStage(int type=INVALID_INT_VALUE, const std::string &vType="", const std::string &line="", const std::string &destStop="", const std::vector< std::string > &edges=std::vector< std::string >(), double travelTime=INVALID_DOUBLE_VALUE, double cost=INVALID_DOUBLE_VALUE, double length=INVALID_DOUBLE_VALUE, const std::string &intended="", double depart=INVALID_DOUBLE_VALUE, double departPos=INVALID_DOUBLE_VALUE, double arrivalPos=INVALID_DOUBLE_VALUE, const std::string &description="")
double depart
intended depart time for public transport ride or INVALID_DOUBLE_VALUE
std::vector< std::string > edges
The sequence of edges to travel.
double arrivalPos
position on the lane when ending the stage
std::string vType
The vehicle type when using a private car or bike.
TRACI_CONST double INVALID_DOUBLE_VALUE
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int INVALID_INT_VALUE
TRACI_CONST int TYPE_DOUBLE
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
TRACI_CONST int TYPE_STRING
double length
The length than can be driven from that lane without lane change.
double occupation
The traffic density along length.
bool allowsContinuation
Whether this lane allows continuing the route.
int bestLaneOffset
The offset of this lane from the best lane.
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
std::string laneID
The id of the lane.
std::string lane
The lane where the collision happended.
std::string type
The type of collision.
std::string collider
The ids of the participating vehicles and persons.
double pos
The position of the collision along the lane.
std::string getString() const
TraCIColor(int r, int g, int b, int a=255)
std::string getString() const
std::vector< double > value
std::string getString() const
std::string getString() const
std::string foeId
the id of the vehicle with intersecting trajectory
std::string stoppingPlaceID
Id assigned to the stop.
std::string lane
The lane to stop at.
std::string actType
additional information for this stop
std::string tripId
id of the trip within a cyclical public transport route
std::string getString() const
double startPos
The stopping position start.
double arrival
The actual arrival time (only for past stops)
TraCINextStopData(const std::string &lane="", double startPos=INVALID_DOUBLE_VALUE, double endPos=INVALID_DOUBLE_VALUE, const std::string &stoppingPlaceID="", int stopFlags=0, double duration=INVALID_DOUBLE_VALUE, double until=INVALID_DOUBLE_VALUE, double intendedArrival=INVALID_DOUBLE_VALUE, double arrival=INVALID_DOUBLE_VALUE, double depart=INVALID_DOUBLE_VALUE, const std::string &split="", const std::string &join="", const std::string &actType="", const std::string &tripId="", const std::string &line="", double speed=0)
double depart
The time at which this stop was ended.
std::string join
the id of the vehicle (train portion) to which this vehicle shall be joined
double speed
the speed at which this stop counts as reached (waypoint mode)
double intendedArrival
The intended arrival time.
double endPos
The stopping position end.
std::string split
the id of the vehicle (train portion) that splits of upon reaching this stop
std::string line
the new line id of the trip within a cyclical public transport route
double duration
The intended (minimum) stopping duration.
double until
The time at which the vehicle may continue its journey.
std::string getString() const
std::vector< TraCINextStopData > value
double dist
The distance to the tls.
int tlIndex
The tls index of the controlled link.
std::string id
The id of the next tls.
char state
The current state of the tls.
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.
std::string getString() const
std::string getString() const
std::vector< TraCIPosition > value
virtual std::string getString() const
virtual int getType() const
An edgeId, position and laneIndex.
std::string getString() const
TraCIRoadPosition(const std::string e, const double p)
std::string foeId
the tripId or vehicle id of the train that must pass first
std::string tripId
the tripId or vehicle id of the train that is constrained
std::string foeSignal
the tlsID of the rail signla that the foe must pass first
std::string signalId
the idea of the rail signal where this constraint is active
std::map< std::string, std::string > param
additional parameters
bool active
whether this constraint is active
std::string getString() const
int type
the type of constraint (predecessor:0, insertionPredecessor:1)
bool mustWait
whether tripId must still wait for foeId to pass foeSignal
int limit
the number of trains that must be recorded at the foeSignal
TraCIString(std::string v)
std::string getString() const
std::vector< std::string > value
std::string getString() const
mirrors MSInductLoop::VehicleData
std::string id
The id of the vehicle.
double entryTime
Entry-time of the vehicle in [s].
std::string typeID
Type of the vehicle in.
double length
Length of the vehicle.
double leaveTime
Leave-time of the vehicle in [s].