Eclipse SUMO - Simulation of Urban MObility
TraCITestClient Class Reference

A test execution class. More...

#include <TraCITestClient.h>

Inheritance diagram for TraCITestClient:
[legend]
Collaboration diagram for TraCITestClient:
[legend]

Public Member Functions

std::pair< int, std::string > getVersion ()
 return TraCI API and SUMO version More...
 
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 (double 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...
 

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...
 
RerouterScope rerouter
 Scope for interaction with rerouters. More...
 
RouteScope route
 Scope for interaction with routes. More...
 
RouteProbeScope routeprobe
 Scope for interaction with route probes. 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 (int cmdId, tcpip::Storage &inMsg)
 
void readVariables (tcpip::Storage &inMsg, const std::string &objectID, int variableCount, libsumo::SubscriptionResults &into)
 
void readVariableSubscription (int cmdId, tcpip::Storage &inMsg)
 
Commands handling
void commandSimulationStep (double 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, double beginTime, double endTime, int varNo, std::ifstream &defFile)
 Sends and validates a SubscribeVariable command. More...
 
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. More...
 
Command sending methods
void send_commandSimulationStep (double 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 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. More...
 
void createFilterCommand (int cmdID, int varID, tcpip::Storage *add=nullptr) const
 
void send_commandSubscribeObjectVariable (int domID, const std::string &objID, double beginTime, double endTime, const std::vector< int > &vars) const
 Sends a SubscribeVariable request. More...
 
void send_commandSubscribeObjectContext (int domID, const std::string &objID, double beginTime, double 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...
 
bool processGet (int command, int expectedType, bool ignoreCommandId=false)
 
bool processSet (int command)
 

Static Protected Member Functions

template<class T >
static std::string toString (const T &t, std::streamsize accuracy=PRECISION)
 

Protected Attributes

std::map< int, TraCIScopeWrapper * > myDomains
 
tcpip::Storage myInput
 The reusable input storage. More...
 
tcpip::Storage myOutput
 The reusable output storage. More...
 
tcpip::SocketmySocket
 The socket. More...
 

Private Member Functions

std::string joinToString (const std::map< std::string, std::string > &m)
 
std::string joinToString (const std::vector< double > &v, const std::string &between)
 
std::string joinToString (const std::vector< std::string > &s, const std::string &between)
 
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...
 

Detailed Description

A test execution class.

Reads a program file and executes the actions stored within it

Definition at line 42 of file TraCITestClient.h.

Constructor & Destructor Documentation

◆ TraCITestClient()

TraCITestClient::TraCITestClient ( std::string  outputFileName = "testclient_result.out")

Constructor.

Parameters
[in]outputFileNameThe name of the file the outputs will be written into

Definition at line 53 of file TraCITestClient.cpp.

References answerLog.

◆ ~TraCITestClient()

TraCITestClient::~TraCITestClient ( )

Destructor.

Definition at line 61 of file TraCITestClient.cpp.

References writeResult().

Member Function Documentation

◆ check_commandGetResult()

int TraCIAPI::check_commandGetResult ( tcpip::Storage inMsg,
int  command,
int  expectedType = -1,
bool  ignoreCommandId = false 
) const
protectedinherited

Validates the result state of a command.

Returns
The command Id

Definition at line 299 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().

Here is the caller graph for this function:

◆ check_resultState()

void TraCIAPI::check_resultState ( tcpip::Storage inMsg,
int  command,
bool  ignoreCommandId = false,
std::string *  acknowledgement = 0 
) const
protectedinherited

Validates the result state of a command.

Parameters
[in]inMsgThe buffer to read the message from
[in]commandThe original command id
[in]ignoreCommandIdWhether the returning command id shall be validated
[in]acknowledgementPointer to an existing string into which the acknowledgement message shall be inserted

Definition at line 260 of file TraCIAPI.cpp.

References TraCIAPI::mySocket, tcpip::Storage::position(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), tcpip::Socket::receiveExact(), libsumo::RTYPE_ERR, libsumo::RTYPE_NOTIMPLEMENTED, libsumo::RTYPE_OK, and TraCIAPI::toString().

Referenced by TraCIAPI::close(), commandClose(), commandGetVariable(), commandSetOrder(), commandSetValue(), commandSimulationStep(), commandSubscribeContextVariable(), commandSubscribeObjectVariable(), TraCIAPI::getVersion(), TraCIAPI::load(), TraCIAPI::processGet(), TraCIAPI::processSet(), TraCIAPI::setOrder(), and TraCIAPI::simulationStep().

Here is the caller graph for this function:

◆ close()

void TraCIAPI::close ( )
inherited

ends the simulation and closes the connection

Definition at line 96 of file TraCIAPI.cpp.

References TraCIAPI::check_resultState(), TraCIAPI::closeSocket(), libsumo::CMD_CLOSE, and TraCIAPI::send_commandClose().

◆ closeSocket()

void TraCIAPI::closeSocket ( )
protectedinherited

Closes the connection.

Definition at line 106 of file TraCIAPI.cpp.

References tcpip::Socket::close(), and TraCIAPI::mySocket.

Referenced by TraCIAPI::close(), and run().

Here is the caller graph for this function:

◆ commandClose()

void TraCITestClient::commandClose ( )
protected

Sends and validates a Close command.

Definition at line 196 of file TraCITestClient.cpp.

References answerLog, TraCIAPI::check_resultState(), libsumo::CMD_CLOSE, and TraCIAPI::send_commandClose().

Referenced by run().

Here is the caller graph for this function:

◆ commandGetVariable()

void TraCITestClient::commandGetVariable ( int  domID,
int  varID,
const std::string &  objID,
tcpip::Storage addData = 0 
)
protected

Sends and validates a GetVariable command.

Parameters
[in]domIDThe ID of the domain the addressed object belongs to
[in]varIDThe ID of the variable one asks for
[in]objIDThe ID of the object a variable shall be retrieved from
[in]addDataStorage to read additional data from, if needed

Definition at line 226 of file TraCITestClient.cpp.

References answerLog, TraCIAPI::check_commandGetResult(), TraCIAPI::check_resultState(), TraCIAPI::createCommand(), errorMsg(), TraCIAPI::myOutput, TraCIAPI::mySocket, readAndReportTypeDependent(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), and tcpip::Socket::sendExact().

Referenced by run().

Here is the caller graph for this function:

◆ commandSetOrder()

void TraCITestClient::commandSetOrder ( int  order)
protected

Sends and validates a SetOrder command.

Definition at line 211 of file TraCITestClient.cpp.

References answerLog, TraCIAPI::check_resultState(), libsumo::CMD_SETORDER, and TraCIAPI::send_commandSetOrder().

Referenced by run().

Here is the caller graph for this function:

◆ commandSetValue()

void TraCITestClient::commandSetValue ( int  domID,
int  varID,
const std::string &  objID,
std::ifstream &  defFile 
)
protected

Sends and validates a SetVariable command.

Parameters
[in]domIDThe ID of the domain the addressed object belongs to
[in]varIDThe ID of the variable to set
[in]objIDThe ID of the object which shall be changed
[in]defFileStorage to read additional data from

Definition at line 260 of file TraCITestClient.cpp.

References answerLog, TraCIAPI::check_resultState(), TraCIAPI::createCommand(), errorMsg(), TraCIAPI::myOutput, TraCIAPI::mySocket, tcpip::Socket::sendExact(), and setValueTypeDependant().

Referenced by run().

Here is the caller graph for this function:

◆ commandSimulationStep()

void TraCITestClient::commandSimulationStep ( double  time)
protected

Sends and validates a simulation step command.

Parameters
[in]timeThe time step to send

Definition at line 180 of file TraCITestClient.cpp.

References answerLog, TraCIAPI::check_resultState(), libsumo::CMD_SIMSTEP, TraCIAPI::send_commandSimulationStep(), and validateSimulationStep2().

Referenced by run().

Here is the caller graph for this function:

◆ commandSubscribeContextVariable()

void TraCITestClient::commandSubscribeContextVariable ( int  domID,
const std::string &  objID,
double  beginTime,
double  endTime,
int  domain,
double  range,
int  varNo,
std::ifstream &  defFile 
)
protected

Sends and validates a SubscribeContext command.

Parameters
[in]domIDThe ID of the domain the addressed object belongs to
[in]objIDThe ID of the object a variable shall be subscribed from
[in]beginTimeThe time the subscription shall begin at
[in]endTimeThe time the subscription shall end at
[in]domainThe domain of the objects which shall be reported
[in]rangeThe range within which objects shall be for being reported
[in]varNoThe number of subscribed variables
[in]defFileThe stream to read variable values from

Definition at line 308 of file TraCITestClient.cpp.

References answerLog, TraCIAPI::check_resultState(), TraCIAPI::send_commandSubscribeObjectContext(), and validateSubscription().

Referenced by run().

Here is the caller graph for this function:

◆ commandSubscribeObjectVariable()

void TraCITestClient::commandSubscribeObjectVariable ( int  domID,
const std::string &  objID,
double  beginTime,
double  endTime,
int  varNo,
std::ifstream &  defFile 
)
protected

Sends and validates a SubscribeVariable command.

Parameters
[in]domIDThe ID of the domain the addressed object belongs to
[in]objIDThe ID of the object a variable shall be subscribed from
[in]beginTimeThe time the subscription shall begin at
[in]endTimeThe time the subscription shall end at
[in]varNoThe number of subscribed variables
[in]defFileThe stream to read variable values from

Definition at line 284 of file TraCITestClient.cpp.

References answerLog, TraCIAPI::check_resultState(), TraCIAPI::send_commandSubscribeObjectVariable(), and validateSubscription().

Referenced by run().

Here is the caller graph for this function:

◆ connect()

void TraCIAPI::connect ( const std::string &  host,
int  port 
)
inherited

Connects to the specified SUMO server.

Parameters
[in]hostThe name of the host to connect to
[in]portThe port to connect to
Exceptions
tcpip::SocketExceptionif the connection fails

Definition at line 68 of file TraCIAPI.cpp.

References tcpip::Socket::connect(), and TraCIAPI::mySocket.

Referenced by joinToString(), and run().

Here is the caller graph for this function:

◆ createCommand()

void TraCIAPI::createCommand ( int  cmdID,
int  varID,
const std::string &  objID,
tcpip::Storage add = nullptr 
) const
protectedinherited

Sends a GetVariable / SetVariable request if mySocket is connected. Otherwise writes to myOutput only.

Parameters
[in]cmdIDThe command and domain of the variable
[in]varIDThe variable to retrieve
[in]objIDThe object to retrieve the variable from
[in]addOptional additional parameter

Definition at line 154 of file TraCIAPI.cpp.

References TraCIAPI::myOutput, tcpip::Storage::reset(), tcpip::Storage::size(), tcpip::Storage::writeInt(), tcpip::Storage::writeStorage(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().

Referenced by commandGetVariable(), and commandSetValue().

Here is the caller graph for this function:

◆ createFilterCommand()

void TraCIAPI::createFilterCommand ( int  cmdID,
int  varID,
tcpip::Storage add = nullptr 
) const
protectedinherited

◆ errorMsg()

void TraCITestClient::errorMsg ( std::stringstream &  msg)
private

Writes an error message.

Parameters
[in]msgThe message to write

Definition at line 351 of file TraCITestClient.cpp.

References answerLog.

Referenced by commandGetVariable(), commandSetValue(), and run().

Here is the caller graph for this function:

◆ getVersion()

std::pair< int, std::string > TraCIAPI::getVersion ( )
inherited

return TraCI API and SUMO version

Definition at line 479 of file TraCIAPI.cpp.

References TraCIAPI::check_resultState(), libsumo::CMD_GETVERSION, TraCIAPI::mySocket, tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), tcpip::Socket::sendExact(), and tcpip::Storage::writeUnsignedByte().

Referenced by testAPI().

Here is the caller graph for this function:

◆ joinToString() [1/3]

std::string TraCITestClient::joinToString ( const std::map< std::string, std::string > &  m)
inlineprivate

Definition at line 200 of file TraCITestClient.h.

References TraCIAPI::connect().

◆ joinToString() [2/3]

std::string TraCITestClient::joinToString ( const std::vector< double > &  v,
const std::string &  between 
)
inlineprivate

Definition at line 214 of file TraCITestClient.h.

References TraCIAPI::connect().

◆ joinToString() [3/3]

std::string TraCITestClient::joinToString ( const std::vector< std::string > &  s,
const std::string &  between 
)
inlineprivate

Definition at line 186 of file TraCITestClient.h.

References TraCIAPI::connect().

Referenced by testAPI().

Here is the caller graph for this function:

◆ load()

void TraCIAPI::load ( const std::vector< std::string > &  args)
inherited

Let sumo load a simulation using the given command line like options.

Definition at line 461 of file TraCIAPI.cpp.

References TraCIAPI::check_resultState(), libsumo::CMD_LOAD, TraCIAPI::mySocket, tcpip::Socket::sendExact(), libsumo::TYPE_STRINGLIST, tcpip::Storage::writeInt(), tcpip::Storage::writeStringList(), and tcpip::Storage::writeUnsignedByte().

Referenced by testAPI().

Here is the caller graph for this function:

◆ processGet()

bool TraCIAPI::processGet ( int  command,
int  expectedType,
bool  ignoreCommandId = false 
)
protectedinherited

◆ processSet()

bool TraCIAPI::processSet ( int  command)
protectedinherited

◆ readAndReportTypeDependent()

void TraCITestClient::readAndReportTypeDependent ( tcpip::Storage inMsg,
int  valueDataType 
)
private

Reads a value of the given type from the given storage and reports it.

Parameters
[in]inMsgThe storage to read the value from
[in]valueDataTypeThe type of the expected value

Definition at line 568 of file TraCITestClient.cpp.

References answerLog, libsumo::POSITION_2D, libsumo::POSITION_3D, libsumo::POSITION_ROADMAP, tcpip::Storage::readByte(), tcpip::Storage::readDouble(), tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readStringList(), tcpip::Storage::readUnsignedByte(), libsumo::TYPE_BYTE, libsumo::TYPE_COLOR, libsumo::TYPE_COMPOUND, libsumo::TYPE_DOUBLE, libsumo::TYPE_INTEGER, libsumo::TYPE_POLYGON, libsumo::TYPE_STRING, libsumo::TYPE_STRINGLIST, and libsumo::TYPE_UBYTE.

Referenced by commandGetVariable(), and validateSubscription().

Here is the caller graph for this function:

◆ readContextSubscription()

void TraCIAPI::readContextSubscription ( int  cmdId,
tcpip::Storage inMsg 
)
protectedinherited

Definition at line 424 of file TraCIAPI.cpp.

References TraCIAPI::myDomains, tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), and TraCIAPI::readVariables().

Referenced by TraCIAPI::simulationStep().

Here is the caller graph for this function:

◆ readVariables()

void TraCIAPI::readVariables ( tcpip::Storage inMsg,
const std::string &  objectID,
int  variableCount,
libsumo::SubscriptionResults into 
)
protectedinherited

◆ readVariableSubscription()

void TraCIAPI::readVariableSubscription ( int  cmdId,
tcpip::Storage inMsg 
)
protectedinherited

Definition at line 416 of file TraCIAPI.cpp.

References TraCIAPI::myDomains, tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), and TraCIAPI::readVariables().

Referenced by TraCIAPI::simulationStep().

Here is the caller graph for this function:

◆ run()

int TraCITestClient::run ( std::string  fileName,
int  port,
std::string  host = "localhost" 
)

Runs a test.

Parameters
[in]fileNameThe name of the file containing the test script
[in]portThe server port to connect to
[in]hostThe server name to connect to

Definition at line 67 of file TraCITestClient.cpp.

References TraCIAPI::closeSocket(), commandClose(), commandGetVariable(), commandSetOrder(), commandSetValue(), commandSimulationStep(), commandSubscribeContextVariable(), commandSubscribeObjectVariable(), TraCIAPI::connect(), errorMsg(), setValueTypeDependant(), and testAPI().

Referenced by main().

Here is the caller graph for this function:

◆ send_commandClose()

void TraCIAPI::send_commandClose ( ) const
protectedinherited

Sends a Close command.

Definition at line 130 of file TraCIAPI.cpp.

References libsumo::CMD_CLOSE, TraCIAPI::mySocket, tcpip::Socket::sendExact(), and tcpip::Storage::writeUnsignedByte().

Referenced by TraCIAPI::close(), and commandClose().

Here is the caller graph for this function:

◆ send_commandSetOrder()

void TraCIAPI::send_commandSetOrder ( int  order) const
protectedinherited

Sends a SetOrder command.

Definition at line 141 of file TraCIAPI.cpp.

References libsumo::CMD_SETORDER, TraCIAPI::mySocket, tcpip::Socket::sendExact(), tcpip::Storage::writeInt(), and tcpip::Storage::writeUnsignedByte().

Referenced by commandSetOrder().

Here is the caller graph for this function:

◆ send_commandSimulationStep()

void TraCIAPI::send_commandSimulationStep ( double  time) const
protectedinherited

Sends a SimulationStep command.

Definition at line 117 of file TraCIAPI.cpp.

References libsumo::CMD_SIMSTEP, TraCIAPI::mySocket, tcpip::Socket::sendExact(), tcpip::Storage::writeDouble(), and tcpip::Storage::writeUnsignedByte().

Referenced by commandSimulationStep(), and TraCIAPI::simulationStep().

Here is the caller graph for this function:

◆ send_commandSubscribeObjectContext()

void TraCIAPI::send_commandSubscribeObjectContext ( int  domID,
const std::string &  objID,
double  beginTime,
double  endTime,
int  domain,
double  range,
const std::vector< int > &  vars 
) const
protectedinherited

Sends a SubscribeContext request.

Parameters
[in]domIDThe domain of the variable
[in]objIDThe object to subscribe the variables from
[in]beginTimeThe begin time step of subscriptions
[in]endTimeThe end time step of subscriptions
[in]domainThe domain of the objects which values shall be returned
[in]rangeThe range around the obj to investigate
[in]varsThe 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().

Here is the caller graph for this function:

◆ send_commandSubscribeObjectVariable()

void TraCIAPI::send_commandSubscribeObjectVariable ( int  domID,
const std::string &  objID,
double  beginTime,
double  endTime,
const std::vector< int > &  vars 
) const
protectedinherited

Sends a SubscribeVariable request.

Parameters
[in]domIDThe domain of the variable
[in]objIDThe object to subscribe the variables from
[in]beginTimeThe begin time step of subscriptions
[in]endTimeThe end time step of subscriptions
[in]varsThe variables to subscribe

Definition at line 201 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 commandSubscribeObjectVariable().

Here is the caller graph for this function:

◆ setOrder()

void TraCIAPI::setOrder ( int  order)
inherited

set priority (execution order) for the client

Definition at line 81 of file TraCIAPI.cpp.

References TraCIAPI::check_resultState(), libsumo::CMD_SETORDER, TraCIAPI::mySocket, tcpip::Socket::sendExact(), tcpip::Storage::writeInt(), and tcpip::Storage::writeUnsignedByte().

Referenced by testAPI().

Here is the caller graph for this function:

◆ setValueTypeDependant()

int TraCITestClient::setValueTypeDependant ( tcpip::Storage into,
std::ifstream &  defFile,
std::stringstream &  msg 
)
private

Parses the next value type / value pair from the stream and inserts it into the storage.

Parameters
[out]intoThe storage to add the value type and the value into
[in]defFileThe file to read the values from
[out]msgIf any error occurs, this should be filled
Returns
The number of written bytes

Definition at line 437 of file TraCITestClient.cpp.

References libsumo::POSITION_2D, libsumo::POSITION_3D, libsumo::POSITION_ROADMAP, libsumo::REQUEST_AIRDIST, libsumo::REQUEST_DRIVINGDIST, libsumo::TYPE_BYTE, libsumo::TYPE_COLOR, libsumo::TYPE_COMPOUND, libsumo::TYPE_DOUBLE, libsumo::TYPE_INTEGER, libsumo::TYPE_POLYGON, libsumo::TYPE_STRING, libsumo::TYPE_STRINGLIST, libsumo::TYPE_UBYTE, tcpip::Storage::writeByte(), tcpip::Storage::writeDouble(), tcpip::Storage::writeInt(), tcpip::Storage::writeString(), tcpip::Storage::writeStringList(), and tcpip::Storage::writeUnsignedByte().

Referenced by commandSetValue(), and run().

Here is the caller graph for this function:

◆ simulationStep()

void TraCIAPI::simulationStep ( double  time = 0)
inherited

Advances by one step (or up to the given time)

Definition at line 439 of file TraCIAPI.cpp.

References TraCIAPI::check_commandGetResult(), TraCIAPI::check_resultState(), libsumo::CMD_SIMSTEP, TraCIAPI::myDomains, TraCIAPI::readContextSubscription(), tcpip::Storage::readInt(), TraCIAPI::readVariableSubscription(), libsumo::RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE, libsumo::RESPONSE_SUBSCRIBE_PERSON_VARIABLE, and TraCIAPI::send_commandSimulationStep().

Referenced by testAPI().

Here is the caller graph for this function:

◆ testAPI()

void TraCITestClient::testAPI ( )
private

call all API methods once

Definition at line 646 of file TraCITestClient.cpp.

References libsumo::TraCIColor::a, TraCIAPI::EdgeScope::adaptTraveltime(), TraCIAPI::PersonScope::add(), TraCIAPI::RouteScope::add(), TraCIAPI::VehicleScope::add(), TraCIAPI::VehicleScope::addSubscriptionFilterCFManeuver(), TraCIAPI::VehicleScope::addSubscriptionFilterDownstreamDistance(), TraCIAPI::VehicleScope::addSubscriptionFilterFieldOfVision(), TraCIAPI::VehicleScope::addSubscriptionFilterLanes(), TraCIAPI::VehicleScope::addSubscriptionFilterLateralDistance(), TraCIAPI::VehicleScope::addSubscriptionFilterLCManeuver(), TraCIAPI::VehicleScope::addSubscriptionFilterLeadFollow(), TraCIAPI::VehicleScope::addSubscriptionFilterNoOpposite(), TraCIAPI::VehicleScope::addSubscriptionFilterTurn(), TraCIAPI::VehicleScope::addSubscriptionFilterUpstreamDistance(), TraCIAPI::VehicleScope::addSubscriptionFilterVClass(), TraCIAPI::VehicleScope::addSubscriptionFilterVType(), answerLog, TraCIAPI::PersonScope::appendDrivingStage(), TraCIAPI::PersonScope::appendStage(), TraCIAPI::PersonScope::appendWaitingStage(), TraCIAPI::PersonScope::appendWalkingStage(), libsumo::TraCIConnection::approachedInternal, libsumo::TraCIConnection::approachedLane, libsumo::TraCIStage::arrivalPos, libsumo::TraCIColor::b, TraCIAPI::VehicleScope::changeTarget(), libsumo::CMD_GET_VEHICLE_VARIABLE, TraCIAPI::SimulationScope::convert2D(), TraCIAPI::SimulationScope::convert3D(), TraCIAPI::SimulationScope::convertGeo(), TraCIAPI::SimulationScope::convertRoad(), TraCIAPI::VehicleTypeScope::copy(), libsumo::TraCIStage::description, libsumo::TraCIConnection::direction, libsumo::TraCINextTLSData::dist, TraCIAPI::edge, libsumo::TraCIStage::edges, libsumo::TraCIVehicleData::entryTime, TraCIAPI::SimulationScope::findRoute(), libsumo::TraCIColor::g, TraCIAPI::VehicleTypeScope::getAccel(), TraCIAPI::VehicleScope::getAcceleration(), TraCIAPI::VehicleScope::getAccumulatedWaitingTime(), TraCIAPI::EdgeScope::getAdaptedTraveltime(), TraCIAPI::TrafficLightScope::getAllProgramLogics(), TraCIAPI::PersonScope::getAngle(), TraCIAPI::VehicleTypeScope::getApparentDecel(), TraCIAPI::SimulationScope::getBusStopWaiting(), TraCIAPI::SimulationScope::getBusStopWaitingIDList(), TraCIAPI::PersonScope::getColor(), TraCIAPI::POIScope::getColor(), TraCIAPI::PolygonScope::getColor(), TraCIAPI::VehicleScope::getColor(), TraCIAPI::TraCIScopeWrapper::getContextSubscriptionResults(), TraCIAPI::TrafficLightScope::getControlledLanes(), TraCIAPI::TrafficLightScope::getControlledLinks(), TraCIAPI::SimulationScope::getCurrentTime(), TraCIAPI::SimulationScope::getDeltaT(), TraCIAPI::SimulationScope::getDistance2D(), TraCIAPI::SimulationScope::getDistanceRoad(), TraCIAPI::PersonScope::getEdges(), TraCIAPI::EdgeScope::getEffort(), TraCIAPI::VehicleTypeScope::getEmergencyDecel(), TraCIAPI::LaneScope::getFoes(), TraCIAPI::VehicleScope::getFollower(), TraCIAPI::VehicleScope::getFollowSpeed(), TraCIAPI::VehicleTypeScope::getHeight(), TraCIAPI::TraCIScopeWrapper::getIDCount(), TraCIAPI::TraCIScopeWrapper::getIDList(), TraCIAPI::LaneScope::getInternalFoes(), TraCIAPI::VehicleScope::getLaneChangeMode(), TraCIAPI::VehicleScope::getLaneChangeState(), TraCIAPI::PersonScope::getLaneID(), TraCIAPI::VehicleScope::getLaneID(), TraCIAPI::EdgeScope::getLaneNumber(), TraCIAPI::PersonScope::getLanePosition(), TraCIAPI::VehicleScope::getLanePosition(), TraCIAPI::VehicleTypeScope::getLateralAlignment(), TraCIAPI::VehicleScope::getLateralLanePosition(), TraCIAPI::VehicleScope::getLateralSpeed(), TraCIAPI::VehicleScope::getLeader(), TraCIAPI::PersonScope::getLength(), TraCIAPI::VehicleScope::getLine(), TraCIAPI::PolygonScope::getLineWidth(), TraCIAPI::LaneScope::getLinkNumber(), TraCIAPI::LaneScope::getLinks(), TraCIAPI::LaneScope::getMaxSpeed(), TraCIAPI::VehicleScope::getMaxSpeed(), TraCIAPI::VehicleTypeScope::getMaxSpeedLat(), TraCIAPI::VehicleTypeScope::getMinGapLat(), TraCIAPI::PersonScope::getNextEdge(), TraCIAPI::TrafficLightScope::getNextSwitch(), TraCIAPI::VehicleScope::getNextTLS(), TraCIAPI::SimulationScope::getOption(), TraCIAPI::TraCIScopeWrapper::getParameter(), TraCIAPI::TraCIScopeWrapper::getParameterWithKey(), TraCIAPI::VehicleTypeScope::getPersonCapacity(), TraCIAPI::VehicleScope::getPersonCapacity(), TraCIAPI::TrafficLightScope::getPhase(), TraCIAPI::TrafficLightScope::getPhaseDuration(), TraCIAPI::TrafficLightScope::getPhaseName(), TraCIAPI::PersonScope::getPosition(), TraCIAPI::POIScope::getPosition(), TraCIAPI::PersonScope::getPosition3D(), TraCIAPI::TrafficLightScope::getProgram(), TraCIAPI::TrafficLightScope::getRedYellowGreenState(), TraCIAPI::PersonScope::getRemainingStages(), TraCIAPI::PersonScope::getRoadID(), TraCIAPI::VehicleScope::getRoadID(), TraCIAPI::VehicleScope::getRoute(), TraCIAPI::VehicleScope::getRouteID(), TraCIAPI::VehicleScope::getRoutingMode(), TraCIAPI::GUIScope::getSchema(), TraCIAPI::VehicleScope::getSecureGap(), TraCIAPI::JunctionScope::getShape(), TraCIAPI::PolygonScope::getShape(), TraCIAPI::VehicleScope::getShapeClass(), TraCIAPI::VehicleScope::getSignals(), TraCIAPI::PersonScope::getSlope(), TraCIAPI::VehicleScope::getSlope(), TraCIAPI::PersonScope::getSpeed(), TraCIAPI::VehicleScope::getSpeed(), TraCIAPI::VehicleScope::getSpeedMode(), TraCIAPI::PersonScope::getStage(), TraCIAPI::VehicleScope::getStopDelay(), TraCIAPI::VehicleScope::getStopSpeed(), TraCIAPI::VehicleScope::getStopState(), TraCIAPI::EdgeScope::getStreetName(), libsumo::TraCIPosition::getString(), libsumo::TraCIRoadPosition::getString(), libsumo::TraCIColor::getString(), libsumo::TraCIPositionVector::getString(), TraCIAPI::TraCIScopeWrapper::getSubscriptionResults(), TraCIAPI::EdgeScope::getTraveltime(), TraCIAPI::PersonScope::getTypeID(), TraCIAPI::VehicleScope::getTypeID(), TraCIAPI::PersonScope::getVehicle(), TraCIAPI::InductionLoopScope::getVehicleData(), TraCIAPI::getVersion(), TraCIAPI::VehicleScope::getVia(), TraCIAPI::PersonScope::getWaitingTime(), TraCIAPI::VehicleScope::getWaitingTime(), TraCIAPI::VehicleTypeScope::getWidth(), TraCIAPI::GUIScope::getZoom(), TraCIAPI::gui, libsumo::TraCIConnection::hasFoe, libsumo::TraCIConnection::hasPrio, libsumo::TraCIVehicleData::id, libsumo::TraCINextTLSData::id, TraCIAPI::inductionloop, libsumo::TraCIConnection::isOpen, TraCIAPI::VehicleScope::isRouteValid(), joinToString(), TraCIAPI::junction, TraCIAPI::lane, libsumo::TraCIVehicleData::leaveTime, libsumo::TraCIConnection::length, libsumo::TraCIVehicleData::length, TraCIAPI::load(), TraCIAPI::VehicleScope::moveTo(), TraCIAPI::VehicleScope::moveToXY(), TraCIAPI::person, libsumo::TraCILogic::phases, TraCIAPI::poi, TraCIAPI::polygon, libsumo::TraCIColor::r, TraCIAPI::VehicleScope::remove(), TraCIAPI::PersonScope::removeStage(), TraCIAPI::PersonScope::removeStages(), TraCIAPI::PersonScope::rerouteTraveltime(), TraCIAPI::VehicleScope::rerouteTraveltime(), TraCIAPI::route, libsumo::ROUTING_MODE_AGGREGATED, TraCIAPI::GUIScope::screenshot(), TraCIAPI::VehicleTypeScope::setAccel(), TraCIAPI::VehicleTypeScope::setApparentDecel(), TraCIAPI::PersonScope::setColor(), TraCIAPI::VehicleScope::setColor(), TraCIAPI::EdgeScope::setEffort(), TraCIAPI::VehicleTypeScope::setEmergencyDecel(), TraCIAPI::PersonScope::setHeight(), TraCIAPI::VehicleTypeScope::setHeight(), TraCIAPI::VehicleScope::setLaneChangeMode(), TraCIAPI::VehicleTypeScope::setLateralAlignment(), TraCIAPI::PersonScope::setLength(), TraCIAPI::VehicleScope::setLine(), TraCIAPI::PolygonScope::setLineWidth(), TraCIAPI::EdgeScope::setMaxSpeed(), TraCIAPI::LaneScope::setMaxSpeed(), TraCIAPI::VehicleScope::setMaxSpeed(), TraCIAPI::VehicleTypeScope::setMaxSpeedLat(), TraCIAPI::PersonScope::setMinGap(), TraCIAPI::VehicleTypeScope::setMinGapLat(), TraCIAPI::setOrder(), TraCIAPI::TraCIScopeWrapper::setParameter(), TraCIAPI::TrafficLightScope::setPhase(), TraCIAPI::TrafficLightScope::setPhaseName(), TraCIAPI::TrafficLightScope::setProgramLogic(), TraCIAPI::TrafficLightScope::setRedYellowGreenState(), TraCIAPI::VehicleScope::setRoute(), TraCIAPI::VehicleScope::setRouteID(), TraCIAPI::VehicleScope::setRoutingMode(), TraCIAPI::GUIScope::setSchema(), TraCIAPI::PolygonScope::setShape(), TraCIAPI::VehicleScope::setShapeClass(), TraCIAPI::VehicleScope::setSignals(), TraCIAPI::PersonScope::setSpeed(), TraCIAPI::VehicleScope::setSpeedFactor(), TraCIAPI::VehicleScope::setSpeedMode(), TraCIAPI::PersonScope::setType(), TraCIAPI::VehicleScope::setType(), TraCIAPI::VehicleScope::setVia(), TraCIAPI::PersonScope::setWidth(), TraCIAPI::VehicleTypeScope::setWidth(), TraCIAPI::GUIScope::setZoom(), TraCIAPI::VehicleScope::SIGNAL_FOGLIGHT, TraCIAPI::simulation, TraCIAPI::simulationStep(), libsumo::STAGE_WALKING, libsumo::TraCIConnection::state, libsumo::TraCINextTLSData::state, TraCIAPI::TraCIScopeWrapper::subscribe(), TraCIAPI::TraCIScopeWrapper::subscribeContext(), libsumo::TraCINextTLSData::tlIndex, TraCIAPI::trafficlights, libsumo::TraCIVehicleData::typeID, libsumo::TraCIPositionVector::value, libsumo::VAR_LANEPOSITION, libsumo::VAR_ROAD_ID, libsumo::VAR_SPEED, TraCIAPI::vehicle, TraCIAPI::vehicletype, and TraCIAPI::SimulationScope::writeMessage().

Referenced by run().

Here is the caller graph for this function:

◆ toString()

template<class T >
static std::string TraCIAPI::toString ( const T &  t,
std::streamsize  accuracy = PRECISION 
)
inlinestaticprotectedinherited

Definition at line 942 of file TraCIAPI.h.

Referenced by TraCIAPI::VehicleScope::add(), TraCIAPI::check_commandGetResult(), TraCIAPI::check_resultState(), and TraCIAPI::readVariables().

Here is the caller graph for this function:

◆ validateSimulationStep2()

bool TraCITestClient::validateSimulationStep2 ( tcpip::Storage inMsg)
private

Validates whether the given message is a valid answer to CMD_SIMSTEP.

Parameters
[in]inMsgThe storage contain the message to validate
Returns
Whether the message is valid

Definition at line 362 of file TraCITestClient.cpp.

References answerLog, tcpip::Storage::readInt(), and validateSubscription().

Referenced by commandSimulationStep().

Here is the caller graph for this function:

◆ validateSubscription()

bool TraCITestClient::validateSubscription ( tcpip::Storage inMsg)
private

Validates whether the given message is a valid subscription return message.

Parameters
[in]inMsgThe storage contain the message to validate
Returns
Whether the message is valid

Definition at line 379 of file TraCITestClient.cpp.

References answerLog, readAndReportTypeDependent(), tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), libsumo::RESPONSE_SUBSCRIBE_GUI_CONTEXT, libsumo::RESPONSE_SUBSCRIBE_GUI_VARIABLE, libsumo::RESPONSE_SUBSCRIBE_INDUCTIONLOOP_CONTEXT, libsumo::RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE, and libsumo::RTYPE_OK.

