38#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN) \
39const int CLASS::DOMAIN_ID(libsumo::CMD_GET_##DOMAIN##_VARIABLE); \
40void CLASS::subscribe(const std::string& objectID, const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& params) { \
41 libtraci::Connection::getActive().subscribe(libsumo::CMD_SUBSCRIBE_##DOMAIN##_VARIABLE, objectID, begin, end, -1, -1, varIDs, params); \
44void CLASS::unsubscribe(const std::string& objectID) { \
45 subscribe(objectID, std::vector<int>()); \
48void CLASS::subscribeContext(const std::string& objectID, int domain, double dist, const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& params) { \
49 libtraci::Connection::getActive().subscribe(libsumo::CMD_SUBSCRIBE_##DOMAIN##_CONTEXT, objectID, begin, end, domain, dist, varIDs, params); \
52void CLASS::unsubscribeContext(const std::string& objectID, int domain, double dist) { \
53 subscribeContext(objectID, domain, dist, std::vector<int>()); \
56const libsumo::SubscriptionResults CLASS::getAllSubscriptionResults() { \
57 return libtraci::Connection::getActive().getAllSubscriptionResults(libsumo::RESPONSE_SUBSCRIBE_##DOMAIN##_VARIABLE); \
60const libsumo::TraCIResults CLASS::getSubscriptionResults(const std::string& objectID) { \
61 return libtraci::Connection::getActive().getAllSubscriptionResults(libsumo::RESPONSE_SUBSCRIBE_##DOMAIN##_VARIABLE)[objectID]; \
64const libsumo::ContextSubscriptionResults CLASS::getAllContextSubscriptionResults() { \
65 return libtraci::Connection::getActive().getAllContextSubscriptionResults(libsumo::RESPONSE_SUBSCRIBE_##DOMAIN##_CONTEXT); \
68const libsumo::SubscriptionResults CLASS::getContextSubscriptionResults(const std::string& objectID) { \
69 return libtraci::Connection::getActive().getAllContextSubscriptionResults(libsumo::RESPONSE_SUBSCRIBE_##DOMAIN##_CONTEXT)[objectID]; \
72void CLASS::subscribeParameterWithKey(const std::string& objectID, const std::string& key, double beginTime, double endTime) { \
73 subscribe(objectID, std::vector<int>({libsumo::VAR_PARAMETER_WITH_KEY}), beginTime, endTime, libsumo::TraCIResults {{libsumo::VAR_PARAMETER_WITH_KEY, std::make_shared<libsumo::TraCIString>(key)}}); \
77#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN) \
79CLASS::getParameter(const std::string& objectID, const std::string& param) { \
80 tcpip::Storage content; \
81 content.writeByte(libsumo::TYPE_STRING); \
82 content.writeString(param); \
83 return Dom::getString(libsumo::VAR_PARAMETER, objectID, &content); \
87CLASS::setParameter(const std::string& objectID, const std::string& key, const std::string& value) { \
88 tcpip::Storage content; \
89 content.writeUnsignedByte(libsumo::TYPE_COMPOUND); \
90 content.writeInt(2); \
91 content.writeUnsignedByte(libsumo::TYPE_STRING); \
92 content.writeString(key); \
93 content.writeUnsignedByte(libsumo::TYPE_STRING); \
94 content.writeString(value); \
95 Connection::getActive().doCommand(libsumo::CMD_SET_##DOMAIN##_VARIABLE, libsumo::VAR_PARAMETER, objectID, &content); \
98const std::pair<std::string, std::string> \
99CLASS::getParameterWithKey(const std::string& objectID, const std::string& key) { \
100 return std::make_pair(key, getParameter(objectID, key)); \
108template<
int GET,
int SET>
143 for (
int i = 0; i < size; ++i) {
148 ret.
value.push_back(p);
224 static void setInt(
int var,
const std::string&
id,
int value) {
228 set(var,
id, &content);
231 static void setDouble(
int var,
const std::string&
id,
double value) {
235 set(var,
id, &content);
238 static void setString(
int var,
const std::string&
id,
const std::string& value) {
242 set(var,
id, &content);
245 static void setStringVector(
int var,
const std::string&
id,
const std::vector<std::string>& value) {
249 set(var,
id, &content);
259 set(var,
id, &content);
static std::vector< std::string > readTypedStringList(tcpip::Storage &ret, const std::string &error="")
static int readTypedInt(tcpip::Storage &ret, const std::string &error="")
static std::string readTypedString(tcpip::Storage &ret, const std::string &error="")
static double readTypedDouble(tcpip::Storage &ret, const std::string &error="")
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.
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.
static Connection & getActive()
std::mutex & getMutex() const
tcpip::Storage & doCommand(int command, int var=-1, const std::string &id="", tcpip::Storage *add=nullptr, int expectedType=-1)
static void setDouble(int var, const std::string &id, double value)
static libsumo::TraCIPosition getPos(int var, const std::string &id, tcpip::Storage *add=nullptr, const bool isGeo=false)
static void setCol(int var, const std::string &id, const libsumo::TraCIColor value)
static std::vector< double > getDoubleVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
static int getUnsignedByte(int var, const std::string &id, tcpip::Storage *add=nullptr)
static void setStringVector(int var, const std::string &id, const std::vector< std::string > &value)
static libsumo::TraCIColor getCol(int var, const std::string &id, tcpip::Storage *add=nullptr)
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
static libsumo::TraCIStage getTraCIStage(int var, const std::string &id, tcpip::Storage *add=nullptr)
static libsumo::TraCIPositionVector getPolygon(int var, const std::string &id, tcpip::Storage *add=nullptr)
static void set(int var, const std::string &id, tcpip::Storage *add)
static libsumo::TraCIPosition getPos3D(int var, const std::string &id, tcpip::Storage *add=nullptr, const bool isGeo=false)
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
static void setInt(int var, const std::string &id, int value)
static void setString(int var, const std::string &id, const std::string &value)
static tcpip::Storage & get(int var, const std::string &id, tcpip::Storage *add=nullptr, int expectedType=libsumo::TYPE_COMPOUND)
static int getByte(int var, const std::string &id, tcpip::Storage *add=nullptr)
virtual std::string readString()
virtual void writeString(const std::string &s)
virtual void writeInt(int)
virtual void writeDouble(double)
virtual int readUnsignedByte()
virtual void writeStringList(const std::vector< std::string > &s)
virtual void writeUnsignedByte(int)
virtual std::vector< std::string > readStringList()
virtual double readDouble()
virtual std::vector< double > readDoubleList()
TRACI_CONST int TYPE_COLOR
TRACI_CONST int POSITION_3D
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int POSITION_2D
TRACI_CONST int TYPE_POLYGON
TRACI_CONST int TYPE_STRINGLIST
TRACI_CONST int TYPE_INTEGER
TRACI_CONST int POSITION_LON_LAT
TRACI_CONST int TYPE_DOUBLELIST
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int TYPE_BYTE
TRACI_CONST int POSITION_LON_LAT_ALT
TRACI_CONST int TYPE_STRING
A 2D or 3D-position, for 2D positions z == INVALID_DOUBLE_VALUE.
std::vector< TraCIPosition > value