![]() |
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, 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... | |
bool | 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 | 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) |
TraCIBoundary | getBoundingBox (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
TraCIPositionVector | getPolygon (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
TraCIPosition | getPosition (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) |
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 | 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_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 52 of file TraCITestClient.h.
|
inherited |
Definition at line 467 of file TraCIAPI.h.
|
inherited |
Definition at line 466 of file TraCIAPI.h.
|
inherited |
{object->{variable->value}}
Definition at line 465 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 56 of file TraCITestClient.cpp.
References answerLog.
TraCITestClient::~TraCITestClient | ( | ) |
|
protectedinherited |
Validates the result state of a command.
Definition at line 289 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 250 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(), commandSetValue(), commandSimulationStep(), commandSubscribeContextVariable(), commandSubscribeObjectVariable(), TraCIAPI::load(), TraCIAPI::processGET(), and TraCIAPI::simulationStep().
|
inherited |
ends the simulation and closes the connection
Definition at line 79 of file TraCIAPI.cpp.
References TraCIAPI::check_resultState(), TraCIAPI::closeSocket(), CMD_CLOSE, and TraCIAPI::send_commandClose().
|
protectedinherited |
Closes the connection.
Definition at line 89 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 196 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 211 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 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 244 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 180 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 291 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 267 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 66 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 334 of file TraCITestClient.cpp.
References answerLog.
Referenced by commandGetVariable(), commandSetValue(), and run().
|
inherited |
Definition at line 376 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readDouble(), TraCIAPI::send_commandGetVariable(), TYPE_BOUNDINGBOX, TraCIBoundary::xMax, TraCIBoundary::xMin, TraCIBoundary::yMax, TraCIBoundary::yMin, TraCIBoundary::zMax, and TraCIBoundary::zMin.
|
inherited |
Definition at line 340 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readByte(), TraCIAPI::send_commandGetVariable(), and TYPE_BYTE.
|
inherited |
Definition at line 446 of file TraCIAPI.cpp.
References TraCIColor::a, TraCIColor::b, TraCIColor::g, TraCIAPI::processGET(), TraCIColor::r, tcpip::Storage::readUnsignedByte(), TraCIAPI::send_commandGetVariable(), and TYPE_COLOR.
Referenced by TraCIAPI::POIScope::~POIScope(), TraCIAPI::PolygonScope::~PolygonScope(), and TraCIAPI::VehicleTypeScope::~VehicleTypeScope().
|
inherited |
Definition at line 367 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readDouble(), TraCIAPI::send_commandGetVariable(), and TYPE_DOUBLE.
|
inherited |
Definition at line 358 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readFloat(), TraCIAPI::send_commandGetVariable(), and TYPE_FLOAT.
|
inherited |
Definition at line 349 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readInt(), TraCIAPI::send_commandGetVariable(), and TYPE_INTEGER.
|
inherited |
Definition at line 392 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readByte(), tcpip::Storage::readDouble(), TraCIAPI::send_commandGetVariable(), TYPE_POLYGON, TraCIPosition::x, TraCIPosition::y, and TraCIPosition::z.
|
inherited |
Definition at line 410 of file TraCIAPI.cpp.
References POSITION_2D, TraCIAPI::processGET(), tcpip::Storage::readDouble(), TraCIAPI::send_commandGetVariable(), TraCIPosition::x, TraCIPosition::y, and TraCIPosition::z.
Referenced by TraCIAPI::InductionLoopScope::~InductionLoopScope(), TraCIAPI::JunctionScope::~JunctionScope(), TraCIAPI::PersonScope::~PersonScope(), and TraCIAPI::POIScope::~POIScope().
|
inherited |
Definition at line 423 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readString(), TraCIAPI::send_commandGetVariable(), and TYPE_STRING.
|
inherited |
Definition at line 432 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readInt(), tcpip::Storage::readString(), TraCIAPI::send_commandGetVariable(), and TYPE_STRINGLIST.
|
inherited |
Definition at line 322 of file TraCIAPI.cpp.
References TraCIAPI::processGET(), tcpip::Storage::readInt(), TraCIAPI::send_commandGetVariable(), and TYPE_INTEGER.
|
inherited |
Definition at line 331 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 562 of file TraCIAPI.cpp.
References TraCIAPI::check_resultState(), CMD_LOAD, TraCIAPI::mySocket, tcpip::Socket::sendExact(), TYPE_STRINGLIST, tcpip::Storage::writeStringList(), and tcpip::Storage::writeUnsignedByte().
Referenced by testAPI().
|
protectedinherited |
Definition at line 313 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::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 556 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 527 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 459 of file TraCIAPI.cpp.
References TraCIColor::a, TraCIColor::b, TraCIValue::color, TraCIColor::g, TraCIValue::position, POSITION_2D, POSITION_3D, TraCIColor::r, tcpip::Storage::readDouble(), tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), RTYPE_OK, TraCIValue::scalar, TraCIValue::string, TraCIValue::stringList, TraCIAPI::toString(), TYPE_COLOR, TYPE_DOUBLE, TYPE_INTEGER, TYPE_STRING, TYPE_STRINGLIST, TraCIPosition::x, TraCIPosition::y, and TraCIPosition::z.
Referenced by TraCIAPI::readContextSubscription(), and TraCIAPI::readVariableSubscription().
|
protectedinherited |
Definition at line 520 of file TraCIAPI.cpp.
References TraCIAPI::mySubscribedValues, tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), and TraCIAPI::readVariables().
Referenced by TraCIAPI::simulationStep().
bool 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 70 of file TraCITestClient.cpp.
References TraCIAPI::closeSocket(), commandClose(), commandGetVariable(), 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 113 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 124 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::getString(), TraCIAPI::getStringVector(), TraCIAPI::getSUMOTime(), and TraCIAPI::getUnsignedByte().
|
protectedinherited |
Definition at line 230 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 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 151 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 100 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 200 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 172 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().
|
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 420 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 541 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 672 of file TraCITestClient.cpp.
References TraCIColor::a, TraCIAPI::EdgeScope::adaptTraveltime(), TraCIAPI::RouteScope::add(), TraCIAPI::VehicleScope::add(), TraCIAPI::PersonScope::add(), answerLog, TraCIAPI::PersonScope::appendDrivingStage(), TraCIAPI::PersonScope::appendWaitingStage(), TraCIAPI::PersonScope::appendWalkingStage(), TraCIColor::b, TraCIAPI::VehicleScope::changeTarget(), CMD_GET_VEHICLE_VARIABLE, CMD_SUBSCRIBE_EDGE_CONTEXT, CMD_SUBSCRIBE_VEHICLE_VARIABLE, TraCIAPI::edge, TraCIVehicleData::entryTime, TraCIColor::g, TraCIAPI::EdgeScope::getAdaptedTraveltime(), TraCIAPI::VehicleScope::getColor(), TraCIAPI::SimulationScope::getContextSubscriptionResults(), TraCIAPI::TrafficLightScope::getControlledLanes(), TraCIAPI::TrafficLightScope::getControlledLinks(), TraCIAPI::SimulationScope::getCurrentTime(), TraCIAPI::VehicleScope::getEdges(), TraCIAPI::PersonScope::getEdges(), TraCIAPI::EdgeScope::getEffort(), TraCIAPI::VehicleTypeScope::getHeight(), TraCIAPI::EdgeScope::getIDCount(), TraCIAPI::VehicleScope::getIDCount(), TraCIAPI::EdgeScope::getIDList(), TraCIAPI::InductionLoopScope::getIDList(), TraCIAPI::RouteScope::getIDList(), TraCIAPI::TrafficLightScope::getIDList(), TraCIAPI::VehicleTypeScope::getIDList(), TraCIAPI::VehicleScope::getIDList(), TraCIAPI::PersonScope::getIDList(), TraCIAPI::VehicleScope::getLaneID(), TraCIAPI::VehicleScope::getLanePosition(), TraCIAPI::VehicleTypeScope::getLateralAlignment(), TraCIAPI::VehicleScope::getLateralLanePosition(), TraCIAPI::VehicleScope::getLine(), 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::GUIScope::getSchema(), TraCIAPI::VehicleScope::getShapeClass(), TraCIAPI::VehicleScope::getSlope(), TraCIAPI::PersonScope::getSpeed(), TraCIAPI::VehicleScope::getSpeedMode(), TraCIAPI::PersonScope::getStage(), TraCIAPI::SimulationScope::getSubscriptionResults(), TraCIAPI::EdgeScope::getTraveltime(), TraCIAPI::PersonScope::getTypeID(), TraCIAPI::PersonScope::getVehicle(), TraCIAPI::InductionLoopScope::getVehicleData(), TraCIAPI::VehicleScope::getVia(), TraCIAPI::VehicleScope::getWaitingTime(), TraCIAPI::PersonScope::getWaitingTime(), TraCIAPI::VehicleTypeScope::getWidth(), TraCIAPI::gui, TraCIVehicleData::id, TraCIAPI::inductionloop, joinToString(), TraCIVehicleData::leaveTime, TraCIVehicleData::length, TraCIAPI::load(), TraCIAPI::VehicleScope::moveToXY(), TraCIAPI::person, TraCIColor::r, TraCIAPI::VehicleScope::remove(), TraCIAPI::PersonScope::removeStage(), TraCIAPI::PersonScope::removeStages(), TraCIAPI::route, TraCIAPI::GUIScope::screenshot(), TraCIAPI::VehicleScope::setColor(), TraCIAPI::PersonScope::setColor(), TraCIAPI::EdgeScope::setEffort(), 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::GUIScope::setSchema(), TraCIAPI::VehicleScope::setShapeClass(), TraCIAPI::PersonScope::setSpeed(), TraCIAPI::PersonScope::setType(), TraCIAPI::VehicleScope::setVia(), TraCIAPI::VehicleTypeScope::setWidth(), TraCIAPI::PersonScope::setWidth(), TraCIAPI::simulation, TraCIAPI::simulationStep(), TraCIAPI::SimulationScope::subscribe(), TraCIAPI::SimulationScope::subscribeContext(), TIME2STEPS, TraCIAPI::trafficlights, TraCIVehicleData::typeID, VAR_LANEPOSITION, VAR_ROAD_ID, TraCIAPI::vehicle, and TraCIAPI::vehicletype.
Referenced by run().
|
inlinestaticprotectedinherited |
Definition at line 883 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 345 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 362 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 318 of file TraCITestClient.cpp.
References answerLog, and outputFileName.
Referenced by ~TraCITestClient().
|
private |
Stream containing the log.
Definition at line 196 of file TraCITestClient.h.
Referenced by commandClose(), commandGetVariable(), commandSetValue(), commandSimulationStep(), commandSubscribeContextVariable(), commandSubscribeObjectVariable(), errorMsg(), readAndReportTypeDependent(), testAPI(), TraCITestClient(), validateSimulationStep2(), validateSubscription(), and writeResult().
|
inherited |
Scope for interaction with edges.
Definition at line 768 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with the gui.
Definition at line 770 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with inductive loops.
Definition at line 772 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with junctions.
Definition at line 774 of file TraCIAPI.h.
|
inherited |
Scope for interaction with lanes.
Definition at line 776 of file TraCIAPI.h.
|
inherited |
Scope for interaction with lanes.
Definition at line 778 of file TraCIAPI.h.
|
inherited |
Scope for interaction with multi-entry/-exit detectors.
Definition at line 780 of file TraCIAPI.h.
|
protectedinherited |
The socket.
Definition at line 896 of file TraCIAPI.h.
Referenced by TraCIAPI::check_resultState(), TraCIAPI::closeSocket(), TraCIAPI::connect(), TraCIAPI::load(), TraCIAPI::send_commandClose(), TraCIAPI::send_commandGetVariable(), TraCIAPI::send_commandSetValue(), TraCIAPI::send_commandSimulationStep(), TraCIAPI::send_commandSubscribeObjectContext(), TraCIAPI::send_commandSubscribeObjectVariable(), and TraCIAPI::~TraCIAPI().
|
protectedinherited |
Definition at line 899 of file TraCIAPI.h.
Referenced by TraCIAPI::readContextSubscription(), and TraCIAPI::simulationStep().
|
protectedinherited |
Definition at line 898 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 193 of file TraCITestClient.h.
Referenced by writeResult().
|
inherited |
Scope for interaction with persons.
Definition at line 782 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with POIs.
Definition at line 784 of file TraCIAPI.h.
|
inherited |
Scope for interaction with polygons.
Definition at line 786 of file TraCIAPI.h.
|
inherited |
Scope for interaction with routes.
Definition at line 788 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with the simulation.
Definition at line 790 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with traffic lights.
Definition at line 792 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with vehicles.
Definition at line 794 of file TraCIAPI.h.
Referenced by testAPI().
|
inherited |
Scope for interaction with vehicle types.
Definition at line 796 of file TraCIAPI.h.
Referenced by testAPI().