Eclipse SUMO - Simulation of Urban MObility
TraCIServer Class Referencefinal

TraCI server used to control sumo by a remote TraCI client. More...

#include <TraCIServer.h>

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

Data Structures

struct  SocketInfo
 

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. More...
 
typedef bool(* SubscriptionHandler) (const std::string &objID, const int variable, VariableWrapper *wrapper, tcpip::Storage *paramData)
 Definition of a method to be called for serving an associated commandID. More...
 

Public Member Functions

void cleanup ()
 clean up subscriptions More...
 
virtual void clear ()
 
virtual void empty (const std::string &)
 
std::vector< std::string > & getLoadArgs ()
 
SUMOTime getTargetTime () const
 
const std::map< MSNet::TransportableState, std::vector< std::string > > & getTransportableStateChanges () const
 
const std::map< MSNet::VehicleState, std::vector< std::string > > & getVehicleStateChanges () const
 
int processCommands (const SUMOTime step, const bool afterMove=false)
 process all commands until the next SUMO simulation step. It is guaranteed that t->getTargetTime() >= myStep after call (except the case that a load or close command is received)s More...
 
virtual void setContext (const std::string *const)
 
void stateLoaded (SUMOTime targetTime)
 updates myTargetTime and resets vehicle state changes after loading a simulation state More...
 
void transportableStateChanged (const MSTransportable *const transportable, MSNet::TransportableState to, const std::string &info="")
 Called if a transportable changes its state. More...
 
void vehicleStateChanged (const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
 Called if a vehicle changes its state. More...
 
void writePositionVector (tcpip::Storage &outputStorage, const libsumo::TraCIPositionVector &shape)
 
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. More...
 
void writeStatusCmd (int commandId, int status, const std::string &description)
 Writes a status command to myOutputStorage. More...
 
bool writeErrorStatusCmd (int commandId, const std::string &description, tcpip::Storage &outputStorage)
 Writes a status command to the given storage with status = RTYPE_ERR. More...
 
Helpers for reading and checking values
bool readTypeCheckingInt (tcpip::Storage &inputStorage, int &into)
 Reads the value type and an int, verifying the type. More...
 
bool readTypeCheckingDouble (tcpip::Storage &inputStorage, double &into)
 Reads the value type and a double, verifying the type. More...
 
bool readTypeCheckingString (tcpip::Storage &inputStorage, std::string &into)
 Reads the value type and a string, verifying the type. More...
 
bool readTypeCheckingStringList (tcpip::Storage &inputStorage, std::vector< std::string > &into)
 Reads the value type and a string list, verifying the type. More...
 
bool readTypeCheckingDoubleList (tcpip::Storage &inputStorage, std::vector< double > &into)
 Reads the value type and a double list, verifying the type. More...
 
bool readTypeCheckingColor (tcpip::Storage &inputStorage, libsumo::TraCIColor &into)
 Reads the value type and a color, verifying the type. More...
 
bool readTypeCheckingPosition2D (tcpip::Storage &inputStorage, libsumo::TraCIPosition &into)
 Reads the value type and a 2D position, verifying the type. More...
 
bool readTypeCheckingByte (tcpip::Storage &inputStorage, int &into)
 Reads the value type and a byte, verifying the type. More...
 
bool readTypeCheckingUnsignedByte (tcpip::Storage &inputStorage, int &into)
 Reads the value type and an unsigned byte, verifying the type. More...
 
bool readTypeCheckingPolygon (tcpip::Storage &inputStorage, PositionVector &into)
 Reads the value type and a polygon, verifying the type. More...
 
VariableWrapper interface
void initWrapper (const int domainID, const int variable, const std::string &objID)
 
bool wrapDouble (const std::string &objID, const int variable, const double value)
 
bool wrapInt (const std::string &objID, const int variable, const int value)
 
bool wrapString (const std::string &objID, const int variable, const std::string &value)
 
bool wrapStringList (const std::string &objID, const int variable, const std::vector< std::string > &value)
 
bool wrapDoubleList (const std::string &objID, const int variable, const std::vector< double > &value)
 
bool wrapPosition (const std::string &objID, const int variable, const libsumo::TraCIPosition &value)
 
bool wrapPositionVector (const std::string &objID, const int variable, const libsumo::TraCIPositionVector &value)
 
bool wrapColor (const std::string &objID, const int variable, const libsumo::TraCIColor &value)
 
bool wrapStringDoublePair (const std::string &objID, const int variable, const std::pair< std::string, double > &value)
 
bool wrapStringPair (const std::string &objID, const int variable, const std::pair< std::string, std::string > &value)
 
tcpip::StoragegetWrapperStorage ()
 

Static Public Member Functions

static TraCIServergetInstance ()
 
Initialisation and Shutdown
static void openSocket (const std::map< int, CmdExecutor > &execs)
 Initialises the server. More...
 
static void close ()
 request termination of connection More...
 
static bool wasClosed ()
 check whether close was requested More...
 

Data Fields

SubscriptionHandler handle
 

Private Member Functions

bool addObjectVariableSubscription (const int commandId, const bool hasContext)
 
bool addSubscriptionFilter ()
 
void addSubscriptionFilterDownstreamDistance (double dist)
 
void addSubscriptionFilterFieldOfVision (double openingAngle)
 Filter only vehicles within field of vision. More...
 
void addSubscriptionFilterLanes (std::vector< int > lanes)
 
void addSubscriptionFilterLateralDistance (double dist)
 Filter only vehicles within the given lateral distance. More...
 
void addSubscriptionFilterLeadFollow ()
 
void addSubscriptionFilterNoOpposite ()
 
void addSubscriptionFilterTurn (double dist)
 
void addSubscriptionFilterUpstreamDistance (double dist)
 
void addSubscriptionFilterVClass (SVCPermissions vClasses)
 
void addSubscriptionFilterVType (std::set< std::string > vTypes)
 
bool centralObject (const libsumo::Subscription &s, const std::string &objID)
 check whether a found objID refers to the central object of a context subscription More...
 
void checkClientOrdering ()
 Called once after connection of all clients for executing SET_ORDER (and possibly prior GET_VERSION) commands, that should be executed before simulation starts (in processCommandsUntilNextSimStep()). More...
 
int dispatchCommand ()
 Handles command, writes response to myOutputStorage. More...
 
void initialiseSubscription (libsumo::Subscription &s)
 
SUMOTime nextTargetTime () const
 get the minimal next target time among all clients More...
 
TraCIServeroperator= (const TraCIServer &s)=delete
 Invalidated assignment operator. More...
 
void processReorderingRequests ()
 checks for and processes reordering requests (relevant for multiple clients) More...
 
bool processSingleSubscription (const libsumo::Subscription &s, tcpip::Storage &writeInto, std::string &errors)
 
int readCommandID (int &commandStart, int &commandLength)
 Reads the next command ID from the input storage. More...
 
std::map< int, SocketInfo * >::iterator removeCurrentSocket ()
 removes myCurrentSocket from mySockets and returns an iterator pointing to the next member according to the ordering More...
 
void removeFilters ()
 
void removeSubscription (int commandId, const std::string &identity, int domain)
 
void sendOutputToAll () const
 send out subscription results (actually just the content of myOutputStorage) to clients which will act in this step (i.e. with client target time <= myTargetTime) More...
 
void sendSingleSimStepResponse ()
 sends an empty response to a simstep command to the current client. (This applies to a situation where the TraCI step frequency is higher than the SUMO step frequency) More...
 
 TraCIServer (const SUMOTime begin, const int port, const int numClients)
 Constructor. More...
 
virtual ~TraCIServer ()
 Destructor. More...
 
Server-internal command handling
bool commandGetVersion ()
 Returns the TraCI-version. More...
 
void postProcessSimulationStep ()
 Handles subscriptions to send after a simstep2 command. More...
 

Private Attributes

std::map< int, SocketInfo * >::iterator myCurrentSocket
 The currently active client socket. More...
 
std::map< int, CmdExecutormyExecutors
 Map of commandIds -> their executors; applicable if the executor applies to the method footprint. More...
 
tcpip::Storage myInputStorage
 The storage to read from. More...
 
libsumo::SubscriptionmyLastContextSubscription
 The last modified context subscription (the one to add a filter to, see @addSubscriptionFilter(), currently only for vehicle to vehicle context) More...
 
std::vector< std::string > myLoadArgs
 
tcpip::Storage myOutputStorage
 The storage to write to. More...
 
std::set< std::pair< int, int > > myParameterized
 Set of variables which have parameters. More...
 
std::map< int, SocketInfo * > mySocketReorderRequests
 This stores the setOrder(int) requests of the clients. More...
 
std::map< int, SocketInfo * > mySockets
 The socket connections to the clients the first component (index) determines the client's order (lowest index's commands are processed first),. More...
 
