SUMO - Simulation of Urban MObility
traci::TraCIServer Class Reference

#include <TraCIServer.h>

Inheritance diagram for traci::TraCIServer:
MSNet::VehicleStateListener

Data Structures

class  Subscription

Public Types

typedef bool(* CmdExecutor )(traci::TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
 Definition of a method to be called for serving an associated commandID.

Public Member Functions

std::map< int, CmdExecutor > & getExecutors ()
 Returns the list of (unified) command executors.
const std::map
< MSNet::VehicleState,
std::vector< std::string > > & 
getVehicleStateChanges () const
void vehicleStateChanged (const SUMOVehicle *const vehicle, MSNet::VehicleState to)
 Called if a vehicle changes its state.
void writeResponseWithLength (tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
void writeStatusCmd (int commandId, int status, const std::string &description)
void writeStatusCmd (int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)

Static Public Member Functions

static void close ()
 request termination of connection
static void openSocket (const std::map< int, CmdExecutor > &execs)
 Initialises the server.
static void processCommandsUntilSimStep (SUMOTime step)
 process all commands until a simulation step is wanted
static bool wasClosed ()
 check whether close was requested

Private Member Functions

bool addSubscription (int commandId)
bool commandAddVehicle ()
bool commandCloseConnection ()
bool commandGetVersion ()
int dispatchCommand ()
void postProcessSimulationStep2 ()
bool processSingleSubscription (const TraCIServer::Subscription &s, tcpip::Storage &writeInto, std::string &errors)
 TraCIServer (int port=0)
virtual ~TraCIServer ()

Private Attributes

const bool myAmEmbedded
bool myDoingSimStep
std::map< int, CmdExecutormyExecutors
 Map of commandIds -> their executors; applicable if the executor applies to the method footprint.
bool myHaveWarnedDeprecation
tcpip::Storage myInputStorage
tcpip::Storage myOutputStorage
tcpip::SocketmySocket
 socket on which server is listening on
std::vector< SubscriptionmySubscriptions
SUMOTime myTargetTime
std::map< MSNet::VehicleState,
std::vector< std::string > > 
myVehicleStateChanges

Static Private Attributes

static bool myDoCloseConnection = false
static TraCIServermyInstance = 0
 singleton instance of the server

Detailed Description

Definition at line 76 of file TraCIServer.h.


Member Typedef Documentation

typedef bool(* traci::TraCIServer::CmdExecutor)(traci::TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)

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

Definition at line 79 of file TraCIServer.h.


Constructor & Destructor Documentation

TraCIServer::TraCIServer ( int  port = 0) [private]

Definition at line 125 of file TraCIServer.cpp.

References tcpip::Socket::accept(), MSNet::addVehicleStateListener(), 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_TL_VARIABLE, CMD_SET_VEHICLE_VARIABLE, CMD_SET_VEHICLETYPE_VARIABLE, MSNet::getInstance(), MsgHandler::getWarningInstance(), MSGlobals::gUsingInternalLanes, MsgHandler::inform(), myAmEmbedded, myDoCloseConnection, myExecutors, mySocket, myVehicleStateChanges, TraCIServerAPI_Edge::processGet(), TraCIServerAPI_Route::processGet(), TraCIServerAPI_TLS::processGet(), TraCIServerAPI_POI::processGet(), TraCIServerAPI_Polygon::processGet(), TraCIServerAPI_VehicleType::processGet(), TraCIServerAPI_Junction::processGet(), TraCIServerAPI_Lane::processGet(), TraCIServerAPI_InductionLoop::processGet(), TraCIServerAPI_MeMeDetector::processGet(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Simulation::processGet(), TraCIServerAPI_Edge::processSet(), TraCIServerAPI_Route::processSet(), TraCIServerAPI_Lane::processSet(), TraCIServerAPI_POI::processSet(), TraCIServerAPI_TLS::processSet(), TraCIServerAPI_Polygon::processSet(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_VehicleType::processSet(), toString(), MSNet::VEHICLE_STATE_ARRIVED, MSNet::VEHICLE_STATE_BUILT, MSNet::VEHICLE_STATE_DEPARTED, MSNet::VEHICLE_STATE_ENDING_TELEPORT, MSNet::VEHICLE_STATE_NEWROUTE, MSNet::VEHICLE_STATE_STARTING_TELEPORT, tcpip::SocketException::what(), WRITE_MESSAGE, and WRITE_WARNING.

Referenced by openSocket(), and processCommandsUntilSimStep().


Member Function Documentation

void TraCIServer::close ( ) [static]

request termination of connection

Definition at line 272 of file TraCIServer.cpp.

References myDoCloseConnection, and myInstance.

Referenced by MSNet::closeSimulation().

Definition at line 522 of file TraCIServer.cpp.

References CMD_CLOSE, myDoCloseConnection, RTYPE_OK, and writeStatusCmd().

Referenced by dispatchCommand().

Returns the list of (unified) command executors.

Not all command executor methods apply to the wanted footprint; other comments may be served internally (aka there are more commandIds recognized than within this container

Returns:
Mapped command executors

Definition at line 120 of file TraCIServer.h.

References myExecutors.

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

Definition at line 109 of file TraCIServer.h.

References myVehicleStateChanges.

Referenced by TraCIServerAPI_Simulation::processGet().

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

Initialises the server.

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

Definition at line 112 of file TraCIServer.cpp.

References OptionsCont::getOptions(), myDoCloseConnection, myExecutors, myInstance, and TraCIServer().

Referenced by GUIApplicationWindow::handleEvent_SimulationLoaded().

void TraCIServer::vehicleStateChanged ( const SUMOVehicle *const  vehicle,
MSNet::VehicleState  to 
) [virtual]

Called if a vehicle changes its state.

Parameters:
[in]vehicleThe vehicle which changed its state
[in]toThe state the vehicle has changed to

Implements MSNet::VehicleStateListener.

Definition at line 190 of file TraCIServer.cpp.

References SUMOVehicle::getID(), OptionsCont::getOptions(), myDoCloseConnection, and myVehicleStateChanges.

check whether close was requested

Definition at line 266 of file TraCIServer.cpp.

References myDoCloseConnection.

Referenced by GUIRunThread::makeStep(), MSNet::simulate(), and MSNet::simulationState().

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

Field Documentation

Definition at line 161 of file TraCIServer.h.

Referenced by processCommandsUntilSimStep().

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

Definition at line 166 of file TraCIServer.h.

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

Definition at line 162 of file TraCIServer.h.

Referenced by dispatchCommand().

TraCIServer * TraCIServer::myInstance = 0 [static, private]

singleton instance of the server

Definition at line 149 of file TraCIServer.h.

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

socket on which server is listening on

Definition at line 153 of file TraCIServer.h.

Referenced by processCommandsUntilSimStep(), TraCIServer(), and ~TraCIServer().

Definition at line 182 of file TraCIServer.h.

Referenced by addSubscription(), and postProcessSimulationStep2().


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines