115 myAmEmbedded(port == 0),
117 #ifdef DEBUG_MULTI_CLIENTS 118 std::cout <<
"Creating new TraCIServer for " << numClients <<
" clients on port " << port <<
"." << std::endl;
163 WRITE_WARNING(
"Starting TraCI without using internal lanes!");
172 while ((
int)
mySockets.size() < numClients) {
187 if (numClients > 1) {
219 for (std::map<int, CmdExecutor>::const_iterator i = execs.begin(); i != execs.end(); ++i) {
259 (*i).second->getInfluencer().postProcessVTD((*i).second);
261 WRITE_WARNING(
"Vehicle '" + (*i).first +
"' was removed though being controlled by VTD");
276 for (std::map<int, SocketInfo*>::iterator i =
mySockets.begin(); i !=
mySockets.end(); ++i) {
277 i->second->vehicleStateChanges[to].push_back(vehicle->
getID());
285 #ifdef DEBUG_MULTI_CLIENTS 286 std::cout <<
"Checking client order requests." << std::endl;
292 #ifdef DEBUG_MULTI_CLIENTS 293 std::cout <<
" Socket " <<
myCurrentSocket->second->socket <<
":" << std::endl;
297 #pragma warning(push) 298 #pragma warning(disable: 4127) // do not warn about constant conditional expression 306 int commandStart, commandLength;
308 #ifdef DEBUG_MULTI_CLIENTS 309 std::cout <<
" received command " << commandId << std::endl;
315 #ifdef DEBUG_MULTI_CLIENTS 316 std::cout <<
" Init command. Sending response." << std::endl;
333 #ifdef DEBUG_MULTI_CLIENTS 334 std::cout <<
" Client " <<
myCurrentSocket->second->socket <<
" did not set order initially." << std::endl;
336 throw ProcessError(
"Execution order (CMD_SETORDER) was not set for all TraCI clients in pre-execution phase.");
354 std::map<int, SocketInfo*>::iterator j;
355 #ifdef DEBUG_MULTI_CLIENTS 356 std::cout <<
SIMTIME <<
" Current socket ordering:\n";
358 std::cout <<
" " << j->first <<
": " << j->second->socket <<
"\n";
360 std::cout <<
"Reordering requests:\n";
362 std::cout <<
" Socket " << i->second->socket <<
" -> " << i->first <<
"\n";
369 if (j->second->socket == i->second->socket) {
381 #ifdef DEBUG_MULTI_CLIENTS 382 std::cout <<
"New socket ordering:\n";
384 std::cout <<
" " << j->first <<
": " << j->second->socket <<
"\n";
386 std::cout << std::endl;
394 #ifdef DEBUG_MULTI_CLIENTS 395 std::cout <<
"\n Determining new target time..." << std::endl;
397 std::cout <<
" All clients have disconnected." << std::endl;
400 std::map<int, SocketInfo*>::const_iterator i;
403 #ifdef DEBUG_MULTI_CLIENTS 404 std::cout <<
" target time for client " << i->second->socket <<
": " << i->second->targetTime <<
"\n";
406 targetTime =
MIN2(targetTime, i->second->targetTime);
408 #ifdef DEBUG_MULTI_CLIENTS 409 std::cout << std::endl;
418 #ifdef DEBUG_MULTI_CLIENTS 419 std::cout <<
"\n Sending subscription results to clients:\n";
421 std::map<int, SocketInfo*>::const_iterator i =
mySockets.begin();
426 #ifdef DEBUG_MULTI_CLIENTS 427 std::cout << i->second->socket <<
"\n";
432 #ifdef DEBUG_MULTI_CLIENTS 433 std::cout << std::endl;
440 #ifdef DEBUG_MULTI_CLIENTS 441 std::cout <<
SIMTIME <<
" processCommandsUntilSimStep(step = " << step <<
"):\n" << std::endl;
460 #ifdef DEBUG_MULTI_CLIENTS 462 std::cout <<
" next target time is larger than next SUMO simstep (" << step <<
"). Returning from processCommandsUntilSimStep()." << std::endl;
474 #ifdef DEBUG_MULTI_CLIENTS 475 std::cout <<
" Next target time: " <<
myTargetTime << std::endl;
480 #ifdef DEBUG_MULTI_CLIENTS 488 #ifdef DEBUG_MULTI_CLIENTS 490 <<
" with target time " <<
myCurrentSocket->second->targetTime << std::endl;
498 while (!done && !closed && !load) {
502 #ifdef DEBUG_MULTI_CLIENTS 503 std::cout <<
" sending response..." << std::endl;
509 #ifdef DEBUG_MULTI_CLIENTS 510 std::cout <<
" No input and no output stored (This is the next client)." << std::endl;
513 #ifdef DEBUG_MULTI_CLIENTS 514 std::cout <<
" resetting input storage and reading next command..." << std::endl;
524 #ifdef DEBUG_MULTI_CLIENTS 525 std::cout <<
" Received command " << cmd << std::endl;
528 #ifdef DEBUG_MULTI_CLIENTS 529 std::cout <<
" Received command SIM_STEP, end turn for client " <<
myCurrentSocket->second->socket << std::endl;
533 #ifdef DEBUG_MULTI_CLIENTS 534 std::cout <<
" Received command LOAD." << std::endl;
538 #ifdef DEBUG_MULTI_CLIENTS 539 std::cout <<
" Received command CLOSE." << std::endl;
562 #ifdef DEBUG_MULTI_CLIENTS 563 std::cout <<
" Breaking loop to load new simulation." << std::endl;
567 #ifdef DEBUG_MULTI_CLIENTS 568 std::cout <<
" Breaking loop because last client closed connection." << std::endl;
587 }
catch (std::invalid_argument& e) {
600 for (std::map<int, NamedRTree*>::const_iterator i =
myObjects.begin(); i !=
myObjects.end(); ++i) {
613 std::map<MSNet::VehicleState, std::vector<std::string> >::iterator i;
626 traciemb_execute(PyObject* , PyObject* args) {
629 if (!PyArg_ParseTuple(args,
"s#", &msg, &size)) {
632 std::string result = TraCIServer::execute(std::string(msg, size));
633 return Py_BuildValue(
"s#", result.c_str(), result.size());
636 static PyMethodDef EmbMethods[] = {
638 "execute", traciemb_execute, METH_VARARGS,
639 "Execute the given TraCI command and return the result." 641 {NULL, NULL, 0, NULL}
646 TraCIServer::execute(std::string cmd) {
651 for (std::string::iterator i = cmd.begin(); i != cmd.end(); ++i) {
656 }
catch (std::invalid_argument& e) {
667 TraCIServer::runEmbedded(std::string pyFile) {
668 PyObject* pName, *pModule;
670 Py_InitModule(
"traciemb", EmbMethods);
671 if (pyFile.length() > 3 && !pyFile.compare(pyFile.length() - 3, 3,
".py")) {
672 PyObject* sys_path, *path;
673 char pathstr[] =
"path";
674 sys_path = PySys_GetObject(pathstr);
675 if (sys_path == NULL || !PyList_Check(sys_path)) {
676 throw ProcessError(
"Could not access python sys.path!");
679 PyList_Insert(sys_path, 0, path);
681 FILE* pFile = fopen(pyFile.c_str(),
"r");
683 throw ProcessError(
"Failed to load \"" + pyFile +
"\"!");
685 PyRun_SimpleFile(pFile, pyFile.c_str());
688 pName = PyString_FromString(pyFile.c_str());
690 pModule = PyImport_Import(pName);
692 if (pModule == NULL) {
694 throw ProcessError(
"Failed to load \"" + pyFile +
"\"!");
702 std::map<int, TraCIServer::SocketInfo*>::iterator
704 #ifdef DEBUG_MULTI_CLIENTS 736 if (commandLength == 0) {
745 int commandStart, commandLength;
747 #ifdef DEBUG_MULTI_CLIENTS 748 std::cout <<
" dispatchCommand() called for client " <<
myCurrentSocket->second->socket
749 <<
", commandId = " << commandId << std::endl;
751 bool success =
false;
761 std::vector<std::string> args;
765 #ifdef DEBUG_MULTI_CLIENTS 766 std::cout <<
" commandId == CMD_LOAD" 767 <<
", args = " <<
toString(args) << std::endl;
803 #ifdef DEBUG_MULTI_CLIENTS 804 std::cout <<
" commandId == CMD_SIMSTEP" 805 <<
", next target time for client is " <<
myCurrentSocket->second->targetTime << std::endl;
883 std::ostringstream msg;
884 msg <<
"Wrong position in requestMessage after dispatching command.";
885 msg <<
" Expected command length was " << commandLength;
901 answerTmp.
writeString(std::string(
"SUMO ") + sumoVersion);
917 #ifdef DEBUG_MULTI_CLIENTS 918 std::cout <<
" postProcessSimulationStep() at time " << t << std::endl;
927 if ((s.
endTime < t) || isArrivedVehicle || isArrivedPerson) {
938 #ifdef DEBUG_SUBSCRIPTIONS 940 <<
"\n Nr. of active subscriptions = " << noActive << std::endl;
943 #ifdef DEBUG_SUBSCRIPTIONS 955 #ifdef DEBUG_SUBSCRIPTIONS 956 std::cout <<
" Size of into-store for subscription " << s.
id 957 <<
": " << into.
size() << std::endl;
967 #ifdef DEBUG_SUBSCRIPTIONS 975 #ifdef DEBUG_MULTI_CLIENTS 976 std::cout <<
" Sending cached simstep response to current client " <<
myCurrentSocket->second->socket
977 <<
" (-> intermediate TraCI step)." 1003 WRITE_ERROR(
"Answered with error to command " +
toHex(commandId, 2) +
": " + description);
1005 WRITE_ERROR(
"Requested command not implemented (" +
toHex(commandId, 2) +
"): " + description);
1007 outputStorage.
writeUnsignedByte(1 + 1 + 1 + 4 + static_cast<int>(description.length()));
1029 bool needNewSubscription =
true;
1031 if (s.
commandId == i->commandId && s.
id == i->id &&
1034 std::vector<std::vector<unsigned char> >::const_iterator k = s.
parameters.begin();
1035 for (std::vector<int>::const_iterator j = s.
variables.begin(); j != s.
variables.end(); ++j, ++k) {
1036 const int offset = (int)(std::find(i->variables.begin(), i->variables.end(), *j) - i->variables.begin());
1037 if (offset == (
int)i->variables.size() || i->parameters[offset] != *k) {
1038 i->variables.push_back(*j);
1039 i->parameters.push_back(*k);
1042 needNewSubscription =
false;
1046 if (needNewSubscription) {
1075 if ((*j).id ==
id && (*j).commandId == commandId && (domain < 0 || (*j).contextDomain == domain)) {
1191 const float cmin[2] = {(float) b.
xmin(), (float) b.
ymin()};
1192 const float cmax[2] = {(float) b.
xmax(), (float) b.
ymax()};
1199 myObjects[domain]->Search(cmin, cmax, sv);
1218 std::string& errors) {
1222 std::set<std::string> objIDs;
1230 objIDs.insert(s.
id);
1233 for (std::set<std::string>::iterator j = objIDs.begin(); j != objIDs.end(); ++j) {
1238 std::vector<std::vector<unsigned char> >::const_iterator k = s.
parameters.begin();
1239 for (std::vector<int>::const_iterator i = s.
variables.begin(); i != s.
variables.end(); ++i, ++k) {
1246 ok &=
myExecutors[getCommandId](*
this, message, tmpOutput);
1254 while (--length > 0) {
1257 int lengthLength = 1;
1269 length -= (lengthLength + 1 + 4 + (int)
id.length());
1270 while (--length > 0) {
1285 errors = errors + msg;
1290 int length = (1 + 4) + 1 + (4 + (
int)(s.
id.length())) + 1 + (int)outputStorage.
size();
1303 writeInto.
writeInt((
int)objIDs.size());
1320 std::vector<int> variables;
1321 std::vector<std::vector<unsigned char> > parameters;
1322 for (
int i = 0; i < num; ++i) {
1324 variables.push_back(varID);
1325 parameters.push_back(std::vector<unsigned char>());
1331 if (variables.size() == 0) {
1336 Subscription s(commandId,
id, variables, parameters, beginTime, endTime, hasContext, domain, range);
1344 if (tempMsg.
size() < 254) {
1359 into = inputStorage.
readInt();
1424 const double xmin = inputStorage.
readDouble();
1425 const double ymin = inputStorage.
readDouble();
1426 const double xmax = inputStorage.
readDouble();
1427 const double ymax = inputStorage.
readDouble();
1428 into.
set(xmin, ymin, xmax, ymax);
1461 for (
int i = 0; i < noEntries; ++i) {
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.
double xmax() const
Returns maximum x-coordinate.
static std::vector< std::string > & getLoadArgs()
#define CMD_SUBSCRIBE_VEHICLE_CONTEXT
#define CMD_SUBSCRIBE_LANE_VARIABLE
tcpip::Storage mySubscriptionCache
The last timestep's subscription results.
bool readTypeCheckingColor(tcpip::Storage &inputStorage, 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
Representation of a vehicle in the micro simulation.
SUMOTime nextTargetTime() const
get the minimal next target time among all clients
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
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
static NamedRTree * getTree()
Returns a tree filled with junction instances.
static NamedRTree * getTree()
Returns a tree filled with polygon instances.
static void fill(RTREE &into)
Fills the given RTree with lane instances.
double ymax() const
Returns maximum y-coordinate.
#define CMD_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
virtual unsigned int position() const
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.
StorageType::size_type size() const
void postProcessSimulationStep()
Handles subscriptions to send after a simstep2 command.
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)
static void load(const std::vector< std::string > &args)
load a simulation with the given arguments
void sendOutputToAll() const
send out subscription results (actually just the content of myOutputStorage) to clients which will ac...
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
std::vector< const MSEdge * > ConstMSEdgeVector
#define CMD_SUBSCRIBE_ROUTE_CONTEXT
void setVTDControlled(Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, const ConstMSEdgeVector &route, SUMOTime t)
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
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
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.
static NamedRTree * getTree()
Returns a tree filled with PoI instances.
#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
Allows to store the object; used as context while traveling the rtree in TraCI.
The vehicle got a new route.
The vehicle arrived at his destination (is deleted)
StorageType::const_iterator end() const
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.
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
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
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
#define CMD_SET_VEHICLETYPE_VARIABLE
virtual void writeByte(int)
void setVTDControlled(MSVehicle *v, Position xyPos, MSLane *l, double pos, double posLat, double angle, int edgeOffset, ConstMSEdgeVector route, SUMOTime t)
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
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
Boundary & grow(double by)
extends the boundary by the given amount
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.
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
#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() >=...
LANE_RTREE_QUAL * myLaneTree
A storage of lanes.
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc5: Change Vehicle Type State)
Allows to store the object; used as context while traveling the rtree in TraCI.
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
Influencer & getInfluencer()
Returns the velocity/lane influencer.
virtual const char * what() const
void collectObjectsInRange(int domain, const PositionVector &shape, double range, std::set< std::string > &into)
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.
double xmin() const
Returns minimum x-coordinate.
#define CMD_SET_LANE_VARIABLE
#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)
static NamedRTree * getTree()
Returns a tree filled with inductive loop instances.
The vehicle ends to stop.
virtual const std::string & getID() const =0
Get the vehicle's ID.
double ymin() const
Returns minimum y-coordinate.
std::map< int, NamedRTree * > myObjects
A storage of objects.
StorageType::const_iterator begin() const
SUMOVehicle * getVehicle(const std::string &id) const
Returns the vehicle with the given id.
bool readTypeCheckingPosition2D(tcpip::Storage &inputStorage, TraCIPosition &into)
Reads the value type and a 2D position, verifying the type.
std::map< std::string, MSVehicle * > myVTDControlledVehicles
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.
void visit(const TraCIServerAPI_Lane::StoringVisitor &cont) const
Callback for visiting the lane when traversing an RTree.
#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...
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc2: Change Traffic Lights State)
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)
Boundary getBoxBoundary() const
Returns a boundary enclosing this list of lines.
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.
The vehicle ended being teleported.
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.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa2: Get Traffic Lights Variable)
#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.
const std::string & getID() const
Returns the name of the vehicle.
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) ...