59 int run(std::string fileName,
int port, std::string host =
"localhost");
97 void commandSetValue(
int domID,
int varID,
const std::string& objID, std::ifstream& defFile);
121 void commandSubscribeContextVariable(
int domID,
const std::string& objID,
double beginTime,
double endTime,
int domain,
double range,
int varNo, std::ifstream& defFile);
138 void errorMsg(std::stringstream& msg);
186 inline std::string
joinToString(
const std::vector<std::string>& s,
const std::string& between) {
187 std::ostringstream oss;
189 for (
const std::string& it : s) {
200 inline std::string
joinToString(
const std::map<std::string, std::string>& m) {
201 std::ostringstream oss;
203 for (
const auto& it : m) {
209 oss << it.first <<
":" << it.second;
214 inline std::string
joinToString(
const std::vector<double>& v,
const std::string& between) {
215 std::ostringstream oss;
217 for (
double it : v) {
C++ TraCI client API implementation.
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
void readAndReportTypeDependent(tcpip::Storage &inMsg, int valueDataType)
Reads a value of the given type from the given storage and reports it.
std::string joinToString(const std::vector< std::string > &s, const std::string &between)
std::string joinToString(const std::vector< double > &v, const std::string &between)
void commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *addData=0)
Sends and validates a GetVariable command.
void testAPI()
call all API methods once
~TraCITestClient()
Destructor.
void commandSetValue(int domID, int varID, const std::string &objID, std::ifstream &defFile)
Sends and validates a SetVariable command.
int run(std::string fileName, int port, std::string host="localhost")
Runs a test.
std::string outputFileName
The name of the file to write the results log into.
void writeResult()
Writes the results file.
int setValueTypeDependant(tcpip::Storage &into, std::ifstream &defFile, std::stringstream &msg)
Parses the next value type / value pair from the stream and inserts it into the storage.
bool validateSubscription(tcpip::Storage &inMsg)
Validates whether the given message is a valid subscription return message.
void errorMsg(std::stringstream &msg)
Writes an error message.
bool validateSimulationStep2(tcpip::Storage &inMsg)
Validates whether the given message is a valid answer to CMD_SIMSTEP.
void commandSetOrder(int order)
Sends and validates a SetOrder command.
std::stringstream answerLog
Stream containing the log.
void commandSubscribeContextVariable(int domID, const std::string &objID, double beginTime, double endTime, int domain, double range, int varNo, std::ifstream &defFile)
Sends and validates a SubscribeContext command.
void commandSubscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, int varNo, std::ifstream &defFile)
Sends and validates a SubscribeVariable command.
void commandClose()
Sends and validates a Close command.
void commandSimulationStep(double time)
Sends and validates a simulation step command.
std::string joinToString(const std::map< std::string, std::string > &m)