95 static void openSocket(
const std::map<int, CmdExecutor>& execs);
123 static std::string execute(std::string cmd);
127 static void runEmbedded(std::string pyFile);
149 void writeStatusCmd(
int commandId,
int status,
const std::string& description);
363 Subscription(
int commandIdArg,
const std::string& idArg,
const std::vector<int>& variablesArg,
403 std::string& errors);
std::map< MSNet::VehicleState, std::vector< std::string > > myVehicleStateChanges
Changes in the states of simulated vehicles.
Subscription(int commandIdArg, const std::string &idArg, const std::vector< int > &variablesArg, SUMOTime beginTimeArg, SUMOTime endTimeArg, bool contextVarsArg, int contextDomainArg, SUMOReal rangeArg)
Constructor.
Representation of a vehicle in the micro simulation.
Interface for objects listening to vehicle state changes.
tcpip::Storage myOutputStorage
The storage to writeto.
bool myDoingSimStep
Whether a step is currently done.
bool(* CmdExecutor)(traci::TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Definition of a method to be called for serving an associated commandID.
static void openSocket(const std::map< int, CmdExecutor > &execs)
Initialises the server.
void initialiseSubscription(const Subscription &s)
std::vector< Subscription > mySubscriptions
The list of known, still valid subscriptions.
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
bool contextVars
Whether the subscription is a context subscription (variable subscription otherwise) ...
std::map< int, CmdExecutor > myExecutors
Map of commandIds -> their executors; applicable if the executor applies to the method footprint...
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
std::string id
The id of the object that is subscribed.
void postProcessSimulationStep2()
Handles subscriptions to send after a simstep2 command.
Representation of a subscription.
A class that stores a 2D geometrical boundary.
bool processSingleSubscription(const TraCIServer::Subscription &s, tcpip::Storage &writeInto, std::string &errors)
SUMOReal range
The range of the context.
bool readTypeCheckingBoundary(tcpip::Storage &inputStorage, Boundary &into)
Reads the value type and a 2D bounding box, verifying the type.
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to)
Called if a vehicle changes its state.
TraCI server used to control sumo by a remote TraCI client.
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
tcpip::Storage myInputStorage
The storage to read from.
static bool wasClosed()
check whether close was requested
const bool myAmEmbedded
Whether the server runs in embedded mode.
Representation of a vehicle.
std::vector< const MSEdge * > MSEdgeVector
A point in 2D or 3D with translation and scaling methods.
void setVTDControlled(MSVehicle *v, MSLane *l, SUMOReal pos, int edgeOffset, MSEdgeVector route)
bool addObjectVariableSubscription(int commandId)
SUMOTime beginTime
The begin time of the subscription.
std::map< std::string, MSVehicle * > myVTDControlledVehicles
static void close()
request termination of connection
SUMOTime endTime
The end time of the subscription.
static TraCIServer * myInstance
Singleton instance of the server.
virtual ~TraCIServer()
Destructor.
static TraCIServer * getInstance()
tcpip::Socket * mySocket
The socket on which server is listening on.
VehicleState
Definition of a vehicle state.
SUMOTime myTargetTime
The time step to reach until processing the next commands.
void removeSubscription(int commandId, const std::string &identity, int domain)
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
static bool myDoCloseConnection
Whether the connection was set to be to close.
std::map< int, TraCIRTree * > myObjects
A storage of objects.
TraCIServer(int port=0)
Constructor.
bool commandCloseConnection()
Indicates the connection as being closed.
static void processCommandsUntilSimStep(SUMOTime step)
process all commands until a simulation step is wanted
bool readTypeCheckingByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and a byte, verifying the type.
bool addObjectContextSubscription(int commandId)
int commandId
commandIdArg The command id of the subscription
int contextDomain
The domain ID of the context.
const std::map< MSNet::VehicleState, std::vector< std::string > > & getVehicleStateChanges() const
bool commandGetVersion()
Returns the TraCI-version.
bool readTypeCheckingUnsignedByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and an unsigned byte, verifying the type.
void collectObjectsInRange(int domain, const PositionVector &shape, SUMOReal range, std::set< std::string > &into)
bool readTypeCheckingColor(tcpip::Storage &inputStorage, RGBColor &into)
Reads the value type and a color, verifying the type.
bool commandAddVehicle()
Adds a vehicle.
Representation of a lane in the micro simulation.
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
bool findObjectShape(int domain, const std::string &id, PositionVector &shape)
bool readTypeCheckingPolygon(tcpip::Storage &inputStorage, PositionVector &into)
Reads the value type and a polygon, verifying the type.
TraCIServer & operator=(const TraCIServer &s)
Invalidated assignment operator.
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
bool readTypeCheckingPosition2D(tcpip::Storage &inputStorage, Position &into)
Reads the value type and a 2D position, verifying the type.
bool myHaveWarnedDeprecation
Whether the usage of deprecated methods was already reported.
std::vector< int > variables
The subscribed variables.