40 class VariableWrapper;
51 #define LIBSUMO_NAMESPACE libtraci
53 #define LIBSUMO_NAMESPACE libsumo
56 #define LIBSUMO_SUBSCRIPTION_API \
57 static void subscribe(const std::string& objectID, const std::vector<int>& varIDs = std::vector<int>({-1}), \
58 double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& params = libsumo::TraCIResults()); \
59 static void unsubscribe(const std::string& objectID); \
60 static void subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs = std::vector<int>({-1}), \
61 double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& params = libsumo::TraCIResults()); \
62 static void unsubscribeContext(const std::string& objectID, int domain, double dist); \
63 static const libsumo::SubscriptionResults getAllSubscriptionResults(); \
64 static const libsumo::TraCIResults getSubscriptionResults(const std::string& objectID); \
65 static const libsumo::ContextSubscriptionResults getAllContextSubscriptionResults(); \
66 static const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string& objectID); \
67 static void subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime = libsumo::INVALID_DOUBLE_VALUE, double endTime = libsumo::INVALID_DOUBLE_VALUE);
69 #define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN) \
71 CLASS::subscribe(const std::string& objectID, const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& params) { \
72 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOMAIN##_VARIABLE, objectID, varIDs, begin, end, params); \
75 CLASS::unsubscribe(const std::string& objectID) { \
76 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOMAIN##_VARIABLE, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults()); \
79 CLASS::subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs, double begin, double end, const TraCIResults& params) { \
80 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOMAIN##_CONTEXT, objectID, varIDs, begin, end, params, domain, dist); \
83 CLASS::unsubscribeContext(const std::string& objectID, int domain, double dist) { \
84 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOMAIN##_CONTEXT, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults(), domain, dist); \
86 const libsumo::SubscriptionResults \
87 CLASS::getAllSubscriptionResults() { \
88 return mySubscriptionResults; \
90 const libsumo::TraCIResults \
91 CLASS::getSubscriptionResults(const std::string& objectID) { \
92 return mySubscriptionResults[objectID]; \
94 const libsumo::ContextSubscriptionResults \
95 CLASS::getAllContextSubscriptionResults() { \
96 return myContextSubscriptionResults; \
98 const libsumo::SubscriptionResults \
99 CLASS::getContextSubscriptionResults(const std::string& objectID) { \
100 return myContextSubscriptionResults[objectID]; \
103 CLASS::subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime, double endTime) { \
104 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOMAIN##_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)}}); \
108 #define LIBSUMO_ID_PARAMETER_API \
109 static std::vector<std::string> getIDList(); \
110 static int getIDCount(); \
111 static std::string getParameter(const std::string& objectID, const std::string& param); \
112 static const std::pair<std::string, std::string> getParameterWithKey(const std::string& objectID, const std::string& key); \
113 static void setParameter(const std::string& objectID, const std::string& param, const std::string& value);
115 #define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS) \
116 const std::pair<std::string, std::string> \
117 CLASS::getParameterWithKey(const std::string& objectID, const std::string& key) { \
118 return std::make_pair(key, getParameter(objectID, key)); \
134 : std::runtime_error(what) {}
145 : std::runtime_error(what) {}
166 std::ostringstream os;
167 os <<
"TraCIPosition(" <<
x <<
"," <<
y <<
"," <<
z <<
")";
180 std::ostringstream os;
196 std::ostringstream os;
197 os <<
"TraCIColor(" <<
r <<
"," <<
g <<
"," <<
b <<
"," <<
a <<
")";
209 std::ostringstream os;
212 os <<
"(" << v.x <<
"," << v.y <<
"," << v.z <<
")";
225 std::ostringstream os;
237 std::ostringstream os;
263 std::ostringstream os;
265 for (std::string v :
value) {
276 typedef std::map<int, std::shared_ptr<libsumo::TraCIResult> >
TraCIResults;
287 const std::vector<int>& _next = std::vector<int>(),
288 const std::string& _name =
"") :
302 %
template(TraCIPhaseVector) std::vector<std::shared_ptr<libsumo::TraCIPhase> >;
310 TraCILogic(
const std::string& _programID,
const int _type,
const int _currentPhaseIndex,
311 const std::vector<std::shared_ptr<libsumo::TraCIPhase> >& _phases = std::vector<std::shared_ptr<libsumo::TraCIPhase> >())
312 : programID(_programID), type(_type), currentPhaseIndex(_currentPhaseIndex), phases(_phases) {}
318 std::vector<std::shared_ptr<libsumo::TraCIPhase> >
phases;
326 TraCILink(
const std::string& _from,
const std::string& _via,
const std::string& _to)
327 : fromLane(_from), viaLane(_via), toLane(_to) {}
339 TraCIConnection(
const std::string& _approachedLane,
const bool _hasPrio,
const bool _isOpen,
const bool _hasFoe,
340 const std::string _approachedInternal,
const std::string _state,
const std::string _direction,
const double _length)
341 : approachedLane(_approachedLane), hasPrio(_hasPrio), isOpen(_isOpen), hasFoe(_hasFoe),
342 approachedInternal(_approachedInternal), state(_state), direction(_direction), length(_length) {}
388 const std::string& stoppingPlaceID =
"",
395 const std::string&
split =
"",
396 const std::string& join =
"",
397 const std::string& actType =
"",
398 const std::string& tripId =
"",
399 const std::string& line =
"",
404 stoppingPlaceID(stoppingPlaceID),
405 stopFlags(stopFlags),
408 intendedArrival(intendedArrival),
420 std::ostringstream os;
421 os <<
"TraCINextStopData(" << lane <<
"," << endPos <<
"," << stoppingPlaceID
422 <<
"," << stopFlags <<
"," << duration <<
"," << until
423 <<
"," << arrival <<
")";
468 std::ostringstream os;
469 os <<
"TraCINextStopDataVector[";
471 os << v.getString() <<
",";
477 std::vector<TraCINextStopData>
value;
500 const std::vector<std::string>& edges = std::vector<std::string>(),
504 type(type), vType(vType), line(line), destStop(destStop), edges(edges), travelTime(travelTime), cost(cost),
505 length(length), intended(intended), depart(depart), departPos(departPos), arrivalPos(arrivalPos), description(description) {}
540 const std::vector<std::string>& persons,
541 const std::string& group,
542 const std::string& fromEdge,
543 const std::string& toEdge,
547 double reservationTime,
549 id(id), persons(persons), group(group), fromEdge(fromEdge), toEdge(toEdge), departPos(departPos), arrivalPos(arrivalPos),
550 depart(depart), reservationTime(reservationTime), state(state) {}
607 std::ostringstream os;
608 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)
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::string getString() const
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.
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::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].