tcpip::Storage mySubscriptionCache
 The last timestep's subscription results. More...
 
std::vector< libsumo::SubscriptionmySubscriptions
 The list of known, still valid subscriptions. More...
 
SUMOTime myTargetTime
 The time step to reach until processing the next commands. More...
 
std::map< MSNet::TransportableState, std::vector< std::string > > myTransportableStateChanges
 Changes in the states of simulated transportables. More...
 
std::map< MSNet::VehicleState, std::vector< std::string > > myVehicleStateChanges
 Changes in the states of simulated vehicles. More...
 
tcpip::Storage myWrapperStorage
 A temporary storage to let the wrapper write to. More...
 

Static Private Attributes

static bool myDoCloseConnection = false
 Whether the connection was set to be to close. More...
 
static TraCIServermyInstance = nullptr
 Singleton instance of the server. More...
 

Detailed Description

TraCI server used to control sumo by a remote TraCI client.

Definition at line 59 of file TraCIServer.h.

Member Typedef Documentation

◆ CmdExecutor

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 62 of file TraCIServer.h.

◆ SubscriptionHandler

typedef bool(* libsumo::VariableWrapper::SubscriptionHandler) (const std::string &objID, const int variable, VariableWrapper *wrapper, tcpip::Storage *paramData)
inherited

Definition of a method to be called for serving an associated commandID.

Definition at line 153 of file Subscription.h.

Constructor & Destructor Documentation

◆ TraCIServer()

TraCIServer::TraCIServer ( const SUMOTime  begin,
const int  port,
const int  numClients 
)
private

Constructor.

Parameters
[in]portThe port to listen to (to open)

Definition at line 232 of file TraCIServer.cpp.

