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& parameters = 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& parameters = 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; \
75static int domainID() { return DOMAIN_ID; }
77#define LIBSUMO_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOM) \
78const int CLASS::DOMAIN_ID(libsumo::CMD_GET_##DOM##_VARIABLE); \
80CLASS::subscribe(const std::string& objectID, const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& parameters) { \
81 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, varIDs, begin, end, parameters); \
84CLASS::unsubscribe(const std::string& objectID) { \
85 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_VARIABLE, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults()); \
88CLASS::subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs, double begin, double end, const TraCIResults& parameters) { \
89 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_CONTEXT, objectID, varIDs, begin, end, parameters, domain, dist); \
92CLASS::unsubscribeContext(const std::string& objectID, int domain, double dist) { \
93 libsumo::Helper::subscribe(libsumo::CMD_SUBSCRIBE_##DOM##_CONTEXT, objectID, std::vector<int>(), libsumo::INVALID_DOUBLE_VALUE, libsumo::INVALID_DOUBLE_VALUE, libsumo::TraCIResults(), domain, dist); \
95const libsumo::SubscriptionResults \
96CLASS::getAllSubscriptionResults() { \
97 return mySubscriptionResults; \
99const libsumo::TraCIResults \
100CLASS::getSubscriptionResults(const std::string& objectID) { \
101 return mySubscriptionResults[objectID]; \
103const libsumo::ContextSubscriptionResults \
104CLASS::getAllContextSubscriptionResults() { \
105 return myContextSubscriptionResults; \
107const libsumo::SubscriptionResults \
108CLASS::getContextSubscriptionResults(const std::string& objectID) { \
109 return myContextSubscriptionResults[objectID]; \
112CLASS::subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime, double endTime) { \
113 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)}}); \
117#define LIBSUMO_ID_PARAMETER_API \
118static std::vector<std::string> getIDList(); \
119static int getIDCount(); \
120static std::string getParameter(const std::string& objectID, const std::string& key); \
121static const std::pair<std::string, std::string> getParameterWithKey(const std::string& objectID, const std::string& key); \
122static void setParameter(const std::string& objectID, const std::string& key, const std::string& value);
124#define LIBSUMO_GET_PARAMETER_WITH_KEY_IMPLEMENTATION(CLASS) \
125const std::pair<std::string, std::string> \
126CLASS::getParameterWithKey(const std::string& objectID, const std::string& key) { \
127 return std::make_pair(key, getParameter(objectID, key)); \
131#define SWIGJAVA_CAST(CLASS) \
132static std::shared_ptr<CLASS> cast(std::shared_ptr<TraCIResult> res) { \
133 return std::dynamic_pointer_cast<CLASS>(res); \
149 :
std::runtime_error(what) {}
160 :
std::runtime_error(what) {}
186 std::ostringstream os;
187 os <<
"TraCIPosition(" <<
x <<
"," <<
y;
209 std::ostringstream os;
231 std::ostringstream os;
232 os <<
"TraCIColor(" <<
r <<
"," <<
g <<
"," <<
b <<
"," <<
a <<
")";
247 std::ostringstream os;
250 os <<
"(" << v.x <<
"," << v.y <<
"," << v.z <<
")";
265 std::ostringstream os;
283 std::ostringstream os;
314 std::ostringstream os;
316 for (std::string v :
value) {
331 std::ostringstream os;
333 for (
double v :
value) {
348 std::ostringstream os;
350 for (
int v :
value) {
365 std::ostringstream os;
367 for (
const auto& v :
value) {
368 os <<
"(" << v.first <<
"," << v.second <<
"),";
373 std::vector<std::pair<std::string, double> >
value;
381typedef std::map<int, std::shared_ptr<libsumo::TraCIResult> >
TraCIResults;
391 const std::vector<int>& _next = std::vector<int>(),
392 const std::string& _name =
"",
393 const std::string& _earlyTarget =
"") :
407%
template(TraCIPhaseVector) std::vector<std::shared_ptr<libsumo::TraCIPhase> >;
414 TraCILogic(
const std::string& _programID,
const int _type,
const int _currentPhaseIndex,
415 const std::vector<std::shared_ptr<libsumo::TraCIPhase> >& _phases = std::vector<std::shared_ptr<libsumo::TraCIPhase> >())
416 : programID(_programID), type(_type), currentPhaseIndex(_currentPhaseIndex), phases(_phases) {}
419 std::ostringstream os;
420 os <<
"TraCILink(" << programID <<
"," << type <<
"," << currentPhaseIndex <<
")";
427 std::vector<std::shared_ptr<libsumo::TraCIPhase> >
phases;
434 std::ostringstream os;
435 os <<
"TraCILogicVectorWrapped[";
437 os << v.getString() <<
",";
449 TraCILink(
const std::string& _from,
const std::string& _via,
const std::string& _to)
450 : fromLane(_from), viaLane(_via), toLane(_to) {}
453 std::ostringstream os;
454 os <<
"TraCILink(" << fromLane <<
"," << viaLane <<
"," << toLane <<
")";
466 std::ostringstream os;
467 os <<
"TraCILinkVectorVectorWrapped[";
468 for (
const std::vector<TraCILink>& v : value) {
471 os << tl.getString() <<
",";
478 std::vector<std::vector<TraCILink> >
value;
484 TraCIConnection(
const std::string& _approachedLane,
const bool _hasPrio,
const bool _isOpen,
const bool _hasFoe,
485 const std::string _approachedInternal,
const std::string _state,
const std::string _direction,
const double _length)
486 : approachedLane(_approachedLane), hasPrio(_hasPrio), isOpen(_isOpen), hasFoe(_hasFoe),
487 approachedInternal(_approachedInternal), state(_state), direction(_direction), length(_length) {}
490 std::ostringstream os;
491 os <<
"TraCIConnection(" << approachedLane <<
"," << hasPrio <<
"," << isOpen
492 <<
"," << hasFoe <<
"," << approachedInternal <<
"," << state <<
"," << direction <<
"," << length <<
")";
509 std::ostringstream os;
510 os <<
"TraCIConnectionVectorWrapped[";
512 os << v.getString() <<
",";
525 std::ostringstream os;
526 os <<
"TraCIVehicleData(" <<
id <<
"," << length <<
"," << entryTime
527 <<
"," << leaveTime <<
"," << typeID <<
")";
546 std::ostringstream os;
547 os <<
"TraCIVehicleDataVectorWrapped[";
549 os << v.getString() <<
",";
555 std::vector<TraCIVehicleData>
value;
561 std::ostringstream os;
562 os <<
"TraCINextTLSData(" <<
id <<
"," << tlIndex <<
"," << dist
563 <<
"," << state <<
")";
580 std::ostringstream os;
581 os <<
"TraCINextTLSDataVectorWrapped[";
583 os << v.getString() <<
",";
589 std::vector<TraCINextTLSData>
value;
596 double startPos = INVALID_DOUBLE_VALUE,
597 double endPos = INVALID_DOUBLE_VALUE,
598 const std::string& stoppingPlaceID =
"",
600 double duration = INVALID_DOUBLE_VALUE,
601 double until = INVALID_DOUBLE_VALUE,
602 double intendedArrival = INVALID_DOUBLE_VALUE,
603 double arrival = INVALID_DOUBLE_VALUE,
604 double depart = INVALID_DOUBLE_VALUE,
605 const std::string&
split =
"",
606 const std::string& join =
"",
607 const std::string& actType =
"",
608 const std::string& tripId =
"",
609 const std::string& line =
"",
614 stoppingPlaceID(stoppingPlaceID),
615 stopFlags(stopFlags),
618 intendedArrival(intendedArrival),
630 std::ostringstream os;
631 os <<
"TraCINextStopData(" << lane <<
"," << endPos <<
"," << stoppingPlaceID
632 <<
"," << stopFlags <<
"," << duration <<
"," << until
633 <<
"," << arrival <<
")";
678 std::ostringstream os;
679 os <<
"TraCINextStopDataVectorWrapped[";
681 os << v.getString() <<
",";
687 std::vector<TraCINextStopData>
value;
693 std::ostringstream os;
694 os <<
"TraCIBestLanesData(" << laneID <<
"," << length <<
"," << occupation
695 <<
"," << bestLaneOffset <<
"," << allowsContinuation <<
",[";
696 for (
const std::string& s : continuationLanes) {
720 std::ostringstream os;
721 os <<
"TraCIBestLanesDataVectorWrapped[";
723 os << v.getString() <<
",";
729 std::vector<TraCIBestLanesData>
value;
735 TraCIStage(
int type = INVALID_INT_VALUE,
const std::string& vType =
"",
const std::string& line =
"",
const std::string& destStop =
"",
736 const std::vector<std::string>& edges = std::vector<std::string>(),
737 double travelTime = INVALID_DOUBLE_VALUE,
double cost = INVALID_DOUBLE_VALUE,
double length = INVALID_DOUBLE_VALUE,
738 const std::string& intended =
"",
double depart = INVALID_DOUBLE_VALUE,
double departPos = INVALID_DOUBLE_VALUE,
739 double arrivalPos = INVALID_DOUBLE_VALUE,
const std::string& description =
"") :
740 type(type), vType(vType), line(line), destStop(destStop), edges(edges), travelTime(travelTime), cost(cost),
741 length(length), intended(intended), depart(depart), departPos(departPos), arrivalPos(arrivalPos), description(description) {}
775 const std::vector<std::string>& persons,
776 const std::string& group,
777 const std::string& fromEdge,
778 const std::string& toEdge,
782 double reservationTime,
784 id(id), persons(persons), group(group), fromEdge(fromEdge), toEdge(toEdge), departPos(departPos), arrivalPos(arrivalPos),
785 depart(depart), reservationTime(reservationTime), state(state) {}
808 std::ostringstream os;
809 os <<
"TraCIReservation(id=" <<
id <<
")";
817 std::ostringstream os;
818 os <<
"TraCIReservationVectorWrapped[";
820 os << v.getString() <<
",";
826 std::vector<TraCIReservation>
value;
846 std::ostringstream os;
847 os <<
"TraCICollision(collider=" << collider <<
", victim=" << victim <<
")";
855 std::ostringstream os;
856 os <<
"TraCICollisionVectorWrapped[";
858 os << v.getString() <<
",";
886 std::map<std::string, std::string>
param;
889 std::ostringstream os;
890 os <<
"TraCISignalConstraint(signalId=" << signalId <<
", tripid=" << tripId <<
", foeSignal=" << foeSignal <<
", foeId=" << foeId <<
")";
898 std::ostringstream os;
899 os <<
"TraCISignalConstraintVectorWrapped[";
901 os << v.getString() <<
",";
907 std::vector<TraCISignalConstraint>
value;
924 std::ostringstream os;
925 os <<
"TraCIJunctionFoe(foeId=" << foeId <<
", egoDist=" << egoDist <<
", foeDist=" << foeDist <<
", foeDist=" << foeDist <<
")";
933 std::ostringstream os;
934 os <<
"TraCIJunctionFoeVectorWrapped[";
936 os << v.getString() <<
",";
942 std::vector<TraCIJunctionFoe>
value;
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)
An error which allows to continue.
TraCIException(std::string what)
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int POSITION_3D
TRACI_CONST int POSITION_ROADMAP
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int POSITION_2D
TRACI_CONST int TYPE_INTEGER
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.
std::string getString() const
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 getString() const override
std::vector< TraCIBestLanesData > value
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
std::vector< TraCICollision > value
std::string getString() const override
std::string getString() const override
TraCIColor(int r, int g, int b, int a=255)
std::string getString() const
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
std::string getString() const override
std::vector< TraCIConnection > value
std::string getString() const override
int getType() const override
std::vector< double > value
std::string getString() const override
int getType() const override
std::string getString() const override
TraCIInt(int v=0, int t=libsumo::TYPE_INTEGER)
std::string getString() const override
std::string getString() const
std::string foeId
the id of the vehicle with intersecting trajectory
std::vector< TraCIJunctionFoe > value
std::string getString() const override
std::string getString() const
TraCILink(const std::string &_from, const std::string &_via, const std::string &_to)
std::vector< std::vector< TraCILink > > value
std::string getString() const override
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 > >())
std::string getString() const
std::vector< TraCILogic > value
std::string getString() const override
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::vector< TraCINextStopData > value
std::string getString() const override
std::string getString() const
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 override
std::vector< TraCINextTLSData > value
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="", const std::string &_earlyTarget="")
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.
std::string getString() const override
int getType() const override
std::string getString() const override
std::vector< TraCIPosition > value
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 getString() const
std::vector< TraCIReservation > value
std::string getString() const override
TraCIResult & operator=(const TraCIResult &)=default
TraCIResult(const TraCIResult &)=default
virtual std::string getString() const
virtual int getType() const
An edgeId, position and laneIndex.
TraCIRoadPosition(const std::string e="", const double p=INVALID_DOUBLE_VALUE, const int li=INVALID_INT_VALUE)
std::string getString() const override
int getType() const override
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
std::vector< TraCISignalConstraint > value
std::string getString() const override
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.
std::string getString() const override
std::vector< std::pair< std::string, double > > value
TraCIString(std::string v="")
int getType() const override
std::string getString() const override
std::string getString() const override
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.
std::string getString() const
double leaveTime
Leave-time of the vehicle in [s].
std::string getString() const override
std::vector< TraCIVehicleData > value