49 static void connect(
const std::string& host,
int port,
int numRetries,
const std::string& label, FILE*
const pipe) {
143 bool processGet(
int command,
int expectedType,
bool ignoreCommandId =
false);
182 for (
int i = 0; i < size; ++i) {
220 std::vector<std::string> r;
224 for (
int i = 0; i < size; ++i) {
292 void setInt(
int command,
int var,
const std::string&
id,
int value) {
298 void setDouble(
int command,
int var,
const std::string&
id,
double value) {
305 void setString(
int command,
int var,
const std::string&
id,
const std::string& value) {
312 void setStringVector(
int command,
int var,
const std::string&
id,
const std::vector<std::string>& value) {
336 std::ostringstream oss;
337 oss.setf(std::ios::fixed, std::ios::floatfield);
338 oss << std::setprecision(accuracy);
348 Connection(
const std::string& host,
int port,
int numRetries,
const std::string& label, FILE*
const pipe);
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.
C++ TraCI client API implementation.
std::vector< std::string > getStringVector(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
void simulationStep(double time)
Sends a SimulationStep command.
void setCol(int command, int var, const std::string &id, const libsumo::TraCIColor c)
int getByte(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
static void connect(const std::string &host, int port, int numRetries, const std::string &label, FILE *const pipe)
void subscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, const std::vector< int > &vars, const libsumo::TraCIResults ¶ms)
Sends a SubscribeVariable request.
Connection(const std::string &host, int port, int numRetries, const std::string &label, FILE *const pipe)
Constructor, connects to the specified SUMO server.
void close()
ends the simulation and closes the connection
void setInt(int command, int var, const std::string &id, int value)
int check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Validates the result state of a command.
libsumo::TraCIColor getCol(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
void setStringVector(int command, int var, const std::string &id, const std::vector< std::string > &value)
bool processGet(int command, int expectedType, bool ignoreCommandId=false)
void readVariableSubscription(int responseID, tcpip::Storage &inMsg)
libsumo::TraCIStage getTraCIStage(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
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.
tcpip::Storage myInput
The reusable input storage.
FILE *const myProcessPipe
libsumo::TraCIPosition getPos(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
const std::string & getLabel()
void createFilterCommand(int cmdID, int varID, tcpip::Storage *add=nullptr) const
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.
static Connection & getActive()
std::string getString(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
Connection & operator=(const Connection &)
Invalidated assignment operator.
libsumo::TraCIPosition getPos3D(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
libsumo::SubscriptionResults getAllSubscriptionResults(const int domain)
void setString(int command, int var, const std::string &id, const std::string &value)
void send_commandSetOrder(int order)
Sends a SetOrder command.
tcpip::Storage & doCommand(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
static std::map< const std::string, Connection * > myConnections
void setDouble(int command, int var, const std::string &id, double value)
const std::string myLabel
void createCommand(int cmdID, int varID, const std::string &objID, tcpip::Storage *add=nullptr) const
Sends a GetVariable / SetVariable request if mySocket is connected. Otherwise writes to myOutput only...
void readContextSubscription(int responseID, tcpip::Storage &inMsg)
double getDouble(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
libsumo::ContextSubscriptionResults & getAllContextSubscriptionResults(const int domain)
static Connection * myActive
libsumo::TraCIPositionVector getPolygon(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
static std::string toString(const T &t, std::streamsize accuracy=PRECISION)
int getInt(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
int getUnsignedByte(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
static void switchCon(const std::string &label)
void subscribeObjectContext(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 request.
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()
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int TYPE_COLOR
TRACI_CONST int POSITION_3D
std::map< int, std::shared_ptr< TraCIResult > > TraCIResults
{variable->value}
TRACI_CONST int TYPE_COMPOUND
std::vector< TraCIPosition > TraCIPositionVector
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
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int INVALID_INT_VALUE
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int TYPE_BYTE
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
TRACI_CONST int TYPE_STRING