SUMO - Simulation of Urban MObility
|
TraCI server used to control sumo by a remote TraCI client. More...
#include <TraCIServer.h>
Data Structures | |
class | Subscription |
Representation of a subscription. More... |
Public Types | |
typedef bool(* | CmdExecutor )(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage) |
Definition of a method to be called for serving an associated commandID. |
Public Member Functions | |
void | collectObjectsInRange (int domain, const PositionVector &shape, SUMOReal range, std::set< std::string > &into) |
SUMOTime | getTargetTime () |
const std::map < MSNet::VehicleState, std::vector< std::string > > & | getVehicleStateChanges () const |
void | postProcessVTD () |
void | setVTDControlled (MSVehicle *v, MSLane *l, SUMOReal pos, int edgeOffset, MSEdgeVector route) |
void | vehicleStateChanged (const SUMOVehicle *const vehicle, MSNet::VehicleState to) |
Called if a vehicle changes its state. | |
bool | vtdDebug () const |
void | writeResponseWithLength (tcpip::Storage &outputStorage, tcpip::Storage &tempMsg) |
Writing Status Messages | |
void | writeStatusCmd (int commandId, int status, const std::string &description, tcpip::Storage &outputStorage) |
Writes a status command to the given storage. | |
void | writeStatusCmd (int commandId, int status, const std::string &description) |
Writes a status command to myOutputStorage. | |
bool | writeErrorStatusCmd (int commandId, const std::string &description, tcpip::Storage &outputStorage) |
Writes a status command to the given storage with status = RTYPE_ERR. | |
Helpers for reading and checking values | |
bool | readTypeCheckingInt (tcpip::Storage &inputStorage, int &into) |
Reads the value type and an int, verifying the type. | |
bool | readTypeCheckingDouble (tcpip::Storage &inputStorage, double &into) |
Reads the value type and a double, verifying the type. | |
bool | readTypeCheckingString (tcpip::Storage &inputStorage, std::string &into) |
Reads the value type and a string, verifying the type. | |
bool | readTypeCheckingStringList (tcpip::Storage &inputStorage, std::vector< std::string > &into) |
Reads the value type and a string list, verifying the type. | |
bool | readTypeCheckingColor (tcpip::Storage &inputStorage, RGBColor &into) |
Reads the value type and a color, verifying the type. | |
bool | readTypeCheckingPosition2D (tcpip::Storage &inputStorage, Position &into) |
Reads the value type and a 2D position, verifying the type. | |
bool | readTypeCheckingBoundary (tcpip::Storage &inputStorage, Boundary &into) |
Reads the value type and a 2D bounding box, verifying the type. | |
bool | readTypeCheckingByte (tcpip::Storage &inputStorage, int &into) |
Reads the value type and a byte, verifying the type. | |
bool | readTypeCheckingUnsignedByte (tcpip::Storage &inputStorage, int &into) |
Reads the value type and an unsigned byte, verifying the type. | |
bool | readTypeCheckingPolygon (tcpip::Storage &inputStorage, PositionVector &into) |
Reads the value type and a polygon, verifying the type. |
Static Public Member Functions | |
static TraCIServer * | getInstance () |
static void | processCommandsUntilSimStep (SUMOTime step) |
process all commands until a simulation step is wanted | |
Initialisation and Shutdown | |
static void | openSocket (const std::map< int, CmdExecutor > &execs) |
Initialises the server. | |
static void | close () |
request termination of connection | |
static bool | wasClosed () |
check whether close was requested |
Private Member Functions | |
bool | addObjectVariableSubscription (const int commandId, const bool hasContext) |
int | dispatchCommand () |
bool | findObjectShape (int domain, const std::string &id, PositionVector &shape) |
void | initialiseSubscription (const Subscription &s) |
TraCIServer & | operator= (const TraCIServer &s) |
Invalidated assignment operator. | |
bool | processSingleSubscription (const TraCIServer::Subscription &s, tcpip::Storage &writeInto, std::string &errors) |
void | removeSubscription (int commandId, const std::string &identity, int domain) |
TraCIServer (const SUMOTime begin, const int port=0) | |
Constructor. | |
virtual | ~TraCIServer () |
Destructor. | |
Server-internal command handling | |
bool | commandGetVersion () |
Returns the TraCI-version. | |
bool | commandCloseConnection () |
Indicates the connection as being closed. | |
void | postProcessSimulationStep2 () |
Handles subscriptions to send after a simstep2 command. |
Private Attributes | |
const bool | myAmEmbedded |
Whether the server runs in embedded mode. | |
bool | myDoingSimStep |
Whether a step is currently done. | |
std::map< int, CmdExecutor > | myExecutors |
Map of commandIds -> their executors; applicable if the executor applies to the method footprint. | |
tcpip::Storage | myInputStorage |
The storage to read from. | |
LANE_RTREE_QUAL * | myLaneTree |
A storage of lanes. | |
std::map< int, NamedRTree * > | myObjects |
A storage of objects. | |
tcpip::Storage | myOutputStorage |
The storage to writeto. | |
std::map< int, int > | myParameterSizes |
Map of variable ids to the size of the parameter in bytes. | |
tcpip::Socket * | mySocket |
The socket on which server is listening on. | |
std::vector< Subscription > | mySubscriptions |
The list of known, still valid subscriptions. | |
SUMOTime | myTargetTime |
The time step to reach until processing the next commands. | |
std::map< MSNet::VehicleState, std::vector< std::string > > | myVehicleStateChanges |
Changes in the states of simulated vehicles. | |
std::map< std::string, MSVehicle * > | myVTDControlledVehicles |
Static Private Attributes | |
static bool | myDoCloseConnection = false |
Whether the connection was set to be to close. | |
static TraCIServer * | myInstance = 0 |
Singleton instance of the server. |
TraCI server used to control sumo by a remote TraCI client.
Definition at line 74 of file TraCIServer.h.
typedef bool(* TraCIServer::CmdExecutor)(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage) |
Definition of a method to be called for serving an associated commandID.
Definition at line 77 of file TraCIServer.h.
Constructor.
[in] | port | The port to listen to (to open) |
Definition at line 106 of file TraCIServer.cpp.
References tcpip::Socket::accept(), CMD_GET_AREAL_DETECTOR_VARIABLE, CMD_GET_EDGE_VARIABLE, CMD_GET_INDUCTIONLOOP_VARIABLE, CMD_GET_JUNCTION_VARIABLE, CMD_GET_LANE_VARIABLE, CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, CMD_GET_POI_VARIABLE, CMD_GET_POLYGON_VARIABLE, CMD_GET_ROUTE_VARIABLE, CMD_GET_SIM_VARIABLE, CMD_GET_TL_VARIABLE, CMD_GET_VEHICLE_VARIABLE, CMD_GET_VEHICLETYPE_VARIABLE, CMD_SET_EDGE_VARIABLE, CMD_SET_LANE_VARIABLE, CMD_SET_POI_VARIABLE, CMD_SET_POLYGON_VARIABLE, CMD_SET_ROUTE_VARIABLE, CMD_SET_SIM_VARIABLE, CMD_SET_TL_VARIABLE, CMD_SET_VEHICLE_VARIABLE, CMD_SET_VEHICLETYPE_VARIABLE, getInstance(), MsgHandler::getWarningInstance(), MSGlobals::gUsingInternalLanes, MsgHandler::inform(), myAmEmbedded, myDoCloseConnection, myExecutors, myParameterSizes, mySocket, myVehicleStateChanges, TraCIServerAPI_Edge::processGet(), TraCIServerAPI_InductionLoop::processGet(), TraCIServerAPI_ArealDetector::processGet(), TraCIServerAPI_Route::processGet(), TraCIServerAPI_MeMeDetector::processGet(), TraCIServerAPI_TLS::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_VehicleType::processGet(), TraCIServerAPI_Junction::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_Lane::processGet(), TraCIServerAPI_Edge::processSet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Route::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_TLS::processSet(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_Simulation::processSet(), TraCIServerAPI_Lane::processSet(), TraCIServerAPI_VehicleType::processSet(), toString(), VAR_LEADER, MSNet::VEHICLE_STATE_ARRIVED, MSNet::VEHICLE_STATE_BUILT, MSNet::VEHICLE_STATE_DEPARTED, MSNet::VEHICLE_STATE_ENDING_PARKING, MSNet::VEHICLE_STATE_ENDING_STOP, MSNet::VEHICLE_STATE_ENDING_TELEPORT, MSNet::VEHICLE_STATE_NEWROUTE, MSNet::VEHICLE_STATE_STARTING_PARKING, MSNet::VEHICLE_STATE_STARTING_STOP, MSNet::VEHICLE_STATE_STARTING_TELEPORT, tcpip::SocketException::what(), WRITE_MESSAGE, and WRITE_WARNING.
Referenced by openSocket().
|
privatevirtual |
Destructor.
Definition at line 169 of file TraCIServer.cpp.
References tcpip::Socket::close(), getInstance(), myLaneTree, myObjects, and mySocket.
|
private |
Definition at line 835 of file TraCIServer.cpp.
References initialiseSubscription(), myInputStorage, myParameterSizes, tcpip::Storage::readChar(), tcpip::Storage::readDouble(), tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), removeSubscription(), and SUMOReal.
Referenced by dispatchCommand().
|
static |
request termination of connection
Definition at line 198 of file TraCIServer.cpp.
References myDoCloseConnection, and myInstance.
Referenced by MSNet::closeSimulation().
void TraCIServer::collectObjectsInRange | ( | int | domain, |
const PositionVector & | shape, | ||
SUMOReal | range, | ||
std::set< std::string > & | into | ||
) |
Definition at line 684 of file TraCIServer.cpp.
References CMD_GET_EDGE_VARIABLE, CMD_GET_INDUCTIONLOOP_VARIABLE, CMD_GET_JUNCTION_VARIABLE, CMD_GET_LANE_VARIABLE, CMD_GET_POI_VARIABLE, CMD_GET_POLYGON_VARIABLE, CMD_GET_VEHICLE_VARIABLE, MSLane::fill(), PositionVector::getBoxBoundary(), TraCIServerAPI_Junction::getTree(), TraCIServerAPI_InductionLoop::getTree(), TraCIServerAPI_POI::getTree(), TraCIServerAPI_Polygon::getTree(), Boundary::grow(), LANE_RTREE_QUAL, myLaneTree, myObjects, MSLane::visit(), Boundary::xmax(), Boundary::xmin(), Boundary::ymax(), and Boundary::ymin().
Referenced by processSingleSubscription(), and TraCIServerAPI_Vehicle::vtdMap_matchingNearest().
|
private |
Indicates the connection as being closed.
Definition at line 510 of file TraCIServer.cpp.
References CMD_CLOSE, myDoCloseConnection, RTYPE_OK, and writeStatusCmd().
Referenced by dispatchCommand().
|
private |
Returns the TraCI-version.
Definition at line 491 of file TraCIServer.cpp.
References CMD_GETVERSION, myOutputStorage, RTYPE_OK, tcpip::Storage::size(), TRACI_VERSION, VERSION_STRING, tcpip::Storage::writeInt(), writeStatusCmd(), tcpip::Storage::writeStorage(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
Referenced by dispatchCommand().
|
private |
Definition at line 401 of file TraCIServer.cpp.
References addObjectVariableSubscription(), CMD_CLOSE, CMD_GETVERSION, CMD_SIMSTEP2, CMD_SUBSCRIBE_EDGE_CONTEXT, CMD_SUBSCRIBE_EDGE_VARIABLE, CMD_SUBSCRIBE_GUI_CONTEXT, CMD_SUBSCRIBE_GUI_VARIABLE, CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT, CMD_SUBSCRIBE_INDUCTIONLOOP_VARIABLE, CMD_SUBSCRIBE_JUNCTION_CONTEXT, CMD_SUBSCRIBE_JUNCTION_VARIABLE, CMD_SUBSCRIBE_LANE_CONTEXT, CMD_SUBSCRIBE_LANE_VARIABLE, CMD_SUBSCRIBE_MULTI_ENTRY_EXIT_DETECTOR_CONTEXT, CMD_SUBSCRIBE_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, CMD_SUBSCRIBE_POI_CONTEXT, CMD_SUBSCRIBE_POI_VARIABLE, CMD_SUBSCRIBE_POLYGON_CONTEXT, CMD_SUBSCRIBE_POLYGON_VARIABLE, CMD_SUBSCRIBE_ROUTE_CONTEXT, CMD_SUBSCRIBE_ROUTE_VARIABLE, CMD_SUBSCRIBE_SIM_CONTEXT, CMD_SUBSCRIBE_SIM_VARIABLE, CMD_SUBSCRIBE_TL_CONTEXT, CMD_SUBSCRIBE_TL_VARIABLE, CMD_SUBSCRIBE_VEHICLE_CONTEXT, CMD_SUBSCRIBE_VEHICLE_VARIABLE, CMD_SUBSCRIBE_VEHICLETYPE_CONTEXT, CMD_SUBSCRIBE_VEHICLETYPE_VARIABLE, commandCloseConnection(), commandGetVersion(), DELTA_T, getInstance(), myAmEmbedded, myDoCloseConnection, myExecutors, myInputStorage, myInstance, myOutputStorage, myTargetTime, myVehicleStateChanges, tcpip::Storage::position(), postProcessSimulationStep2(), tcpip::Storage::readChar(), tcpip::Storage::readInt(), tcpip::Storage::readUnsignedByte(), RTYPE_ERR, RTYPE_NOTIMPLEMENTED, tcpip::Storage::valid_pos(), and writeStatusCmd().
Referenced by processCommandsUntilSimStep().
|
private |
Definition at line 623 of file TraCIServer.cpp.
References CMD_SUBSCRIBE_EDGE_CONTEXT, CMD_SUBSCRIBE_GUI_CONTEXT, CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT, CMD_SUBSCRIBE_JUNCTION_CONTEXT, CMD_SUBSCRIBE_LANE_CONTEXT, CMD_SUBSCRIBE_MULTI_ENTRY_EXIT_DETECTOR_CONTEXT, CMD_SUBSCRIBE_POI_CONTEXT, CMD_SUBSCRIBE_POLYGON_CONTEXT, CMD_SUBSCRIBE_ROUTE_CONTEXT, CMD_SUBSCRIBE_SIM_CONTEXT, CMD_SUBSCRIBE_TL_CONTEXT, CMD_SUBSCRIBE_VEHICLE_CONTEXT, CMD_SUBSCRIBE_VEHICLETYPE_CONTEXT, TraCIServerAPI_InductionLoop::getPosition(), TraCIServerAPI_Junction::getPosition(), TraCIServerAPI_POI::getPosition(), TraCIServerAPI_Vehicle::getPosition(), TraCIServerAPI_Edge::getShape(), TraCIServerAPI_Polygon::getShape(), TraCIServerAPI_Lane::getShape(), and PositionVector::push_back().
Referenced by processSingleSubscription().
|
inlinestatic |
Definition at line 83 of file TraCIServer.h.
References myInstance.
Referenced by dispatchCommand(), postProcessSimulationStep2(), MSNet::simulationStep(), TraCIServer(), and ~TraCIServer().
|
inline |
Definition at line 80 of file TraCIServer.h.
References myTargetTime.
Referenced by MSNet::simulationStep().
|
inline |
Definition at line 160 of file TraCIServer.h.
References myVehicleStateChanges.
Referenced by TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_Simulation::writeVehicleStateIDs(), and TraCIServerAPI_Simulation::writeVehicleStateNumber().
|
private |
Definition at line 585 of file TraCIServer.cpp.
References TraCIServer::Subscription::commandId, TraCIServer::Subscription::endTime, MSNet::getCurrentTimeStep(), MSNet::getInstance(), myOutputStorage, mySubscriptions, processSingleSubscription(), RTYPE_ERR, RTYPE_OK, writeStatusCmd(), and tcpip::Storage::writeStorage().
Referenced by addObjectVariableSubscription().
|
static |
Initialises the server.
[in] | execs | The (additional) command executors to use |
Definition at line 184 of file TraCIServer.cpp.
References OptionsCont::getOptions(), myDoCloseConnection, myExecutors, myInstance, string2time(), and TraCIServer().
Referenced by load(), and GUILoadThread::run().
|
private |
Invalidated assignment operator.
|
private |
Handles subscriptions to send after a simstep2 command.
Definition at line 519 of file TraCIServer.cpp.
References TraCIServer::Subscription::beginTime, CMD_SIMSTEP2, CMD_SUBSCRIBE_VEHICLE_CONTEXT, CMD_SUBSCRIBE_VEHICLE_VARIABLE, TraCIServer::Subscription::commandId, TraCIServer::Subscription::endTime, getInstance(), TraCIServer::Subscription::id, myOutputStorage, mySubscriptions, myVehicleStateChanges, processSingleSubscription(), RTYPE_OK, MSNet::VEHICLE_STATE_ARRIVED, tcpip::Storage::writeInt(), writeStatusCmd(), and tcpip::Storage::writeStorage().
Referenced by dispatchCommand(), and processCommandsUntilSimStep().
void TraCIServer::postProcessVTD | ( | ) |
Definition at line 220 of file TraCIServer.cpp.
References MSNet::getInstance(), MSVehicleControl::getVehicle(), MSNet::getVehicleControl(), myVTDControlledVehicles, and WRITE_WARNING.
|
static |
process all commands until a simulation step is wanted
Definition at line 250 of file TraCIServer.cpp.
References CMD_SIMSTEP2, dispatchCommand(), myAmEmbedded, myDoCloseConnection, myDoingSimStep, myInputStorage, myInstance, myOutputStorage, mySocket, myTargetTime, myVehicleStateChanges, postProcessSimulationStep2(), tcpip::Socket::receiveExact(), tcpip::Storage::reset(), tcpip::Socket::sendExact(), tcpip::Storage::size(), tcpip::Storage::valid_pos(), and tcpip::SocketException::what().
Referenced by MSNet::simulationStep().
|
private |
Definition at line 739 of file TraCIServer.cpp.
References collectObjectsInRange(), TraCIServer::Subscription::commandId, TraCIServer::Subscription::contextDomain, TraCIServer::Subscription::contextVars, findObjectShape(), TraCIServer::Subscription::id, ID_LIST, myExecutors, TraCIServer::Subscription::parameters, TraCIServer::Subscription::range, tcpip::Storage::readInt(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), RTYPE_ERR, RTYPE_NOTIMPLEMENTED, RTYPE_OK, tcpip::Storage::size(), TYPE_STRING, TraCIServer::Subscription::variables, tcpip::Storage::writeInt(), tcpip::Storage::writePacket(), writeStatusCmd(), tcpip::Storage::writeStorage(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
Referenced by initialiseSubscription(), and postProcessSimulationStep2().
bool TraCIServer::readTypeCheckingBoundary | ( | tcpip::Storage & | inputStorage, |
Boundary & | into | ||
) |
Reads the value type and a 2D bounding box, verifying the type.
in,changed] | inputStorage The storage to read from | |
[out] | into | Holder of the read value |
Definition at line 943 of file TraCIServer.cpp.
References tcpip::Storage::readDouble(), tcpip::Storage::readUnsignedByte(), Boundary::set(), SUMOReal, and TYPE_BOUNDINGBOX.
Referenced by TraCIServerAPI_GUI::processSet().
bool TraCIServer::readTypeCheckingByte | ( | tcpip::Storage & | inputStorage, |
int & | into | ||
) |
Reads the value type and a byte, verifying the type.
in,changed] | inputStorage The storage to read from | |
[out] | into | Holder of the read value |
Definition at line 957 of file TraCIServer.cpp.
References tcpip::Storage::readByte(), tcpip::Storage::readUnsignedByte(), and TYPE_BYTE.
Referenced by TraCIServerAPI_Vehicle::processSet().
bool TraCIServer::readTypeCheckingColor | ( | tcpip::Storage & | inputStorage, |
RGBColor & | into | ||
) |
Reads the value type and a color, verifying the type.
in,changed] | inputStorage The storage to read from | |
[out] | into | Holder of the read value |
Definition at line 917 of file TraCIServer.cpp.
References tcpip::Storage::readUnsignedByte(), RGBColor::set(), and TYPE_COLOR.
Referenced by TraCIServerAPI_POI::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_Vehicle::processSet(), and TraCIServerAPI_VehicleType::setVariable().
bool TraCIServer::readTypeCheckingDouble | ( | tcpip::Storage & | inputStorage, |
double & | into | ||
) |
Reads the value type and a double, verifying the type.
in,changed] | inputStorage The storage to read from | |
[out] | into | Holder of the read value |
Definition at line 887 of file TraCIServer.cpp.
References tcpip::Storage::readDouble(), tcpip::Storage::readUnsignedByte(), and TYPE_DOUBLE.
Referenced by TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Edge::processSet(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_Lane::processSet(), TraCIServerAPI_GUI::processSet(), and TraCIServerAPI_VehicleType::setVariable().
bool TraCIServer::readTypeCheckingInt | ( | tcpip::Storage & | inputStorage, |
int & | into | ||
) |
Reads the value type and an int, verifying the type.
in,changed] | inputStorage The storage to read from | |
[out] | into | Holder of the read value |
Definition at line 877 of file TraCIServer.cpp.
References tcpip::Storage::readInt(), tcpip::Storage::readUnsignedByte(), and TYPE_INTEGER.
Referenced by TraCIServerAPI_Edge::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Edge::processSet(), TraCIServerAPI_TLS::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_POI::processSet(), and TraCIServerAPI_Vehicle::processSet().
bool TraCIServer::readTypeCheckingPolygon | ( | tcpip::Storage & | inputStorage, |
PositionVector & | into | ||
) |
Reads the value type and a polygon, verifying the type.
in,changed] | inputStorage The storage to read from | |
[out] | into | Holder of the read value |
Definition at line 977 of file TraCIServer.cpp.
References PositionVector::push_back(), tcpip::Storage::readDouble(), tcpip::Storage::readUnsignedByte(), SUMOReal, and TYPE_POLYGON.
Referenced by TraCIServerAPI_Polygon::processSet().
bool TraCIServer::readTypeCheckingPosition2D | ( | tcpip::Storage & | inputStorage, |
Position & | into | ||
) |
Reads the value type and a 2D position, verifying the type.
in,changed] | inputStorage The storage to read from | |
[out] | into | Holder of the read value |
Definition at line 931 of file TraCIServer.cpp.
References POSITION_2D, tcpip::Storage::readDouble(), tcpip::Storage::readUnsignedByte(), Position::set(), and SUMOReal.
Referenced by TraCIServerAPI_POI::processSet(), and TraCIServerAPI_GUI::processSet().
bool TraCIServer::readTypeCheckingString | ( | tcpip::Storage & | inputStorage, |
std::string & | into | ||
) |
Reads the value type and a string, verifying the type.
in,changed] | inputStorage The storage to read from | |
[out] | into | Holder of the read value |
Definition at line 897 of file TraCIServer.cpp.
References tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), and TYPE_STRING.
Referenced by TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_TLS::processSet(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_Simulation::processSet(), TraCIServerAPI_GUI::processSet(), and TraCIServerAPI_VehicleType::setVariable().
bool TraCIServer::readTypeCheckingStringList | ( | tcpip::Storage & | inputStorage, |
std::vector< std::string > & | into | ||
) |
Reads the value type and a string list, verifying the type.
in,changed] | inputStorage The storage to read from | |
[out] | into | Holder of the read value |
Definition at line 907 of file TraCIServer.cpp.
References tcpip::Storage::readStringList(), tcpip::Storage::readUnsignedByte(), and TYPE_STRINGLIST.
Referenced by TraCIServerAPI_Edge::processSet(), TraCIServerAPI_Route::processSet(), TraCIServerAPI_Vehicle::processSet(), and TraCIServerAPI_Lane::processSet().
bool TraCIServer::readTypeCheckingUnsignedByte | ( | tcpip::Storage & | inputStorage, |
int & | into | ||
) |
Reads the value type and an unsigned byte, verifying the type.
in,changed] | inputStorage The storage to read from | |
[out] | into | Holder of the read value |
Definition at line 967 of file TraCIServer.cpp.
References tcpip::Storage::readUnsignedByte(), and TYPE_UBYTE.
Referenced by TraCIServerAPI_Simulation::commandPositionConversion(), and TraCIServerAPI_Polygon::processSet().
|
private |
Definition at line 603 of file TraCIServer.cpp.
References mySubscriptions, RTYPE_OK, and writeStatusCmd().
Referenced by addObjectVariableSubscription().
void TraCIServer::setVTDControlled | ( | MSVehicle * | v, |
MSLane * | l, | ||
SUMOReal | pos, | ||
int | edgeOffset, | ||
MSEdgeVector | route | ||
) |
Definition at line 214 of file TraCIServer.cpp.
References MSBaseVehicle::getID(), MSVehicle::getInfluencer(), myVTDControlledVehicles, and MSVehicle::Influencer::setVTDControlled().
Referenced by TraCIServerAPI_Vehicle::processSet().
|
virtual |
Called if a vehicle changes its state.
[in] | vehicle | The vehicle which changed its state |
[in] | to | The state the vehicle has changed to |
Implements MSNet::VehicleStateListener.
Definition at line 242 of file TraCIServer.cpp.
References SUMOVehicle::getID(), myDoCloseConnection, and myVehicleStateChanges.
bool TraCIServer::vtdDebug | ( | ) | const |
Definition at line 233 of file TraCIServer.cpp.
Referenced by TraCIServerAPI_Vehicle::processSet().
|
static |
check whether close was requested
Definition at line 208 of file TraCIServer.cpp.
References myDoCloseConnection.
Referenced by GUIRunThread::makeStep(), MSNet::simulate(), and MSNet::simulationState().
bool TraCIServer::writeErrorStatusCmd | ( | int | commandId, |
const std::string & | description, | ||
tcpip::Storage & | outputStorage | ||
) |
Writes a status command to the given storage with status = RTYPE_ERR.
[in] | commandId | The id of the command to respond to |
[in] | description | The status description (error message, for example) |
in,filled] | outputStorage The storage to write the status into |
Definition at line 578 of file TraCIServer.cpp.
References RTYPE_ERR, and writeStatusCmd().
Referenced by TraCIServerAPI_Vehicle::commandDistanceRequest(), TraCIServerAPI_Edge::processGet(), TraCIServerAPI_TLS::processGet(), TraCIServerAPI_ArealDetector::processGet(), TraCIServerAPI_MeMeDetector::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_InductionLoop::processGet(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_VehicleType::processGet(), TraCIServerAPI_Junction::processGet(), TraCIServerAPI_Route::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_Lane::processGet(), TraCIServerAPI_GUI::processGet(), TraCIServerAPI_Edge::processSet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Route::processSet(), TraCIServerAPI_TLS::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_Simulation::processSet(), TraCIServerAPI_Lane::processSet(), TraCIServerAPI_GUI::processSet(), TraCIServerAPI_VehicleType::processSet(), and TraCIServerAPI_VehicleType::setVariable().
void TraCIServer::writeResponseWithLength | ( | tcpip::Storage & | outputStorage, |
tcpip::Storage & | tempMsg | ||
) |
Definition at line 865 of file TraCIServer.cpp.
References tcpip::Storage::size(), tcpip::Storage::writeInt(), tcpip::Storage::writeStorage(), and tcpip::Storage::writeUnsignedByte().
Referenced by TraCIServerAPI_Edge::processGet(), TraCIServerAPI_ArealDetector::processGet(), TraCIServerAPI_InductionLoop::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_Junction::processGet(), TraCIServerAPI_Route::processGet(), TraCIServerAPI_MeMeDetector::processGet(), TraCIServerAPI_VehicleType::processGet(), TraCIServerAPI_TLS::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_Lane::processGet(), and TraCIServerAPI_GUI::processGet().
void TraCIServer::writeStatusCmd | ( | int | commandId, |
int | status, | ||
const std::string & | description, | ||
tcpip::Storage & | outputStorage | ||
) |
Writes a status command to the given storage.
[in] | commandId | The id of the command to respond to |
[in] | status | The status to send |
[in] | description | The status description (error message, for example) |
in,filled] | outputStorage The storage to write the status into |
Definition at line 564 of file TraCIServer.cpp.
References RTYPE_ERR, RTYPE_NOTIMPLEMENTED, toHex(), WRITE_ERROR, tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().
Referenced by commandCloseConnection(), TraCIServerAPI_Simulation::commandDistanceRequest(), commandGetVersion(), TraCIServerAPI_Simulation::commandPositionConversion(), dispatchCommand(), initialiseSubscription(), postProcessSimulationStep2(), TraCIServerAPI_Edge::processGet(), TraCIServerAPI_Junction::processGet(), TraCIServerAPI_VehicleType::processGet(), TraCIServerAPI_MeMeDetector::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_ArealDetector::processGet(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_Route::processGet(), TraCIServerAPI_InductionLoop::processGet(), TraCIServerAPI_TLS::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_Lane::processGet(), TraCIServerAPI_GUI::processGet(), TraCIServerAPI_Edge::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Route::processSet(), TraCIServerAPI_TLS::processSet(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_Simulation::processSet(), TraCIServerAPI_Lane::processSet(), TraCIServerAPI_GUI::processSet(), TraCIServerAPI_VehicleType::processSet(), processSingleSubscription(), removeSubscription(), writeErrorStatusCmd(), and writeStatusCmd().
Writes a status command to myOutputStorage.
[in] | commandId | The id of the command to respond to |
[in] | status | The status to send |
[in] | description | The status description (error message, for example) |
Definition at line 558 of file TraCIServer.cpp.
References myOutputStorage, and writeStatusCmd().
|
private |
Whether the server runs in embedded mode.
Definition at line 323 of file TraCIServer.h.
Referenced by dispatchCommand(), processCommandsUntilSimStep(), and TraCIServer().
|
staticprivate |
Whether the connection was set to be to close.
Definition at line 304 of file TraCIServer.h.
Referenced by close(), commandCloseConnection(), dispatchCommand(), openSocket(), processCommandsUntilSimStep(), TraCIServer(), vehicleStateChanged(), and wasClosed().
|
private |
Whether a step is currently done.
Definition at line 320 of file TraCIServer.h.
Referenced by processCommandsUntilSimStep().
|
private |
Map of commandIds -> their executors; applicable if the executor applies to the method footprint.
Definition at line 326 of file TraCIServer.h.
Referenced by dispatchCommand(), openSocket(), processSingleSubscription(), and TraCIServer().
|
private |
The storage to read from.
Definition at line 313 of file TraCIServer.h.
Referenced by addObjectVariableSubscription(), dispatchCommand(), and processCommandsUntilSimStep().
|
staticprivate |
Singleton instance of the server.
Definition at line 301 of file TraCIServer.h.
Referenced by close(), dispatchCommand(), getInstance(), openSocket(), and processCommandsUntilSimStep().
|
private |
A storage of lanes.
Definition at line 386 of file TraCIServer.h.
Referenced by collectObjectsInRange(), and ~TraCIServer().
|
private |
A storage of objects.
Definition at line 383 of file TraCIServer.h.
Referenced by collectObjectsInRange(), and ~TraCIServer().
|
private |
The storage to writeto.
Definition at line 316 of file TraCIServer.h.
Referenced by commandGetVersion(), dispatchCommand(), initialiseSubscription(), postProcessSimulationStep2(), processCommandsUntilSimStep(), and writeStatusCmd().
Map of variable ids to the size of the parameter in bytes.
Definition at line 329 of file TraCIServer.h.
Referenced by addObjectVariableSubscription(), and TraCIServer().
|
private |
The socket on which server is listening on.
Definition at line 307 of file TraCIServer.h.
Referenced by processCommandsUntilSimStep(), TraCIServer(), and ~TraCIServer().
|
private |
The list of known, still valid subscriptions.
Definition at line 377 of file TraCIServer.h.
Referenced by initialiseSubscription(), postProcessSimulationStep2(), and removeSubscription().
|
private |
The time step to reach until processing the next commands.
Definition at line 310 of file TraCIServer.h.
Referenced by dispatchCommand(), getTargetTime(), and processCommandsUntilSimStep().
|
private |
Changes in the states of simulated vehicles.
Definition at line 380 of file TraCIServer.h.
Referenced by dispatchCommand(), getVehicleStateChanges(), postProcessSimulationStep2(), processCommandsUntilSimStep(), TraCIServer(), and vehicleStateChanged().
|
private |
Definition at line 331 of file TraCIServer.h.
Referenced by postProcessVTD(), and setVTDControlled().