Referenced by commandSubscribeContextVariable(), commandSubscribeObjectVariable(), and validateSimulationStep2().

Here is the caller graph for this function:

◆ writeResult()

void TraCITestClient::writeResult ( )
private

Writes the results file.

Definition at line 335 of file TraCITestClient.cpp.

References answerLog, and outputFileName.

Referenced by ~TraCITestClient().

Here is the caller graph for this function:

Field Documentation

◆ answerLog

◆ edge

EdgeScope TraCIAPI::edge
inherited

Scope for interaction with edges.

Definition at line 829 of file TraCIAPI.h.

Referenced by testAPI(), and TraCIAPI::TraCIAPI().

◆ gui

GUIScope TraCIAPI::gui
inherited

Scope for interaction with the gui.

Definition at line 831 of file TraCIAPI.h.

Referenced by testAPI(), and TraCIAPI::TraCIAPI().

◆ inductionloop

InductionLoopScope TraCIAPI::inductionloop
inherited

Scope for interaction with inductive loops.

Definition at line 833 of file TraCIAPI.h.

Referenced by testAPI().

◆ junction

JunctionScope TraCIAPI::junction
inherited

Scope for interaction with junctions.

Definition at line 835 of file TraCIAPI.h.

Referenced by testAPI(), and TraCIAPI::TraCIAPI().

