83 static void openSocket(
const std::map<int, CmdExecutor>& execs);
107 static std::string execute(std::string cmd);
111 static void runEmbedded(std::string pyFile);
133 void writeStatusCmd(
int commandId,
int status,
const std::string& description);
258 void initWrapper(
const int domainID,
const int variable,
const std::string& objID);
259 bool wrapDouble(
const std::string& objID,
const int variable,
const double value);
260 bool wrapInt(
const std::string& objID,
const int variable,
const int value);
261 bool wrapString(
const std::string& objID,
const int variable,
const std::string& value);
262 bool wrapStringList(
const std::string& objID,
const int variable,
const std::vector<std::string>& value);
285 : targetTime(t), socket(socket) {}
409 std::string& errors);
void addSubscriptionFilterDownstreamDistance(double dist)
tcpip::Storage mySubscriptionCache
The last timestep's subscription results.
bool readTypeCheckingColor(tcpip::Storage &inputStorage, libsumo::TraCIColor &into)
Reads the value type and a color, verifying the type.
bool findObjectShape(int domain, const std::string &id, PositionVector &shape)
Representation of a subscription.
Interface for objects listening to vehicle state changes.
TraCIServer & operator=(const TraCIServer &s)
Invalidated assignment operator.
bool wrapString(const std::string &objID, const int variable, const std::string &value)
bool processSingleSubscription(const libsumo::Subscription &s, tcpip::Storage &writeInto, std::string &errors)
virtual ~TraCIServer()
Destructor.
bool commandGetVersion()
Returns the TraCI-version.
bool wrapInt(const std::string &objID, const int variable, const int value)
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
bool(* CmdExecutor)(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Definition of a method to be called for serving an associated commandID.
tcpip::Storage myOutputStorage
The storage to write to.
void initialiseSubscription(libsumo::Subscription &s)
void postProcessSimulationStep()
Handles subscriptions to send after a simstep2 command.
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
std::vector< std::string > myLoadArgs
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
tcpip::Storage myInputStorage
The storage to read from.
bool centralObject(const libsumo::Subscription &s, const std::string &objID)
check whether a found objID refers to the central object of a context subscription ...
void cleanup()
clean up subscriptions
bool readTypeCheckingPolygon(tcpip::Storage &inputStorage, PositionVector &into)
Reads the value type and a polygon, verifying the type.
std::vector< std::string > & getLoadArgs()
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
static bool myDoCloseConnection
Whether the connection was set to be to close.
std::map< int, SocketInfo * >::iterator removeCurrentSocket()
removes myCurrentSocket from mySockets and returns an iterator pointing to the next member according ...
SUMOTime targetTime
Target time: next point of action for the client.
void addSubscriptionFilterVClass(SVCPermissions vClasses)
std::map< int, CmdExecutor > myExecutors
Map of commandIds -> their executors; applicable if the executor applies to the method footprint...
void removeSubscription(int commandId, const std::string &identity, int domain)
static void close()
request termination of connection
bool addObjectVariableSubscription(const int commandId, const bool hasContext)
tcpip::Socket * socket
Socket object for this client.
Representation of a vehicle.
void addSubscriptionFilterNoOpposite()
SUMOTime getTargetTime() const
bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
SocketInfo(tcpip::Socket *socket, SUMOTime t)
constructor
void addSubscriptionFilterUpstreamDistance(double dist)
bool addSubscriptionFilter()
tcpip::Storage & getWrapperStorage()
libsumo::Subscription * myLastContextSubscription
The last modified context subscription (the one to add a filter to, see (), currently only for vehicl...
void addSubscriptionFilterTurn()
void addSubscriptionFilterLeadFollow()
bool isVehicleToVehicleContextSubscription(const libsumo::Subscription &s)
int readCommandID(int &commandStart, int &commandLength)
Reads the next command ID from the input storage.
static TraCIServer * myInstance
Singleton instance of the server.
bool readTypeCheckingUnsignedByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and an unsigned byte, verifying the type.
TraCI server used to control sumo by a remote TraCI client.
void sendOutputToAll() const
send out subscription results (actually just the content of myOutputStorage) to clients which will ac...
TraCIServer(const SUMOTime begin, const int port, const int numClients)
Constructor.
void sendSingleSimStepResponse()
sends an empty response to a simstep command to the current client. (This applies to a situation wher...
bool wrapColor(const std::string &objID, const int variable, const libsumo::TraCIColor &value)
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
VehicleState
Definition of a vehicle state.
const bool myAmEmbedded
Whether the server runs in embedded mode.
void processCommandsUntilSimStep(SUMOTime step)
process all commands until the next SUMO simulation step. It is guaranteed that t->getTargetTime() >=...
void processReorderingRequests()
checks for and processes reordering requests (relevant for multiple clients)
static void openSocket(const std::map< int, CmdExecutor > &execs)
Initialises the server.
void writePositionVector(tcpip::Storage &outputStorage, const libsumo::TraCIPositionVector &shape)
std::vector< TraCIPosition > TraCIPositionVector
bool wrapPosition(const std::string &objID, const int variable, const libsumo::TraCIPosition &value)
std::map< MSNet::VehicleState, std::vector< std::string > > vehicleStateChanges
container for vehicle state changes since last step taken by this client
std::map< int, SocketInfo * >::iterator myCurrentSocket
The currently active client socket.
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
SUMOTime nextTargetTime() const
get the minimal next target time among all clients
void setTargetTime(SUMOTime targetTime)
Sets myTargetTime on server and sockets to the given value.
const std::map< MSNet::VehicleState, std::vector< std::string > > & getVehicleStateChanges() const
static TraCIServer * getInstance()
SUMOTime myTargetTime
The time step to reach until processing the next commands.
std::vector< libsumo::Subscription > mySubscriptions
The list of known, still valid subscriptions.
bool readTypeCheckingPosition2D(tcpip::Storage &inputStorage, libsumo::TraCIPosition &into)
Reads the value type and a 2D position, verifying the type.
void addSubscriptionFilterLanes(std::vector< int > lanes)
int dispatchCommand()
Handles command, writes response to myOutputStorage.
tcpip::Storage myWrapperStorage
A temporary storage to let the wrapper write to.
std::map< int, SocketInfo * > mySockets
The socket connections to the clients the first component (index) determines the client's order (lowe...
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
std::map< int, SocketInfo * > mySocketReorderRequests
This stores the setOrder(int) requests of the clients.
void initWrapper(const int domainID, const int variable, const std::string &objID)
void addSubscriptionFilterVType(std::set< std::string > vTypes)
static bool wasClosed()
check whether close was requested
std::map< MSNet::VehicleState, std::vector< std::string > > myVehicleStateChanges
Changes in the states of simulated vehicles.
bool readTypeCheckingByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and a byte, verifying the type.
bool wrapDouble(const std::string &objID, const int variable, const double value)
tcpip::Socket * myServerSocket
The server socket.
std::map< int, int > myParameterSizes
Map of variable ids to the size of the parameter in bytes.
void checkClientOrdering()
Called once after connection of all clients for executing SET_ORDER (and possibly prior GET_VERSION) ...