93 static void openSocket(
const std::map<int, CmdExecutor>& execs);
121 static std::string execute(std::string cmd);
125 static void runEmbedded(std::string pyFile);
147 void writeStatusCmd(
int commandId,
int status,
const std::string& description);
350 const std::vector<int>& variablesArg,
const std::vector<std::vector<unsigned char> >& paramsArg,
394 std::string& errors);
bool processSingleSubscription(const TraCIServer::Subscription &s, tcpip::Storage &writeInto, std::string &errors)
bool myDoingSimStep
Whether a step is currently done.
tcpip::Socket * mySocket
The socket on which server is listening on.
bool findObjectShape(int domain, const std::string &id, PositionVector &shape)
Representation of a vehicle in the micro simulation.
bool contextVars
Whether the subscription is a context subscription (variable subscription otherwise) ...
Interface for objects listening to vehicle state changes.
TraCIServer & operator=(const TraCIServer &s)
Invalidated assignment operator.
void collectObjectsInRange(int domain, const PositionVector &shape, SUMOReal range, std::set< std::string > &into)
Subscription(int commandIdArg, const std::string &idArg, const std::vector< int > &variablesArg, const std::vector< std::vector< unsigned char > > ¶msArg, SUMOTime beginTimeArg, SUMOTime endTimeArg, bool contextVarsArg, int contextDomainArg, SUMOReal rangeArg)
Constructor.
virtual ~TraCIServer()
Destructor.
bool commandGetVersion()
Returns the TraCI-version.
std::vector< std::vector< unsigned char > > parameters
The parameters for the subscribed variables.
bool readTypeCheckingColor(tcpip::Storage &inputStorage, RGBColor &into)
Reads the value type and a color, verifying the type.
SUMOTime beginTime
The begin time of the subscription.
tcpip::Storage myOutputStorage
The storage to writeto.
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
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.
Representation of a subscription.
bool readTypeCheckingPolygon(tcpip::Storage &inputStorage, PositionVector &into)
Reads the value type and a polygon, verifying the type.
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
A class that stores a 2D geometrical boundary.
static bool myDoCloseConnection
Whether the connection was set to be to close.
std::map< int, CmdExecutor > myExecutors
Map of commandIds -> their executors; applicable if the executor applies to the method footprint...
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to)
Called if a vehicle changes its state.
bool readTypeCheckingBoundary(tcpip::Storage &inputStorage, Boundary &into)
Reads the value type and a 2D bounding box, verifying the type.
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)
int commandId
commandIdArg The command id of the subscription
std::vector< Subscription > mySubscriptions
The list of known, still valid subscriptions.
Representation of a vehicle.
SUMOReal range
The range of the context.
bool commandCloseConnection()
Indicates the connection as being closed.
std::vector< const MSEdge * > MSEdgeVector
const std::map< MSNet::VehicleState, std::vector< std::string > > & getVehicleStateChanges() const
A point in 2D or 3D with translation and scaling methods.
std::string id
The id of the object that is subscribed.
std::vector< int > variables
The subscribed variables.
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
void postProcessSimulationStep2()
Handles subscriptions to send after a simstep2 command.
void setVTDControlled(MSVehicle *v, MSLane *l, SUMOReal pos, int edgeOffset, MSEdgeVector route)
static TraCIServer * myInstance
Singleton instance of the server.
TraCIServer(const SUMOTime begin, const int port=0)
Constructor.
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 writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
VehicleState
Definition of a vehicle state.
const bool myAmEmbedded
Whether the server runs in embedded mode.
bool readTypeCheckingPosition2D(tcpip::Storage &inputStorage, Position &into)
Reads the value type and a 2D position, verifying the type.
static void processCommandsUntilSimStep(SUMOTime step)
process all commands until a simulation step is wanted
LANE_RTREE_QUAL * myLaneTree
A storage of lanes.
static void openSocket(const std::map< int, CmdExecutor > &execs)
Initialises the server.
static TraCIServer * getInstance()
SUMOTime myTargetTime
The time step to reach until processing the next commands.
std::map< int, NamedRTree * > myObjects
A storage of objects.
std::map< std::string, MSVehicle * > myVTDControlledVehicles
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
int contextDomain
The domain ID of the context.
bool(* CmdExecutor)(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Definition of a method to be called for serving an associated commandID.
void initialiseSubscription(const Subscription &s)
Representation of a lane in the micro simulation.
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.
SUMOTime endTime
The end time of the subscription.
std::map< int, int > myParameterSizes
Map of variable ids to the size of the parameter in bytes.