Eclipse SUMO - Simulation of Urban MObility
TraCIServer.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2007-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
24 // TraCI server used to control sumo by a remote TraCI client (e.g., ns2)
25 /****************************************************************************/
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #include <config.h>
31 
32 #ifdef HAVE_VERSION_H
33 #include <version.h>
34 #endif
35 
36 #include <string>
37 #include <cmath>
38 #include <map>
39 #include <iostream>
40 #include <algorithm>
41 #include <foreign/tcpip/socket.h>
42 #include <foreign/tcpip/storage.h>
43 #include <utils/common/SUMOTime.h>
51 #include <utils/xml/XMLSubSys.h>
52 #include <microsim/MSNet.h>
53 #include <microsim/MSVehicle.h>
54 #include <microsim/MSEdge.h>
57 #include <microsim/MSJunction.h>
58 #include <microsim/MSEdgeControl.h>
59 #include <microsim/MSLane.h>
60 #include <microsim/MSGlobals.h>
62 #include <libsumo/Simulation.h>
63 #include <libsumo/Subscription.h>
64 #include <libsumo/TraCIConstants.h>
65 #include "TraCIServer.h"
68 #include "TraCIServerAPI_Lane.h"
72 #include "TraCIServerAPI_Vehicle.h"
74 #include "TraCIServerAPI_Route.h"
75 #include "TraCIServerAPI_POI.h"
76 #include "TraCIServerAPI_Polygon.h"
77 #include "TraCIServerAPI_Edge.h"
79 #include "TraCIServerAPI_Person.h"
80 
81 
82 // ===========================================================================
83 // debug constants
84 // ===========================================================================
85 //#define DEBUG_MULTI_CLIENTS
86 //#define DEBUG_SUBSCRIPTIONS
87 //#define DEBUG_SUBSCRIPTION_FILTERS
88 //#define DEBUG_RAW_INPUT
89 
90 
91 // ===========================================================================
92 // static member definitions
93 // ===========================================================================
96 
97 
98 // ===========================================================================
99 // method definitions
100 // ===========================================================================
101 void
102 TraCIServer::initWrapper(const int domainID, const int variable, const std::string& objID) {
107 }
108 
109 
110 bool
111 TraCIServer::wrapDouble(const std::string& /* objID */, const int /* variable */, const double value) {
114  return true;
115 }
116 
117 
118 bool
119 TraCIServer::wrapInt(const std::string& /* objID */, const int /* variable */, const int value) {
121  myWrapperStorage.writeInt(value);
122  return true;
123 }
124 
125 
126 bool
127 TraCIServer::wrapString(const std::string& /* objID */, const int /* variable */, const std::string& value) {
130  return true;
131 }
132 
133 
134 bool
135 TraCIServer::wrapStringList(const std::string& /* objID */, const int /* variable */, const std::vector<std::string>& value) {
138  return true;
139 }
140 
141 
142 bool
143 TraCIServer::wrapPosition(const std::string& /* objID */, const int variable, const libsumo::TraCIPosition& value) {
144  const bool includeZ = variable == libsumo::VAR_POSITION3D;
148  if (includeZ) {
150  }
151  return true;
152 }
153 
154 
155 bool
156 TraCIServer::wrapColor(const std::string& /* objID */, const int /* variable */, const libsumo::TraCIColor& value) {
162  return true;
163 }
164 
165 
166 bool
167 TraCIServer::wrapRoadPosition(const std::string& /* objID */, const int /* variable */, const libsumo::TraCIRoadPosition& /* value */) {
168  // this is currently only a placeholder to allow vehicle.subscribeLeader to work with libsumo
169  return false;
170 }
171 
172 
175  return myWrapperStorage;
176 }
177 
178 
179 
180 TraCIServer::TraCIServer(const SUMOTime begin, const int port, const int numClients)
181  : myServerSocket(nullptr), myTargetTime(begin), myLastContextSubscription(nullptr) {
182 #ifdef DEBUG_MULTI_CLIENTS
183  std::cout << "Creating new TraCIServer for " << numClients << " clients on port " << port << "." << std::endl;
184 #endif
185  myVehicleStateChanges[MSNet::VEHICLE_STATE_BUILT] = std::vector<std::string>();
186  myVehicleStateChanges[MSNet::VEHICLE_STATE_DEPARTED] = std::vector<std::string>();
188  myVehicleStateChanges[MSNet::VEHICLE_STATE_ENDING_TELEPORT] = std::vector<std::string>();
189  myVehicleStateChanges[MSNet::VEHICLE_STATE_ARRIVED] = std::vector<std::string>();
190  myVehicleStateChanges[MSNet::VEHICLE_STATE_NEWROUTE] = std::vector<std::string>();
191  myVehicleStateChanges[MSNet::VEHICLE_STATE_STARTING_PARKING] = std::vector<std::string>();
192  myVehicleStateChanges[MSNet::VEHICLE_STATE_MANEUVERING] = std::vector<std::string>();
193  myVehicleStateChanges[MSNet::VEHICLE_STATE_ENDING_PARKING] = std::vector<std::string>();
194  myVehicleStateChanges[MSNet::VEHICLE_STATE_STARTING_STOP] = std::vector<std::string>();
195  myVehicleStateChanges[MSNet::VEHICLE_STATE_ENDING_STOP] = std::vector<std::string>();
196  myVehicleStateChanges[MSNet::VEHICLE_STATE_COLLISION] = std::vector<std::string>();
197  myVehicleStateChanges[MSNet::VEHICLE_STATE_EMERGENCYSTOP] = std::vector<std::string>();
198 
202 
224 
226 
227  myDoCloseConnection = false;
228 
229  // display warning if internal lanes are not used
231  WRITE_WARNING("Starting TraCI without using internal lanes!");
232  MsgHandler::getWarningInstance()->inform("Vehicles will jump over junctions.", false);
233  MsgHandler::getWarningInstance()->inform("Use without option --no-internal-links to avoid unexpected behavior", false);
234  }
235 
236  try {
237  WRITE_MESSAGE("***Starting server on port " + toString(port) + " ***");
238  myServerSocket = new tcpip::Socket(port);
239  if (numClients > 1) {
240  WRITE_MESSAGE(" waiting for " + toString(numClients) + " clients...");
241  }
242  while ((int)mySockets.size() < numClients) {
243  int index = (int)mySockets.size() + libsumo::MAX_ORDER + 1;
244  mySockets[index] = new SocketInfo(myServerSocket->accept(true), begin);
245  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_BUILT] = std::vector<std::string>();
246  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_DEPARTED] = std::vector<std::string>();
247  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_STARTING_TELEPORT] = std::vector<std::string>();
248  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_ENDING_TELEPORT] = std::vector<std::string>();
249  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_ARRIVED] = std::vector<std::string>();
250  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_NEWROUTE] = std::vector<std::string>();
251  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_STARTING_PARKING] = std::vector<std::string>();
252  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_MANEUVERING] = std::vector<std::string>();
253  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_ENDING_PARKING] = std::vector<std::string>();
254  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_STARTING_STOP] = std::vector<std::string>();
255  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_ENDING_STOP] = std::vector<std::string>();
256  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_COLLISION] = std::vector<std::string>();
257  mySockets[index]->vehicleStateChanges[MSNet::VEHICLE_STATE_EMERGENCYSTOP] = std::vector<std::string>();
258  if (numClients > 1) {
259  WRITE_MESSAGE(" client connected");
260  }
261  }
262  // When got here, all clients have connected
263  if (numClients > 1) {
265  }
266  // set myCurrentSocket != mySockets.end() to indicate that this is the first step in processCommandsUntilSimStep()
267  myCurrentSocket = mySockets.begin();
268  } catch (tcpip::SocketException& e) {
269  throw ProcessError(e.what());
270  }
271 }
272 
273 
275  for (myCurrentSocket = mySockets.begin(); myCurrentSocket != mySockets.end(); ++myCurrentSocket) {
276  delete myCurrentSocket->second;
277  }
278  delete myServerSocket;
279  cleanup();
280 }
281 
282 
283 // ---------- Initialisation and Shutdown
284 void
285 TraCIServer::openSocket(const std::map<int, CmdExecutor>& execs) {
286  if (myInstance == nullptr && !myDoCloseConnection && (OptionsCont::getOptions().getInt("remote-port") != 0)) {
287  myInstance = new TraCIServer(string2time(OptionsCont::getOptions().getString("begin")),
288  OptionsCont::getOptions().getInt("remote-port"),
289  OptionsCont::getOptions().getInt("num-clients"));
290  for (std::map<int, CmdExecutor>::const_iterator i = execs.begin(); i != execs.end(); ++i) {
291  myInstance->myExecutors[i->first] = i->second;
292  }
293  }
294  if (myInstance != nullptr) {
295  // maybe net was deleted and built again
298  }
299 }
300 
301 
302 void
304  if (myInstance == nullptr) {
305  return;
306  }
307  delete myInstance;
308  myInstance = nullptr;
309  myDoCloseConnection = true;
310 }
311 
312 
313 bool
315  return myDoCloseConnection;
316 }
317 
318 
319 // ---------- Initialisation and Shutdown
320 
321 
322 void
323 TraCIServer::vehicleStateChanged(const SUMOVehicle* const vehicle, MSNet::VehicleState to, const std::string& /*info*/) {
324  if (!myDoCloseConnection) {
325  myVehicleStateChanges[to].push_back(vehicle->getID());
326  for (std::map<int, SocketInfo*>::iterator i = mySockets.begin(); i != mySockets.end(); ++i) {
327  i->second->vehicleStateChanges[to].push_back(vehicle->getID());
328  }
329  }
330 }
331 
332 
333 void
335 #ifdef DEBUG_MULTI_CLIENTS
336  std::cout << "Checking client order requests." << std::endl;
337 #endif
338  // check for SET_ORDER commands queued by connected clients
339  // In multiclient cas it is mandatory that SET_ORDER is sent as the first command (or directly after GET_VERSION)
340  myCurrentSocket = mySockets.begin();
341  while (myCurrentSocket != mySockets.end()) {
342 #ifdef DEBUG_MULTI_CLIENTS
343  std::cout << " Socket " << myCurrentSocket->second->socket << ":" << std::endl;
344 #endif
345 // bool clientUnordered = true;
346 #ifdef _MSC_VER
347 #pragma warning(push)
348 #pragma warning(disable: 4127) // do not warn about constant conditional expression
349 #endif
350  while (true) {
351 #ifdef _MSC_VER
352 #pragma warning(pop)
353 #endif
355  myCurrentSocket->second->socket->receiveExact(myInputStorage);
356  int commandStart, commandLength;
357  int commandId = readCommandID(commandStart, commandLength);
358 #ifdef DEBUG_MULTI_CLIENTS
359  std::cout << " received command " << commandId << std::endl;
360 #endif
361  // Whether the received command is a permitted command for the initialization phase.
362  // Currently, getVersion and setOrder are permitted.
363  bool initCommand = commandId == libsumo::CMD_SETORDER || commandId == libsumo::CMD_GETVERSION;
364  if (initCommand) {
365 #ifdef DEBUG_MULTI_CLIENTS
366  std::cout << " Init command. Sending response." << std::endl;
367 #endif
368  // reset input storage to initial state before reading the commandId
369  // (ugly, but we can't just reset the store's iter_ from here)
370  // Giving the commandId to dispatch command didn't work either
371  tcpip::Storage tmp;
374  // we don't know whether the command was set with extended
375  // length syntax or not so we hardcode the length here (#5037)
379 
380  // Handle initialization command completely
381  dispatchCommand();
382  myCurrentSocket->second->socket->sendExact(myOutputStorage);
384  } else {
385 #ifdef DEBUG_MULTI_CLIENTS
386  std::cout << " Client " << myCurrentSocket->second->socket << " did not set order initially." << std::endl;
387 #endif
388  throw ProcessError("Execution order (libsumo::CMD_SETORDER) was not set for all TraCI clients in pre-execution phase.");
389  }
390  if (commandId == libsumo::CMD_SETORDER) {
391  // This is what we have waited for.
392  break;
393  }
394  }
395  ++myCurrentSocket;
396  }
397 }
398 
399 
400 void
402  // Process reordering requests
403  if (mySocketReorderRequests.size() > 0) {
404  // process reordering requests
405  std::map<int, SocketInfo*>::const_iterator i = mySocketReorderRequests.begin();
406  std::map<int, SocketInfo*>::iterator j;
407 #ifdef DEBUG_MULTI_CLIENTS
408  std::cout << SIMTIME << " Current socket ordering:\n";
409  for (j = mySockets.begin(); j != mySockets.end(); ++j) {
410  std::cout << " " << j->first << ": " << j->second->socket << "\n";
411  }
412  std::cout << "Reordering requests:\n";
413  for (i = mySocketReorderRequests.begin(); i != mySocketReorderRequests.end(); ++i) {
414  std::cout << " Socket " << i->second->socket << " -> " << i->first << "\n";
415  }
416  i = mySocketReorderRequests.begin();
417 #endif
418  while (i != mySocketReorderRequests.end()) {
419  j = mySockets.begin();
420  while (j != mySockets.end()) {
421  if (j->second->socket == i->second->socket) {
422  break;
423  } else {
424  j++;
425  }
426  }
427  assert(j != mySockets.end());
428  mySockets.erase(j);
429  mySockets[i->first] = i->second;
430  ++i;
431  }
432  mySocketReorderRequests.clear();
433 #ifdef DEBUG_MULTI_CLIENTS
434  std::cout << "New socket ordering:\n";
435  for (j = mySockets.begin(); j != mySockets.end(); ++j) {
436  std::cout << " " << j->first << ": " << j->second->socket << "\n";
437  }
438  std::cout << std::endl;
439 #endif
440  }
441 }
442 
443 
444 SUMOTime
446 #ifdef DEBUG_MULTI_CLIENTS
447  std::cout << "\n Determining new target time..." << std::endl;
448  if (mySockets.size() == 0) {
449  std::cout << " All clients have disconnected." << std::endl;
450  }
451 #endif
452  std::map<int, SocketInfo*>::const_iterator i;
453  SUMOTime targetTime = std::numeric_limits<SUMOTime>::max();
454  for (i = mySockets.begin(); i != mySockets.end(); ++i) {
455 #ifdef DEBUG_MULTI_CLIENTS
456  std::cout << " target time for client " << i->second->socket << ": " << i->second->targetTime << "\n";
457 #endif
458  targetTime = MIN2(targetTime, i->second->targetTime);
459  }
460 #ifdef DEBUG_MULTI_CLIENTS
461  std::cout << std::endl;
462 #endif
463  return targetTime;
464 }
465 
466 
467 // send out subscription results to clients which will act in this step (i.e. with client target time <= myTargetTime)
468 void
470 #ifdef DEBUG_MULTI_CLIENTS
471  std::cout << "\n Sending subscription results to clients:\n";
472 #endif
473  std::map<int, SocketInfo*>::const_iterator i = mySockets.begin();
474  while (i != mySockets.end()) {
475  if (i->second->targetTime <= MSNet::getInstance()->getCurrentTimeStep()) {
476  // this client will become active before the next SUMO step. Provide subscription results.
477  i->second->socket->sendExact(myOutputStorage);
478 #ifdef DEBUG_MULTI_CLIENTS
479  std::cout << i->second->socket << "\n";
480 #endif
481  }
482  ++i;
483  }
484 #ifdef DEBUG_MULTI_CLIENTS
485  std::cout << std::endl;
486 #endif
487 }
488 
489 
490 void
492 #ifdef DEBUG_MULTI_CLIENTS
493  std::cout << SIMTIME << " processCommandsUntilSimStep(step = " << step << "):\n" << std::endl;
494 #endif
495  try {
496  const bool firstStep = myCurrentSocket != mySockets.end();
497  // update client order if requested
499  if (!firstStep) {
500  // This is the entry point after performing a SUMO step (block is skipped before first SUMO step since then no simulation results have to be sent)
501  // update subscription results
503  // Send out subscription results to clients which will act in this SUMO step (i.e. with client target time <= current sumo timestep end)
504  sendOutputToAll();
506  }
507 
508  // determine minimal next target time among clients
510 
511  if (step < myTargetTime) {
512 #ifdef DEBUG_MULTI_CLIENTS
513  if (step < myTargetTime) {
514  std::cout << " next target time is larger than next SUMO simstep (" << step << "). Returning from processCommandsUntilSimStep()." << std::endl;
515  }
516 #endif
517  return;
518  }
519 
520  // Simulation should run until
521  // 1. end time reached or
522  // 2. got libsumo::CMD_CLOSE or
523  // 3. got libsumo::CMD_LOAD or
524  // 4. Client closes socket connection
525  while (!myDoCloseConnection && myTargetTime <= (MSNet::getInstance()->getCurrentTimeStep())) {
526 #ifdef DEBUG_MULTI_CLIENTS
527  std::cout << " Next target time: " << myTargetTime << std::endl;
528 #endif
529  // Iterate over clients and process communication for the ones with target time == myTargetTime
530  myCurrentSocket = mySockets.begin();
531  while (myCurrentSocket != mySockets.end()) {
532 #ifdef DEBUG_MULTI_CLIENTS
533  std::cout << " current socket: " << myCurrentSocket->second->socket
534  << " with target time " << myCurrentSocket->second->targetTime
535  << std::endl;
536 #endif
537 
538  if (myCurrentSocket->second->targetTime > myTargetTime) {
539  // this client must wait
540 #ifdef DEBUG_MULTI_CLIENTS
541  std::cout << " skipping client " << myCurrentSocket->second->socket
542  << " with target time " << myCurrentSocket->second->targetTime << std::endl;
543 #endif
544  myCurrentSocket++;
545  continue;
546  }
547  bool done = false;
548  bool closed = false;
549  bool load = false;
550  while (!done && !closed && !load) {
551  if (!myInputStorage.valid_pos()) {
552  // have read request completely, send response if adequate
553  if (myOutputStorage.size() > 0) {
554 #ifdef DEBUG_MULTI_CLIENTS
555  std::cout << " sending response..." << std::endl;
556 #endif
557  // send response to previous query
558  myCurrentSocket->second->socket->sendExact(myOutputStorage);
560  } else {
561 #ifdef DEBUG_MULTI_CLIENTS
562  std::cout << " No input and no output stored (This is the next client)." << std::endl;
563 #endif
564  }
565 #ifdef DEBUG_MULTI_CLIENTS
566  std::cout << " resetting input storage and reading next command..." << std::endl;
567 #endif
568  // Read next request
570  myCurrentSocket->second->socket->receiveExact(myInputStorage);
571  }
572 
574  // dispatch command
575  const int cmd = dispatchCommand();
576 #ifdef DEBUG_MULTI_CLIENTS
577  std::cout << " Received command " << cmd << std::endl;
578 #endif
579  if (cmd == libsumo::CMD_SIMSTEP) {
580 #ifdef DEBUG_MULTI_CLIENTS
581  std::cout << " Received command SIM_STEP, end turn for client " << myCurrentSocket->second->socket << std::endl;
582 #endif
583  done = true;
584  } else if (cmd == libsumo::CMD_LOAD) {
585 #ifdef DEBUG_MULTI_CLIENTS
586  std::cout << " Received command LOAD." << std::endl;
587 #endif
588  load = true;
589  } else if (cmd == libsumo::CMD_CLOSE) {
590 #ifdef DEBUG_MULTI_CLIENTS
591  std::cout << " Received command CLOSE." << std::endl;
592 #endif
593  closed = true;
594  }
595  }
596  }
597  if (done) {
598  // Clear vehicleStateChanges for this client -> For subsequent TraCI stepping
599  // that is performed within this SUMO step, no updates on vehicle states
600  // belonging to the last SUMO simulation step will be received by this client.
601  for (std::map<MSNet::VehicleState, std::vector<std::string> >::iterator i = myCurrentSocket->second->vehicleStateChanges.begin(); i != myCurrentSocket->second->vehicleStateChanges.end(); ++i) {
602  (*i).second.clear();
603  }
604  myCurrentSocket++;
605  } else if (load) {
606  myCurrentSocket = mySockets.end();
607  } else {
608  assert(closed);
609  // remove current socket and increment to next socket in ordering
611  }
612  }
613  if (!myLoadArgs.empty()) {
614 #ifdef DEBUG_MULTI_CLIENTS
615  std::cout << " Breaking loop to load new simulation." << std::endl;
616 #endif
617  break;
618  } else if (myDoCloseConnection) {
619 #ifdef DEBUG_MULTI_CLIENTS
620  std::cout << " Breaking loop because last client closed connection." << std::endl;
621 #endif
622  break;
623  }
624  SUMOTime nextT = nextTargetTime();
625  // minimal target time among clients should have been increased during the last loop through mySockets
626  // XXX: The assert below is disabled since many tests do sth. like simulationStep(step). Such that for a first call step=0,
627  // leading to targetTime==1000 (increased by DELTA_T in dispatchCommand()),
628  // the next call is then usually simulationStep(step=1000) leading to no further increase
629  // and thus a failing assertion here.
630  //assert(myTargetTime < nextT || myDoCloseConnection);
631  myTargetTime = nextT;
632  }
633  // All clients are done with the current time step
634  // Reset myVehicleStateChanges
635  for (std::map<MSNet::VehicleState, std::vector<std::string> >::iterator i = myVehicleStateChanges.begin(); i != myVehicleStateChanges.end(); ++i) {
636  (*i).second.clear();
637  }
638  } catch (std::invalid_argument& e) {
639  throw ProcessError(e.what());
640  } catch (libsumo::TraCIException& e) {
641  throw ProcessError(e.what());
642  } catch (tcpip::SocketException& e) {
643  throw ProcessError(e.what());
644  }
645 }
646 
647 
648 void
650  mySubscriptions.clear();
651  myTargetTime = string2time(OptionsCont::getOptions().getString("begin"));
652  for (myCurrentSocket = mySockets.begin(); myCurrentSocket != mySockets.end(); ++myCurrentSocket) {
653  myCurrentSocket->second->targetTime = myTargetTime;
654  }
658  std::map<MSNet::VehicleState, std::vector<std::string> >::iterator i;
659  for (i = myVehicleStateChanges.begin(); i != myVehicleStateChanges.end(); i++) {
660  i->second.clear();
661  }
662  myCurrentSocket = mySockets.begin();
663 }
664 
665 
666 std::map<int, TraCIServer::SocketInfo*>::iterator
668 #ifdef DEBUG_MULTI_CLIENTS
669  std::cout << " Removing socket " << myCurrentSocket->second->socket
670  << " (order " << myCurrentSocket->first << ")" << std::endl;
671 #endif
672 
673  if (mySockets.size() == 1) {
674  // Last client has disconnected
675  delete myCurrentSocket->second->socket;
676  mySockets.clear();
677  myCurrentSocket = mySockets.end();
678  return myCurrentSocket;
679  }
680 
681  const int currOrder = myCurrentSocket->first;
682  delete myCurrentSocket->second->socket;
683  myCurrentSocket++;
684  if (myCurrentSocket != mySockets.end()) {
685  const int nextOrder = myCurrentSocket->first;
686  mySockets.erase(currOrder);
687  myCurrentSocket = mySockets.find(nextOrder);
688  } else {
689  mySockets.erase(currOrder);
690  myCurrentSocket = mySockets.end();
691  }
692  return myCurrentSocket;
693 }
694 
695 
696 int
697 TraCIServer::readCommandID(int& commandStart, int& commandLength) {
698  commandStart = myInputStorage.position();
699  commandLength = myInputStorage.readUnsignedByte();
700  if (commandLength == 0) {
701  commandLength = myInputStorage.readInt();
702  }
703 #ifdef DEBUG_RAW_INPUT
704  std::cout << " commandStart=" << commandStart << " commandLength=" << commandLength << " pos=" << myInputStorage.position() << " raw=";
705  for (auto it = myInputStorage.begin(); it != myInputStorage.end(); ++it) {
706  std::cout << (int)*it << " ";
707  }
708  std::cout << "\n";
709 #endif
711 }
712 
713 
714 int
716  int commandStart, commandLength;
717  int commandId = readCommandID(commandStart, commandLength);
718 #ifdef DEBUG_MULTI_CLIENTS
719  std::cout << " dispatchCommand() called for client " << myCurrentSocket->second->socket
720  << ", commandId = " << commandId << std::endl;
721 #endif
722  bool success = false;
723  // dispatch commands
724  if (myExecutors.find(commandId) != myExecutors.end()) {
725  success = myExecutors[commandId](*this, myInputStorage, myOutputStorage);
726  } else {
727  switch (commandId) {
729  success = commandGetVersion();
730  break;
731  case libsumo::CMD_LOAD: {
732  std::vector<std::string> args;
734  return writeErrorStatusCmd(libsumo::CMD_LOAD, "A load command needs a list of string arguments.", myOutputStorage);
735  }
736 #ifdef DEBUG_MULTI_CLIENTS
737  std::cout << " commandId == libsumo::CMD_LOAD"
738  << ", args = " << toString(args) << std::endl;
739 #endif
740  try {
741  myLoadArgs = args;
742  success = true;
744  // XXX: This only cares for the client that issued the load command.
745  // Multiclient-load functionality is still to be implemented. Refs #3146.
746  myCurrentSocket->second->socket->sendExact(myOutputStorage);
748  } catch (libsumo::TraCIException& e) {
750  }
751  break;
752  }
753  case libsumo::CMD_SIMSTEP: {
754  const double nextT = myInputStorage.readDouble();
755  if (nextT == 0.) {
756  myCurrentSocket->second->targetTime += DELTA_T;
757  } else {
758  myCurrentSocket->second->targetTime = TIME2STEPS(nextT);
759  }
760 #ifdef DEBUG_MULTI_CLIENTS
761  std::cout << " commandId == libsumo::CMD_SIMSTEP"
762  << ", next target time for client is " << myCurrentSocket->second->targetTime << std::endl;
763 #endif
764  if (myCurrentSocket->second->targetTime <= MSNet::getInstance()->getCurrentTimeStep()) {
765  // This is not the last TraCI simstep in the current SUMO simstep -> send single simstep response.
766  // @note: In the other case the simstep results are sent to all after the SUMO step was performed, see entry point for processCommandsUntilSimStep()
768  }
769  return commandId;
770  }
771  case libsumo::CMD_CLOSE:
773  myCurrentSocket->second->socket->sendExact(myOutputStorage);
775  if (mySockets.size() == 1) {
776  // Last client has closed connection
777  myDoCloseConnection = true;
778  }
779  success = true;
780  break;
781  case libsumo::CMD_SETORDER: {
782  const int order = myInputStorage.readInt();
783 #ifdef DEBUG_MULTI_CLIENTS
784  std::cout << " commandId == libsumo::CMD_SETORDER"
785  << ", order index is " << order << std::endl;
786 #endif
787  if (order > libsumo::MAX_ORDER) {
788  return writeErrorStatusCmd(libsumo::CMD_SETORDER, "A set order command needs an int argument below " + toString(libsumo::MAX_ORDER) + ".", myOutputStorage);
789  }
790  if (mySockets.count(order) > 0 || mySocketReorderRequests.count(order) > 0) {
791  return writeErrorStatusCmd(libsumo::CMD_SETORDER, "Order '" + toString(order) + "' is already taken.", myOutputStorage);
792  }
793  // memorize reorder request (will only take effect in the next step)
794  mySocketReorderRequests[order] = myCurrentSocket->second;
795  success = true;
797  break;
798  }
814  success = addObjectVariableSubscription(commandId, false);
815  break;
831  success = addObjectVariableSubscription(commandId, true);
832  break;
834  success = addSubscriptionFilter();
835  break;
836  default:
837  if (commandId == libsumo::CMD_GET_GUI_VARIABLE || commandId == libsumo::CMD_SET_GUI_VARIABLE) {
838  writeStatusCmd(commandId, libsumo::RTYPE_NOTIMPLEMENTED, "GUI is not running, command not implemented in command line sumo");
839  } else {
840  writeStatusCmd(commandId, libsumo::RTYPE_NOTIMPLEMENTED, "Command not implemented in sumo");
841  }
842  }
843  }
844  if (!success) {
845  while (myInputStorage.valid_pos() && (int)myInputStorage.position() < commandStart + commandLength) {
847  }
848  }
849  if ((int)myInputStorage.position() != commandStart + commandLength) {
850  std::ostringstream msg;
851  msg << "Wrong position in requestMessage after dispatching command " << commandId << ".";
852  msg << " Expected command length was " << commandLength;
853  msg << " but " << myInputStorage.position() - commandStart << " Bytes were read.";
854  writeStatusCmd(commandId, libsumo::RTYPE_ERR, msg.str());
855  myDoCloseConnection = true;
856  }
857  return commandId;
858 }
859 
860 
861 // ---------- Server-internal command handling
862 bool
864  std::string sumoVersion = VERSION_STRING;
865  // Prepare response
866  tcpip::Storage answerTmp;
867  answerTmp.writeInt(libsumo::TRACI_VERSION);
868  answerTmp.writeString(std::string("SUMO ") + sumoVersion);
869  // When we get here, the response is stored in answerTmp -> put into myOutputStorage
871  // command length
872  myOutputStorage.writeUnsignedByte(1 + 1 + static_cast<int>(answerTmp.size()));
873  // command type
875  // and the parameter dependant part
876  myOutputStorage.writeStorage(answerTmp);
877  return true;
878 }
879 
880 
881 void
884 #ifdef DEBUG_MULTI_CLIENTS
885  std::cout << " postProcessSimulationStep() at time " << t << std::endl;
886 #endif
888  int noActive = 0;
889  for (std::vector<libsumo::Subscription>::iterator i = mySubscriptions.begin(); i != mySubscriptions.end();) {
890  const libsumo::Subscription& s = *i;
894  if ((s.endTime < t) || isArrivedVehicle || isArrivedPerson) {
895  i = mySubscriptions.erase(i);
896  continue;
897  }
898  ++i;
899  if (s.beginTime > t) {
900  continue;
901  }
902  ++noActive;
903  }
905 #ifdef DEBUG_SUBSCRIPTIONS
906  std::cout << " Initial size of mySubscriptionCache is " << mySubscriptionCache.size()
907  << "\n Nr. of active subscriptions = " << noActive << std::endl;
908 #endif
909  mySubscriptionCache.writeInt(noActive);
910 #ifdef DEBUG_SUBSCRIPTIONS
911  std::cout << " Size after writing an int is " << mySubscriptionCache.size() << std::endl;
912 #endif
913  for (std::vector<libsumo::Subscription>::iterator i = mySubscriptions.begin(); i != mySubscriptions.end();) {
914  const libsumo::Subscription& s = *i;
915  if (s.beginTime > t) {
916  ++i;
917  continue;
918  }
919  tcpip::Storage into;
920  std::string errors;
921  bool ok = processSingleSubscription(s, into, errors);
922 #ifdef DEBUG_SUBSCRIPTIONS
923  std::cout << " Size of into-store for subscription " << s.id
924  << ": " << into.size() << std::endl;
925 #endif
927  if (ok) {
928  ++i;
929  } else {
930  i = mySubscriptions.erase(i);
931  }
932  }
934 #ifdef DEBUG_SUBSCRIPTIONS
935  std::cout << " Size after writing subscriptions is " << mySubscriptionCache.size() << std::endl;
936 #endif
937 }
938 
939 
940 void
942 #ifdef DEBUG_MULTI_CLIENTS
943  std::cout << " Sending cached simstep response to current client " << myCurrentSocket->second->socket
944  << " (-> intermediate TraCI step)."
945  << "\n Size of mySubscriptionCache is " << mySubscriptionCache.size()
946  << std::endl;
947 #endif
949 
950 // NOTE: the commented code would send an empty response
951 // myOutputStorage.writeInt(0);
952 // myCurrentSocket->second->socket->sendExact(myOutputStorage);
953 // myOutputStorage.reset();
955  // send results to active client
956  myCurrentSocket->second->socket->sendExact(myOutputStorage);
958 }
959 
960 
961 void
962 TraCIServer::writeStatusCmd(int commandId, int status, const std::string& description) {
963  writeStatusCmd(commandId, status, description, myOutputStorage);
964 }
965 
966 
967 void
968 TraCIServer::writeStatusCmd(int commandId, int status, const std::string& description, tcpip::Storage& outputStorage) {
969  if (status == libsumo::RTYPE_ERR) {
970  WRITE_ERROR("Answered with error to command " + toHex(commandId, 2) + ": " + description);
971  } else if (status == libsumo::RTYPE_NOTIMPLEMENTED) {
972  WRITE_ERROR("Requested command not implemented (" + toHex(commandId, 2) + "): " + description);
973  }
974  outputStorage.writeUnsignedByte(1 + 1 + 1 + 4 + static_cast<int>(description.length())); // command length
975  outputStorage.writeUnsignedByte(commandId); // command type
976  outputStorage.writeUnsignedByte(status); // status
977  outputStorage.writeString(description); // description
978 }
979 
980 
981 bool
982 TraCIServer::writeErrorStatusCmd(int commandId, const std::string& description, tcpip::Storage& outputStorage) {
983  writeStatusCmd(commandId, libsumo::RTYPE_ERR, description, outputStorage);
984  return false;
985 }
986 
987 
988 void
990  tcpip::Storage writeInto;
991  std::string errors;
992  libsumo::Subscription* modifiedSubscription = nullptr;
993  if (processSingleSubscription(s, writeInto, errors)) {
995  writeStatusCmd(s.commandId, libsumo::RTYPE_ERR, "Subscription has ended.");
996  } else {
997  if (libsumo::Helper::needNewSubscription(s, mySubscriptions, modifiedSubscription)) {
998  mySubscriptions.push_back(s);
999  modifiedSubscription = &mySubscriptions.back();
1000  // Add new subscription to subscription cache (note: seems a bit inefficient)
1002  // copy new subscription into cache
1003  int noActive = 1 + (mySubscriptionCache.size() > 0 ? mySubscriptionCache.readInt() : 0);
1004  tcpip::Storage tmp;
1005  tmp.writeInt(noActive);
1006  while (mySubscriptionCache.valid_pos()) {
1008  }
1009  tmp.writeStorage(writeInto);
1012  }
1013  }
1015  }
1016  if (modifiedSubscription != nullptr && isVehicleToVehicleContextSubscription(*modifiedSubscription)) {
1017  // Set last modified vehicle context subscription active for filter modifications
1018  myLastContextSubscription = modifiedSubscription;
1019  } else {
1020  // adding other subscriptions deactivates the activation for filter addition
1021  myLastContextSubscription = nullptr;
1022  }
1023  } else {
1024  writeStatusCmd(s.commandId, libsumo::RTYPE_ERR, "Could not add subscription. " + errors);
1025  }
1026  myOutputStorage.writeStorage(writeInto);
1027 }
1028 
1029 
1030 void
1031 TraCIServer::removeSubscription(int commandId, const std::string& id, int domain) {
1032  bool found = false;
1033  std::vector<libsumo::Subscription>::iterator j;
1034  for (j = mySubscriptions.begin(); j != mySubscriptions.end();) {
1035  if (j->id == id && j->commandId == commandId && (domain < 0 || j->contextDomain == domain)) {
1036  j = mySubscriptions.erase(j);
1037  if (j != mySubscriptions.end() && myLastContextSubscription == &(*j)) {
1038  // Remove also reference for filter additions
1039  myLastContextSubscription = nullptr;
1040  }
1041  found = true;
1042  continue;
1043  }
1044  ++j;
1045  }
1046  // try unsubscribe
1047  if (found) {
1048  writeStatusCmd(commandId, libsumo::RTYPE_OK, "");
1049  } else {
1050  writeStatusCmd(commandId, libsumo::RTYPE_ERR, "The subscription to remove was not found.");
1051  }
1052 }
1053 
1054 bool
1057 }
1058 
1059 
1060 bool
1062  std::string& errors) {
1063  bool ok = true;
1064  tcpip::Storage outputStorage;
1065  const int getCommandId = s.contextDomain > 0 ? s.contextDomain : s.commandId - 0x30;
1066  std::set<std::string> objIDs;
1067  if (s.contextDomain > 0) {
1069  PositionVector shape;
1072  }
1074  } else {
1075  objIDs.insert(s.id);
1076  }
1077  const int numVars = s.contextDomain > 0 && s.variables.size() == 1 && s.variables[0] == libsumo::TRACI_ID_LIST ? 0 : (int)s.variables.size();
1078  int skipped = 0;
1079  for (std::set<std::string>::iterator j = objIDs.begin(); j != objIDs.end(); ++j) {
1080  if (s.contextDomain > 0) {
1081  //if (centralObject(s, *j)) {
1082  // skipped++;
1083  // continue;
1084  //}
1085  outputStorage.writeString(*j);
1086  }
1087  if (numVars > 0) {
1088  std::vector<std::vector<unsigned char> >::const_iterator k = s.parameters.begin();
1089  for (std::vector<int>::const_iterator i = s.variables.begin(); i != s.variables.end(); ++i, ++k) {
1090  tcpip::Storage message;
1091  message.writeUnsignedByte(*i);
1092  message.writeString(*j);
1093  message.writePacket(*k);
1094  tcpip::Storage tmpOutput;
1095  if (myExecutors.find(getCommandId) != myExecutors.end()) {
1096  ok &= myExecutors[getCommandId](*this, message, tmpOutput);
1097  } else {
1098  writeStatusCmd(s.commandId, libsumo::RTYPE_NOTIMPLEMENTED, "Unsupported command specified", tmpOutput);
1099  ok = false;
1100  }
1101  // copy response part
1102  if (ok) {
1103  int length = tmpOutput.readUnsignedByte();
1104  while (--length > 0) {
1105  tmpOutput.readUnsignedByte();
1106  }
1107  int lengthLength = 1;
1108  length = tmpOutput.readUnsignedByte();
1109  if (length == 0) {
1110  lengthLength = 5;
1111  length = tmpOutput.readInt();
1112  }
1113  //read responseType
1114  tmpOutput.readUnsignedByte();
1115  int variable = tmpOutput.readUnsignedByte();
1116  std::string id = tmpOutput.readString();
1117  outputStorage.writeUnsignedByte(variable);
1118  outputStorage.writeUnsignedByte(libsumo::RTYPE_OK);
1119  length -= (lengthLength + 1 + 4 + (int)id.length());
1120  while (--length > 0) {
1121  outputStorage.writeUnsignedByte(tmpOutput.readUnsignedByte());
1122  }
1123  } else {
1124  //read length
1125  tmpOutput.readUnsignedByte();
1126  //read cmd
1127  tmpOutput.readUnsignedByte();
1128  //read status
1129  tmpOutput.readUnsignedByte();
1130  std::string msg = tmpOutput.readString();
1131  outputStorage.writeUnsignedByte(*i);
1132  outputStorage.writeUnsignedByte(libsumo::RTYPE_ERR);
1133  outputStorage.writeUnsignedByte(libsumo::TYPE_STRING);
1134  outputStorage.writeString(msg);
1135  errors = errors + msg;
1136  }
1137  }
1138  }
1139  }
1140  int length = (1 + 4) + 1 + (4 + (int)(s.id.length())) + 1 + (int)outputStorage.size();
1141  if (s.contextDomain > 0) {
1142  length += 4;
1143  }
1144  writeInto.writeUnsignedByte(0); // command length -> extended
1145  writeInto.writeInt(length);
1146  writeInto.writeUnsignedByte(s.commandId + 0x10);
1147  writeInto.writeString(s.id);
1148  if (s.contextDomain > 0) {
1149  writeInto.writeUnsignedByte(s.contextDomain);
1150  }
1151  writeInto.writeUnsignedByte(numVars);
1152  if (s.contextDomain > 0) {
1153  writeInto.writeInt((int)objIDs.size() - skipped);
1154  }
1155  if (s.contextDomain == 0 || objIDs.size() != 0) {
1156  writeInto.writeStorage(outputStorage);
1157  }
1158  return ok;
1159 }
1160 
1161 
1162 bool
1163 TraCIServer::addObjectVariableSubscription(const int commandId, const bool hasContext) {
1164  const double beginTime = myInputStorage.readDouble();
1165  const double endTime = myInputStorage.readDouble();
1166  const SUMOTime begin = beginTime == libsumo::INVALID_DOUBLE_VALUE ? 0 : TIME2STEPS(beginTime);
1167  const SUMOTime end = endTime == libsumo::INVALID_DOUBLE_VALUE || endTime > STEPS2TIME(SUMOTime_MAX) ? SUMOTime_MAX : TIME2STEPS(endTime);
1168  const std::string id = myInputStorage.readString();
1169  const int domain = hasContext ? myInputStorage.readUnsignedByte() : 0;
1170  const double range = hasContext ? myInputStorage.readDouble() : 0.;
1171  const int num = myInputStorage.readUnsignedByte();
1172  std::vector<int> variables;
1173  std::vector<std::vector<unsigned char> > parameters;
1174  for (int i = 0; i < num; ++i) {
1175  const int varID = myInputStorage.readUnsignedByte();
1176  variables.push_back(varID);
1177  parameters.push_back(std::vector<unsigned char>());
1178  for (int j = 0; j < myParameterSizes[varID]; j++) {
1179  parameters.back().push_back(myInputStorage.readChar());
1180  }
1181  }
1182  // check subscribe/unsubscribe
1183  if (variables.size() == 0) {
1184  removeSubscription(commandId, id, -1);
1185  return true;
1186  }
1187  // process subscription
1188  libsumo::Subscription s(commandId, id, variables, parameters, begin, end, domain, range);
1190  return true;
1191 }
1192 
1193 
1194 
1195 bool
1197  bool success = true;
1198  if (myLastContextSubscription == nullptr) {
1199  WRITE_WARNING("addSubscriptionFilter: No previous vehicle context subscription exists to apply the context filter.");
1200  return true;
1201  }
1202  // Read filter type
1203  int filterType = myInputStorage.readUnsignedByte();
1204 
1205  // dispatch according to filter type
1206  switch (filterType) {
1208  // Remove all filters
1209  removeFilters();
1210  break;
1212  // Read relative lanes to consider for context filter
1213  int nrLanes = (int)myInputStorage.readByte();
1214  std::vector<int> lanes;
1215  for (int i = 0; i < nrLanes; ++i) {
1216  lanes.push_back((int) myInputStorage.readByte());
1217  }
1219  }
1220  break;
1222  // Add no-opposite filter
1224  break;
1226  myInputStorage.readByte(); // read type double
1227  double dist = myInputStorage.readDouble();
1229  }
1230  break;
1232  myInputStorage.readByte(); // read type double
1233  double dist = myInputStorage.readDouble();
1235  }
1236  break;
1238  // Read relative lanes to consider for context filter
1240  }
1241  break;
1244  break;
1246  myInputStorage.readByte(); // read type stringlist
1248  addSubscriptionFilterVClass(vClasses);
1249  }
1250  break;
1252  myInputStorage.readByte(); // read type stringlist
1253  std::vector<std::string> vTypesVector = myInputStorage.readStringList();
1254  std::set<std::string> vTypesSet;
1255  vTypesSet.insert(vTypesVector.begin(), vTypesVector.end());
1256  addSubscriptionFilterVType(vTypesSet);
1257  }
1258  break;
1260  myInputStorage.readByte(); // read type double
1261  double angle = myInputStorage.readDouble();
1263  }
1264  break;
1265  default:
1266  writeStatusCmd(filterType, libsumo::RTYPE_NOTIMPLEMENTED, "'" + toString(filterType) + "' is no valid filter type code.");
1267  success = false;
1268  }
1269 
1270  if (success) {
1271  // acknowledge filter addition
1273  }
1274 
1275  return success;
1276 }
1277 
1278 
1279 void
1281 #ifdef DEBUG_SUBSCRIPTION_FILTERS
1282  std::cout << "Removing filters" << std::endl;
1283 #endif
1285 }
1286 
1287 void
1289 #ifdef DEBUG_SUBSCRIPTION_FILTERS
1290  std::cout << "Adding lane filter (lanes=" << toString(lanes) << ")" << std::endl;
1291 #endif
1294 }
1295 
1296 void
1298 #ifdef DEBUG_SUBSCRIPTION_FILTERS
1299  std::cout << "Adding no opposite filter" << std::endl;
1300 #endif
1302 }
1303 
1304 void
1306 #ifdef DEBUG_SUBSCRIPTION_FILTERS
1307  std::cout << "Adding downstream dist filter (dist=" << toString(dist) << ")" << std::endl;
1308 #endif
1311 }
1312 
1313 void
1315 #ifdef DEBUG_SUBSCRIPTION_FILTERS
1316  std::cout << "Adding upstream dist filter (dist=" << toString(dist) << ")" << std::endl;
1317 #endif
1320 }
1321 
1322 void
1324 #ifdef DEBUG_SUBSCRIPTION_FILTERS
1325  std::cout << "Adding Lead/Follow-maneuver filter" << std::endl;
1326 #endif
1328 }
1329 
1330 void
1332 #ifdef DEBUG_SUBSCRIPTION_FILTERS
1333  std::cout << "Adding turn-maneuver filter" << std::endl;
1334 #endif
1336 }
1337 
1338 void
1340 #ifdef DEBUG_SUBSCRIPTION_FILTERS
1341  std::cout << "Adding vClass filter (vClasses=" << toString(vClasses) << ")" << std::endl;
1342 #endif
1345 }
1346 
1347 void
1348 TraCIServer::addSubscriptionFilterVType(std::set<std::string> vTypes) {
1349 #ifdef DEBUG_SUBSCRIPTION_FILTERS
1350  std::cout << "Adding vType filter (vTypes=" << toString(vTypes) << ")" << std::endl;
1351 #endif
1354 }
1355 
1356 void
1358 #ifdef DEBUG_SUBSCRIPTION_FILTERS
1359  std::cout << "Adding FieldOfVision filter (openingAngle=" << toString(openingAngle) << ")" << std::endl;
1360 #endif
1363 }
1364 
1365 void
1367  if (tempMsg.size() < 254) {
1368  outputStorage.writeUnsignedByte(1 + (int)tempMsg.size()); // command length -> short
1369  } else {
1370  outputStorage.writeUnsignedByte(0); // command length -> extended
1371  outputStorage.writeInt(1 + 4 + (int)tempMsg.size());
1372  }
1373  outputStorage.writeStorage(tempMsg);
1374 }
1375 
1376 
1377 void
1380  if (shape.size() < 256) {
1381  outputStorage.writeUnsignedByte((int)shape.size());
1382  } else {
1383  outputStorage.writeUnsignedByte(0);
1384  outputStorage.writeInt((int)shape.size());
1385  }
1386  for (const libsumo::TraCIPosition& pos : shape) {
1387  outputStorage.writeDouble(pos.x);
1388  outputStorage.writeDouble(pos.y);
1389  }
1390 }
1391 
1392 
1393 bool
1395  if (inputStorage.readUnsignedByte() != libsumo::TYPE_INTEGER) {
1396  return false;
1397  }
1398  into = inputStorage.readInt();
1399  return true;
1400 }
1401 
1402 
1403 bool
1405  if (inputStorage.readUnsignedByte() != libsumo::TYPE_DOUBLE) {
1406  return false;
1407  }
1408  into = inputStorage.readDouble();
1409  return true;
1410 }
1411 
1412 
1413 bool
1414 TraCIServer::readTypeCheckingString(tcpip::Storage& inputStorage, std::string& into) {
1415  if (inputStorage.readUnsignedByte() != libsumo::TYPE_STRING) {
1416  return false;
1417  }
1418  into = inputStorage.readString();
1419  return true;
1420 }
1421 
1422 
1423 bool
1424 TraCIServer::readTypeCheckingStringList(tcpip::Storage& inputStorage, std::vector<std::string>& into) {
1425  if (inputStorage.readUnsignedByte() != libsumo::TYPE_STRINGLIST) {
1426  return false;
1427  }
1428  into = inputStorage.readStringList();
1429  return true;
1430 }
1431 
1432 
1433 bool
1434 TraCIServer::readTypeCheckingDoubleList(tcpip::Storage& inputStorage, std::vector<double>& into) {
1435  if (inputStorage.readUnsignedByte() != libsumo::TYPE_DOUBLELIST) {
1436  return false;
1437  }
1438  into = inputStorage.readDoubleList();
1439  return true;
1440 }
1441 
1442 
1443 bool
1445  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COLOR) {
1446  return false;
1447  }
1448  into.r = static_cast<unsigned char>(inputStorage.readUnsignedByte());
1449  into.g = static_cast<unsigned char>(inputStorage.readUnsignedByte());
1450  into.b = static_cast<unsigned char>(inputStorage.readUnsignedByte());
1451  into.a = static_cast<unsigned char>(inputStorage.readUnsignedByte());
1452  return true;
1453 }
1454 
1455 
1456 bool
1458  if (inputStorage.readUnsignedByte() != libsumo::POSITION_2D) {
1459  return false;
1460  }
1461  into.x = inputStorage.readDouble();
1462  into.y = inputStorage.readDouble();
1463  into.z = 0;
1464  return true;
1465 }
1466 
1467 
1468 bool
1470  if (inputStorage.readByte() != libsumo::TYPE_BYTE) {
1471  return false;
1472  }
1473  into = inputStorage.readByte();
1474  return true;
1475 }
1476 
1477 
1478 bool
1480  if (inputStorage.readUnsignedByte() != libsumo::TYPE_UBYTE) {
1481  return false;
1482  }
1483  into = inputStorage.readUnsignedByte();
1484  return true;
1485 }
1486 
1487 
1488 bool
1490  if (inputStorage.readUnsignedByte() != libsumo::TYPE_POLYGON) {
1491  return false;
1492  }
1493  into.clear();
1494  int size = inputStorage.readUnsignedByte();
1495  if (size == 0) {
1496  size = inputStorage.readInt();
1497  }
1498  PositionVector shape;
1499  for (int i = 0; i < size; ++i) {
1500  double x = inputStorage.readDouble();
1501  double y = inputStorage.readDouble();
1502  if (std::isnan(x) || std::isnan(y)) {
1503  throw libsumo::TraCIException("NaN-Value in shape.");
1504  }
1505  into.push_back(Position(x, y));
1506  }
1507  return true;
1508 }
1509 
1510 
1511 void
1513  myTargetTime = targetTime;
1514  for (auto& s : mySockets) {
1515  s.second->targetTime = targetTime;
1516  }
1517 }
1518 
1519 
1520 bool
1521 TraCIServer::centralObject(const libsumo::Subscription& s, const std::string& objID) {
1522  return (s.id == objID && s.commandId + 32 == s.contextDomain);
1523 }
1524 
1525 
1526 /****************************************************************************/
libsumo::CMD_SUBSCRIBE_VEHICLETYPE_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_VEHICLETYPE_VARIABLE
Definition: TraCIConstants.h:170
libsumo::CMD_GET_TL_VARIABLE
TRACI_CONST int CMD_GET_TL_VARIABLE
Definition: TraCIConstants.h:119
libsumo::FILTER_TYPE_VCLASS
TRACI_CONST int FILTER_TYPE_VCLASS
Definition: TraCIConstants.h:486
TraCIServer::addSubscriptionFilterUpstreamDistance
void addSubscriptionFilterUpstreamDistance(double dist)
Definition: TraCIServer.cpp:1314
libsumo::RTYPE_OK
TRACI_CONST int RTYPE_OK
Definition: TraCIConstants.h:352
tcpip::Storage::writeUnsignedByte
virtual void writeUnsignedByte(int)
Definition: storage.cpp:160
tcpip::Storage::position
virtual unsigned int position() const
Definition: storage.cpp:76
TraCIServerAPI_Route::processSet
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc6: Change Route State)
Definition: TraCIServerAPI_Route.cpp:68
libsumo::Subscription::activeFilters
int activeFilters
Active filters for the subscription (bitset,.
Definition: Subscription.h:117
TraCIServer::wrapRoadPosition
bool wrapRoadPosition(const std::string &objID, const int variable, const libsumo::TraCIRoadPosition &value)
Definition: TraCIServer.cpp:167
libsumo::CMD_GET_POLYGON_VARIABLE
TRACI_CONST int CMD_GET_POLYGON_VARIABLE
Definition: TraCIConstants.h:209
TraCIServerAPI_TrafficLight.h
MIN2
T MIN2(T a, T b)
Definition: StdDefs.h:73
libsumo::CMD_SET_GUI_VARIABLE
TRACI_CONST int CMD_SET_GUI_VARIABLE
Definition: TraCIConstants.h:273
TraCIServer::myVehicleStateChanges
std::map< MSNet::VehicleState, std::vector< std::string > > myVehicleStateChanges
Changes in the states of simulated vehicles.
Definition: TraCIServer.h:396
TraCIServerAPI_Route.h
libsumo::TYPE_COLOR
TRACI_CONST int TYPE_COLOR
Definition: TraCIConstants.h:345
TraCIServerAPI_Vehicle.h
MSNet::VEHICLE_STATE_DEPARTED
@ VEHICLE_STATE_DEPARTED
The vehicle has departed (was inserted into the network)
Definition: MSNet.h:539
TraCIServer::setTargetTime
void setTargetTime(SUMOTime targetTime)
Sets myTargetTime on server and sockets to the given value.
Definition: TraCIServer.cpp:1512
TraCIServerAPI_Vehicle::processSet
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc4: Change Vehicle State)
Definition: TraCIServerAPI_Vehicle.cpp:291
libsumo::Subscription::filterUpstreamDist
double filterUpstreamDist
Upstream distance specified by the upstream distance filter.
Definition: Subscription.h:123
TraCIServer::checkClientOrdering
void checkClientOrdering()
Called once after connection of all clients for executing SET_ORDER (and possibly prior GET_VERSION) ...
Definition: TraCIServer.cpp:334
TraCIServer::addSubscriptionFilterFieldOfVision
void addSubscriptionFilterFieldOfVision(double openingAngle)
Filter only vehicles within field of vision.
Definition: TraCIServer.cpp:1357
TraCIServer::TraCIServer
TraCIServer(const SUMOTime begin, const int port, const int numClients)
Constructor.
Definition: TraCIServer.cpp:180
WRITE_WARNING
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:275
libsumo::CMD_SUBSCRIBE_VEHICLE_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_VEHICLE_VARIABLE
Definition: TraCIConstants.h:155
tcpip::Socket
Definition: socket.h:61
SUMOTime.h
MSTLLogicControl.h
MSNet.h
libsumo::INVALID_DOUBLE_VALUE
TRACI_CONST double INVALID_DOUBLE_VALUE
Definition: TraCIConstants.h:362
TraCIServerAPI_VehicleType::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa5: Get Vehicle Type Variable)
Definition: TraCIServerAPI_VehicleType.cpp:41
libsumo::POSITION_3D
TRACI_CONST int POSITION_3D
Definition: TraCIConstants.h:318
TraCIServer::readTypeCheckingUnsignedByte
bool readTypeCheckingUnsignedByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and an unsigned byte, verifying the type.
Definition: TraCIServer.cpp:1479
TraCIServer::addSubscriptionFilter
bool addSubscriptionFilter()
Definition: TraCIServer.cpp:1196
DELTA_T
SUMOTime DELTA_T
Definition: SUMOTime.cpp:36
libsumo::TraCIPosition
A 3D-position.
Definition: TraCIDefs.h:109
libsumo::Subscription::filterDownstreamDist
double filterDownstreamDist
Downstream distance specified by the downstream distance filter.
Definition: Subscription.h:121
libsumo::TraCIPosition::x
double x
Definition: TraCIDefs.h:115
TraCIServer::removeFilters
void removeFilters()
Definition: TraCIServer.cpp:1280
libsumo::CMD_CLOSE
TRACI_CONST int CMD_CLOSE
Definition: TraCIConstants.h:82
libsumo::CMD_SUBSCRIBE_ROUTE_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_ROUTE_CONTEXT
Definition: TraCIConstants.h:175
TraCIServer::dispatchCommand
int dispatchCommand()
Handles command, writes response to myOutputStorage.
Definition: TraCIServer.cpp:715
TraCIServer::myInstance
static TraCIServer * myInstance
Singleton instance of the server.
Definition: TraCIServer.h:342
libsumo::SUBS_FILTER_VCLASS
@ SUBS_FILTER_VCLASS
Definition: Subscription.h:50
TraCIServerAPI_Simulation::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xab: Get Simulation Variable)
Definition: TraCIServerAPI_Simulation.cpp:47
TraCIServerAPI_InductionLoop.h
TraCIServer::readTypeCheckingColor
bool readTypeCheckingColor(tcpip::Storage &inputStorage, libsumo::TraCIColor &into)
Reads the value type and a color, verifying the type.
Definition: TraCIServer.cpp:1444
TraCIServer::addSubscriptionFilterNoOpposite
void addSubscriptionFilterNoOpposite()
Definition: TraCIServer.cpp:1297
TraCIServer::addObjectVariableSubscription
bool addObjectVariableSubscription(const int commandId, const bool hasContext)
Definition: TraCIServer.cpp:1163
SUMOTrafficObject::getID
virtual const std::string & getID() const =0
Get the vehicle's ID.
MsgHandler.h
TraCIServer::mySocketReorderRequests
std::map< int, SocketInfo * > mySocketReorderRequests
This stores the setOrder(int) requests of the clients.
Definition: TraCIServer.h:355
libsumo::CMD_GET_PERSON_VARIABLE
TRACI_CONST int CMD_GET_PERSON_VARIABLE
Definition: TraCIConstants.h:297
libsumo::TraCIColor::a
int a
Definition: TraCIDefs.h:143
libsumo::CMD_SET_POI_VARIABLE
TRACI_CONST int CMD_SET_POI_VARIABLE
Definition: TraCIConstants.h:198
TraCIServer::commandGetVersion
bool commandGetVersion()
Returns the TraCI-version.
Definition: TraCIServer.cpp:863
TraCIServerAPI_Simulation.h
TraCIServer::readTypeCheckingString
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
Definition: TraCIServer.cpp:1414
libsumo::TraCIColor::g
int g
Definition: TraCIDefs.h:143
TraCIServerAPI_Polygon.h
libsumo::CMD_SET_POLYGON_VARIABLE
TRACI_CONST int CMD_SET_POLYGON_VARIABLE
Definition: TraCIConstants.h:213
TraCIServer::writeResponseWithLength
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
Definition: TraCIServer.cpp:1366
TraCIServerAPI_Polygon::processSet
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc8: Change Polygon State)
Definition: TraCIServerAPI_Polygon.cpp:74
libsumo::Subscription::filterLanes
std::vector< int > filterLanes
lanes specified by the lanes filter
Definition: Subscription.h:119
MsgHandler::inform
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
Definition: MsgHandler.cpp:118
libsumo::CMD_GET_LANEAREA_VARIABLE
TRACI_CONST int CMD_GET_LANEAREA_VARIABLE
Definition: TraCIConstants.h:284
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
libsumo::Subscription::id
std::string id
The id of the object that is subscribed.
Definition: Subscription.h:102
libsumo::CMD_SET_SIM_VARIABLE
TRACI_CONST int CMD_SET_SIM_VARIABLE
Definition: TraCIConstants.h:258
TraCIServer::wrapDouble
bool wrapDouble(const std::string &objID, const int variable, const double value)
Definition: TraCIServer.cpp:111
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:57
tcpip::Storage::end
StorageType::const_iterator end() const
Definition: storage.h:121
libsumo::Helper::needNewSubscription
static bool needNewSubscription(libsumo::Subscription &s, std::vector< Subscription > &subscriptions, libsumo::Subscription *&modifiedSubscription)
Definition: Helper.cpp:157
libsumo::TYPE_DOUBLELIST
TRACI_CONST int TYPE_DOUBLELIST
Definition: TraCIConstants.h:343
MSJunctionControl.h
libsumo::CMD_SUBSCRIBE_PERSON_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_PERSON_CONTEXT
Definition: TraCIConstants.h:293
libsumo::TYPE_BYTE
TRACI_CONST int TYPE_BYTE
Definition: TraCIConstants.h:331
libsumo::CMD_SUBSCRIBE_JUNCTION_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_JUNCTION_VARIABLE
Definition: TraCIConstants.h:230
libsumo::Subscription::endTime
SUMOTime endTime
The end time of the subscription.
Definition: Subscription.h:110
TraCIServer::mySubscriptions
std::vector< libsumo::Subscription > mySubscriptions
The list of known, still valid subscriptions.
Definition: TraCIServer.h:384
TraCIServerAPI_MultiEntryExit::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa1: Get MeMeDetector Variable)
Definition: TraCIServerAPI_MultiEntryExit.cpp:34
tcpip::Socket::accept
Socket * accept(const bool create=false)
Wait for a incoming connection to port_.
Definition: socket.cpp:260
libsumo::Helper::applySubscriptionFilters
static void applySubscriptionFilters(const Subscription &s, std::set< std::string > &objIDs)
Filter the given ID-Set (which was obtained from an R-Tree search) according to the filters set by th...
Definition: Helper.cpp:529
MSEdge.h
libsumo::FILTER_TYPE_FIELD_OF_VISION
TRACI_CONST int FILTER_TYPE_FIELD_OF_VISION
Definition: TraCIConstants.h:492
libsumo::TraCIColor
A color.
Definition: TraCIDefs.h:135
TraCIServer::addSubscriptionFilterLeadFollow
void addSubscriptionFilterLeadFollow()
Definition: TraCIServer.cpp:1323
libsumo::CMD_SUBSCRIBE_POI_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_POI_CONTEXT
Definition: TraCIConstants.h:190
libsumo::CMD_SUBSCRIBE_PERSON_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_PERSON_VARIABLE
Definition: TraCIConstants.h:303
libsumo::VAR_LEADER
TRACI_CONST int VAR_LEADER
Definition: TraCIConstants.h:819
libsumo::CMD_SUBSCRIBE_LANEAREA_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_LANEAREA_CONTEXT
Definition: TraCIConstants.h:280
libsumo::CMD_GET_LANE_VARIABLE
TRACI_CONST int CMD_GET_LANE_VARIABLE
Definition: TraCIConstants.h:134
tcpip::Storage::readByte
virtual int readByte()
Definition: storage.cpp:123
TraCIServer::myTargetTime
SUMOTime myTargetTime
The time step to reach until processing the next commands.
Definition: TraCIServer.h:361
PositionVector
A list of positions.
Definition: PositionVector.h:45
MSNet::VEHICLE_STATE_ARRIVED
@ VEHICLE_STATE_ARRIVED
The vehicle arrived at his destination (is deleted)
Definition: MSNet.h:545
libsumo::CMD_SUBSCRIBE_VEHICLE_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_VEHICLE_CONTEXT
Definition: TraCIConstants.h:145
libsumo::TraCIColor::b
int b
Definition: TraCIDefs.h:143
TraCIServer::close
static void close()
request termination of connection
Definition: TraCIServer.cpp:303
MSNet::VEHICLE_STATE_NEWROUTE
@ VEHICLE_STATE_NEWROUTE
The vehicle got a new route.
Definition: MSNet.h:547
TraCIServer::getWrapperStorage
tcpip::Storage & getWrapperStorage()
Definition: TraCIServer.cpp:174
TraCIServer::removeCurrentSocket
std::map< int, SocketInfo * >::iterator removeCurrentSocket()
removes myCurrentSocket from mySockets and returns an iterator pointing to the next member according ...
Definition: TraCIServer.cpp:667
TraCIServerAPI_VehicleType.h
libsumo::CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
Definition: TraCIConstants.h:149
libsumo::CMD_SET_VEHICLE_VARIABLE
TRACI_CONST int CMD_SET_VEHICLE_VARIABLE
Definition: TraCIConstants.h:153
libsumo::CMD_GET_VEHICLETYPE_VARIABLE
TRACI_CONST int CMD_GET_VEHICLETYPE_VARIABLE
Definition: TraCIConstants.h:164
TraCIServer::addSubscriptionFilterLanes
void addSubscriptionFilterLanes(std::vector< int > lanes)
Definition: TraCIServer.cpp:1288
libsumo::Subscription::variables
std::vector< int > variables
The subscribed variables.
Definition: Subscription.h:104
libsumo::CMD_ADD_SUBSCRIPTION_FILTER
TRACI_CONST int CMD_ADD_SUBSCRIPTION_FILTER
Definition: TraCIConstants.h:85
TraCIServer::readCommandID
int readCommandID(int &commandStart, int &commandLength)
Reads the next command ID from the input storage.
Definition: TraCIServer.cpp:697
TraCIServer::readTypeCheckingDouble
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
Definition: TraCIServer.cpp:1404
libsumo::SUBS_FILTER_NOOPPOSITE
@ SUBS_FILTER_NOOPPOSITE
Definition: Subscription.h:40
MSNet::VEHICLE_STATE_EMERGENCYSTOP
@ VEHICLE_STATE_EMERGENCYSTOP
The vehicle had to brake harder than permitted.
Definition: MSNet.h:559
TraCIServer::initialiseSubscription
void initialiseSubscription(libsumo::Subscription &s)
Definition: TraCIServer.cpp:989
MSVehicle.h
libsumo::SUBS_FILTER_NONE
@ SUBS_FILTER_NONE
Definition: Subscription.h:36
tcpip::Storage::writeDouble
virtual void writeDouble(double)
Definition: storage.cpp:349
SUMOVehicleParameter.h
libsumo::FILTER_TYPE_UPSTREAM_DIST
TRACI_CONST int FILTER_TYPE_UPSTREAM_DIST
Definition: TraCIConstants.h:477
TraCIServer::mySubscriptionCache
tcpip::Storage mySubscriptionCache
The last timestep's subscription results.
Definition: TraCIServer.h:373
TraCIServer::writeStatusCmd
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
Definition: TraCIServer.cpp:968
libsumo::Subscription::parameters
std::vector< std::vector< unsigned char > > parameters
The parameters for the subscribed variables.
Definition: Subscription.h:106
TraCIServer::~TraCIServer
virtual ~TraCIServer()
Destructor.
Definition: TraCIServer.cpp:274
libsumo::CMD_SUBSCRIBE_EDGE_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_EDGE_VARIABLE
Definition: TraCIConstants.h:245
libsumo::FILTER_TYPE_LEAD_FOLLOW
TRACI_CONST int FILTER_TYPE_LEAD_FOLLOW
Definition: TraCIConstants.h:480
parseVehicleClasses
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
Definition: SUMOVehicleClass.cpp:222
libsumo::FILTER_TYPE_NOOPPOSITE
TRACI_CONST int FILTER_TYPE_NOOPPOSITE
Definition: TraCIConstants.h:471
MSTransportableControl::get
MSTransportable * get(const std::string &id) const
Returns the named transportable, if existing.
Definition: MSTransportableControl.cpp:75
TraCIServerAPI_POI::processSet
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc7: Change PoI State)
Definition: TraCIServerAPI_POI.cpp:70
TraCIServer::initWrapper
void initWrapper(const int domainID, const int variable, const std::string &objID)
Definition: TraCIServer.cpp:102
TraCIServerAPI_Simulation::processSet
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xcb: Set Simulation Variable)
Definition: TraCIServerAPI_Simulation.cpp:293
libsumo::CMD_SUBSCRIBE_POLYGON_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_POLYGON_CONTEXT
Definition: TraCIConstants.h:205
libsumo::CMD_SETORDER
TRACI_CONST int CMD_SETORDER
Definition: TraCIConstants.h:55
TraCIServer::SocketInfo
Definition: TraCIServer.h:278
libsumo::Subscription::commandId
int commandId
commandIdArg The command id of the subscription
Definition: Subscription.h:100
TraCIServer::myInputStorage
tcpip::Storage myInputStorage
The storage to read from.
Definition: TraCIServer.h:364
libsumo::CMD_SUBSCRIBE_SIM_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_SIM_CONTEXT
Definition: TraCIConstants.h:250
libsumo::SUBS_FILTER_TURN
@ SUBS_FILTER_TURN
Definition: Subscription.h:48
TraCIServer::centralObject
bool centralObject(const libsumo::Subscription &s, const std::string &objID)
check whether a found objID refers to the central object of a context subscription
Definition: TraCIServer.cpp:1521
TraCIServer::addSubscriptionFilterVType
void addSubscriptionFilterVType(std::set< std::string > vTypes)
Definition: TraCIServer.cpp:1348
tcpip::Storage::writeString
virtual void writeString(const std::string &s)
Definition: storage.cpp:192
TraCIServer::readTypeCheckingDoubleList
bool readTypeCheckingDoubleList(tcpip::Storage &inputStorage, std::vector< double > &into)
Reads the value type and a double list, verifying the type.
Definition: TraCIServer.cpp:1434
Simulation.h
SIMTIME
#define SIMTIME
Definition: SUMOTime.h:63
libsumo::CMD_GETVERSION
TRACI_CONST int CMD_GETVERSION
Definition: TraCIConstants.h:46
TraCIServer::readTypeCheckingPolygon
bool readTypeCheckingPolygon(tcpip::Storage &inputStorage, PositionVector &into)
Reads the value type and a polygon, verifying the type.
Definition: TraCIServer.cpp:1489
tcpip::Storage::writeInt
virtual void writeInt(int)
Definition: storage.cpp:316
libsumo::FILTER_TYPE_TURN
TRACI_CONST int FILTER_TYPE_TURN
Definition: TraCIConstants.h:483
MSNet::VEHICLE_STATE_STARTING_PARKING
@ VEHICLE_STATE_STARTING_PARKING
The vehicles starts to park.
Definition: MSNet.h:549
libsumo::TYPE_DOUBLE
TRACI_CONST int TYPE_DOUBLE
Definition: TraCIConstants.h:335
libsumo::TYPE_POLYGON
TRACI_CONST int TYPE_POLYGON
Definition: TraCIConstants.h:327
tcpip::Storage::writeStorage
virtual void writeStorage(tcpip::Storage &store)
Definition: storage.cpp:383
libsumo::CMD_GET_POI_VARIABLE
TRACI_CONST int CMD_GET_POI_VARIABLE
Definition: TraCIConstants.h:194
TraCIServerAPI_Vehicle::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa4: Get Vehicle Variable)
Definition: TraCIServerAPI_Vehicle.cpp:58
tcpip::Storage::readUnsignedByte
virtual int readUnsignedByte()
Definition: storage.cpp:150
TraCIConstants.h
TraCIServer::readTypeCheckingByte
bool readTypeCheckingByte(tcpip::Storage &inputStorage, int &into)
Reads the value type and a byte, verifying the type.
Definition: TraCIServer.cpp:1469
libsumo::CMD_SUBSCRIBE_GUI_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_GUI_VARIABLE
Definition: TraCIConstants.h:275
TraCIServer::wrapPosition
bool wrapPosition(const std::string &objID, const int variable, const libsumo::TraCIPosition &value)
Definition: TraCIServer.cpp:143
libsumo::SUBS_FILTER_UPSTREAM_DIST
@ SUBS_FILTER_UPSTREAM_DIST
Definition: Subscription.h:44
libsumo::CMD_SUBSCRIBE_SIM_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_SIM_VARIABLE
Definition: TraCIConstants.h:260
libsumo::Subscription
Representation of a subscription.
Definition: Subscription.h:67
libsumo::Subscription::filterFieldOfVisionOpeningAngle
double filterFieldOfVisionOpeningAngle
Opening angle (in deg) specified by the field of vision filter.
Definition: Subscription.h:129
libsumo::FILTER_TYPE_VTYPE
TRACI_CONST int FILTER_TYPE_VTYPE
Definition: TraCIConstants.h:489
SVCPermissions
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
Definition: SUMOVehicleClass.h:218
libsumo::TYPE_INTEGER
TRACI_CONST int TYPE_INTEGER
Definition: TraCIConstants.h:333
MSTransportableControl.h
TIME2STEPS
#define TIME2STEPS(x)
Definition: SUMOTime.h:58
MSNet::VehicleState
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:535
MSJunction.h
MsgHandler::getWarningInstance
static MsgHandler * getWarningInstance()
Returns the instance to add warnings to.
Definition: MsgHandler.cpp:68
libsumo::CMD_SET_VEHICLETYPE_VARIABLE
TRACI_CONST int CMD_SET_VEHICLETYPE_VARIABLE
Definition: TraCIConstants.h:168
tcpip::Storage::writeStringList
virtual void writeStringList(const std::vector< std::string > &s)
Definition: storage.cpp:242
TraCIServer::myOutputStorage
tcpip::Storage myOutputStorage
The storage to write to.
Definition: TraCIServer.h:367
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:283
TraCIServer::addSubscriptionFilterDownstreamDistance
void addSubscriptionFilterDownstreamDistance(double dist)
Definition: TraCIServer.cpp:1305
libsumo::Subscription::filterVClasses
int filterVClasses
vClasses specified by the vClasses filter,
Definition: Subscription.h:127
STEPS2TIME
#define STEPS2TIME(x)
Definition: SUMOTime.h:56
libsumo::CMD_SUBSCRIBE_VEHICLETYPE_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_VEHICLETYPE_CONTEXT
Definition: TraCIConstants.h:160
TraCIServer::postProcessSimulationStep
void postProcessSimulationStep()
Handles subscriptions to send after a simstep2 command.
Definition: TraCIServer.cpp:882
libsumo::CMD_SET_LANE_VARIABLE
TRACI_CONST int CMD_SET_LANE_VARIABLE
Definition: TraCIConstants.h:138
libsumo::FILTER_TYPE_NONE
TRACI_CONST int FILTER_TYPE_NONE
Definition: TraCIConstants.h:465
TraCIServerAPI_InductionLoop::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa0: Get Induction Loop Variable)
Definition: TraCIServerAPI_InductionLoop.cpp:37
libsumo::RTYPE_ERR
TRACI_CONST int RTYPE_ERR
Definition: TraCIConstants.h:356
TraCIServer::vehicleStateChanged
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
Definition: TraCIServer.cpp:323
TraCIServer::myDoCloseConnection
static bool myDoCloseConnection
Whether the connection was set to be to close.
Definition: TraCIServer.h:345
libsumo::TraCIPosition::z
double z
Definition: TraCIDefs.h:115
TraCIServer::myLoadArgs
std::vector< std::string > myLoadArgs
Definition: TraCIServer.h:381
libsumo::CMD_SUBSCRIBE_POLYGON_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_POLYGON_VARIABLE
Definition: TraCIConstants.h:215
MSNet::addVehicleStateListener
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:877
tcpip::Storage::readStringList
virtual std::vector< std::string > readStringList()
Definition: storage.cpp:206
libsumo::CMD_SUBSCRIBE_LANEAREA_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_LANEAREA_VARIABLE
Definition: TraCIConstants.h:288
ProcessError
Definition: UtilExceptions.h:39
MSNet::VEHICLE_STATE_COLLISION
@ VEHICLE_STATE_COLLISION
The vehicle is involved in a collision.
Definition: MSNet.h:557
toHex
std::string toHex(const T i, std::streamsize numDigits=0)
Definition: ToString.h:57
MSNet::VEHICLE_STATE_STARTING_TELEPORT
@ VEHICLE_STATE_STARTING_TELEPORT
The vehicle started to teleport.
Definition: MSNet.h:541
libsumo::CMD_SET_TL_VARIABLE
TRACI_CONST int CMD_SET_TL_VARIABLE
Definition: TraCIConstants.h:123
libsumo::CMD_SET_PERSON_VARIABLE
TRACI_CONST int CMD_SET_PERSON_VARIABLE
Definition: TraCIConstants.h:301
MSNet::VEHICLE_STATE_BUILT
@ VEHICLE_STATE_BUILT
The vehicle was built, but has not yet departed.
Definition: MSNet.h:537
Position
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:38
libsumo::CMD_GET_SIM_VARIABLE
TRACI_CONST int CMD_GET_SIM_VARIABLE
Definition: TraCIConstants.h:254
tcpip::Storage::writeByte
virtual void writeByte(int)
Definition: storage.cpp:135
MSNet::VEHICLE_STATE_STARTING_STOP
@ VEHICLE_STATE_STARTING_STOP
The vehicles starts to stop.
Definition: MSNet.h:553
TraCIServer::wrapColor
bool wrapColor(const std::string &objID, const int variable, const libsumo::TraCIColor &value)
Definition: TraCIServer.cpp:156
libsumo::TRACI_ID_LIST
TRACI_CONST int TRACI_ID_LIST
Definition: TraCIConstants.h:498
TraCIServer::myParameterSizes
std::map< int, int > myParameterSizes
Map of variable ids to the size of the parameter in bytes.
Definition: TraCIServer.h:379
MSGlobals.h
TraCIServerAPI_LaneArea.h
TraCIServerAPI_VehicleType::processSet
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc5: Change Vehicle Type State)
Definition: TraCIServerAPI_VehicleType.cpp:75
libsumo::TraCIColor::r
int r
Definition: TraCIDefs.h:143
libsumo::Subscription::beginTime
SUMOTime beginTime
The begin time of the subscription.
Definition: Subscription.h:108
tcpip::Storage::reset
void reset()
Definition: storage.cpp:85
tcpip::Storage::readChar
virtual unsigned char readChar()
Definition: storage.cpp:97
libsumo::CMD_SUBSCRIBE_JUNCTION_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_JUNCTION_CONTEXT
Definition: TraCIConstants.h:220
TraCIServerAPI_Route::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa6: Get Route Variable)
Definition: TraCIServerAPI_Route.cpp:37
TraCIServer::processReorderingRequests
void processReorderingRequests()
checks for and processes reordering requests (relevant for multiple clients)
Definition: TraCIServer.cpp:401
TraCIServer::myWrapperStorage
tcpip::Storage myWrapperStorage
A temporary storage to let the wrapper write to.
Definition: TraCIServer.h:370
TraCIServer::mySockets
std::map< int, SocketInfo * > mySockets
The socket connections to the clients the first component (index) determines the client's order (lowe...
Definition: TraCIServer.h:352
TraCIServer::cleanup
void cleanup()
clean up subscriptions
Definition: TraCIServer.cpp:649
TraCIServer::processSingleSubscription
bool processSingleSubscription(const libsumo::Subscription &s, tcpip::Storage &writeInto, std::string &errors)
Definition: TraCIServer.cpp:1061
libsumo::SUBS_FILTER_LANES
@ SUBS_FILTER_LANES
Definition: Subscription.h:38
TraCIServer::readTypeCheckingStringList
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
Definition: TraCIServer.cpp:1424
TraCIServer::processCommandsUntilSimStep
void processCommandsUntilSimStep(SUMOTime step)
process all commands until the next SUMO simulation step. It is guaranteed that t->getTargetTime() >=...
Definition: TraCIServer.cpp:491
string2time
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:44
libsumo::CMD_SUBSCRIBE_GUI_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_GUI_CONTEXT
Definition: TraCIConstants.h:265
libsumo::TraCIException
Definition: TraCIDefs.h:89
libsumo::CMD_SUBSCRIBE_POI_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_POI_VARIABLE
Definition: TraCIConstants.h:200
TraCIServer::openSocket
static void openSocket(const std::map< int, CmdExecutor > &execs)
Initialises the server.
Definition: TraCIServer.cpp:285
libsumo::SUBS_FILTER_NO_RTREE
@ SUBS_FILTER_NO_RTREE
Definition: Subscription.h:57
TraCIServer::writePositionVector
void writePositionVector(tcpip::Storage &outputStorage, const libsumo::TraCIPositionVector &shape)
Definition: TraCIServer.cpp:1378
TraCIServerAPI_Person::processSet
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xce: Change Person State)
Definition: TraCIServerAPI_Person.cpp:91
libsumo::TYPE_STRINGLIST
TRACI_CONST int TYPE_STRINGLIST
Definition: TraCIConstants.h:339
tcpip::SocketException
Definition: socket.h:55
MSGlobals::gUsingInternalLanes
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:68
TraCIServerAPI_MultiEntryExit.h
TraCIServerAPI_Edge::processSet
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xca: Change Edge State)
Definition: TraCIServerAPI_Edge.cpp:102
libsumo::CMD_SUBSCRIBE_TL_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_TL_CONTEXT
Definition: TraCIConstants.h:115
tcpip::Storage::readDoubleList
virtual std::vector< double > readDoubleList()
Definition: storage.cpp:224
NamedObjectCont.h
TraCIServerAPI_Lane.h
MSEdgeControl.h
TraCIServerAPI_Lane::processSet
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc3: Change Lane State)
Definition: TraCIServerAPI_Lane.cpp:137
libsumo::CMD_SUBSCRIBE_ROUTE_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_ROUTE_VARIABLE
Definition: TraCIConstants.h:185
tcpip::Storage::valid_pos
virtual bool valid_pos()
Definition: storage.cpp:69
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:47
MSNet::VEHICLE_STATE_MANEUVERING
@ VEHICLE_STATE_MANEUVERING
Vehicle maneuvering either entering or exiting a parking space.
Definition: MSNet.h:561
TraCIServer::myCurrentSocket
std::map< int, SocketInfo * >::iterator myCurrentSocket
The currently active client socket.
Definition: TraCIServer.h:358
libsumo::CMD_GET_GUI_VARIABLE
TRACI_CONST int CMD_GET_GUI_VARIABLE
Definition: TraCIConstants.h:269
libsumo::Helper::collectObjectsInRange
static void collectObjectsInRange(int domain, const PositionVector &shape, double range, std::set< std::string > &into)
Definition: Helper.cpp:470
PointOfInterest.h
TraCIServer::myLastContextSubscription
libsumo::Subscription * myLastContextSubscription
The last modified context subscription (the one to add a filter to, see @addSubscriptionFilter(),...
Definition: TraCIServer.h:387
TraCIServer::addSubscriptionFilterVClass
void addSubscriptionFilterVClass(SVCPermissions vClasses)
Definition: TraCIServer.cpp:1339
TraCIServer::readTypeCheckingInt
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
Definition: TraCIServer.cpp:1394
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
MSNet::getPersonControl
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:810
libsumo::CMD_GET_MULTIENTRYEXIT_VARIABLE
TRACI_CONST int CMD_GET_MULTIENTRYEXIT_VARIABLE
Definition: TraCIConstants.h:106
TraCIServerAPI_POI.h
tcpip::Storage::begin
StorageType::const_iterator begin() const
Definition: storage.h:120
libsumo::FILTER_TYPE_DOWNSTREAM_DIST
TRACI_CONST int FILTER_TYPE_DOWNSTREAM_DIST
Definition: TraCIConstants.h:474
libsumo::CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
Definition: TraCIConstants.h:89
TraCIServerAPI_TrafficLight::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa2: Get Traffic Lights Variable)
Definition: TraCIServerAPI_TrafficLight.cpp:39
storage.h
libsumo::POSITION_2D
TRACI_CONST int POSITION_2D
Definition: TraCIConstants.h:314
libsumo::Subscription::range
double range
The range of the context.
Definition: Subscription.h:114
libsumo::CMD_GET_INDUCTIONLOOP_VARIABLE
TRACI_CONST int CMD_GET_INDUCTIONLOOP_VARIABLE
Definition: TraCIConstants.h:93
TraCIServer::sendOutputToAll
void sendOutputToAll() const
send out subscription results (actually just the content of myOutputStorage) to clients which will ac...
Definition: TraCIServer.cpp:469
TraCIServerAPI_LaneArea::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa1: Get AreaDetector Variable)
Definition: TraCIServerAPI_LaneArea.cpp:37
libsumo::TYPE_STRING
TRACI_CONST int TYPE_STRING
Definition: TraCIConstants.h:337
Subscription.h
TraCIServerAPI_Polygon::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa8: Get Polygon Variable)
Definition: TraCIServerAPI_Polygon.cpp:41
libsumo::MAX_ORDER
TRACI_CONST int MAX_ORDER
Definition: TraCIConstants.h:366
TraCIServerAPI_Junction.h
libsumo::CMD_SUBSCRIBE_LANE_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_LANE_CONTEXT
Definition: TraCIConstants.h:130
libsumo::VAR_POSITION3D
TRACI_CONST int VAR_POSITION3D
Definition: TraCIConstants.h:621
MSNet::VEHICLE_STATE_ENDING_PARKING
@ VEHICLE_STATE_ENDING_PARKING
The vehicle ends to park.
Definition: MSNet.h:551
libsumo::SUBS_FILTER_DOWNSTREAM_DIST
@ SUBS_FILTER_DOWNSTREAM_DIST
Definition: Subscription.h:42
libsumo::Helper::findObjectShape
static void findObjectShape(int domain, const std::string &id, PositionVector &shape)
Definition: Helper.cpp:437
TraCIServerAPI_Lane::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa3: Get Lane Variable)
Definition: TraCIServerAPI_Lane.cpp:44
libsumo::CMD_SET_EDGE_VARIABLE
TRACI_CONST int CMD_SET_EDGE_VARIABLE
Definition: TraCIConstants.h:243
libsumo::FILTER_TYPE_LANES
TRACI_CONST int FILTER_TYPE_LANES
Definition: TraCIConstants.h:468
libsumo::TYPE_UBYTE
TRACI_CONST int TYPE_UBYTE
Definition: TraCIConstants.h:329
libsumo::CMD_SUBSCRIBE_EDGE_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_EDGE_CONTEXT
Definition: TraCIConstants.h:235
libsumo::CMD_SUBSCRIBE_MULTIENTRYEXIT_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_MULTIENTRYEXIT_VARIABLE
Definition: TraCIConstants.h:110
socket.h
MSNet::VEHICLE_STATE_ENDING_TELEPORT
@ VEHICLE_STATE_ENDING_TELEPORT
The vehicle ended being teleported.
Definition: MSNet.h:543
TraCIServer.h
tcpip::Storage::size
StorageType::size_type size() const
Definition: storage.h:118
libsumo::SUBS_FILTER_FIELD_OF_VISION
@ SUBS_FILTER_FIELD_OF_VISION
Definition: Subscription.h:55
libsumo::CMD_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
Definition: TraCIConstants.h:97
libsumo::TraCIRoadPosition
An edgeId, position and laneIndex.
Definition: TraCIDefs.h:121
libsumo::Subscription::contextDomain
int contextDomain
The domain ID of the context.
Definition: Subscription.h:112
config.h
TraCIServer::wrapStringList
bool wrapStringList(const std::string &objID, const int variable, const std::vector< std::string > &value)
Definition: TraCIServer.cpp:135
TraCIServer::nextTargetTime
SUMOTime nextTargetTime() const
get the minimal next target time among all clients
Definition: TraCIServer.cpp:445
ShapeContainer.h
TraCIServerAPI_Person.h
TraCIServerAPI_Junction::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa9: Get Junction Variable)
Definition: TraCIServerAPI_Junction.cpp:37
libsumo::TRACI_VERSION
TRACI_CONST int TRACI_VERSION
Definition: TraCIConstants.h:40
RandHelper.h
tcpip::Storage::readString
virtual std::string readString()
Definition: storage.cpp:175
DijkstraRouter.h
libsumo::CMD_SUBSCRIBE_MULTIENTRYEXIT_CONTEXT
TRACI_CONST int CMD_SUBSCRIBE_MULTIENTRYEXIT_CONTEXT
Definition: TraCIConstants.h:102
libsumo::CMD_SUBSCRIBE_LANE_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_LANE_VARIABLE
Definition: TraCIConstants.h:140
TraCIServer::myServerSocket
tcpip::Socket * myServerSocket
The server socket.
Definition: TraCIServer.h:348
tcpip::Storage::readDouble
virtual double readDouble()
Definition: storage.cpp:357
TraCIServer::removeSubscription
void removeSubscription(int commandId, const std::string &identity, int domain)
Definition: TraCIServer.cpp:1031
libsumo::TraCIPositionVector
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIDefs.h:149
TraCIServer::wrapInt
bool wrapInt(const std::string &objID, const int variable, const int value)
Definition: TraCIServer.cpp:119
TraCIServerAPI_TrafficLight::processSet
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc2: Change Traffic Lights State)
Definition: TraCIServerAPI_TrafficLight.cpp:211
TraCIServer::wasClosed
static bool wasClosed()
check whether close was requested
Definition: TraCIServer.cpp:314
TraCIServer
TraCI server used to control sumo by a remote TraCI client.
Definition: TraCIServer.h:61
SUMOTime_MAX
#define SUMOTime_MAX
Definition: SUMOTime.h:35
MSLane.h
TraCIServerAPI_Person::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xae: Get Person Variable)
Definition: TraCIServerAPI_Person.cpp:42
TraCIServer::addSubscriptionFilterTurn
void addSubscriptionFilterTurn()
Definition: TraCIServer.cpp:1331
TraCIServerAPI_Edge.h
libsumo::SUBS_FILTER_LEAD_FOLLOW
@ SUBS_FILTER_LEAD_FOLLOW
Definition: Subscription.h:46
TraCIServerAPI_Edge::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xaa: Get Edge Variable)
Definition: TraCIServerAPI_Edge.cpp:47
TraCIServer::isVehicleToVehicleContextSubscription
bool isVehicleToVehicleContextSubscription(const libsumo::Subscription &s)
Definition: TraCIServer.cpp:1055
TraCIServer::sendSingleSimStepResponse
void sendSingleSimStepResponse()
sends an empty response to a simstep command to the current client. (This applies to a situation wher...
Definition: TraCIServer.cpp:941
libsumo::SUBS_FILTER_VTYPE
@ SUBS_FILTER_VTYPE
Definition: Subscription.h:52
TraCIServerAPI_POI::processGet
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa7: Get PoI Variable)
Definition: TraCIServerAPI_POI.cpp:39
libsumo::CMD_SUBSCRIBE_TL_VARIABLE
TRACI_CONST int CMD_SUBSCRIBE_TL_VARIABLE
Definition: TraCIConstants.h:125
libsumo::CMD_SET_ROUTE_VARIABLE
TRACI_CONST int CMD_SET_ROUTE_VARIABLE
Definition: TraCIConstants.h:183
tcpip::Storage::writePacket
virtual void writePacket(unsigned char *packet, int length)
Definition: storage.cpp:367
VERSION_STRING
#define VERSION_STRING
Definition: config.h:210
libsumo::CMD_LOAD
TRACI_CONST int CMD_LOAD
Definition: TraCIConstants.h:49
TraCIServer::myExecutors
std::map< int, CmdExecutor > myExecutors
Map of commandIds -> their executors; applicable if the executor applies to the method footprint.
Definition: TraCIServer.h:376
libsumo::CMD_GET_EDGE_VARIABLE
TRACI_CONST int CMD_GET_EDGE_VARIABLE
Definition: TraCIConstants.h:239
TraCIServer::readTypeCheckingPosition2D
bool readTypeCheckingPosition2D(tcpip::Storage &inputStorage, libsumo::TraCIPosition &into)
Reads the value type and a 2D position, verifying the type.
Definition: TraCIServer.cpp:1457
WRITE_ERROR
#define WRITE_ERROR(msg)
Definition: MsgHandler.h:283
MSNet::VEHICLE_STATE_ENDING_STOP
@ VEHICLE_STATE_ENDING_STOP
The vehicle ends to stop.
Definition: MSNet.h:555
WRITE_MESSAGE
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:277
libsumo::RTYPE_NOTIMPLEMENTED
TRACI_CONST int RTYPE_NOTIMPLEMENTED
Definition: TraCIConstants.h:354
tcpip::Storage
Definition: storage.h:38
TraCIServer::wrapString
bool wrapString(const std::string &objID, const int variable, const std::string &value)
Definition: TraCIServer.cpp:127
libsumo::CMD_SIMSTEP
TRACI_CONST int CMD_SIMSTEP
Definition: TraCIConstants.h:52
tcpip::Storage::readInt
virtual int readInt()
Definition: storage.cpp:306
XMLSubSys.h
libsumo::Subscription::filterVTypes
std::set< std::string > filterVTypes
vTypes specified by the vTypes filter
Definition: Subscription.h:125
libsumo::CMD_GET_JUNCTION_VARIABLE
TRACI_CONST int CMD_GET_JUNCTION_VARIABLE
Definition: TraCIConstants.h:224
libsumo::CMD_GET_ROUTE_VARIABLE
TRACI_CONST int CMD_GET_ROUTE_VARIABLE
Definition: TraCIConstants.h:179
libsumo::TraCIPosition::y
double y
Definition: TraCIDefs.h:115
TraCIServer::writeErrorStatusCmd
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
Definition: TraCIServer.cpp:982