53 static void connect(
const std::string& host,
int port,
int numRetries,
const std::string& label, FILE*
const pipe) {
123 void subscribe(
int domID,
const std::string& objID,
double beginTime,
double endTime,
151 std::ostringstream oss;
152 oss.setf(std::ios::fixed, std::ios::floatfield);
153 oss << std::setprecision(accuracy);
159 inline std::string
toHex(
const T i, std::streamsize numDigits = 2) {
161 std::stringstream stream;
162 stream <<
"0x" << std::setfill(
'0') << std::setw(numDigits == 0 ?
sizeof(T) * 2 : numDigits) << std::hex << i;
173 Connection(
const std::string& host,
int port,
int numRetries,
const std::string& label, FILE*
const pipe);
An error which is not recoverable.
C++ TraCI client API implementation.
void simulationStep(double time)
Sends a SimulationStep command.
static void connect(const std::string &host, int port, int numRetries, const std::string &label, FILE *const pipe)
void close()
ends the simulation and closes the connection
void createCommand(int cmdID, int varID, const std::string *const objID, tcpip::Storage *add=nullptr) const
Sends a GetVariable / SetVariable request if mySocket is connected. Otherwise writes to myOutput only...
int check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Validates the result state of a command.
static Connection & getActive()
void addFilter(int var, tcpip::Storage *add=nullptr)
void readVariableSubscription(int responseID, tcpip::Storage &inMsg)
libsumo::ContextSubscriptionResults & getAllContextSubscriptionResults(const int domain)
tcpip::Socket mySocket
The socket.
std::map< int, libsumo::SubscriptionResults > mySubscriptionResults
void check_resultState(tcpip::Storage &inMsg, int command, bool ignoreCommandId=false, std::string *acknowledgement=0)
Validates the result state of a command.
std::mutex & getMutex() const
tcpip::Storage myInput
The reusable input storage.
FILE *const myProcessPipe
void readVariables(tcpip::Storage &inMsg, const std::string &objectID, int variableCount, libsumo::SubscriptionResults &into)
std::map< int, libsumo::ContextSubscriptionResults > myContextSubscriptionResults
tcpip::Storage myOutput
The reusable output storage.
Connection & operator=(const Connection &)
Invalidated assignment operator.
void setOrder(int order)
Sends a SetOrder command.
void subscribe(int domID, const std::string &objID, double beginTime, double endTime, int domain, double range, const std::vector< int > &vars, const libsumo::TraCIResults ¶ms)
Sends a SubscribeContext or a SubscribeVariable request.
libsumo::SubscriptionResults & getAllSubscriptionResults(const int domain)
static std::map< const std::string, Connection * > myConnections
const std::string myLabel
void readContextSubscription(int responseID, tcpip::Storage &inMsg)
tcpip::Storage & doCommand(int command, int var=-1, const std::string &id="", tcpip::Storage *add=nullptr, int expectedType=-1)
static Connection * myActive
static std::string toString(const T &t, std::streamsize accuracy=PRECISION)
std::thread * myProcessReader
static void switchCon(const std::string &label)
const std::string & getLabel() const
std::string toHex(const T i, std::streamsize numDigits=2)
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}