113 myAmEmbedded(port == 0) {
114 #ifdef DEBUG_MULTI_CLIENTS 115 std::cout <<
"Creating new TraCIServer for " << numClients <<
" clients on port " << port <<
"." << std::endl;
160 WRITE_WARNING(
"Starting TraCI without using internal lanes!");
169 while ((
int)
mySockets.size() < numClients) {
184 if (numClients > 1) {
216 for (std::map<int, CmdExecutor>::const_iterator i = execs.begin(); i != execs.end(); ++i) {
252 for (std::map<int, SocketInfo*>::iterator i =
mySockets.begin(); i !=
mySockets.end(); ++i) {
253 i->second->vehicleStateChanges[to].push_back(vehicle->
getID());
261 #ifdef DEBUG_MULTI_CLIENTS 262 std::cout <<
"Checking client order requests." << std::endl;
268 #ifdef DEBUG_MULTI_CLIENTS 269 std::cout <<
" Socket " <<
myCurrentSocket->second->socket <<
":" << std::endl;
273 #pragma warning(push) 274 #pragma warning(disable: 4127) // do not warn about constant conditional expression 282 int commandStart, commandLength;
284 #ifdef DEBUG_MULTI_CLIENTS 285 std::cout <<
" received command " << commandId << std::endl;
291 #ifdef DEBUG_MULTI_CLIENTS 292 std::cout <<
" Init command. Sending response." << std::endl;
309 #ifdef DEBUG_MULTI_CLIENTS 310 std::cout <<
" Client " <<
myCurrentSocket->second->socket <<
" did not set order initially." << std::endl;
312 throw ProcessError(
"Execution order (CMD_SETORDER) was not set for all TraCI clients in pre-execution phase.");
330 std::map<int, SocketInfo*>::iterator j;
331 #ifdef DEBUG_MULTI_CLIENTS 332 std::cout <<
SIMTIME <<
" Current socket ordering:\n";
334 std::cout <<
" " << j->first <<
": " << j->second->socket <<
"\n";
336 std::cout <<
"Reordering requests:\n";
338 std::cout <<
" Socket " << i->second->socket <<
" -> " << i->first <<
"\n";
345 if (j->second->socket == i->second->socket) {
357 #ifdef DEBUG_MULTI_CLIENTS 358 std::cout <<
"New socket ordering:\n";
360 std::cout <<
" " << j->first <<
": " << j->second->socket <<
"\n";
362 std::cout << std::endl;
370 #ifdef DEBUG_MULTI_CLIENTS 371 std::cout <<
"\n Determining new target time..." << std::endl;
373 std::cout <<
" All clients have disconnected." << std::endl;
376 std::map<int, SocketInfo*>::const_iterator i;
377 SUMOTime targetTime = std::numeric_limits<SUMOTime>::max();
379 #ifdef DEBUG_MULTI_CLIENTS 380 std::cout <<
" target time for client " << i->second->socket <<
": " << i->second->targetTime <<
"\n";
382 targetTime =
MIN2(targetTime, i->second->targetTime);
384 #ifdef DEBUG_MULTI_CLIENTS 385 std::cout << std::endl;
394 #ifdef DEBUG_MULTI_CLIENTS 395 std::cout <<
"\n Sending subscription results to clients:\n";
397 std::map<int, SocketInfo*>::const_iterator i =
mySockets.begin();
402 #ifdef DEBUG_MULTI_CLIENTS 403 std::cout << i->second->socket <<
"\n";
408 #ifdef DEBUG_MULTI_CLIENTS 409 std::cout << std::endl;
416 #ifdef DEBUG_MULTI_CLIENTS 417 std::cout <<
SIMTIME <<
" processCommandsUntilSimStep(step = " << step <<
"):\n" << std::endl;
436 #ifdef DEBUG_MULTI_CLIENTS 438 std::cout <<
" next target time is larger than next SUMO simstep (" << step <<
"). Returning from processCommandsUntilSimStep()." << std::endl;
450 #ifdef DEBUG_MULTI_CLIENTS 451 std::cout <<
" Next target time: " <<
myTargetTime << std::endl;
456 #ifdef DEBUG_MULTI_CLIENTS 464 #ifdef DEBUG_MULTI_CLIENTS 466 <<
" with target time " <<
myCurrentSocket->second->targetTime << std::endl;
474 while (!done && !closed && !load) {
478 #ifdef DEBUG_MULTI_CLIENTS 479 std::cout <<
" sending response..." << std::endl;
485 #ifdef DEBUG_MULTI_CLIENTS 486 std::cout <<
" No input and no output stored (This is the next client)." << std::endl;
489 #ifdef DEBUG_MULTI_CLIENTS 490 std::cout <<
" resetting input storage and reading next command..." << std::endl;
500 #ifdef DEBUG_MULTI_CLIENTS 501 std::cout <<
" Received command " << cmd << std::endl;
504 #ifdef DEBUG_MULTI_CLIENTS 505 std::cout <<
" Received command SIM_STEP, end turn for client " <<
myCurrentSocket->second->socket << std::endl;
509 #ifdef DEBUG_MULTI_CLIENTS 510 std::cout <<
" Received command LOAD." << std::endl;
514 #ifdef DEBUG_MULTI_CLIENTS 515 std::cout <<
" Received command CLOSE." << std::endl;
538 #ifdef DEBUG_MULTI_CLIENTS 539 std::cout <<
" Breaking loop to load new simulation." << std::endl;
543 #ifdef DEBUG_MULTI_CLIENTS 544 std::cout <<
" Breaking loop because last client closed connection." << std::endl;
563 }
catch (std::invalid_argument& e) {
583 std::map<MSNet::VehicleState, std::vector<std::string> >::iterator i;
596 traciemb_execute(PyObject* , PyObject* args) {
599 if (!PyArg_ParseTuple(args,
"s#", &msg, &size)) {
602 std::string result = TraCIServer::execute(std::string(msg, size));
603 return Py_BuildValue(
"s#", result.c_str(), result.size());
606 static PyMethodDef EmbMethods[] = {
608 "execute", traciemb_execute, METH_VARARGS,
609 "Execute the given TraCI command and return the result." 611 {NULL, NULL, 0, NULL}
616 TraCIServer::execute(std::string cmd) {
621 for (std::string::iterator i = cmd.begin(); i != cmd.end(); ++i) {
626 }
catch (std::invalid_argument& e) {
637 TraCIServer::runEmbedded(std::string pyFile) {
638 PyObject* pName, *pModule;
640 Py_InitModule(
"traciemb", EmbMethods);
641 if (pyFile.length() > 3 && !pyFile.compare(pyFile.length() - 3, 3,
".py")) {
642 PyObject* sys_path, *path;
643 char pathstr[] =
"path";
644 sys_path = PySys_GetObject(pathstr);
645 if (sys_path == NULL || !PyList_Check(sys_path)) {
646 throw ProcessError(
"Could not access python sys.path!");
649 PyList_Insert(sys_path, 0, path);
651 FILE* pFile = fopen(pyFile.c_str(),
"r");
653 throw ProcessError(
"Failed to load \"" + pyFile +
"\"!");
655 PyRun_SimpleFile(pFile, pyFile.c_str());
658 pName = PyString_FromString(pyFile.c_str());
660 pModule = PyImport_Import(pName);
662 if (pModule == NULL) {
664 throw ProcessError(
"Failed to load \"" + pyFile +
"\"!");
672 std::map<int, TraCIServer::SocketInfo*>::iterator
674 #ifdef DEBUG_MULTI_CLIENTS 706 if (commandLength == 0) {
715 int commandStart, commandLength;
717 #ifdef DEBUG_MULTI_CLIENTS 718 std::cout <<
" dispatchCommand() called for client " <<
myCurrentSocket->second->socket
719 <<
", commandId = " << commandId << std::endl;
721 bool success =
false;
731 std::vector<std::string> args;
735 #ifdef DEBUG_MULTI_CLIENTS 736 std::cout <<
" commandId == CMD_LOAD" 737 <<
", args = " <<
toString(args) << std::endl;
773 #ifdef DEBUG_MULTI_CLIENTS 774 std::cout <<
" commandId == CMD_SIMSTEP" 775 <<
", next target time for client is " <<
myCurrentSocket->second->targetTime << std::endl;
797 #ifdef DEBUG_MULTI_CLIENTS 798 std::cout <<
" commandId == CMD_SETORDER" 799 <<
", order index is " << order << std::endl;
857 std::ostringstream msg;
858 msg <<
"Wrong position in requestMessage after dispatching command.";
859 msg <<
" Expected command length was " << commandLength;
875 answerTmp.
writeString(std::string(
"SUMO ") + sumoVersion);
891 #ifdef DEBUG_MULTI_CLIENTS 892 std::cout <<
" postProcessSimulationStep() at time " << t << std::endl;
901 if ((s.
endTime < t) || isArrivedVehicle || isArrivedPerson) {
912 #ifdef DEBUG_SUBSCRIPTIONS 914 <<
"\n Nr. of active subscriptions = " << noActive << std::endl;
917 #ifdef DEBUG_SUBSCRIPTIONS 929 #ifdef DEBUG_SUBSCRIPTIONS 930 std::cout <<
" Size of into-store for subscription " << s.
id 931 <<
": " << into.
size() << std::endl;
941 #ifdef DEBUG_SUBSCRIPTIONS 949 #ifdef DEBUG_MULTI_CLIENTS 950 std::cout <<
" Sending cached simstep response to current client " <<
myCurrentSocket->second->socket
951 <<
" (-> intermediate TraCI step)." 977 WRITE_ERROR(
"Answered with error to command " +
toHex(commandId, 2) +
": " + description);
979 WRITE_ERROR(
"Requested command not implemented (" +
toHex(commandId, 2) +
"): " + description);
981 outputStorage.
writeUnsignedByte(1 + 1 + 1 + 4 + static_cast<int>(description.length()));
1003 bool needNewSubscription =
true;
1005 if (s.
commandId == i->commandId && s.
id == i->id &&
1008 std::vector<std::vector<unsigned char> >::const_iterator k = s.
parameters.begin();
1009 for (std::vector<int>::const_iterator j = s.
variables.begin(); j != s.
variables.end(); ++j, ++k) {
1010 const int offset = (int)(std::find(i->variables.begin(), i->variables.end(), *j) - i->variables.begin());
1011 if (offset == (
int)i->variables.size() || i->parameters[offset] != *k) {
1012 i->variables.push_back(*j);
1013 i->parameters.push_back(*k);
1016 needNewSubscription =
false;
1020 if (needNewSubscription) {
1049 if ((*j).id ==
id && (*j).commandId == commandId && (domain < 0 || (*j).contextDomain == domain)) {
1134 std::string& errors) {
1138 std::set<std::string> objIDs;
1146 objIDs.insert(s.
id);
1149 for (std::set<std::string>::iterator j = objIDs.begin(); j != objIDs.end(); ++j) {
1154 std::vector<std::vector<unsigned char> >::const_iterator k = s.
parameters.begin();
1155 for (std::vector<int>::const_iterator i = s.
variables.begin(); i != s.
variables.end(); ++i, ++k) {
1162 ok &=
myExecutors[getCommandId](*
this, message, tmpOutput);
1170 while (--length > 0) {
1173 int lengthLength = 1;
1185 length -= (lengthLength + 1 + 4 + (int)
id.length());
1186 while (--length > 0) {
1201 errors = errors + msg;
1206 int length = (1 + 4) + 1 + (4 + (
int)(s.
id.length())) + 1 + (int)outputStorage.
size();
1219 writeInto.
writeInt((
int)objIDs.size());
1236 std::vector<int> variables;
1237 std::vector<std::vector<unsigned char> > parameters;
1238 for (
int i = 0; i < num; ++i) {
1240 variables.push_back(varID);
1241 parameters.push_back(std::vector<unsigned char>());
1247 if (variables.size() == 0) {
1252 Subscription s(commandId,
id, variables, parameters, beginTime, endTime, hasContext, domain, range);
1260 if (tempMsg.
size() < 254) {
1275 into = inputStorage.
readInt();
1340 const double xmin = inputStorage.
readDouble();
1341 const double ymin = inputStorage.
readDouble();
1342 const double xmax = inputStorage.
readDouble();
1343 const double ymax = inputStorage.
readDouble();
1344 into.
set(xmin, ymin, xmax, ymax);
1377 for (
int i = 0; i < noEntries; ++i) {
1389 s.second->targetTime = targetTime;
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa3: Get Lane Variable)
bool processSingleSubscription(const TraCIServer::Subscription &s, tcpip::Storage &writeInto, std::string &errors)
The vehicle has departed (was inserted into the network)
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
#define CMD_SUBSCRIBE_VEHICLE_CONTEXT
#define CMD_SUBSCRIBE_LANE_VARIABLE
static void collectObjectsInRange(int domain, const PositionVector &shape, double range, std::set< std::string > &into)
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)
#define CMD_SUBSCRIBE_LANEAREA_VARIABLE
bool contextVars
Whether the subscription is a context subscription (variable subscription otherwise) ...
double range
The range of the context.
#define CMD_GET_TL_VARIABLE
#define CMD_SUBSCRIBE_JUNCTION_CONTEXT
StorageType::const_iterator end() const
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc3: Change Lane State)
#define CMD_GET_VEHICLE_VARIABLE
virtual ~TraCIServer()
Destructor.
#define CMD_SUBSCRIBE_SIM_CONTEXT
bool commandGetVersion()
Returns the TraCI-version.
#define CMD_SUBSCRIBE_VEHICLETYPE_CONTEXT
virtual std::vector< std::string > readStringList()
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc4: Change Vehicle State)
std::vector< std::vector< unsigned char > > parameters
The parameters for the subscribed variables.
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc7: Change PoI State)
#define CMD_GET_INDUCTIONLOOP_VARIABLE
#define CMD_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
SUMOTime beginTime
The begin time of the subscription.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa9: Get Junction Variable)
#define CMD_GET_LANEAREA_VARIABLE
#define CMD_GET_PERSON_VARIABLE
virtual double readDouble()
tcpip::Storage myOutputStorage
The storage to writeto.
void postProcessSimulationStep()
Handles subscriptions to send after a simstep2 command.
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc2: Change Traffic Lights State)
static bool getPosition(const std::string &id, Position &p)
Returns the named vehicle's position.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xab: Get Simulation Variable)
void set(double xmin, double ymin, double xmax, double ymax)
Sets the boundary to the given values.
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc6: Change Route State)
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.
#define CMD_SUBSCRIBE_POLYGON_CONTEXT
tcpip::Storage myInputStorage
The storage to read from.
#define CMD_GET_POLYGON_VARIABLE
virtual void writePacket(unsigned char *packet, int length)
#define CMD_SUBSCRIBE_JUNCTION_VARIABLE
Representation of a subscription.
void cleanup()
clean up subscriptions
#define CMD_SUBSCRIBE_ROUTE_CONTEXT
bool readTypeCheckingPolygon(tcpip::Storage &inputStorage, PositionVector &into)
Reads the value type and a polygon, verifying the type.
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xca: Change Edge State)
virtual void writeUnsignedByte(int)
#define CMD_SET_EDGE_VARIABLE
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
#define CMD_SUBSCRIBE_EDGE_VARIABLE
virtual unsigned char readChar()
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
#define CMD_GET_ROUTE_VARIABLE
A class that stores a 2D geometrical boundary.
#define CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
virtual void writeInt(int)
#define WRITE_WARNING(msg)
static OptionsCont & getOptions()
Retrieves the options.
virtual int readUnsignedByte()
virtual void writeChar(unsigned char)
#define CMD_SUBSCRIBE_POI_VARIABLE
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa4: Get Vehicle Variable)
static bool getPosition(const std::string &id, Position &p)
Returns the named inductive loop's position.
static bool getPosition(const std::string &id, Position &p)
Returns the named persons's position.
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 ...
The vehicles starts to stop.
std::map< int, CmdExecutor > myExecutors
Map of commandIds -> their executors; applicable if the executor applies to the method footprint...
#define CMD_SET_TL_VARIABLE
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa1: Get AreaDetector Variable)
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.
#define CMD_SUBSCRIBE_LANE_CONTEXT
#define CMD_SUBSCRIBE_SIM_VARIABLE
void removeSubscription(int commandId, const std::string &identity, int domain)
#define CMD_GET_VEHICLETYPE_VARIABLE
static void close()
request termination of connection
bool addObjectVariableSubscription(const int commandId, const bool hasContext)
#define CMD_SET_ROUTE_VARIABLE
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xcb: Set Simulation Variable)
#define CMD_SUBSCRIBE_GUI_CONTEXT
The vehicle got a new route.
The vehicle arrived at his destination (is deleted)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
The vehicles starts to park.
int commandId
commandIdArg The command id of the subscription
std::vector< Subscription > mySubscriptions
The list of known, still valid subscriptions.
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xce: Change Person State)
Representation of a vehicle.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
A point in 2D or 3D with translation and scaling methods.
std::string id
The id of the object that is subscribed.
#define CMD_GET_POI_VARIABLE
#define CMD_SUBSCRIBE_MULTIENTRYEXIT_VARIABLE
std::vector< int > variables
The subscribed variables.
#define CMD_SUBSCRIBE_MULTIENTRYEXIT_CONTEXT
#define CMD_SET_VEHICLETYPE_VARIABLE
virtual void writeByte(int)
virtual const char * what() const
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
#define CMD_SUBSCRIBE_GUI_VARIABLE
#define CMD_GET_LANE_VARIABLE
#define CMD_SUBSCRIBE_LANEAREA_CONTEXT
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa5: Get Vehicle Type Variable)
#define CMD_SET_VEHICLE_VARIABLE
SUMOTime string2time(const std::string &r)
The vehicle started to teleport.
#define CMD_GET_SIM_VARIABLE
virtual std::string readString()
#define CMD_GET_EDGE_VARIABLE
virtual unsigned int position() const
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
#define CMD_SET_POI_VARIABLE
int readCommandID(int &commandStart, int &commandLength)
Reads the next command ID from the input storage.
#define CMD_SUBSCRIBE_POLYGON_VARIABLE
static TraCIServer * myInstance
Singleton instance of the server.
static bool getPosition(const std::string &id, Position &p)
Returns the named PoI's position.
#define CMD_SUBSCRIBE_TL_CONTEXT
The vehicle ends to park.
#define CMD_SUBSCRIBE_EDGE_CONTEXT
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa0: Get Induction Loop Variable)
#define CMD_GET_JUNCTION_VARIABLE
Socket * accept(const bool create=false)
Wait for a incoming connection to port_.
#define CMD_SUBSCRIBE_PERSON_VARIABLE
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.
virtual void writeStorage(tcpip::Storage &store)
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xae: Get Person Variable)
void sendSingleSimStepResponse()
sends an empty response to a simstep command to the current client. (This applies to a situation wher...
#define CMD_SET_SIM_VARIABLE
StorageType::size_type size() const
#define CMD_SUBSCRIBE_VEHICLETYPE_VARIABLE
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
VehicleState
Definition of a vehicle state.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa7: Get PoI Variable)
const bool myAmEmbedded
Whether the server runs in embedded mode.
The vehicle was built, but has not yet departed.
void processCommandsUntilSimStep(SUMOTime step)
process all commands until the next SUMO simulation step. It is guaranteed that t->getTargetTime() >=...
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa2: Get Traffic Lights Variable)
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc5: Change Vehicle Type State)
void processReorderingRequests()
checks for and processes reordering requests (relevant for multiple clients)
#define CMD_SET_POLYGON_VARIABLE
static void openSocket(const std::map< int, CmdExecutor > &execs)
Initialises the server.
static bool getShape(const std::string &id, PositionVector &shape)
Returns the named edge's shape.
virtual void writeString(const std::string &s)
#define RTYPE_NOTIMPLEMENTED
std::string toHex(const T i, std::streamsize numDigits=0)
static bool getPosition(const std::string &id, Position &p)
Returns the named junction's position.
#define CMD_SUBSCRIBE_VEHICLE_VARIABLE
#define CMD_SUBSCRIBE_PERSON_CONTEXT
std::map< int, SocketInfo * >::iterator myCurrentSocket
The currently active client socket.
SUMOTime nextTargetTime() const
get the minimal next target time among all clients
StorageType::const_iterator begin() const
#define CMD_SET_LANE_VARIABLE
void setTargetTime(SUMOTime targetTime)
Sets myTargetTime on server and sockets to the given value.
#define CMD_GET_MULTIENTRYEXIT_VARIABLE
void inform(std::string msg, bool addType=true)
adds a new error to the list
SUMOTime myTargetTime
The time step to reach until processing the next commands.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa6: Get Route Variable)
The vehicle ends to stop.
bool readTypeCheckingPosition2D(tcpip::Storage &inputStorage, libsumo::TraCIPosition &into)
Reads the value type and a 2D position, verifying the type.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa1: Get MeMeDetector Variable)
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa8: Get Polygon Variable)
int dispatchCommand()
Handles command, writes response to myOutputStorage.
#define CMD_SUBSCRIBE_TL_VARIABLE
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.
static std::string getFilePath(const std::string &path)
Removes the file information from the given path.
#define CMD_SET_PERSON_VARIABLE
void simulationStep()
Performs a single simulation step.
int contextDomain
The domain ID of the context.
#define WRITE_MESSAGE(msg)
void initialiseSubscription(const Subscription &s)
#define CMD_SUBSCRIBE_POI_CONTEXT
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xaa: Get Edge Variable)
static bool wasClosed()
check whether close was requested
std::map< MSNet::VehicleState, std::vector< std::string > > myVehicleStateChanges
Changes in the states of simulated vehicles.
The vehicle ended being teleported.
virtual const std::string & getID() const =0
Get the vehicle's ID.
static bool getShape(const std::string &id, PositionVector &shape)
Returns the named polygons's shape.
bool readTypeCheckingByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and a byte, verifying the type.
tcpip::Socket * myServerSocket
The server socket.
SUMOTime endTime
The end time of the subscription.
#define CMD_SUBSCRIBE_ROUTE_VARIABLE
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc8: Change Polygon State)
static bool getShape(const std::string &id, PositionVector &shape)
Returns the named lane's shape.
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) ...