References tcpip::Socket::accept(), MSNet::ARRIVED, MSNet::BUILT, checkClientOrdering(), libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_GET_CALIBRATOR_VARIABLE, libsumo::CMD_GET_CHARGINGSTATION_VARIABLE, libsumo::CMD_GET_EDGE_VARIABLE, libsumo::CMD_GET_INDUCTIONLOOP_VARIABLE, libsumo::CMD_GET_JUNCTION_VARIABLE, libsumo::CMD_GET_LANE_VARIABLE, libsumo::CMD_GET_LANEAREA_VARIABLE, libsumo::CMD_GET_MEANDATA_VARIABLE, libsumo::CMD_GET_MULTIENTRYEXIT_VARIABLE, libsumo::CMD_GET_OVERHEADWIRE_VARIABLE, libsumo::CMD_GET_PARKINGAREA_VARIABLE, libsumo::CMD_GET_PERSON_VARIABLE, libsumo::CMD_GET_POI_VARIABLE, libsumo::CMD_GET_POLYGON_VARIABLE, libsumo::CMD_GET_REROUTER_VARIABLE, libsumo::CMD_GET_ROUTE_VARIABLE, libsumo::CMD_GET_ROUTEPROBE_VARIABLE, libsumo::CMD_GET_SIM_VARIABLE, libsumo::CMD_GET_TL_VARIABLE, libsumo::CMD_GET_VARIABLESPEEDSIGN_VARIABLE, libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::CMD_GET_VEHICLETYPE_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE, libsumo::CMD_SET_CALIBRATOR_VARIABLE, libsumo::CMD_SET_CHARGINGSTATION_VARIABLE, libsumo::CMD_SET_EDGE_VARIABLE, libsumo::CMD_SET_INDUCTIONLOOP_VARIABLE, libsumo::CMD_SET_JUNCTION_VARIABLE, libsumo::CMD_SET_LANE_VARIABLE, libsumo::CMD_SET_LANEAREA_VARIABLE, libsumo::CMD_SET_MULTIENTRYEXIT_VARIABLE, libsumo::CMD_SET_OVERHEADWIRE_VARIABLE, libsumo::CMD_SET_PARKINGAREA_VARIABLE, libsumo::CMD_SET_PERSON_VARIABLE, libsumo::CMD_SET_POI_VARIABLE, libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::CMD_SET_REROUTER_VARIABLE, libsumo::CMD_SET_ROUTE_VARIABLE, libsumo::CMD_SET_ROUTEPROBE_VARIABLE, libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_SET_TL_VARIABLE, libsumo::CMD_SET_VARIABLESPEEDSIGN_VARIABLE, libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::CMD_SUBSCRIBE_VEHICLE_VARIABLE, MSNet::COLLISION, MSNet::CONTAINER_ARRIVED, MSNet::CONTAINER_DEPARTED, MSNet::DEPARTED, MSNet::EMERGENCYSTOP, MSNet::ENDING_PARKING, MSNet::ENDING_STOP, MSNet::ENDING_TELEPORT, MsgHandler::getWarningInstance(), MSGlobals::gUseMesoSim, MSGlobals::gUsingInternalLanes, MsgHandler::inform(), MSNet::MANEUVERING, libsumo::MAX_ORDER, myCurrentSocket, myDoCloseConnection, myExecutors, myParameterized, mySockets, myTransportableStateChanges, myVehicleStateChanges, MSNet::NEWROUTE, MSNet::PERSON_ARRIVED, MSNet::PERSON_DEPARTED, TraCIServerAPI_BusStop::processGet(), TraCIServerAPI_Calibrator::processGet(), TraCIServerAPI_ChargingStation::processGet(), TraCIServerAPI_Edge::processGet(), TraCIServerAPI_InductionLoop::processGet(), TraCIServerAPI_Junction::processGet(), TraCIServerAPI_Lane::processGet(), TraCIServerAPI_LaneArea::processGet(), TraCIServerAPI_MeanData::processGet(), TraCIServerAPI_MultiEntryExit::processGet(), TraCIServerAPI_OverheadWire::processGet(), TraCIServerAPI_ParkingArea::processGet(), TraCIServerAPI_Person::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_Rerouter::processGet(), TraCIServerAPI_Route::processGet(), TraCIServerAPI_RouteProbe::processGet(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_TrafficLight::processGet(), TraCIServerAPI_VariableSpeedSign::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_VehicleType::processGet(), TraCIServerAPI_BusStop::processSet(), TraCIServerAPI_Calibrator::processSet(), TraCIServerAPI_ChargingStation::processSet(), TraCIServerAPI_Edge::processSet(), TraCIServerAPI_InductionLoop::processSet(), TraCIServerAPI_Junction::processSet(), TraCIServerAPI_Lane::processSet(), TraCIServerAPI_LaneArea::processSet(), TraCIServerAPI_MultiEntryExit::processSet(), TraCIServerAPI_OverheadWire::processSet(), TraCIServerAPI_ParkingArea::processSet(), TraCIServerAPI_Person::processSet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_Rerouter::processSet(), TraCIServerAPI_Route::processSet(), TraCIServerAPI_RouteProbe::processSet(), TraCIServerAPI_Simulation::processSet(), TraCIServerAPI_TrafficLight::processSet(), TraCIServerAPI_VariableSpeedSign::processSet(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_VehicleType::processSet(), MSNet::STARTING_PARKING, MSNet::STARTING_STOP, MSNet::STARTING_TELEPORT, TL, toString(), libsumo::VAR_FOLLOWER, libsumo::VAR_LEADER, libsumo::VAR_PARAMETER, libsumo::VAR_PARAMETER_WITH_KEY, WRITE_MESSAGE, WRITE_MESSAGEF, and WRITE_WARNING.

Referenced by openSocket().

Here is the caller graph for this function:

◆ ~TraCIServer()

TraCIServer::~TraCIServer ( )
privatevirtual

Destructor.

Definition at line 362 of file TraCIServer.cpp.

References mySockets.

Member Function Documentation

◆ addObjectVariableSubscription()

bool TraCIServer::addObjectVariableSubscription ( const int  commandId,
const bool  hasContext 
)
private

Definition at line 1244 of file TraCIServer.cpp.

References libsumo::CMD_SUBSCRIBE_SIM_CONTEXT, initialiseSubscription(), libsumo::INVALID_DOUBLE_VALUE, myInputStorage, myParameterized, tcpip::Storage::readDouble(), tcpip::Storage::readString(), tcpip::Storage::readUnsignedByte(), removeSubscription(), STEPS2TIME, SUMOTime_MAX, TIME2STEPS, libsumo::TYPE_DOUBLE, and libsumo::TYPE_STRING.

Referenced by dispatchCommand().

Here is the caller graph for this function:

◆ addSubscriptionFilter()

◆ addSubscriptionFilterDownstreamDistance()

void TraCIServer::addSubscriptionFilterDownstreamDistance ( double  dist)
private

Definition at line 1409 of file TraCIServer.cpp.

References libsumo::Subscription::activeFilters, libsumo::Subscription::filterDownstreamDist, myLastContextSubscription, libsumo::SUBS_FILTER_DOWNSTREAM_DIST, and toString().

Referenced by addSubscriptionFilter().

Here is the caller graph for this function:

◆ addSubscriptionFilterFieldOfVision()

void TraCIServer::addSubscriptionFilterFieldOfVision ( double  openingAngle)
private

Filter only vehicles within field of vision.

Parameters
[in]openingAngleThe opening angle of the circle sector

Definition at line 1462 of file TraCIServer.cpp.

References libsumo::Subscription::activeFilters, libsumo::Subscription::filterFieldOfVisionOpeningAngle, myLastContextSubscription, libsumo::SUBS_FILTER_FIELD_OF_VISION, and toString().

Referenced by addSubscriptionFilter().

Here is the caller graph for this function:

◆ addSubscriptionFilterLanes()

void TraCIServer::addSubscriptionFilterLanes ( std::vector< int >  lanes)
private

Definition at line 1392 of file TraCIServer.cpp.

References libsumo::Subscription::activeFilters, libsumo::Subscription::filterLanes, myLastContextSubscription, libsumo::SUBS_FILTER_LANES, and toString().

Referenced by addSubscriptionFilter().

Here is the caller graph for this function:

◆ addSubscriptionFilterLateralDistance()

void TraCIServer::addSubscriptionFilterLateralDistance ( double  dist)
private

Filter only vehicles within the given lateral distance.

Parameters
[in]distThe lateral distance

Definition at line 1471 of file TraCIServer.cpp.

References libsumo::Subscription::activeFilters, libsumo::Subscription::filterLateralDist, myLastContextSubscription, libsumo::SUBS_FILTER_LATERAL_DIST, and toString().

Referenced by addSubscriptionFilter().

Here is the caller graph for this function:

◆ addSubscriptionFilterLeadFollow()

void TraCIServer::addSubscriptionFilterLeadFollow ( )
private

Definition at line 1427 of file TraCIServer.cpp.

References libsumo::Subscription::activeFilters, myLastContextSubscription, and libsumo::SUBS_FILTER_LEAD_FOLLOW.

Referenced by addSubscriptionFilter().

Here is the caller graph for this function:

◆ addSubscriptionFilterNoOpposite()

void TraCIServer::addSubscriptionFilterNoOpposite ( )
private

Definition at line 1401 of file TraCIServer.cpp.

References libsumo::Subscription::activeFilters, myLastContextSubscription, and libsumo::SUBS_FILTER_NOOPPOSITE.

Referenced by addSubscriptionFilter().

Here is the caller graph for this function:

◆ addSubscriptionFilterTurn()

void TraCIServer::addSubscriptionFilterTurn ( double  dist)
private

Definition at line 1435 of file TraCIServer.cpp.

References libsumo::Subscription::activeFilters, libsumo::Subscription::filterFoeDistToJunction, myLastContextSubscription, and libsumo::SUBS_FILTER_TURN.

Referenced by addSubscriptionFilter().

Here is the caller graph for this function:

◆ addSubscriptionFilterUpstreamDistance()

void TraCIServer::addSubscriptionFilterUpstreamDistance ( double  dist)
private

Definition at line 1418 of file TraCIServer.cpp.

References libsumo::Subscription::activeFilters, libsumo::Subscription::filterUpstreamDist, myLastContextSubscription, libsumo::SUBS_FILTER_UPSTREAM_DIST, and toString().

Referenced by addSubscriptionFilter().

Here is the caller graph for this function:

◆ addSubscriptionFilterVClass()

void TraCIServer::addSubscriptionFilterVClass ( SVCPermissions  vClasses)
private

Definition at line 1444 of file TraCIServer.cpp.

References libsumo::Subscription::activeFilters, libsumo::Subscription::filterVClasses, myLastContextSubscription, libsumo::SUBS_FILTER_VCLASS, and toString().

Referenced by addSubscriptionFilter().

Here is the caller graph for this function:

◆ addSubscriptionFilterVType()

void TraCIServer::addSubscriptionFilterVType ( std::set< std::string >  vTypes)
private

Definition at line 1453 of file TraCIServer.cpp.

References libsumo::Subscription::activeFilters, libsumo::Subscription::filterVTypes, myLastContextSubscription, libsumo::SUBS_FILTER_VTYPE, and toString().

Referenced by addSubscriptionFilter().

Here is the caller graph for this function:

◆ centralObject()

bool TraCIServer::centralObject ( const libsumo::Subscription s,
const std::string &  objID 
)
private

check whether a found objID refers to the central object of a context subscription

Definition at line 1644 of file TraCIServer.cpp.

References libsumo::Subscription::commandId, libsumo::Subscription::contextDomain, and libsumo::Subscription::id.

◆ checkClientOrdering()

void TraCIServer::checkClientOrdering ( )
private

Called once after connection of all clients for executing SET_ORDER (and possibly prior GET_VERSION) commands, that should be executed before simulation starts (in processCommandsUntilNextSimStep()).

Definition at line 433 of file TraCIServer.cpp.

References libsumo::CMD_GETVERSION, libsumo::CMD_SETORDER, dispatchCommand(), myCurrentSocket, myInputStorage, myOutputStorage, mySockets, readCommandID(), tcpip::Storage::reset(), TL, tcpip::Storage::writeStorage(), and tcpip::Storage::writeUnsignedByte().

Referenced by TraCIServer().

Here is the caller graph for this function:

◆ cleanup()

void TraCIServer::cleanup ( )

clean up subscriptions

Definition at line 703 of file TraCIServer.cpp.

References OptionsCont::getOptions(), myCurrentSocket, myInputStorage, myOutputStorage, mySockets, mySubscriptionCache, mySubscriptions, myTargetTime, myTransportableStateChanges, myVehicleStateChanges, tcpip::Storage::reset(), and string2time().

Referenced by MSNet::clearAll().

Here is the caller graph for this function:

◆ clear()

virtual void libsumo::VariableWrapper::clear ( )
inlinevirtualinherited

Reimplemented in libsumo::Helper::SubscriptionWrapper.

Definition at line 158 of file Subscription.h.

◆ close()

void TraCIServer::close ( )
static

request termination of connection

Definition at line 391 of file TraCIServer.cpp.

References myDoCloseConnection, and myInstance.

Referenced by main().

Here is the caller graph for this function:

◆ commandGetVersion()

bool TraCIServer::commandGetVersion ( )
private

Returns the TraCI-version.

Returns
Always true

Definition at line 941 of file TraCIServer.cpp.

References libsumo::CMD_GETVERSION, myOutputStorage, libsumo::RTYPE_OK, tcpip::Storage::size(), libsumo::TRACI_VERSION, tcpip::Storage::writeInt(), writeStatusCmd(), tcpip::Storage::writeStorage(), tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().

Referenced by dispatchCommand().

Here is the caller graph for this function:

◆ dispatchCommand()

int TraCIServer::dispatchCommand ( )
private

Handles command, writes response to myOutputStorage.

Definition at line 754 of file TraCIServer.cpp.

References addObjectVariableSubscription(), addSubscriptionFilter(), libsumo::CMD_ADD_SUBSCRIPTION_FILTER, libsumo::CMD_CLOSE, libsumo::CMD_EXECUTEMOVE, libsumo::CMD_GET_GUI_VARIABLE, libsumo::CMD_GETVERSION, libsumo::CMD_LOAD, libsumo::CMD_SET_GUI_VARIABLE, libsumo::CMD_SETORDER, libsumo::CMD_SIMSTEP, libsumo::CMD_SUBSCRIBE_BUSSTOP_CONTEXT, libsumo::CMD_SUBSCRIBE_BUSSTOP_VARIABLE, libsumo::CMD_SUBSCRIBE_CALIBRATOR_CONTEXT, libsumo::CMD_SUBSCRIBE_CALIBRATOR_VARIABLE, libsumo::CMD_SUBSCRIBE_CHARGINGSTATION_CONTEXT, libsumo::CMD_SUBSCRIBE_CHARGINGSTATION_VARIABLE, libsumo::CMD_SUBSCRIBE_EDGE_CONTEXT, libsumo::CMD_SUBSCRIBE_EDGE_VARIABLE, libsumo::CMD_SUBSCRIBE_GUI_CONTEXT, libsumo::CMD_SUBSCRIBE_GUI_VARIABLE, libsumo::CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT, libsumo::CMD_SUBSCRIBE_INDUCTIONLOOP_VARIABLE, libsumo::CMD_SUBSCRIBE_JUNCTION_CONTEXT, libsumo::CMD_SUBSCRIBE_JUNCTION_VARIABLE, libsumo::CMD_SUBSCRIBE_LANE_CONTEXT, libsumo::CMD_SUBSCRIBE_LANE_VARIABLE, libsumo::CMD_SUBSCRIBE_LANEAREA_CONTEXT, libsumo::CMD_SUBSCRIBE_LANEAREA_VARIABLE, libsumo::CMD_SUBSCRIBE_MEANDATA_CONTEXT, libsumo::CMD_SUBSCRIBE_MEANDATA_VARIABLE, libsumo::CMD_SUBSCRIBE_MULTIENTRYEXIT_CONTEXT, libsumo::CMD_SUBSCRIBE_MULTIENTRYEXIT_VARIABLE, libsumo::CMD_SUBSCRIBE_OVERHEADWIRE_CONTEXT, libsumo::CMD_SUBSCRIBE_OVERHEADWIRE_VARIABLE, libsumo::CMD_SUBSCRIBE_PARKINGAREA_CONTEXT, libsumo::CMD_SUBSCRIBE_PARKINGAREA_VARIABLE, libsumo::CMD_SUBSCRIBE_PERSON_CONTEXT, libsumo::CMD_SUBSCRIBE_PERSON_VARIABLE, libsumo::CMD_SUBSCRIBE_POI_CONTEXT, libsumo::CMD_SUBSCRIBE_POI_VARIABLE, libsumo::CMD_SUBSCRIBE_POLYGON_CONTEXT, libsumo::CMD_SUBSCRIBE_POLYGON_VARIABLE, libsumo::CMD_SUBSCRIBE_REROUTER_CONTEXT, libsumo::CMD_SUBSCRIBE_REROUTER_VARIABLE, libsumo::CMD_SUBSCRIBE_ROUTE_CONTEXT, libsumo::CMD_SUBSCRIBE_ROUTE_VARIABLE, libsumo::CMD_SUBSCRIBE_ROUTEPROBE_CONTEXT, libsumo::CMD_SUBSCRIBE_ROUTEPROBE_VARIABLE, libsumo::CMD_SUBSCRIBE_SIM_CONTEXT, libsumo::CMD_SUBSCRIBE_SIM_VARIABLE, libsumo::CMD_SUBSCRIBE_TL_CONTEXT, libsumo::CMD_SUBSCRIBE_TL_VARIABLE, libsumo::CMD_SUBSCRIBE_VARIABLESPEEDSIGN_CONTEXT, libsumo::CMD_SUBSCRIBE_VARIABLESPEEDSIGN_VARIABLE, libsumo::CMD_SUBSCRIBE_VEHICLE_CONTEXT, libsumo::CMD_SUBSCRIBE_VEHICLE_VARIABLE, libsumo::CMD_SUBSCRIBE_VEHICLETYPE_CONTEXT, libsumo::CMD_SUBSCRIBE_VEHICLETYPE_VARIABLE, commandGetVersion(), DELTA_T, MSNet::getCurrentTimeStep(), MSNet::getInstance(), libsumo::MAX_ORDER, myCurrentSocket, myDoCloseConnection, myExecutors, myInputStorage, myLoadArgs, myOutputStorage, mySocketReorderRequests, mySockets, tcpip::Storage::position(), tcpip::Storage::readChar(), readCommandID(), tcpip::Storage::readDouble(), tcpip::Storage::readInt(), readTypeCheckingStringList(), removeCurrentSocket(), tcpip::Storage::reset(), libsumo::RTYPE_ERR, libsumo::RTYPE_NOTIMPLEMENTED, libsumo::RTYPE_OK, sendSingleSimStepResponse(), TIME2STEPS, toString(), tcpip::Storage::valid_pos(), writeErrorStatusCmd(), and writeStatusCmd().

Referenced by checkClientOrdering(), and processCommands().

Here is the caller graph for this function:

◆ empty()

virtual void libsumo::VariableWrapper::empty ( const std::string &  )
inlinevirtualinherited

Reimplemented in libsumo::Helper::SubscriptionWrapper.

Definition at line 169 of file Subscription.h.

Referenced by libsumo::Helper::handleSingleSubscription().

Here is the caller graph for this function:

◆ getInstance()

static TraCIServer* TraCIServer::getInstance ( void  )
inlinestatic

◆ getLoadArgs()

std::vector<std::string>& TraCIServer::getLoadArgs ( )
inline

Definition at line 258 of file TraCIServer.h.

References myLoadArgs.

Referenced by MSNet::adaptToState(), and MSNet::simulationStep().

Here is the caller graph for this function:

◆ getTargetTime()

SUMOTime TraCIServer::getTargetTime ( ) const
inline

Definition at line 64 of file TraCIServer.h.

References myTargetTime.

Referenced by MSNet::simulationStep().

Here is the caller graph for this function:

◆ getTransportableStateChanges()

const std::map<MSNet::TransportableState, std::vector<std::string> >& TraCIServer::getTransportableStateChanges ( ) const
inline

Definition at line 145 of file TraCIServer.h.

References myCurrentSocket, mySockets, and myTransportableStateChanges.

Referenced by TraCIServerAPI_Simulation::writeTransportableStateIDs(), and TraCIServerAPI_Simulation::writeTransportableStateNumber().

Here is the caller graph for this function:

◆ getVehicleStateChanges()

const std::map<MSNet::VehicleState, std::vector<std::string> >& TraCIServer::getVehicleStateChanges ( ) const
inline

Definition at line 135 of file TraCIServer.h.

References myCurrentSocket, mySockets, and myVehicleStateChanges.

Referenced by TraCIServerAPI_Simulation::writeVehicleStateIDs(), and TraCIServerAPI_Simulation::writeVehicleStateNumber().

Here is the caller graph for this function:

◆ getWrapperStorage()

◆ initialiseSubscription()

◆ initWrapper()

◆ nextTargetTime()

SUMOTime TraCIServer::nextTargetTime ( ) const
private

get the minimal next target time among all clients

Definition at line 537 of file TraCIServer.cpp.

References MIN2(), and mySockets.

Referenced by processCommands().

Here is the caller graph for this function:

◆ openSocket()

void TraCIServer::openSocket ( const std::map< int, CmdExecutor > &  execs)
static

Initialises the server.

Parameters
[in]execsThe (additional) command executors to use

Definition at line 372 of file TraCIServer.cpp.

References MSNet::addTransportableStateListener(), MSNet::addVehicleStateListener(), MSNet::getInstance(), OptionsCont::getOptions(), myDoCloseConnection, myExecutors, myInstance, mySubscriptionCache, string2time(), TraCIServer(), and tcpip::Storage::writeInt().

Referenced by NLBuilder::init(), and GUILoadThread::run().

Here is the caller graph for this function:

◆ operator=()

TraCIServer& TraCIServer::operator= ( const TraCIServer s)
privatedelete

Invalidated assignment operator.

◆ postProcessSimulationStep()

◆ processCommands()

int TraCIServer::processCommands ( const SUMOTime  step,
const bool  afterMove = false 
)

process all commands until the next SUMO simulation step. It is guaranteed that t->getTargetTime() >= myStep after call (except the case that a load or close command is received)s

Definition at line 583 of file TraCIServer.cpp.

References libsumo::CMD_CLOSE, libsumo::CMD_EXECUTEMOVE, libsumo::CMD_LOAD, libsumo::CMD_SIMSTEP, dispatchCommand(), MSNet::getInstance(), myCurrentSocket, myDoCloseConnection, myInputStorage, myLoadArgs, myOutputStorage, mySockets, myTargetTime, myTransportableStateChanges, myVehicleStateChanges, nextTargetTime(), postProcessSimulationStep(), processReorderingRequests(), tcpip::Storage::reset(), sendOutputToAll(), SIMTIME, tcpip::Storage::size(), and tcpip::Storage::valid_pos().

Referenced by MSNet::simulationStep().

Here is the caller graph for this function:

◆ processReorderingRequests()

void TraCIServer::processReorderingRequests ( )
private

checks for and processes reordering requests (relevant for multiple clients)

Definition at line 493 of file TraCIServer.cpp.

References mySocketReorderRequests, mySockets, and SIMTIME.

Referenced by processCommands().

Here is the caller graph for this function:

◆ processSingleSubscription()

◆ readCommandID()

int TraCIServer::readCommandID ( int &  commandStart,
int &  commandLength 
)
private

Reads the next command ID from the input storage.

Returns
the command ID
Parameters
[out]theversion with reference parameters provides information on the command start position and length used in dispatchCommand for checking purposes

Definition at line 736 of file TraCIServer.cpp.

References tcpip::Storage::begin(), tcpip::Storage::end(), myInputStorage, tcpip::Storage::position(), tcpip::Storage::readInt(), and tcpip::Storage::readUnsignedByte().

Referenced by checkClientOrdering(), and dispatchCommand().

Here is the caller graph for this function:

◆ readTypeCheckingByte()

bool TraCIServer::readTypeCheckingByte ( tcpip::Storage inputStorage,
int &  into 
)

Reads the value type and a byte, verifying the type.

Parameters
[in,changed]inputStorage The storage to read from
[out]intoHolder of the read value
Returns
Whether a byte was given (by data type)

Definition at line 1583 of file TraCIServer.cpp.

References tcpip::Storage::readByte(), and libsumo::TYPE_BYTE.

Referenced by TraCIServerAPI_Vehicle::insertReplaceStop(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Person::processSet(), and TraCIServerAPI_Vehicle::processSet().

Here is the caller graph for this function:

◆ readTypeCheckingColor()

bool TraCIServer::readTypeCheckingColor ( tcpip::Storage inputStorage,
libsumo::TraCIColor into 
)

Reads the value type and a color, verifying the type.

Parameters
[in,changed]inputStorage The storage to read from
[out]intoHolder of the read value
Returns
Whether a color was given (by data type)

Definition at line 1558 of file TraCIServer.cpp.

References libsumo::TraCIColor::a, libsumo::TraCIColor::b, libsumo::TraCIColor::g, libsumo::TraCIColor::r, tcpip::Storage::readUnsignedByte(), and libsumo::TYPE_COLOR.

Referenced by TraCIServerAPI_Person::processSet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_Vehicle::processSet(), and TraCIServerAPI_VehicleType::setVariable().

Here is the caller graph for this function:

◆ readTypeCheckingDouble()

bool TraCIServer::readTypeCheckingDouble ( tcpip::Storage inputStorage,
double &  into 
)

Reads the value type and a double, verifying the type.

Parameters
[in,changed]inputStorage The storage to read from
[out]intoHolder of the read value
Returns
Whether a double value was given (by data type)

Definition at line 1518 of file TraCIServer.cpp.

References tcpip::Storage::readDouble(), tcpip::Storage::readUnsignedByte(), and libsumo::TYPE_DOUBLE.

Referenced by TraCIServerAPI_Vehicle::insertReplaceStop(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_GUI::processSet(), TraCIServerAPI_InductionLoop::processSet(), TraCIServerAPI_Person::processSet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_Simulation::processSet(), TraCIServerAPI_TrafficLight::processSet(), TraCIServerAPI_Vehicle::processSet(), and TraCIServerAPI_VehicleType::setVariable().

Here is the caller graph for this function:

◆ readTypeCheckingDoubleList()

bool TraCIServer::readTypeCheckingDoubleList ( tcpip::Storage inputStorage,
std::vector< double > &  into 
)

Reads the value type and a double list, verifying the type.

Parameters
[in,changed]inputStorage The storage to read from
[out]intoHolder of the read value
Returns
Whether a double value was given (by data type)

Definition at line 1548 of file TraCIServer.cpp.

References tcpip::Storage::readDoubleList(), tcpip::Storage::readUnsignedByte(), and libsumo::TYPE_DOUBLELIST.

Referenced by TraCIServerAPI_Polygon::processSet().

Here is the caller graph for this function:

◆ readTypeCheckingInt()

bool TraCIServer::readTypeCheckingInt ( tcpip::Storage inputStorage,
int &  into 
)

Reads the value type and an int, verifying the type.

Parameters
[in,changed]inputStorage The storage to read from
[out]intoHolder of the read value
Returns
Whether an integer value was given (by data type)

Definition at line 1508 of file TraCIServer.cpp.

References tcpip::Storage::readInt(), tcpip::Storage::readUnsignedByte(), and libsumo::TYPE_INTEGER.

Referenced by TraCIServerAPI_Vehicle::insertReplaceStop(), TraCIServerAPI_Person::processGet(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_TrafficLight::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_GUI::processSet(), TraCIServerAPI_LaneArea::processSet(), TraCIServerAPI_Person::processSet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_TrafficLight::processSet(), and TraCIServerAPI_Vehicle::processSet().

Here is the caller graph for this function:

◆ readTypeCheckingPolygon()

bool TraCIServer::readTypeCheckingPolygon ( tcpip::Storage inputStorage,
PositionVector into 
)

Reads the value type and a polygon, verifying the type.

Parameters
[in,changed]inputStorage The storage to read from
[out]intoHolder of the read value
Returns
Whether an unsigned byte was given (by data type)

Definition at line 1603 of file TraCIServer.cpp.

References tcpip::Storage::readDouble(), tcpip::Storage::readInt(), tcpip::Storage::readUnsignedByte(), and libsumo::TYPE_POLYGON.

Referenced by TraCIServerAPI_GUI::processSet(), and TraCIServerAPI_Polygon::processSet().

Here is the caller graph for this function:

◆ readTypeCheckingPosition2D()

bool TraCIServer::readTypeCheckingPosition2D ( tcpip::Storage inputStorage,
libsumo::TraCIPosition into 
)

Reads the value type and a 2D position, verifying the type.

Parameters
[in,changed]inputStorage The storage to read from
[out]intoHolder of the read value
Returns
Whether a 2D position was given (by data type)

Definition at line 1571 of file TraCIServer.cpp.

References libsumo::POSITION_2D, tcpip::Storage::readDouble(), tcpip::Storage::readUnsignedByte(), libsumo::TraCIPosition::x, libsumo::TraCIPosition::y, and libsumo::TraCIPosition::z.

Referenced by TraCIServerAPI_GUI::processSet(), and TraCIServerAPI_POI::processSet().

Here is the caller graph for this function:

◆ readTypeCheckingString()

◆ readTypeCheckingStringList()

bool TraCIServer::readTypeCheckingStringList ( tcpip::Storage inputStorage,
std::vector< std::string > &  into 
)

Reads the value type and a string list, verifying the type.

Parameters
[in,changed]inputStorage The storage to read from
[out]intoHolder of the read value
Returns
Whether a double value was given (by data type)

Definition at line 1538 of file TraCIServer.cpp.

References tcpip::Storage::readStringList(), tcpip::Storage::readUnsignedByte(), and libsumo::TYPE_STRINGLIST.

Referenced by dispatchCommand(), TraCIServerAPI_Person::processGet(), TraCIServerAPI_Person::processSet(), TraCIServerAPI_Route::processSet(), TraCIServerAPI_TrafficLight::processSet(), and TraCIServerAPI_Vehicle::processSet().

Here is the caller graph for this function:

◆ readTypeCheckingUnsignedByte()

bool TraCIServer::readTypeCheckingUnsignedByte ( tcpip::Storage inputStorage,
int &  into 
)

Reads the value type and an unsigned byte, verifying the type.

Parameters
[in,changed]inputStorage The storage to read from
[out]intoHolder of the read value
Returns
Whether an unsigned byte was given (by data type)

Definition at line 1593 of file TraCIServer.cpp.

References tcpip::Storage::readUnsignedByte(), and libsumo::TYPE_UBYTE.

Referenced by TraCIServerAPI_Simulation::commandPositionConversion(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Polygon::processSet(), and TraCIServerAPI_Vehicle::processSet().

Here is the caller graph for this function:

◆ removeCurrentSocket()

std::map< int, TraCIServer::SocketInfo * >::iterator TraCIServer::removeCurrentSocket ( )
private

removes myCurrentSocket from mySockets and returns an iterator pointing to the next member according to the ordering

Definition at line 724 of file TraCIServer.cpp.

References myCurrentSocket, and mySockets.

Referenced by dispatchCommand().

Here is the caller graph for this function:

◆ removeFilters()

void TraCIServer::removeFilters ( )
private

Definition at line 1384 of file TraCIServer.cpp.

References libsumo::Subscription::activeFilters, myLastContextSubscription, and libsumo::SUBS_FILTER_NONE.

Referenced by addSubscriptionFilter().

Here is the caller graph for this function:

◆ removeSubscription()

void TraCIServer::removeSubscription ( int  commandId,
const std::string &  identity,
int  domain 
)
private

Definition at line 1113 of file TraCIServer.cpp.

References myLastContextSubscription, mySubscriptions, libsumo::RTYPE_ERR, libsumo::RTYPE_OK, and writeStatusCmd().

Referenced by addObjectVariableSubscription().

Here is the caller graph for this function:

◆ sendOutputToAll()

void TraCIServer::sendOutputToAll ( ) const
private

send out subscription results (actually just the content of myOutputStorage) to clients which will act in this step (i.e. with client target time <= myTargetTime)

Definition at line 561 of file TraCIServer.cpp.

References MSNet::getCurrentTimeStep(), MSNet::getInstance(), myOutputStorage, and mySockets.

Referenced by processCommands().

Here is the caller graph for this function:

◆ sendSingleSimStepResponse()

void TraCIServer::sendSingleSimStepResponse ( )
private

sends an empty response to a simstep command to the current client. (This applies to a situation where the TraCI step frequency is higher than the SUMO step frequency)

Definition at line 1019 of file TraCIServer.cpp.

References libsumo::CMD_SIMSTEP, myCurrentSocket, myOutputStorage, mySubscriptionCache, tcpip::Storage::reset(), libsumo::RTYPE_OK, tcpip::Storage::size(), writeStatusCmd(), and tcpip::Storage::writeStorage().

Referenced by dispatchCommand().

Here is the caller graph for this function:

◆ setContext()

virtual void libsumo::VariableWrapper::setContext ( const std::string * const  )
inlinevirtualinherited

Reimplemented in libsumo::Helper::SubscriptionWrapper.

Definition at line 157 of file Subscription.h.

Referenced by libsumo::Helper::handleSingleSubscription().

Here is the caller graph for this function:

◆ stateLoaded()

void TraCIServer::stateLoaded ( SUMOTime  targetTime)

updates myTargetTime and resets vehicle state changes after loading a simulation state

Note
Used in MSStateHandler to update the server's time after loading a state

Definition at line 1626 of file TraCIServer.cpp.

References mySockets, mySubscriptionCache, mySubscriptions, myTargetTime, and tcpip::Storage::reset().

Referenced by NLBuilder::build(), and TraCIServerAPI_Simulation::processSet().

Here is the caller graph for this function:

◆ transportableStateChanged()

void TraCIServer::transportableStateChanged ( const MSTransportable *const  transportable,
MSNet::TransportableState  to,
const std::string &  info = "" 
)
virtual

Called if a transportable changes its state.

Parameters
[in]transportableThe transportable which changed its state
[in]toThe state the transportable has changed to
[in]infoAdditional information on the state change

Implements MSNet::TransportableStateListener.

Definition at line 422 of file TraCIServer.cpp.

References Named::getID(), myDoCloseConnection, mySockets, and myTransportableStateChanges.

◆ vehicleStateChanged()

void TraCIServer::vehicleStateChanged ( const SUMOVehicle *const  vehicle,
MSNet::VehicleState  to,
const std::string &  info = "" 
)
virtual

Called if a vehicle changes its state.

Parameters
[in]vehicleThe vehicle which changed its state
[in]toThe state the vehicle has changed to
[in]infoAdditional information on the state change

Implements MSNet::VehicleStateListener.

Definition at line 411 of file TraCIServer.cpp.

References Named::getID(), myDoCloseConnection, mySockets, and myVehicleStateChanges.

◆ wasClosed()

bool TraCIServer::wasClosed ( )
static

check whether close was requested

Returns
Whether the connection was closed

Definition at line 402 of file TraCIServer.cpp.

References myDoCloseConnection.

Referenced by MSNet::adaptToState(), MSNet::simulationState(), and MSNet::simulationStep().

Here is the caller graph for this function:

◆ wrapColor()

bool TraCIServer::wrapColor ( const std::string &  objID,
const int  variable,
const libsumo::TraCIColor value 
)
virtual

◆ wrapDouble()

bool TraCIServer::wrapDouble ( const std::string &  objID,
const int  variable,
const double  value 
)
virtual

◆ wrapDoubleList()

bool TraCIServer::wrapDoubleList ( const std::string &  objID,
const int  variable,
const std::vector< double > &  value 
)
virtual

◆ wrapInt()

bool TraCIServer::wrapInt ( const std::string &  objID,
const int  variable,
const int  value 
)
virtual

◆ wrapPosition()

bool TraCIServer::wrapPosition ( const std::string &  objID,
const int  variable,
const libsumo::TraCIPosition value 
)
virtual

◆ wrapPositionVector()

bool TraCIServer::wrapPositionVector ( const std::string &  objID,
const int  variable,
const libsumo::TraCIPositionVector value 
)
virtual

◆ wrapString()

bool TraCIServer::wrapString ( const std::string &  objID,
const int  variable,
const std::string &  value 
)
virtual

◆ wrapStringDoublePair()

bool TraCIServer::wrapStringDoublePair ( const std::string &  objID,
const int  variable,
const std::pair< std::string, double > &  value 
)
virtual

◆ wrapStringList()

bool TraCIServer::wrapStringList ( const std::string &  objID,
const int  variable,
const std::vector< std::string > &  value 
)
virtual

◆ wrapStringPair()

bool TraCIServer::wrapStringPair ( const std::string &  objID,
const int  variable,
const std::pair< std::string, std::string > &  value 
)
virtual

◆ writeErrorStatusCmd()

bool TraCIServer::writeErrorStatusCmd ( int  commandId,
const std::string &  description,
tcpip::Storage outputStorage 
)

Writes a status command to the given storage with status = RTYPE_ERR.

Parameters
[in]commandIdThe id of the command to respond to
[in]descriptionThe status description (error message, for example)
[in,filled]outputStorage The storage to write the status into

Definition at line 1060 of file TraCIServer.cpp.

References libsumo::RTYPE_ERR, and writeStatusCmd().

Referenced by dispatchCommand(), TraCIServerAPI_Vehicle::insertReplaceStop(), TraCIServerAPI_GUI::processGet(), TraCIServerAPI_BusStop::processGet(), TraCIServerAPI_Calibrator::processGet(), TraCIServerAPI_ChargingStation::processGet(), TraCIServerAPI_Edge::processGet(), TraCIServerAPI_InductionLoop::processGet(), TraCIServerAPI_Junction::processGet(), TraCIServerAPI_Lane::processGet(), TraCIServerAPI_LaneArea::processGet(), TraCIServerAPI_MeanData::processGet(), TraCIServerAPI_MultiEntryExit::processGet(), TraCIServerAPI_OverheadWire::processGet(), TraCIServerAPI_ParkingArea::processGet(), TraCIServerAPI_Person::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_Rerouter::processGet(), TraCIServerAPI_Route::processGet(), TraCIServerAPI_RouteProbe::processGet(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_TrafficLight::processGet(), TraCIServerAPI_VariableSpeedSign::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_VehicleType::processGet(), TraCIServerAPI_GUI::processSet(), TraCIServerAPI_BusStop::processSet(), TraCIServerAPI_Calibrator::processSet(), TraCIServerAPI_ChargingStation::processSet(), TraCIServerAPI_Edge::processSet(), TraCIServerAPI_InductionLoop::processSet(), TraCIServerAPI_Junction::processSet(), TraCIServerAPI_Lane::processSet(), TraCIServerAPI_LaneArea::processSet(), TraCIServerAPI_MultiEntryExit::processSet(), TraCIServerAPI_OverheadWire::processSet(), TraCIServerAPI_ParkingArea::processSet(), TraCIServerAPI_Person::processSet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_Rerouter::processSet(), TraCIServerAPI_Route::processSet(), TraCIServerAPI_RouteProbe::processSet(), TraCIServerAPI_Simulation::processSet(), TraCIServerAPI_TrafficLight::processSet(), TraCIServerAPI_VariableSpeedSign::processSet(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_VehicleType::processSet(), and TraCIServerAPI_VehicleType::setVariable().

◆ writePositionVector()

◆ writeResponseWithLength()

◆ writeStatusCmd() [1/2]

void TraCIServer::writeStatusCmd ( int  commandId,
int  status,
const std::string &  description 
)

Writes a status command to myOutputStorage.

Parameters
[in]commandIdThe id of the command to respond to
[in]statusThe status to send
[in]descriptionThe status description (error message, for example)

Definition at line 1040 of file TraCIServer.cpp.

References myOutputStorage, and writeStatusCmd().

◆ writeStatusCmd() [2/2]

void TraCIServer::writeStatusCmd ( int  commandId,
int  status,
const std::string &  description,
tcpip::Storage outputStorage 
)

Writes a status command to the given storage.

Parameters
[in]commandIdThe id of the command to respond to
[in]statusThe status to send
[in]descriptionThe status description (error message, for example)
[in,filled]outputStorage The storage to write the status into

Definition at line 1046 of file TraCIServer.cpp.

References libsumo::RTYPE_ERR, libsumo::RTYPE_NOTIMPLEMENTED, toHex(), WRITE_ERROR, tcpip::Storage::writeString(), and tcpip::Storage::writeUnsignedByte().

Referenced by addSubscriptionFilter(), TraCIServerAPI_Simulation::commandDistanceRequest(), commandGetVersion(), TraCIServerAPI_Simulation::commandPositionConversion(), dispatchCommand(), initialiseSubscription(), postProcessSimulationStep(), TraCIServerAPI_GUI::processGet(), TraCIServerAPI_BusStop::processGet(), TraCIServerAPI_Calibrator::processGet(), TraCIServerAPI_ChargingStation::processGet(), TraCIServerAPI_Edge::processGet(), TraCIServerAPI_InductionLoop::processGet(), TraCIServerAPI_Junction::processGet(), TraCIServerAPI_Lane::processGet(), TraCIServerAPI_LaneArea::processGet(), TraCIServerAPI_MeanData::processGet(), TraCIServerAPI_MultiEntryExit::processGet(), TraCIServerAPI_OverheadWire::processGet(), TraCIServerAPI_ParkingArea::processGet(), TraCIServerAPI_Person::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_Rerouter::processGet(), TraCIServerAPI_Route::processGet(), TraCIServerAPI_RouteProbe::processGet(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_TrafficLight::processGet(), TraCIServerAPI_VariableSpeedSign::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_VehicleType::processGet(), TraCIServerAPI_GUI::processSet(), TraCIServerAPI_BusStop::processSet(), TraCIServerAPI_Calibrator::processSet(), TraCIServerAPI_ChargingStation::processSet(), TraCIServerAPI_Edge::processSet(), TraCIServerAPI_InductionLoop::processSet(), TraCIServerAPI_Junction::processSet(), TraCIServerAPI_Lane::processSet(), TraCIServerAPI_LaneArea::processSet(), TraCIServerAPI_MultiEntryExit::processSet(), TraCIServerAPI_OverheadWire::processSet(), TraCIServerAPI_ParkingArea::processSet(), TraCIServerAPI_Person::processSet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_Rerouter::processSet(), TraCIServerAPI_Route::processSet(), TraCIServerAPI_RouteProbe::processSet(), TraCIServerAPI_Simulation::processSet(), TraCIServerAPI_TrafficLight::processSet(), TraCIServerAPI_VariableSpeedSign::processSet(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_VehicleType::processSet(), processSingleSubscription(), removeSubscription(), sendSingleSimStepResponse(), writeErrorStatusCmd(), and writeStatusCmd().

Field Documentation

◆ handle

SubscriptionHandler libsumo::VariableWrapper::handle
inherited

Definition at line 156 of file Subscription.h.

◆ myCurrentSocket

std::map<int, SocketInfo*>::iterator TraCIServer::myCurrentSocket
private

◆ myDoCloseConnection

bool TraCIServer::myDoCloseConnection = false
staticprivate

Whether the connection was set to be to close.

Definition at line 361 of file TraCIServer.h.

Referenced by close(), dispatchCommand(), openSocket(), processCommands(), TraCIServer(), transportableStateChanged(), vehicleStateChanged(), and wasClosed().

◆ myExecutors

std::map<int, CmdExecutor> TraCIServer::myExecutors
private

Map of commandIds -> their executors; applicable if the executor applies to the method footprint.

Definition at line 389 of file TraCIServer.h.

Referenced by dispatchCommand(), openSocket(), processSingleSubscription(), and TraCIServer().

◆ myInputStorage

tcpip::Storage TraCIServer::myInputStorage
private

◆ myInstance

TraCIServer * TraCIServer::myInstance = nullptr
staticprivate

Singleton instance of the server.

Definition at line 358 of file TraCIServer.h.

Referenced by close(), getInstance(), and openSocket().

◆ myLastContextSubscription

◆ myLoadArgs

std::vector<std::string> TraCIServer::myLoadArgs
private

Definition at line 394 of file TraCIServer.h.

Referenced by dispatchCommand(), getLoadArgs(), and processCommands().

◆ myOutputStorage

◆ myParameterized

std::set<std::pair<int, int> > TraCIServer::myParameterized
private

Set of variables which have parameters.

Definition at line 392 of file TraCIServer.h.

Referenced by addObjectVariableSubscription(), and TraCIServer().

◆ mySocketReorderRequests

std::map<int, SocketInfo*> TraCIServer::mySocketReorderRequests
private

This stores the setOrder(int) requests of the clients.

Definition at line 368 of file TraCIServer.h.

Referenced by dispatchCommand(), and processReorderingRequests().

◆ mySockets

std::map<int, SocketInfo*> TraCIServer::mySockets
private

The socket connections to the clients the first component (index) determines the client's order (lowest index's commands are processed first),.

See also
CMD_SETORDER

Definition at line 365 of file TraCIServer.h.

Referenced by checkClientOrdering(), cleanup(), dispatchCommand(), getTransportableStateChanges(), getVehicleStateChanges(), nextTargetTime(), processCommands(), processReorderingRequests(), removeCurrentSocket(), sendOutputToAll(), stateLoaded(), TraCIServer(), transportableStateChanged(), vehicleStateChanged(), and ~TraCIServer().

◆ mySubscriptionCache

tcpip::Storage TraCIServer::mySubscriptionCache
private

The last timestep's subscription results.

Definition at line 386 of file TraCIServer.h.

Referenced by cleanup(), initialiseSubscription(), openSocket(), postProcessSimulationStep(), sendSingleSimStepResponse(), and stateLoaded().

◆ mySubscriptions

std::vector<libsumo::Subscription> TraCIServer::mySubscriptions
private

The list of known, still valid subscriptions.

Definition at line 397 of file TraCIServer.h.

Referenced by cleanup(), initialiseSubscription(), postProcessSimulationStep(), removeSubscription(), and stateLoaded().

◆ myTargetTime

SUMOTime TraCIServer::myTargetTime
private

The time step to reach until processing the next commands.

Definition at line 374 of file TraCIServer.h.

Referenced by cleanup(), getTargetTime(), processCommands(), and stateLoaded().

◆ myTransportableStateChanges

std::map<MSNet::TransportableState, std::vector<std::string> > TraCIServer::myTransportableStateChanges
private

Changes in the states of simulated transportables.

Note
Server cache myTransportableStateChanges is used for managing last steps subscription updates and for client information in case that myAmEmbedded==true, which implies a single client. For the potential multiclient case (myAmEmbedded==false), each socket in mySockets is associated with a proper TransportableStateChanges container mySockets[...].second->TransportableStateChanges Performance could be improved if for a single client, myTransportableStateChanges is used only.

Definition at line 418 of file TraCIServer.h.

Referenced by cleanup(), getTransportableStateChanges(), processCommands(), TraCIServer(), and transportableStateChanged().

◆ myVehicleStateChanges

std::map<MSNet::VehicleState, std::vector<std::string> > TraCIServer::myVehicleStateChanges
private

Changes in the states of simulated vehicles.

Note
Server cache myVehicleStateChanges is used for managing last steps subscription updates and for client information in case that myAmEmbedded==true, which implies a single client. For the potential multiclient case (myAmEmbedded==false), each socket in mySockets is associated with a proper vehicleStateChanges container mySockets[...].second->vehicleStateChanges Performance could be improved if for a single client, myVehicleStateChanges is used only.

Definition at line 409 of file TraCIServer.h.

Referenced by cleanup(), getVehicleStateChanges(), postProcessSimulationStep(), processCommands(), TraCIServer(), and vehicleStateChanged().

◆ myWrapperStorage

tcpip::Storage TraCIServer::myWrapperStorage
private

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