![]() |
SUMO - Simulation of Urban MObility
|
A test execution class. More...
#include <TraCITestClient.h>
Public Types | |
typedef std::map< std::string, SubscribedValues > | SubscribedContextValues |
typedef std::map< std::string, TraCIValues > | SubscribedValues |
typedef std::map< int, libsumo::TraCIValue > | TraCIValues |
{object->{variable->value}} More... | |
Public Member Functions | |
void | load (const std::vector< std::string > &args) |
Let sumo load a simulation using the given command line like options. More... | |
int | run (std::string fileName, int port, std::string host="localhost") |
Runs a test. More... | |
void | simulationStep (SUMOTime time=0) |
Advances by one step (or up to the given time) More... | |
TraCITestClient (std::string outputFileName="testclient_result.out") | |
Constructor. More... | |
~TraCITestClient () | |
Destructor. More... | |
Connection handling | |
void | connect (const std::string &host, int port) |
Connects to the specified SUMO server. More... | |
void | setOrder (int order) |
set priority (execution order) for the client More... | |
void | close () |
ends the simulation and closes the connection More... | |
Atomar getter | |
SUMOTime | getSUMOTime (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
int | getUnsignedByte (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
int | getByte (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
int | getInt (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
double | getFloat (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
double | getDouble (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
libsumo::TraCIBoundary | getBoundingBox (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
libsumo::TraCIPositionVector | getPolygon (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
libsumo::TraCIPosition | getPosition (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
libsumo::TraCIPosition | getPosition3D (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
std::string | getString (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
std::vector< std::string > | getStringVector (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
libsumo::TraCIColor | getColor (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
Data Fields | |
EdgeScope | edge |
Scope for interaction with edges. More... | |
GUIScope | gui |
Scope for interaction with the gui. More... | |
InductionLoopScope | inductionloop |
Scope for interaction with inductive loops. More... | |
JunctionScope | junction |
Scope for interaction with junctions. More... | |
LaneScope | lane |
Scope for interaction with lanes. More... | |
LaneAreaScope | lanearea |
Scope for interaction with lanes. More... | |
MeMeScope | multientryexit |
Scope for interaction with multi-entry/-exit detectors. More... | |
PersonScope | person |
Scope for interaction with persons. More... | |
POIScope | poi |
Scope for interaction with POIs. More... | |
PolygonScope | polygon |
Scope for interaction with polygons. More... | |
RouteScope | route |
Scope for interaction with routes. More... | |
SimulationScope | simulation |
Scope for interaction with the simulation. More... | |
TrafficLightScope | trafficlights |
Scope for interaction with traffic lights. More... | |
VehicleScope | vehicle |
Scope for interaction with vehicles. More... | |
VehicleTypeScope | vehicletype |
Scope for interaction with vehicle types. More... | |
Protected Member Functions | |
void | closeSocket () |
Closes the connection. More... | |
void | readContextSubscription (tcpip::Storage &inMsg) |
void | readVariables (tcpip::Storage &inMsg, const std::string &objectID, int variableCount, SubscribedValues &into) |
void | readVariableSubscription (tcpip::Storage &inMsg) |
void | send_commandMoveToXY (const std::string &vehicleID, const std::string &edgeID, const int lane, const double x, const double y, const double angle, const int keepRoute) const |
Commands handling | |
void | commandSimulationStep (SUMOTime time) |
Sends and validates a simulation step command. More... | |
void | commandClose () |
Sends and validates a Close command. More... | |
void | commandSetOrder (int order) |
Sends and validates a SetOrder command. More... | |
void | commandGetVariable (int domID, int varID, const std::string &objID, tcpip::Storage *addData=0) |
Sends and validates a GetVariable command. More... | |
void | commandSetValue (int domID, int varID, const std::string &objID, std::ifstream &defFile) |
Sends and validates a SetVariable command. More... | |
void | commandSubscribeObjectVariable (int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int varNo, std::ifstream &defFile) |
Sends and validates a SubscribeVariable command. More... | |
void | commandSubscribeContextVariable (int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int domain, double range, int varNo, std::ifstream &defFile) |
Sends and validates a SubscribeContext command. More... | |
Command sending methods | |
void | send_commandSimulationStep (SUMOTime time) const |
Sends a SimulationStep command. More... | |
void | send_commandClose () const |
Sends a Close command. More... | |
void | send_commandSetOrder (int order) const |
Sends a SetOrder command. More... | |
void | send_commandGetVariable (int domID, int varID, const std::string &objID, tcpip::Storage *add=0) const |
Sends a GetVariable request. More... | |
void | send_commandSetValue (int domID, int varID, const std::string &objID, tcpip::Storage &content) const |
Sends a SetVariable request. More... | |
void | send_commandSubscribeObjectVariable (int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, const std::vector< int > &vars) const |
Sends a SubscribeVariable request. More... | |
void | send_commandSubscribeObjectContext (int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int domain, double range, const std::vector< int > &vars) const |
Sends a SubscribeContext request. More... | |
void | check_resultState (tcpip::Storage &inMsg, int command, bool ignoreCommandId=false, std::string *acknowledgement=0) const |
Validates the result state of a command. More... | |
int | check_commandGetResult (tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const |
Validates the result state of a command. More... | |
void | processGET (tcpip::Storage &inMsg, int command, int expectedType, bool ignoreCommandId=false) const |
Static Protected Member Functions | |
template<class T > | |
static std::string | toString (const T &t, std::streamsize accuracy=PRECISION) |
Protected Attributes | |
tcpip::Socket * | mySocket |
The socket. More... | |
SubscribedContextValues | mySubscribedContextValues |
SubscribedValues | mySubscribedValues |
Private Member Functions | |
void | testAPI () |
call all API methods once More... | |
Report helper | |
void | writeResult () |
Writes the results file. More... | |
void | errorMsg (std::stringstream &msg) |
Writes an error message. More... | |
Results validation methods | |
bool | validateSimulationStep2 (tcpip::Storage &inMsg) |
Validates whether the given message is a valid answer to CMD_SIMSTEP. More... | |
bool | validateSubscription (tcpip::Storage &inMsg) |
Validates whether the given message is a valid subscription return message. More... | |
Conversion helper | |
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. More... | |
void | readAndReportTypeDependent (tcpip::Storage &inMsg, int valueDataType) |
Reads a value of the given type from the given storage and reports it. More... | |
Private Attributes | |
std::stringstream | answerLog |
Stream containing the log. More... | |
std::string | outputFileName |
The name of the file to write the results log into. More... | |
A test execution class.
Reads a program file and executes the actions stored within it
Definition at line 51 of file TraCITestClient.h.
|
inherited |
Definition at line 469 of file TraCIAPI.h.
|
inherited |
Definition at line 468 of file TraCIAPI.h.
|
inherited |
{object->{variable->value}}
Definition at line 467 of file TraCIAPI.h.
TraCITestClient::TraCITestClient | ( | std::string | outputFileName = "testclient_result.out" | ) |
Constructor.
[in] | outputFileName | The name of the file the outputs will be written into |
Definition at line 57 of file TraCITestClient.cpp.
References answerLog.
TraCITestClient::~TraCITestClient | ( | ) |
|
protectedinherited |
Validates the result state of a command.
Definition at line 318 of file TraCIAPI.cpp.
References tcpip::Storage::position(), tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), and TraCIAPI::toString().
Referenced by commandGetVariable(), TraCIAPI::processGET(), and TraCIAPI::simulationStep().
|
protectedinherited |
Validates the result state of a command.
[in] | inMsg | The buffer to read the message from |
[in] | command | The original command id |
[in] | ignoreCommandId | Whether the returning command id shall be validated |
[in] | acknowledgement | Pointer to an existing string into which the acknowledgement message shall be inserted |
Definition at line 279 of file TraCIAPI.cpp.
References TraCIAPI::mySocket, tcpip::Storage::position(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), tcpip::Socket::receiveExact(), RTYPE_ERR, RTYPE_NOTIMPLEMENTED, RTYPE_OK, and TraCIAPI::toString().
Referenced by TraCIAPI::close(), commandClose(), commandGetVariable(), commandSetOrder(), commandSetValue(), commandSimulationStep(), commandSubscribeContextVariable(), commandSubscribeObjectVariable(), TraCIAPI::load(), TraCIAPI::processGET(), TraCIAPI::setOrder(), and TraCIAPI::simulationStep().
|
inherited |
ends the simulation and closes the connection
Definition at line 95 of file TraCIAPI.cpp.
References TraCIAPI::check_resultState(), TraCIAPI::closeSocket(), CMD_CLOSE, and TraCIAPI::send_commandClose().
|
protectedinherited |
Closes the connection.
Definition at line 105 of file TraCIAPI.cpp.
References tcpip::Socket::close(), and TraCIAPI::mySocket.
Referenced by TraCIAPI::close(), run(), and TraCIAPI::toString().
|
protected |
Sends and validates a Close command.
Definition at line 202 of file TraCITestClient.cpp.
References answerLog, TraCIAPI::check_resultState(), CMD_CLOSE, TraCIAPI::send_commandClose(), and tcpip::SocketException::what().
Referenced by run().
|
protected |
Sends and validates a GetVariable command.
[in] | domID | The ID of the domain the addressed object belongs to |
[in] | varID | The ID of the variable one asks for |
[in] | objID | The ID of the object a variable shall be retrieved from |
[in] | addData | Storage to read additional data from, if needed |
Definition at line 232 of file TraCITestClient.cpp.
References answerLog, TraCIAPI::check_commandGetResult(), TraCIAPI::check_resultState(), errorMsg(), readAndReportTypeDependent(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), TraCIAPI::send_commandGetVariable(), and tcpip::SocketException::what().
Referenced by run().
|
protected |
Sends and validates a SetOrder command.
Definition at line 217 of file TraCITestClient.cpp.
References answerLog, TraCIAPI::check_resultState(), CMD_SETORDER, TraCIAPI::send_commandSetOrder(), and tcpip::SocketException::what().
Referenced by run().
|
protected |
Sends and validates a SetVariable command.
[in] | domID | The ID of the domain the addressed object belongs to |
[in] | varID | The ID of the variable to set |
[in] | objID | The ID of the object which shall be changed |
[in] | defFile | Storage to read additional data from |
Definition at line 265 of file TraCITestClient.cpp.
References answerLog, TraCIAPI::check_resultState(), errorMsg(), TraCIAPI::send_commandSetValue(), setValueTypeDependant(), and tcpip::SocketException::what().
Referenced by run().
|
protected |
Sends and validates a simulation step command.
[in] | time | The time step to send |
Definition at line 186 of file TraCITestClient.cpp.
References answerLog, TraCIAPI::check_resultState(), CMD_SIMSTEP, TraCIAPI::send_commandSimulationStep(), validateSimulationStep2(), and tcpip::SocketException::what().
Referenced by run().
|
protected |
Sends and validates a SubscribeContext command.
[in] | domID | The ID of the domain the addressed object belongs to |
[in] | objID | The ID of the object a variable shall be subscribed from |
[in] | beginTime | The time the subscription shall begin at |
[in] | endTime | The time the subscription shall end at |
[in] | domain | The domain of the objects which shall be reported |
[in] | range | The range within which objects shall be for being reported |
[in] | varNo | The number of subscribed variables |
[in] | defFile | The stream to read variable values from |
Definition at line 312 of file TraCITestClient.cpp.
References answerLog, TraCIAPI::check_resultState(), TraCIAPI::send_commandSubscribeObjectContext(), validateSubscription(), and tcpip::SocketException::what().
Referenced by run().
|
protected |
Sends and validates a SubscribeVariable command.
[in] | domID | The ID of the domain the addressed object belongs to |
[in] | objID | The ID of the object a variable shall be subscribed from |
[in] | beginTime | The time the subscription shall begin at |
[in] | endTime | The time the subscription shall end at |
[in] | varNo | The number of subscribed variables |
[in] | defFile | The stream to read variable values from |
Definition at line 288 of file TraCITestClient.cpp.
References answerLog, TraCIAPI::check_resultState(), TraCIAPI::send_commandSubscribeObjectVariable(), validateSubscription(), and tcpip::SocketException::what().
Referenced by run().
|
inherited |
Connects to the specified SUMO server.
[in] | host | The name of the host to connect to |
[in] | port | The port to connect to |
tcpip::SocketException | if the connection fails |
Definition at line 67 of file TraCIAPI.cpp.
References tcpip::Socket::connect(), and TraCIAPI::mySocket.
Referenced by run().
|
private |
Writes an error message.
[in] | msg | The message to write |
Definition at line 355 of file TraCITestClient.cpp.
References answerLog.
Referenced by commandGetVariable(), commandSetValue(), and run().
|
inherited |
Definition at line 405 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readDouble(), TraCIAPI::send_commandGetVariable(), TYPE_BOUNDINGBOX, libsumo::TraCIBoundary::xMax, libsumo::TraCIBoundary::xMin, libsumo::TraCIBoundary::yMax, libsumo::TraCIBoundary::yMin, libsumo::TraCIBoundary::zMax, and libsumo::TraCIBoundary::zMin.
|
inherited |
Definition at line 369 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readByte(), TraCIAPI::send_commandGetVariable(), and TYPE_BYTE.
|
inherited |
Definition at line 488 of file TraCIAPI.cpp.
References libsumo::TraCIColor::a, libsumo::TraCIColor::b, libsumo::TraCIColor::g, TraCIAPI::processGET(), libsumo::TraCIColor::r, tcpip::Storage::readUnsignedByte(), TraCIAPI::send_commandGetVariable(), and TYPE_COLOR.
Referenced by TraCIAPI::POIScope::~POIScope(), TraCIAPI::PolygonScope::~PolygonScope(), TraCIAPI::VehicleScope::~VehicleScope(), and TraCIAPI::VehicleTypeScope::~VehicleTypeScope().
|
inherited |
Definition at line 396 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readDouble(), TraCIAPI::send_commandGetVariable(), and TYPE_DOUBLE.
|
inherited |
Definition at line 387 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readFloat(), TraCIAPI::send_commandGetVariable(), and TYPE_FLOAT.
|
inherited |
Definition at line 378 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readInt(), TraCIAPI::send_commandGetVariable(), and TYPE_INTEGER.
|
inherited |
Definition at line 421 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readByte(), tcpip::Storage::readDouble(), TraCIAPI::send_commandGetVariable(), TYPE_POLYGON, libsumo::TraCIPosition::x, libsumo::TraCIPosition::y, and libsumo::TraCIPosition::z.
|
inherited |
Definition at line 439 of file TraCIAPI.cpp.
References POSITION_2D, TraCIAPI::processGET(), tcpip::Storage::readDouble(), TraCIAPI::send_commandGetVariable(), libsumo::TraCIPosition::x, libsumo::TraCIPosition::y, and libsumo::TraCIPosition::z.
Referenced by TraCIAPI::InductionLoopScope::~InductionLoopScope(), TraCIAPI::JunctionScope::~JunctionScope(), TraCIAPI::PersonScope::~PersonScope(), TraCIAPI::POIScope::~POIScope(), and TraCIAPI::VehicleScope::~VehicleScope().
|
inherited |
Definition at line 452 of file TraCIAPI.cpp.
References POSITION_3D, TraCIAPI::processGET(), tcpip::Storage::readDouble(), TraCIAPI::send_commandGetVariable(), libsumo::TraCIPosition::x, libsumo::TraCIPosition::y, and libsumo::TraCIPosition::z.
Referenced by TraCIAPI::VehicleScope::~VehicleScope().
|
inherited |
Definition at line 465 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readString(), TraCIAPI::send_commandGetVariable(), and TYPE_STRING.
|
inherited |
Definition at line 474 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readInt(), tcpip::Storage::readString(), TraCIAPI::send_commandGetVariable(), and TYPE_STRINGLIST.
|
inherited |
Definition at line 351 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readInt(), TraCIAPI::send_commandGetVariable(), and TYPE_INTEGER.
|
inherited |
Definition at line 360 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readUnsignedByte(), TraCIAPI::send_commandGetVariable(), and TYPE_UBYTE.
|
inherited |
Let sumo load a simulation using the given command line like options.
Definition at line 604 of file TraCIAPI.cpp.
References TraCIAPI::check_resultState(), CMD_LOAD, TraCIAPI::mySocket, tcpip::Socket::sendExact(), TYPE_STRINGLIST, tcpip::Storage::writeInt(), tcpip::Storage::writeStringList(), and tcpip::Storage::writeUnsignedByte().
Referenced by testAPI().
|
protectedinherited |
Definition at line 342 of file TraCIAPI.cpp.
References TraCIAPI::check_commandGetResult(), and TraCIAPI::check_resultState().
Referenced by TraCIAPI::getBoundingBox(), TraCIAPI::getByte(), TraCIAPI::getColor(), TraCIAPI::getDouble(), TraCIAPI::getFloat(), TraCIAPI::getInt(), TraCIAPI::getPolygon(), TraCIAPI::getPosition(), TraCIAPI::getPosition3D(), TraCIAPI::getString(), TraCIAPI::getStringVector(), TraCIAPI::getSUMOTime(), and TraCIAPI::getUnsignedByte().
|
private |
Reads a value of the given type from the given storage and reports it.
[in] | inMsg | The storage to read the value from |
[in] | valueDataType | The type of the expected value |
Definition at line 577 of file TraCITestClient.cpp.
References answerLog, POSITION_2D, POSITION_3D, POSITION_ROADMAP, tcpip::Storage::readByte(), tcpip::Storage::readDouble(), tcpip::Storage::readFloat(), tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readStringList(), tcpip::Storage::readUnsignedByte(), TLPHASE_GREEN, TLPHASE_RED, TLPHASE_YELLOW, TYPE_BOUNDINGBOX, TYPE_BYTE, TYPE_COLOR, TYPE_COMPOUND, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_POLYGON, TYPE_STRING, TYPE_STRINGLIST, TYPE_TLPHASELIST, and TYPE_UBYTE.
Referenced by commandGetVariable(), and validateSubscription().
|
protectedinherited |
Definition at line 569 of file TraCIAPI.cpp.
References TraCIAPI::mySubscribedContextValues, tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), and TraCIAPI::readVariables().
Referenced by TraCIAPI::simulationStep().
|
protectedinherited |
Definition at line 501 of file TraCIAPI.cpp.
References libsumo::TraCIColor::a, libsumo::TraCIColor::b, libsumo::TraCIValue::color, libsumo::TraCIColor::g, libsumo::TraCIValue::position, POSITION_2D, POSITION_3D, libsumo::TraCIColor::r, tcpip::Storage::readDouble(), tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), RTYPE_OK, libsumo::TraCIValue::scalar, libsumo::TraCIValue::string, libsumo::TraCIValue::stringList, TraCIAPI::toString(), TYPE_COLOR, TYPE_DOUBLE, TYPE_INTEGER, TYPE_STRING, TYPE_STRINGLIST, libsumo::TraCIPosition::x, libsumo::TraCIPosition::y, and libsumo::TraCIPosition::z.
Referenced by TraCIAPI::readContextSubscription(), and TraCIAPI::readVariableSubscription().
|
protectedinherited |
Definition at line 562 of file TraCIAPI.cpp.
References TraCIAPI::mySubscribedValues, tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), and TraCIAPI::readVariables().
Referenced by TraCIAPI::simulationStep().
int TraCITestClient::run | ( | std::string | fileName, |
int | port, | ||
std::string | host = "localhost" |
||
) |
Runs a test.
[in] | fileName | The name of the file containing the test script |
[in] | port | The server port to connect to |
[in] | host | The server name to connect to |
Definition at line 71 of file TraCITestClient.cpp.
References TraCIAPI::closeSocket(), commandClose(), commandGetVariable(), commandSetOrder(), commandSetValue(), commandSimulationStep(), commandSubscribeContextVariable(), commandSubscribeObjectVariable(), TraCIAPI::connect(), errorMsg(), setValueTypeDependant(), string2time(), testAPI(), and tcpip::SocketException::what().
Referenced by main().
|
protectedinherited |
Sends a Close command.
Definition at line 129 of file TraCIAPI.cpp.
References CMD_CLOSE, TraCIAPI::mySocket, tcpip::Socket::sendExact(), and tcpip::Storage::writeUnsignedByte().
Referenced by TraCIAPI::close(), and commandClose().
|
protectedinherited |
Sends a GetVariable request.
[in] | domID | The domain of the variable |
[in] | varID | The variable to retrieve |
[in] | objID | The object to retrieve the variable from |
[in] | add | Optional additional parameter |
Definition at line 153 of file TraCIAPI.cpp.
References TraCIAPI::mySocket, tcpip::Socket::sendExact(), tcpip::Storage::size(), tcpip::Storage::writeStorage(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
Referenced by commandGetVariable(), TraCIAPI::getBoundingBox(), TraCIAPI::getByte(), TraCIAPI::getColor(), TraCIAPI::getDouble(), TraCIAPI::getFloat(), TraCIAPI::getInt(), TraCIAPI::getPolygon(), TraCIAPI::getPosition(), TraCIAPI::getPosition3D(), TraCIAPI::getString(), TraCIAPI::getStringVector(), TraCIAPI::getSUMOTime(), and TraCIAPI::getUnsignedByte().
|
protectedinherited |
Definition at line 259 of file TraCIAPI.cpp.
References CMD_SET_VEHICLE_VARIABLE, MOVE_TO_XY, TraCIAPI::send_commandSetValue(), TYPE_BYTE, TYPE_COMPOUND, TYPE_DOUBLE, TYPE_INTEGER, TYPE_STRING, tcpip::Storage::writeByte(), tcpip::Storage::writeDouble(), tcpip::Storage::writeInt(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
|
protectedinherited |
Sends a SetOrder command.
Definition at line 140 of file TraCIAPI.cpp.
References CMD_SETORDER, TraCIAPI::mySocket, tcpip::Socket::sendExact(), tcpip::Storage::writeInt(), and tcpip::Storage::writeUnsignedByte().
Referenced by commandSetOrder().
|
protectedinherited |
Sends a SetVariable request.
[in] | domID | The domain of the variable |
[in] | varID | The variable to set |
[in] | objID | The object to change |
[in] | content | The value of the variable |
Definition at line 180 of file TraCIAPI.cpp.
References TraCIAPI::mySocket, tcpip::Socket::sendExact(), tcpip::Storage::size(), tcpip::Storage::writeStorage(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
Referenced by commandSetValue(), and TraCIAPI::send_commandMoveToXY().
|
protectedinherited |
Sends a SimulationStep command.
Definition at line 116 of file TraCIAPI.cpp.
References CMD_SIMSTEP, TraCIAPI::mySocket, tcpip::Socket::sendExact(), tcpip::Storage::writeInt(), and tcpip::Storage::writeUnsignedByte().
Referenced by commandSimulationStep(), and TraCIAPI::simulationStep().
|
protectedinherited |
Sends a SubscribeContext request.
[in] | domID | The domain of the variable |
[in] | objID | The object to subscribe the variables from |
[in] | beginTime | The begin time step of subscriptions |
[in] | endTime | The end time step of subscriptions |
[in] | domain | The domain of the objects which values shall be returned |
[in] | range | The range around the obj to investigate |
[in] | vars | The variables to subscribe |
Definition at line 229 of file TraCIAPI.cpp.
References TraCIAPI::mySocket, tcpip::Socket::sendExact(), tcpip::Storage::size(), tcpip::Storage::writeDouble(), tcpip::Storage::writeInt(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
Referenced by commandSubscribeContextVariable().
|
protectedinherited |
Sends a SubscribeVariable request.
[in] | domID | The domain of the variable |
[in] | objID | The object to subscribe the variables from |
[in] | beginTime | The begin time step of subscriptions |
[in] | endTime | The end time step of subscriptions |
[in] | vars | The variables to subscribe |
Definition at line 201 of file TraCIAPI.cpp.
References TraCIAPI::mySocket, tcpip::Socket::sendExact(), tcpip::Storage::size(), tcpip::Storage::writeInt(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
Referenced by commandSubscribeObjectVariable().
|
inherited |
set priority (execution order) for the client
Definition at line 80 of file TraCIAPI.cpp.
References TraCIAPI::check_resultState(), CMD_SETORDER, TraCIAPI::mySocket, tcpip::Socket::sendExact(), tcpip::Storage::writeInt(), and tcpip::Storage::writeUnsignedByte().
Referenced by testAPI().
|
private |
Parses the next value type / value pair from the stream and inserts it into the storage.
[out] | into | The storage to add the value type and the value into |
[in] | defFile | The file to read the values from |
[out] | msg | If any error occurs, this should be filled |
Definition at line 441 of file TraCITestClient.cpp.
References POSITION_2D, POSITION_3D, POSITION_ROADMAP, REQUEST_AIRDIST, REQUEST_DRIVINGDIST, TYPE_BYTE, TYPE_COLOR, TYPE_COMPOUND, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_POLYGON, TYPE_STRING, TYPE_STRINGLIST, TYPE_UBYTE, tcpip::Storage::writeByte(), tcpip::Storage::writeDouble(), tcpip::Storage::writeFloat(), tcpip::Storage::writeInt(), tcpip::Storage::writeString(), tcpip::Storage::writeStringList(), and tcpip::Storage::writeUnsignedByte().
Referenced by commandSetValue(), and run().
|
inherited |
Advances by one step (or up to the given time)
Definition at line 583 of file TraCIAPI.cpp.
References TraCIAPI::check_commandGetResult(), TraCIAPI::check_resultState(), CMD_SIMSTEP, TraCIAPI::mySubscribedContextValues, TraCIAPI::mySubscribedValues, TraCIAPI::readContextSubscription(), tcpip::Storage::readInt(), TraCIAPI::readVariableSubscription(), RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE, RESPONSE_SUBSCRIBE_PERSON_VARIABLE, and TraCIAPI::send_commandSimulationStep().
Referenced by testAPI().
|
private |
call all API methods once
Definition at line 693 of file TraCITestClient.cpp.
References libsumo::TraCIColor::a, TraCIAPI::EdgeScope::adaptTraveltime(), TraCIAPI::RouteScope::add(), TraCIAPI::VehicleScope::add(), TraCIAPI::PersonScope::add(), answerLog, TraCIAPI::PersonScope::appendDrivingStage(), TraCIAPI::PersonScope::appendWaitingStage(), TraCIAPI::PersonScope::appendWalkingStage(), libsumo::TraCIConnection::approachedInternal, libsumo::TraCIConnection::approachedLane, libsumo::TraCIColor::b, TraCIAPI::VehicleScope::changeTarget(), CMD_GET_VEHICLE_VARIABLE, CMD_SUBSCRIBE_EDGE_CONTEXT, CMD_SUBSCRIBE_VEHICLE_VARIABLE, TraCIAPI::VehicleTypeScope::copy(), libsumo::TraCIConnection::direction, libsumo::TraCINextTLSData::dist, TraCIAPI::edge, libsumo::TraCIVehicleData::entryTime, libsumo::TraCIColor::g, TraCIAPI::VehicleTypeScope::getAccel(), TraCIAPI::VehicleScope::getAccumulatedWaitingTime(), TraCIAPI::EdgeScope::getAdaptedTraveltime(), TraCIAPI::VehicleTypeScope::getApparentDecel(), TraCIAPI::VehicleScope::getColor(), TraCIAPI::TrafficLightScope::getCompleteRedYellowGreenDefinition(), TraCIAPI::SimulationScope::getContextSubscriptionResults(), TraCIAPI::TrafficLightScope::getControlledLanes(), TraCIAPI::TrafficLightScope::getControlledLinks(), TraCIAPI::SimulationScope::getCurrentTime(), TraCIAPI::VehicleScope::getEdges(), TraCIAPI::PersonScope::getEdges(), TraCIAPI::EdgeScope::getEffort(), TraCIAPI::VehicleTypeScope::getEmergencyDecel(), TraCIAPI::LaneScope::getFoes(), TraCIAPI::VehicleTypeScope::getHeight(), TraCIAPI::EdgeScope::getIDCount(), TraCIAPI::LaneScope::getIDCount(), TraCIAPI::VehicleScope::getIDCount(), TraCIAPI::EdgeScope::getIDList(), TraCIAPI::InductionLoopScope::getIDList(), TraCIAPI::LaneScope::getIDList(), TraCIAPI::RouteScope::getIDList(), TraCIAPI::TrafficLightScope::getIDList(), TraCIAPI::VehicleTypeScope::getIDList(), TraCIAPI::VehicleScope::getIDList(), TraCIAPI::PersonScope::getIDList(), TraCIAPI::LaneScope::getInternalFoes(), TraCIAPI::VehicleScope::getLaneID(), TraCIAPI::VehicleScope::getLanePosition(), TraCIAPI::VehicleTypeScope::getLateralAlignment(), TraCIAPI::VehicleScope::getLateralLanePosition(), TraCIAPI::VehicleScope::getLeader(), TraCIAPI::VehicleScope::getLine(), TraCIAPI::LaneScope::getLinkNumber(), TraCIAPI::LaneScope::getLinks(), TraCIAPI::VehicleScope::getMaxSpeed(), TraCIAPI::VehicleTypeScope::getMaxSpeedLat(), TraCIAPI::VehicleTypeScope::getMinGapLat(), TraCIAPI::PersonScope::getNextEdge(), TraCIAPI::TrafficLightScope::getNextSwitch(), TraCIAPI::VehicleScope::getNextTLS(), TraCIAPI::TrafficLightScope::getPhase(), TraCIAPI::TrafficLightScope::getProgram(), TraCIAPI::TrafficLightScope::getRedYellowGreenState(), TraCIAPI::PersonScope::getRemainingStages(), TraCIAPI::VehicleScope::getRoadID(), TraCIAPI::PersonScope::getRoadID(), TraCIAPI::VehicleScope::getRouteID(), TraCIAPI::GUIScope::getSchema(), TraCIAPI::VehicleScope::getShapeClass(), TraCIAPI::VehicleScope::getSlope(), TraCIAPI::PersonScope::getSpeed(), TraCIAPI::VehicleScope::getSpeedMode(), TraCIAPI::PersonScope::getStage(), TraCIAPI::SimulationScope::getSubscriptionResults(), TraCIAPI::EdgeScope::getTraveltime(), TraCIAPI::VehicleScope::getTypeID(), TraCIAPI::PersonScope::getTypeID(), TraCIAPI::PersonScope::getVehicle(), TraCIAPI::InductionLoopScope::getVehicleData(), TraCIAPI::VehicleScope::getVia(), TraCIAPI::VehicleScope::getWaitingTime(), TraCIAPI::PersonScope::getWaitingTime(), TraCIAPI::VehicleTypeScope::getWidth(), TraCIAPI::gui, libsumo::TraCIConnection::hasFoe, libsumo::TraCIConnection::hasPrio, libsumo::TraCIVehicleData::id, libsumo::TraCINextTLSData::id, TraCIAPI::inductionloop, libsumo::TraCIConnection::isOpen, TraCIAPI::VehicleScope::isRouteValid(), joinToString(), TraCIAPI::lane, libsumo::TraCIVehicleData::leaveTime, libsumo::TraCIConnection::length, libsumo::TraCIVehicleData::length, TraCIAPI::load(), TraCIAPI::VehicleScope::moveTo(), TraCIAPI::VehicleScope::moveToXY(), TraCIAPI::person, libsumo::TraCIColor::r, TraCIAPI::VehicleScope::remove(), TraCIAPI::PersonScope::removeStage(), TraCIAPI::PersonScope::removeStages(), TraCIAPI::VehicleScope::rerouteTraveltime(), TraCIAPI::PersonScope::rerouteTraveltime(), TraCIAPI::route, TraCIAPI::GUIScope::screenshot(), TraCIAPI::VehicleTypeScope::setAccel(), TraCIAPI::VehicleTypeScope::setApparentDecel(), TraCIAPI::VehicleScope::setColor(), TraCIAPI::PersonScope::setColor(), TraCIAPI::EdgeScope::setEffort(), TraCIAPI::VehicleTypeScope::setEmergencyDecel(), TraCIAPI::VehicleTypeScope::setHeight(), TraCIAPI::PersonScope::setHeight(), TraCIAPI::VehicleTypeScope::setLateralAlignment(), TraCIAPI::PersonScope::setLength(), TraCIAPI::VehicleScope::setLine(), TraCIAPI::VehicleScope::setMaxSpeed(), TraCIAPI::VehicleTypeScope::setMaxSpeedLat(), TraCIAPI::PersonScope::setMinGap(), TraCIAPI::VehicleTypeScope::setMinGapLat(), TraCIAPI::setOrder(), TraCIAPI::VehicleScope::setRoute(), TraCIAPI::VehicleScope::setRouteID(), TraCIAPI::GUIScope::setSchema(), TraCIAPI::VehicleScope::setShapeClass(), TraCIAPI::PersonScope::setSpeed(), TraCIAPI::VehicleScope::setType(), TraCIAPI::PersonScope::setType(), TraCIAPI::VehicleScope::setVia(), TraCIAPI::VehicleTypeScope::setWidth(), TraCIAPI::PersonScope::setWidth(), TraCIAPI::simulation, TraCIAPI::simulationStep(), libsumo::TraCIConnection::state, libsumo::TraCINextTLSData::state, TraCIAPI::SimulationScope::subscribe(), TraCIAPI::SimulationScope::subscribeContext(), TIME2STEPS, libsumo::TraCINextTLSData::tlIndex, TraCIAPI::trafficlights, libsumo::TraCIVehicleData::typeID, VAR_LANEPOSITION, VAR_ROAD_ID, TraCIAPI::vehicle, and TraCIAPI::vehicletype.
Referenced by run().
|
inlinestaticprotectedinherited |
Definition at line 917 of file TraCIAPI.h.
References TraCIAPI::closeSocket().
Referenced by TraCIAPI::VehicleScope::add(), TraCIAPI::check_commandGetResult(), TraCIAPI::check_resultState(), and TraCIAPI::readVariables().
|
private |
Validates whether the given message is a valid answer to CMD_SIMSTEP.
[in] | inMsg | The storage contain the message to validate |
Definition at line 366 of file TraCITestClient.cpp.
References answerLog, tcpip::Storage::readInt(), and validateSubscription().
Referenced by commandSimulationStep().
|
private |
Validates whether the given message is a valid subscription return message.
[in] | inMsg | The storage contain the message to validate |
Definition at line 383 of file TraCITestClient.cpp.
References answerLog, readAndReportTypeDependent(), tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), RESPONSE_SUBSCRIBE_GUI_CONTEXT, RESPONSE_SUBSCRIBE_GUI_VARIABLE, RESPONSE_SUBSCRIBE_INDUCTIONLOOP_CONTEXT, RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE, and RTYPE_OK.
Referenced by commandSubscribeContextVariable(), commandSubscribeObjectVariable(), and validateSimulationStep2().
|
private |
Writes the results file.
Definition at line 339 of file TraCITestClient.cpp.
References answerLog, and outputFileName.
Referenced by ~TraCITestClient().
|
private |
Stream containing the log.
Definition at line 200 of file TraCITestClient.h.
Referenced by commandClose(), commandGetVariable(), commandSetOrder(), commandSetValue(), commandSimulationStep(), commandSubscribeContextVariable(), commandSubscribeObjectVariable(), errorMsg(), readAndReportTypeDependent(), testAPI(), TraCITestClient(), validateSimulationStep2(), validateSubscription(), and writeResult().
|
inherited |
Scope for interaction with edges.
Definition at line 798 of file TraCIAPI.h.
Referenced by testAPI(), and TraCIAPI::VehicleScope::~VehicleScope().
|
inherited |
Scope for interaction with the gui.
Definition at line 800 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with inductive loops.
Definition at line 802 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with junctions.
Definition at line 804 of file TraCIAPI.h.
|
inherited |
Scope for interaction with lanes.
Definition at line 806 of file TraCIAPI.h.
Referenced by testAPI(), and TraCIAPI::VehicleScope::~VehicleScope().
|
inherited |
Scope for interaction with lanes.
Definition at line 808 of file TraCIAPI.h.
|
inherited |
Scope for interaction with multi-entry/-exit detectors.
Definition at line 810 of file TraCIAPI.h.
|
protectedinherited |
The socket.
Definition at line 930 of file TraCIAPI.h.
Referenced by TraCIAPI::check_resultState(), TraCIAPI::closeSocket(), TraCIAPI::connect(), TraCIAPI::load(), TraCIAPI::send_commandClose(), TraCIAPI::send_commandGetVariable(), TraCIAPI::send_commandSetOrder(), TraCIAPI::send_commandSetValue(), TraCIAPI::send_commandSimulationStep(), TraCIAPI::send_commandSubscribeObjectContext(), TraCIAPI::send_commandSubscribeObjectVariable(), TraCIAPI::setOrder(), and TraCIAPI::~TraCIAPI().
|
protectedinherited |
Definition at line 933 of file TraCIAPI.h.
Referenced by TraCIAPI::readContextSubscription(), and TraCIAPI::simulationStep().
|
protectedinherited |
Definition at line 932 of file TraCIAPI.h.
Referenced by TraCIAPI::readVariableSubscription(), and TraCIAPI::simulationStep().
|
private |
The name of the file to write the results log into.
Definition at line 197 of file TraCITestClient.h.
Referenced by writeResult().
|
inherited |
Scope for interaction with persons.
Definition at line 812 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with POIs.
Definition at line 814 of file TraCIAPI.h.
|
inherited |
Scope for interaction with polygons.
Definition at line 816 of file TraCIAPI.h.
|
inherited |
Scope for interaction with routes.
Definition at line 818 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with the simulation.
Definition at line 820 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with traffic lights.
Definition at line 822 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with vehicles.
Definition at line 824 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with vehicle types.
Definition at line 826 of file TraCIAPI.h.
Referenced by testAPI().