39 #define LIBSUMO_NAMESPACE libtraci
41 #define LIBSUMO_NAMESPACE libsumo
44 #define LIBSUMO_SUBSCRIPTION_API \
45 static void subscribe(const std::string& objectID, const std::vector<int>& varIDs = std::vector<int>({-1}), \
46 double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& params = libsumo::TraCIResults()); \
47 static void unsubscribe(const std::string& objectID); \
48 static void subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs = std::vector<int>({-1}), \
49 double begin = libsumo::INVALID_DOUBLE_VALUE, double end = libsumo::INVALID_DOUBLE_VALUE, const libsumo::TraCIResults& params = libsumo::TraCIResults()); \
50 static void unsubscribeContext(const std::string& objectID, int domain, double dist); \
51 static const libsumo::SubscriptionResults getAllSubscriptionResults(); \
52 static const libsumo::TraCIResults getSubscriptionResults(const std::string& objectID); \
53 static const libsumo::ContextSubscriptionResults getAllContextSubscriptionResults(); \
54 static const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string& objectID); \
55 static void subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime = libsumo::INVALID_DOUBLE_VALUE, double endTime = libsumo::INVALID_DOUBLE_VALUE);
57 #define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN) \
59 CLASS::subscribe(const std::string& objectID, const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& params) { \
60 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOMAIN##_VARIABLE, objectID, varIDs, begin, end, params); \
63 CLASS::unsubscribe(const std::string& objectID) { \
64 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOMAIN##_VARIABLE, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults()); \
67 CLASS::subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs, double begin, double end, const TraCIResults& params) { \
68 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOMAIN##_CONTEXT, objectID, varIDs, begin, end, params, domain, dist); \
71 CLASS::unsubscribeContext(const std::string& objectID, int domain, double dist) { \
72 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOMAIN##_CONTEXT, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults(), domain, dist); \
74 const libsumo::SubscriptionResults \
75 CLASS::getAllSubscriptionResults() { \
76 return mySubscriptionResults; \
78 const libsumo::TraCIResults \
79 CLASS::getSubscriptionResults(const std::string& objectID) { \
80 return mySubscriptionResults[objectID]; \
82 const libsumo::ContextSubscriptionResults \
83 CLASS::getAllContextSubscriptionResults() { \
84 return myContextSubscriptionResults; \
86 const libsumo::SubscriptionResults \
87 CLASS::getContextSubscriptionResults(const std::string& objectID) { \
88 return myContextSubscriptionResults[objectID]; \
91 CLASS::subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime, double endTime) { \
92 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)}}); \
93 libsumo::Helper::addSubscriptionParam(key); \
97 #define LIBSUMO_ID_PARAMETER_API \
98 static std::vector<std::string> getIDList(); \
99 static int getIDCount(); \
100 static std::string getParameter(const std::string& objectID, const std::string& param); \
101 static const std::pair<std::string, std::string> getParameterWithKey(const std::string& objectID, const std::string& key); \
102 static void setParameter(const std::string& objectID, const std::string& param, const std::string& value);
104 #define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS) \
105 const std::pair<std::string, std::string> \
106 CLASS::getParameterWithKey(const std::string& objectID, const std::string& key) { \
107 return std::make_pair(key, getParameter(objectID, key)); \
122 : std::runtime_error(what) {}
133 virtual const std::vector<unsigned char>
toPacket()
const {
134 return std::vector<unsigned char>();
143 std::ostringstream os;
144 os <<
"TraCIPosition(" <<
x <<
"," <<
y <<
"," <<
z <<
")";
155 std::ostringstream os;
171 std::ostringstream os;
172 os <<
"TraCIColor(" <<
r <<
"," <<
g <<
"," <<
b <<
"," <<
a <<
")";
184 std::ostringstream os;
185 os <<
"TraCILeaderDistance(" <<
leaderID <<
"," <<
dist <<
")";
203 std::ostringstream os;
215 std::ostringstream os;
235 std::ostringstream os;
237 for (std::string v :
value) {
259 const std::vector<int>& _next = std::vector<int>(),
260 const std::string& _name =
"") :
274 %
template(TraCIPhaseVector) std::vector<libsumo::TraCIPhase*>;
282 TraCILogic(
const std::string& _programID,
const int _type,
const int _currentPhaseIndex,
283 const std::vector<libsumo::TraCIPhase*>& _phases = std::vector<libsumo::TraCIPhase*>())
284 : programID(_programID), type(_type), currentPhaseIndex(_currentPhaseIndex), phases(_phases) {}
297 TraCILink(
const std::string& _from,
const std::string& _via,
const std::string& _to)
298 : fromLane(_from), viaLane(_via), toLane(_to) {}
310 TraCIConnection(
const std::string& _approachedLane,
const bool _hasPrio,
const bool _isOpen,
const bool _hasFoe,
311 const std::string _approachedInternal,
const std::string _state,
const std::string _direction,
const double _length)
312 : approachedLane(_approachedLane), hasPrio(_hasPrio), isOpen(_isOpen), hasFoe(_hasFoe),
313 approachedInternal(_approachedInternal), state(_state), direction(_direction), length(_length) {}
359 const std::string& stoppingPlaceID =
"",
366 const std::string&
split =
"",
367 const std::string& join =
"",
368 const std::string& actType =
"",
369 const std::string& tripId =
"",
370 const std::string& line =
"",
375 stoppingPlaceID(stoppingPlaceID),
376 stopFlags(stopFlags),
379 intendedArrival(intendedArrival),
391 std::ostringstream os;
392 os <<
"TraCINextStopData(" << lane <<
"," << endPos <<
"," << stoppingPlaceID
393 <<
"," << stopFlags <<
"," << duration <<
"," << until
394 <<
"," << arrival <<
")";
439 std::ostringstream os;
440 os <<
"TraCINextStopDataVector[";
442 os << v.getString() <<
",";
448 std::vector<TraCINextStopData>
value;
471 const std::vector<std::string>& edges = std::vector<std::string>(),
475 type(type), vType(vType), line(line), destStop(destStop), edges(edges), travelTime(travelTime), cost(cost),
476 length(length), intended(intended), depart(depart), departPos(departPos), arrivalPos(arrivalPos), description(description) {}
511 const std::vector<std::string>& persons,
512 const std::string& group,
513 const std::string& fromEdge,
514 const std::string& toEdge,
518 double reservationTime) :
519 id(id), persons(persons), group(group), fromEdge(fromEdge), toEdge(toEdge), departPos(departPos), arrivalPos(arrivalPos),
520 depart(depart), reservationTime(reservationTime) {}
std::vector< std::string > & split(const std::string &s, char delim, std::vector< std::string > &elems)
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
TraCIException(std::string what)
TraCILink(const std::string &_from, const std::string &_via, const std::string &_to)
std::map< std::string, std::string > subParameter
TraCILogic(const std::string &_programID, const int _type, const int _currentPhaseIndex, const std::vector< libsumo::TraCIPhase * > &_phases=std::vector< libsumo::TraCIPhase * >())
std::vector< TraCIPhase * > phases
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
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)
std::vector< std::string > persons
The persons ids that are part 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.
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< int, std::shared_ptr< TraCIResult > > TraCIResults
{variable->value}
std::vector< TraCIPosition > TraCIPositionVector
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int INVALID_INT_VALUE
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
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.
TraCIColor(int r, int g, int b, int a=255)
A leaderId and distance to leader.
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
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::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.
virtual std::string getString()
virtual const std::vector< unsigned char > toPacket() const
An edgeId, position and laneIndex.
TraCIString(std::string v)
std::vector< std::string > value
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].