|
SUMO - Simulation of Urban MObility
|
C++ TraCI client API implementation. More...
#include <TraCIAPI.h>


Data Structures | |
| class | AreaScope |
| Scope for interaction with areal detectors. More... | |
| class | EdgeScope |
| Scope for interaction with edges. More... | |
| class | GUIScope |
| Scope for interaction with the gui. More... | |
| class | InductionLoopScope |
| Scope for interaction with inductive loops. More... | |
| class | JunctionScope |
| Scope for interaction with junctions. More... | |
| class | LaneScope |
| Scope for interaction with lanes. More... | |
| class | MeMeScope |
| Scope for interaction with multi entry/-exit detectors. More... | |
| class | POIScope |
| Scope for interaction with POIs. More... | |
| class | PolygonScope |
| Scope for interaction with polygons. More... | |
| class | RouteScope |
| Scope for interaction with routes. More... | |
| class | SimulationScope |
| Scope for interaction with the simulation. More... | |
| struct | TraCIBoundary |
| A 3D-bounding box. More... | |
| struct | TraCIColor |
| class | TraCILink |
| class | TraCILogic |
| class | TraCIPhase |
| struct | TraCIPosition |
| A 3D-position. More... | |
| class | TraCIScopeWrapper |
| An abstract interface for accessing type-dependent values. More... | |
| class | TrafficLightScope |
| Scope for interaction with traffic lights. More... | |
| class | VehicleTypeScope |
| Scope for interaction with vehicle types. More... | |
Public Types | |
Structures definitions | |
| typedef std::vector< TraCIPosition > | TraCIPositionVector |
Public Member Functions | |
| void | simulationStep (SUMOTime time=0) |
| Advances by one step (or up to the given time) More... | |
| TraCIAPI () | |
| Constructor. More... | |
| ~TraCIAPI () | |
| Destructor. More... | |
Connection handling | |
| void | connect (const std::string &host, int port) |
| Connects to the specified SUMO server. More... | |
| void | close () |
| 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) |
| SUMOReal | getFloat (int cmd, int var, const std::string &id, tcpip::Storage *add=0) |
| SUMOReal | 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... | |
| MeMeScope | multientryexit |
| Scope for interaction with multi-entry/-exit detectors. 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... | |
| VehicleTypeScope | vehicletype |
| Scope for interaction with vehicle types. More... | |
Protected Member Functions | |
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, SUMOReal 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... | |
| void | check_commandGetResult (tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const |
| void | processGET (tcpip::Storage &inMsg, int command, int expectedType, bool ignoreCommandId=false) const |
Protected Attributes | |
| tcpip::Socket * | mySocket |
| The socket. More... | |
C++ TraCI client API implementation.
Definition at line 54 of file TraCIAPI.h.
| typedef std::vector<TraCIPosition> TraCIAPI::TraCIPositionVector |
Definition at line 76 of file TraCIAPI.h.
| TraCIAPI::TraCIAPI | ( | ) |
Constructor.
Definition at line 52 of file TraCIAPI.cpp.
| TraCIAPI::~TraCIAPI | ( | ) |
|
protected |
Definition at line 265 of file TraCIAPI.cpp.
References tcpip::Storage::position(), tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), and toString().
Referenced by TraCITestClient::commandGetVariable(), and processGET().
|
protected |
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 226 of file TraCIAPI.cpp.
References mySocket, tcpip::Storage::position(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), tcpip::Socket::receiveExact(), RTYPE_ERR, RTYPE_NOTIMPLEMENTED, RTYPE_OK, and toString().
Referenced by TraCITestClient::commandClose(), TraCITestClient::commandGetVariable(), TraCITestClient::commandSetValue(), TraCITestClient::commandSimulationStep(), TraCITestClient::commandSubscribeContextVariable(), TraCITestClient::commandSubscribeObjectVariable(), processGET(), and simulationStep().
| void TraCIAPI::close | ( | ) |
Closes the connection.
Definition at line 82 of file TraCIAPI.cpp.
References tcpip::Socket::close(), and mySocket.
Referenced by TraCITestClient::run().
| void TraCIAPI::connect | ( | const std::string & | host, |
| int | port | ||
| ) |
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 69 of file TraCIAPI.cpp.
References tcpip::Socket::connect(), and mySocket.
Referenced by TraCITestClient::run().
| TraCIAPI::TraCIBoundary TraCIAPI::getBoundingBox | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 351 of file TraCIAPI.cpp.
References processGET(), tcpip::Storage::readDouble(), send_commandGetVariable(), TYPE_BOUNDINGBOX, TraCIAPI::TraCIBoundary::xMax, TraCIAPI::TraCIBoundary::xMin, TraCIAPI::TraCIBoundary::yMax, TraCIAPI::TraCIBoundary::yMin, TraCIAPI::TraCIBoundary::zMax, and TraCIAPI::TraCIBoundary::zMin.
| int TraCIAPI::getByte | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 315 of file TraCIAPI.cpp.
References processGET(), tcpip::Storage::readByte(), send_commandGetVariable(), and TYPE_BYTE.
| TraCIAPI::TraCIColor TraCIAPI::getColor | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 421 of file TraCIAPI.cpp.
References TraCIAPI::TraCIColor::a, TraCIAPI::TraCIColor::b, TraCIAPI::TraCIColor::g, processGET(), TraCIAPI::TraCIColor::r, tcpip::Storage::readUnsignedByte(), send_commandGetVariable(), and TYPE_COLOR.
| SUMOReal TraCIAPI::getDouble | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 342 of file TraCIAPI.cpp.
References processGET(), tcpip::Storage::readDouble(), send_commandGetVariable(), and TYPE_DOUBLE.
| SUMOReal TraCIAPI::getFloat | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 333 of file TraCIAPI.cpp.
References processGET(), tcpip::Storage::readFloat(), send_commandGetVariable(), and TYPE_FLOAT.
| int TraCIAPI::getInt | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 324 of file TraCIAPI.cpp.
References processGET(), tcpip::Storage::readInt(), send_commandGetVariable(), and TYPE_INTEGER.
| TraCIAPI::TraCIPositionVector TraCIAPI::getPolygon | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 367 of file TraCIAPI.cpp.
References processGET(), tcpip::Storage::readDouble(), tcpip::Storage::readInt(), send_commandGetVariable(), TYPE_POLYGON, TraCIAPI::TraCIPosition::x, TraCIAPI::TraCIPosition::y, and TraCIAPI::TraCIPosition::z.
| TraCIAPI::TraCIPosition TraCIAPI::getPosition | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 385 of file TraCIAPI.cpp.
References POSITION_2D, processGET(), tcpip::Storage::readDouble(), send_commandGetVariable(), TraCIAPI::TraCIPosition::x, TraCIAPI::TraCIPosition::y, and TraCIAPI::TraCIPosition::z.
| std::string TraCIAPI::getString | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 398 of file TraCIAPI.cpp.
References processGET(), tcpip::Storage::readString(), send_commandGetVariable(), and TYPE_STRING.
| std::vector< std::string > TraCIAPI::getStringVector | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 407 of file TraCIAPI.cpp.
References processGET(), tcpip::Storage::readInt(), tcpip::Storage::readString(), send_commandGetVariable(), and TYPE_STRINGLIST.
Referenced by TraCIAPI::EdgeScope::getIDList().
| SUMOTime TraCIAPI::getSUMOTime | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 297 of file TraCIAPI.cpp.
References processGET(), tcpip::Storage::readInt(), send_commandGetVariable(), and TYPE_INTEGER.
| int TraCIAPI::getUnsignedByte | ( | int | cmd, |
| int | var, | ||
| const std::string & | id, | ||
| tcpip::Storage * | add = 0 |
||
| ) |
Definition at line 306 of file TraCIAPI.cpp.
References processGET(), tcpip::Storage::readUnsignedByte(), send_commandGetVariable(), and TYPE_UBYTE.
|
protected |
Definition at line 288 of file TraCIAPI.cpp.
References check_commandGetResult(), and check_resultState().
Referenced by getBoundingBox(), getByte(), getColor(), getDouble(), getFloat(), getInt(), getPolygon(), getPosition(), getString(), getStringVector(), getSUMOTime(), and getUnsignedByte().
|
protected |
Sends a Close command.
Definition at line 106 of file TraCIAPI.cpp.
References CMD_CLOSE, mySocket, tcpip::Socket::sendExact(), and tcpip::Storage::writeUnsignedByte().
Referenced by TraCITestClient::commandClose().
|
protected |
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 117 of file TraCIAPI.cpp.
References mySocket, tcpip::Socket::sendExact(), tcpip::Storage::size(), tcpip::Storage::writeStorage(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
Referenced by TraCITestClient::commandGetVariable(), getBoundingBox(), getByte(), getColor(), getDouble(), getFloat(), getInt(), getPolygon(), getPosition(), getString(), getStringVector(), getSUMOTime(), and getUnsignedByte().
|
protected |
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 144 of file TraCIAPI.cpp.
References mySocket, tcpip::Socket::sendExact(), tcpip::Storage::size(), tcpip::Storage::writeStorage(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
Referenced by TraCITestClient::commandSetValue().
|
protected |
Sends a SimulationStep command.
Definition at line 93 of file TraCIAPI.cpp.
References CMD_SIMSTEP2, mySocket, tcpip::Socket::sendExact(), tcpip::Storage::writeInt(), and tcpip::Storage::writeUnsignedByte().
Referenced by TraCITestClient::commandSimulationStep(), and simulationStep().
|
protected |
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 193 of file TraCIAPI.cpp.
References mySocket, tcpip::Socket::sendExact(), tcpip::Storage::size(), tcpip::Storage::writeDouble(), tcpip::Storage::writeInt(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
Referenced by TraCITestClient::commandSubscribeContextVariable().
|
protected |
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 165 of file TraCIAPI.cpp.
References mySocket, tcpip::Socket::sendExact(), tcpip::Storage::size(), tcpip::Storage::writeInt(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
Referenced by TraCITestClient::commandSubscribeObjectVariable().
| void TraCIAPI::simulationStep | ( | SUMOTime | time = 0 | ) |
Advances by one step (or up to the given time)
Definition at line 435 of file TraCIAPI.cpp.
References check_resultState(), CMD_SIMSTEP2, and send_commandSimulationStep().
| EdgeScope TraCIAPI::edge |
Scope for interaction with edges.
Definition at line 648 of file TraCIAPI.h.
Referenced by TraCITestClient::testAPI().
| GUIScope TraCIAPI::gui |
Scope for interaction with the gui.
Definition at line 650 of file TraCIAPI.h.
| InductionLoopScope TraCIAPI::inductionloop |
Scope for interaction with inductive loops.
Definition at line 652 of file TraCIAPI.h.
| JunctionScope TraCIAPI::junction |
Scope for interaction with junctions.
Definition at line 654 of file TraCIAPI.h.
| LaneScope TraCIAPI::lane |
Scope for interaction with lanes.
Definition at line 656 of file TraCIAPI.h.
| MeMeScope TraCIAPI::multientryexit |
Scope for interaction with multi-entry/-exit detectors.
Definition at line 658 of file TraCIAPI.h.
|
protected |
The socket.
Definition at line 749 of file TraCIAPI.h.
Referenced by check_resultState(), close(), connect(), send_commandClose(), send_commandGetVariable(), send_commandSetValue(), send_commandSimulationStep(), send_commandSubscribeObjectContext(), send_commandSubscribeObjectVariable(), and ~TraCIAPI().
| POIScope TraCIAPI::poi |
Scope for interaction with POIs.
Definition at line 660 of file TraCIAPI.h.
| PolygonScope TraCIAPI::polygon |
Scope for interaction with polygons.
Definition at line 662 of file TraCIAPI.h.
| RouteScope TraCIAPI::route |
Scope for interaction with routes.
Definition at line 664 of file TraCIAPI.h.
| SimulationScope TraCIAPI::simulation |
Scope for interaction with the simulation.
Definition at line 666 of file TraCIAPI.h.
Referenced by TraCITestClient::testAPI().
| TrafficLightScope TraCIAPI::trafficlights |
Scope for interaction with traffic lights.
Definition at line 668 of file TraCIAPI.h.
| VehicleTypeScope TraCIAPI::vehicletype |
Scope for interaction with vehicle types.
Definition at line 670 of file TraCIAPI.h.