◆ lane

LaneScope TraCIAPI::lane
inherited

Scope for interaction with lanes.

Definition at line 837 of file TraCIAPI.h.

Referenced by TraCIAPI::VehicleScope::moveToXY(), testAPI(), and TraCIAPI::TraCIAPI().

◆ lanearea

LaneAreaScope TraCIAPI::lanearea
inherited

Scope for interaction with lanes.

Definition at line 839 of file TraCIAPI.h.

Referenced by TraCIAPI::TraCIAPI().

◆ multientryexit

MeMeScope TraCIAPI::multientryexit
inherited

Scope for interaction with multi-entry/-exit detectors.

Definition at line 841 of file TraCIAPI.h.

Referenced by TraCIAPI::TraCIAPI().

◆ myDomains

std::map<int, TraCIScopeWrapper*> TraCIAPI::myDomains
protectedinherited

◆ myInput

tcpip::Storage TraCIAPI::myInput
mutableprotectedinherited

The reusable input storage.

Definition at line 960 of file TraCIAPI.h.

Referenced by TraCIAPI::processGet(), and TraCIAPI::processSet().

◆ myOutput

tcpip::Storage TraCIAPI::myOutput
mutableprotectedinherited

◆ mySocket

◆ outputFileName

std::string TraCITestClient::outputFileName
private

