20 #ifndef TRACITESTCLIENT_H 21 #define TRACITESTCLIENT_H 62 int run(std::string fileName,
int port, std::string host =
"localhost");
100 void commandSetValue(
int domID,
int varID,
const std::string& objID, std::ifstream& defFile);
124 void commandSubscribeContextVariable(
int domID,
const std::string& objID,
double beginTime,
double endTime,
int domain,
double range,
int varNo, std::ifstream& defFile);
141 void errorMsg(std::stringstream& msg);
int run(std::string fileName, int port, std::string host="localhost")
Runs a test.
void readAndReportTypeDependent(tcpip::Storage &inMsg, int valueDataType)
Reads a value of the given type from the given storage and reports it.
C++ TraCI client API implementation.
void commandSubscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, int varNo, std::ifstream &defFile)
Sends and validates a SubscribeVariable command.
void commandSetOrder(int order)
Sends and validates a SetOrder command.
std::stringstream answerLog
Stream containing the log.
void testAPI()
call all API methods once
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.
std::string outputFileName
The name of the file to write the results log into.
bool validateSimulationStep2(tcpip::Storage &inMsg)
Validates whether the given message is a valid answer to CMD_SIMSTEP.
void commandSetValue(int domID, int varID, const std::string &objID, std::ifstream &defFile)
Sends and validates a SetVariable command.
void commandSimulationStep(double time)
Sends and validates a simulation step command.
void writeResult()
Writes the results file.
TraCITestClient(std::string outputFileName="testclient_result.out")
Constructor.
void errorMsg(std::stringstream &msg)
Writes an error message.
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 commandClose()
Sends and validates a Close command.
void commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *addData=0)
Sends and validates a GetVariable command.
~TraCITestClient()
Destructor.