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