The name of the file to write the results log into.

Definition at line 230 of file TraCITestClient.h.

Referenced by writeResult().

◆ person

PersonScope TraCIAPI::person
inherited

Scope for interaction with persons.

Definition at line 843 of file TraCIAPI.h.

Referenced by testAPI(), and TraCIAPI::TraCIAPI().

◆ poi

POIScope TraCIAPI::poi
inherited

Scope for interaction with POIs.

Definition at line 845 of file TraCIAPI.h.

Referenced by testAPI(), and TraCIAPI::TraCIAPI().

◆ polygon

PolygonScope TraCIAPI::polygon
inherited

Scope for interaction with polygons.

Definition at line 847 of file TraCIAPI.h.

Referenced by testAPI(), and TraCIAPI::TraCIAPI().

◆ rerouter

RerouterScope TraCIAPI::rerouter
inherited

Scope for interaction with rerouters.

Definition at line 849 of file TraCIAPI.h.

Referenced by TraCIAPI::TraCIAPI().

◆ route

RouteScope TraCIAPI::route
inherited

Scope for interaction with routes.

Definition at line 851 of file TraCIAPI.h.

Referenced by testAPI(), and TraCIAPI::TraCIAPI().

◆ routeprobe

RouteProbeScope TraCIAPI::routeprobe
inherited

Scope for interaction with route probes.

Definition at line 853 of file TraCIAPI.h.

Referenced by TraCIAPI::TraCIAPI().

◆ simulation

SimulationScope TraCIAPI::simulation
inherited

Scope for interaction with the simulation.

Definition at line 855 of file TraCIAPI.h.

Referenced by testAPI(), and TraCIAPI::TraCIAPI().

◆ trafficlights

TrafficLightScope TraCIAPI::trafficlights
inherited

Scope for interaction with traffic lights.

Definition at line 857 of file TraCIAPI.h.

Referenced by testAPI(), and TraCIAPI::TraCIAPI().

◆ vehicle

VehicleScope TraCIAPI::vehicle
inherited

Scope for interaction with vehicles.

Definition at line 859 of file TraCIAPI.h.

Referenced by testAPI(), and TraCIAPI::TraCIAPI().

◆ vehicletype

VehicleTypeScope TraCIAPI::vehicletype
inherited

Scope for interaction with vehicle types.

Definition at line 861 of file TraCIAPI.h.

Referenced by testAPI(), and TraCIAPI::TraCIAPI().


The documentation for this class was generated from the following files: