LCOV - code coverage report
Current view: top level - src/utils/traci - TraCIAPI.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1505 2366 63.6 %
Date: 2024-05-01 15:34:42 Functions: 214 404 53.0 %

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2012-2024 German Aerospace Center (DLR) and others.
       4             : // This program and the accompanying materials are made available under the
       5             : // terms of the Eclipse Public License 2.0 which is available at
       6             : // https://www.eclipse.org/legal/epl-2.0/
       7             : // This Source Code may also be made available under the following Secondary
       8             : // Licenses when the conditions for such availability set forth in the Eclipse
       9             : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10             : // or later which is available at
      11             : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12             : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13             : /****************************************************************************/
      14             : /// @file    TraCIAPI.cpp
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Mario Krumnow
      17             : /// @author  Jakob Erdmann
      18             : /// @author  Michael Behrisch
      19             : /// @date    30.05.2012
      20             : ///
      21             : // C++ TraCI client API implementation
      22             : /****************************************************************************/
      23             : #include "TraCIAPI.h"
      24             : 
      25             : 
      26             : // ===========================================================================
      27             : // member definitions
      28             : // ===========================================================================
      29             : 
      30             : // ---------------------------------------------------------------------------
      31             : // TraCIAPI-methods
      32             : // ---------------------------------------------------------------------------
      33             : 
      34        1184 : TraCIAPI::TraCIAPI() :
      35             :     edge(*this), gui(*this), inductionloop(*this),
      36             :     junction(*this), lane(*this), lanearea(*this), multientryexit(*this),
      37             :     person(*this), poi(*this), polygon(*this),
      38             :     rerouter(*this), route(*this), routeprobe(*this),
      39             :     simulation(*this), trafficlights(*this),
      40             :     vehicle(*this), vehicletype(*this),
      41        1184 :     mySocket(nullptr) {
      42        1184 :     std::cerr << "TraCIAPI is deprecated. Please use libtraci instead, see https://sumo.dlr.de/docs/Libtraci.html.\n";
      43        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_EDGE_VARIABLE] = &edge;
      44        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_GUI_VARIABLE] = &gui;
      45        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_JUNCTION_VARIABLE] = &junction;
      46        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_LANE_VARIABLE] = &lane;
      47        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_LANEAREA_VARIABLE] = &lanearea;
      48        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_MULTIENTRYEXIT_VARIABLE] = &multientryexit;
      49        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_PERSON_VARIABLE] = &person;
      50        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_POI_VARIABLE] = &poi;
      51        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_POLYGON_VARIABLE] = &polygon;
      52        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_REROUTER_VARIABLE] = &rerouter;
      53        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_ROUTE_VARIABLE] = &route;
      54        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_ROUTEPROBE_VARIABLE] = &routeprobe;
      55        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_SIM_VARIABLE] = &simulation;
      56        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_TL_VARIABLE] = &trafficlights;
      57        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_VEHICLE_VARIABLE] = &vehicle;
      58        1184 :     myDomains[libsumo::RESPONSE_SUBSCRIBE_VEHICLETYPE_VARIABLE] = &vehicletype;
      59        1184 : }
      60             : 
      61             : 
      62        1184 : TraCIAPI::~TraCIAPI() {
      63        1184 :     delete mySocket;
      64        1184 : }
      65             : 
      66             : 
      67             : void
      68        1184 : TraCIAPI::connect(const std::string& host, int port) {
      69        1184 :     mySocket = new tcpip::Socket(host, port);
      70             :     try {
      71        1184 :         mySocket->connect();
      72         592 :     } catch (tcpip::SocketException&) {
      73         592 :         delete mySocket;
      74         592 :         mySocket = nullptr;
      75         592 :         throw;
      76         592 :     }
      77         592 : }
      78             : 
      79             : 
      80             : void
      81           1 : TraCIAPI::setOrder(int order) {
      82           1 :     tcpip::Storage outMsg;
      83             :     // command length
      84           1 :     outMsg.writeUnsignedByte(1 + 1 + 4);
      85             :     // command id
      86           1 :     outMsg.writeUnsignedByte(libsumo::CMD_SETORDER);
      87           1 :     outMsg.writeInt(order);
      88             :     // send request message
      89           1 :     mySocket->sendExact(outMsg);
      90           1 :     tcpip::Storage inMsg;
      91           1 :     check_resultState(inMsg, libsumo::CMD_SETORDER);
      92           1 : }
      93             : 
      94             : 
      95             : void
      96           0 : TraCIAPI::close() {
      97           0 :     send_commandClose();
      98           0 :     tcpip::Storage inMsg;
      99             :     std::string acknowledgement;
     100           0 :     check_resultState(inMsg, libsumo::CMD_CLOSE, false, &acknowledgement);
     101           0 :     closeSocket();
     102           0 : }
     103             : 
     104             : 
     105             : void
     106         591 : TraCIAPI::closeSocket() {
     107         591 :     if (mySocket == nullptr) {
     108             :         return;
     109             :     }
     110         591 :     mySocket->close();
     111         591 :     delete mySocket;
     112         591 :     mySocket = nullptr;
     113             : }
     114             : 
     115             : 
     116             : void
     117        5020 : TraCIAPI::send_commandSimulationStep(double time) const {
     118        5020 :     tcpip::Storage outMsg;
     119             :     // command length
     120        5020 :     outMsg.writeUnsignedByte(1 + 1 + 8);
     121             :     // command id
     122        5020 :     outMsg.writeUnsignedByte(libsumo::CMD_SIMSTEP);
     123        5020 :     outMsg.writeDouble(time);
     124             :     // send request message
     125        5020 :     mySocket->sendExact(outMsg);
     126        5020 : }
     127             : 
     128             : 
     129             : void
     130         591 : TraCIAPI::send_commandClose() const {
     131         591 :     tcpip::Storage outMsg;
     132             :     // command length
     133         591 :     outMsg.writeUnsignedByte(1 + 1);
     134             :     // command id
     135         591 :     outMsg.writeUnsignedByte(libsumo::CMD_CLOSE);
     136         591 :     mySocket->sendExact(outMsg);
     137         591 : }
     138             : 
     139             : 
     140             : void
     141           1 : TraCIAPI::send_commandSetOrder(int order) const {
     142           1 :     tcpip::Storage outMsg;
     143             :     // command length
     144           1 :     outMsg.writeUnsignedByte(1 + 1 + 4);
     145             :     // command id
     146           1 :     outMsg.writeUnsignedByte(libsumo::CMD_SETORDER);
     147             :     // client index
     148           1 :     outMsg.writeInt(order);
     149           1 :     mySocket->sendExact(outMsg);
     150           1 : }
     151             : 
     152             : 
     153             : void
     154        1901 : TraCIAPI::createCommand(int cmdID, int varID, const std::string& objID, tcpip::Storage* add) const {
     155        1901 :     myOutput.reset();
     156             :     // command length
     157        1901 :     int length = 1 + 1 + 1 + 4 + (int) objID.length();
     158        1901 :     if (add != nullptr) {
     159         503 :         length += (int)add->size();
     160             :     }
     161        1901 :     if (length <= 255) {
     162        1900 :         myOutput.writeUnsignedByte(length);
     163             :     } else {
     164           1 :         myOutput.writeUnsignedByte(0);
     165           1 :         myOutput.writeInt(length + 4);
     166             :     }
     167        1901 :     myOutput.writeUnsignedByte(cmdID);
     168        1901 :     myOutput.writeUnsignedByte(varID);
     169        1901 :     myOutput.writeString(objID);
     170             :     // additional values
     171        1901 :     if (add != nullptr) {
     172         503 :         myOutput.writeStorage(*add);
     173             :     }
     174        1901 : }
     175             : 
     176             : 
     177             : void
     178          15 : TraCIAPI::createFilterCommand(int cmdID, int varID, tcpip::Storage* add) const {
     179          15 :     myOutput.reset();
     180             :     // command length
     181             :     int length = 1 + 1 + 1;
     182          15 :     if (add != nullptr) {
     183          11 :         length += (int)add->size();
     184             :     }
     185          11 :     if (length <= 255) {
     186          15 :         myOutput.writeUnsignedByte(length);
     187             :     } else {
     188           0 :         myOutput.writeUnsignedByte(0);
     189           0 :         myOutput.writeInt(length + 4);
     190             :     }
     191          15 :     myOutput.writeUnsignedByte(cmdID);
     192          15 :     myOutput.writeUnsignedByte(varID);
     193             :     // additional values
     194          15 :     if (add != nullptr) {
     195          11 :         myOutput.writeStorage(*add);
     196             :     }
     197          15 : }
     198             : 
     199             : 
     200             : void
     201          13 : TraCIAPI::send_commandSubscribeObjectVariable(int domID, const std::string& objID, double beginTime, double endTime,
     202             :         const std::vector<int>& vars) const {
     203          13 :     if (mySocket == nullptr) {
     204           0 :         throw tcpip::SocketException("Socket is not initialised");
     205             :     }
     206          13 :     tcpip::Storage outMsg;
     207             :     // command length (domID, objID, beginTime, endTime, length, vars)
     208          13 :     int varNo = (int) vars.size();
     209          13 :     outMsg.writeUnsignedByte(0);
     210          13 :     outMsg.writeInt(5 + 1 + 8 + 8 + 4 + (int) objID.length() + 1 + varNo);
     211             :     // command id
     212          13 :     outMsg.writeUnsignedByte(domID);
     213             :     // time
     214          13 :     outMsg.writeDouble(beginTime);
     215          13 :     outMsg.writeDouble(endTime);
     216             :     // object id
     217          13 :     outMsg.writeString(objID);
     218             :     // command id
     219          13 :     outMsg.writeUnsignedByte((int)vars.size());
     220          30 :     for (int i = 0; i < varNo; ++i) {
     221          17 :         outMsg.writeUnsignedByte(vars[i]);
     222             :     }
     223             :     // send message
     224          13 :     mySocket->sendExact(outMsg);
     225          13 : }
     226             : 
     227             : 
     228             : void
     229           8 : TraCIAPI::send_commandSubscribeObjectContext(int domID, const std::string& objID, double beginTime, double endTime,
     230             :         int domain, double range, const std::vector<int>& vars) const {
     231           8 :     if (mySocket == nullptr) {
     232           0 :         throw tcpip::SocketException("Socket is not initialised");
     233             :     }
     234           8 :     tcpip::Storage outMsg;
     235             :     // command length (domID, objID, beginTime, endTime, length, vars)
     236           8 :     int varNo = (int) vars.size();
     237           8 :     outMsg.writeUnsignedByte(0);
     238           8 :     outMsg.writeInt(5 + 1 + 8 + 8 + 4 + (int) objID.length() + 1 + 8 + 1 + varNo);
     239             :     // command id
     240           8 :     outMsg.writeUnsignedByte(domID);
     241             :     // time
     242           8 :     outMsg.writeDouble(beginTime);
     243           8 :     outMsg.writeDouble(endTime);
     244             :     // object id
     245           8 :     outMsg.writeString(objID);
     246             :     // domain and range
     247           8 :     outMsg.writeUnsignedByte(domain);
     248           8 :     outMsg.writeDouble(range);
     249             :     // command id
     250           8 :     outMsg.writeUnsignedByte((int)vars.size());
     251          19 :     for (int i = 0; i < varNo; ++i) {
     252          11 :         outMsg.writeUnsignedByte(vars[i]);
     253             :     }
     254             :     // send message
     255           8 :     mySocket->sendExact(outMsg);
     256           8 : }
     257             : 
     258             : 
     259             : void
     260        7552 : TraCIAPI::check_resultState(tcpip::Storage& inMsg, int command, bool ignoreCommandId, std::string* acknowledgement) const {
     261        7552 :     mySocket->receiveExact(inMsg);
     262             :     int cmdLength;
     263             :     int cmdId;
     264             :     int resultType;
     265             :     int cmdStart;
     266             :     std::string msg;
     267             :     try {
     268        7551 :         cmdStart = inMsg.position();
     269        7551 :         cmdLength = inMsg.readUnsignedByte();
     270        7551 :         cmdId = inMsg.readUnsignedByte();
     271        7551 :         if (command != cmdId && !ignoreCommandId) {
     272           0 :             throw libsumo::TraCIException("#Error: received status response to command: " + toString(cmdId) + " but expected: " + toString(command));
     273             :         }
     274        7551 :         resultType = inMsg.readUnsignedByte();
     275        7551 :         msg = inMsg.readString();
     276           0 :     } catch (std::invalid_argument&) {
     277           0 :         throw libsumo::TraCIException("#Error: an exception was thrown while reading result state message");
     278           0 :     }
     279        7551 :     switch (resultType) {
     280         153 :         case libsumo::RTYPE_ERR:
     281         306 :             throw libsumo::TraCIException(".. Answered with error to command (" + toString(command) + "), [description: " + msg + "]");
     282           2 :         case libsumo::RTYPE_NOTIMPLEMENTED:
     283           4 :             throw libsumo::TraCIException(".. Sent command is not implemented (" + toString(command) + "), [description: " + msg + "]");
     284        7396 :         case libsumo::RTYPE_OK:
     285        7396 :             if (acknowledgement != nullptr) {
     286       14263 :                 (*acknowledgement) = ".. Command acknowledged (" + toString(command) + "), [description: " + msg + "]";
     287             :             }
     288             :             break;
     289           0 :         default:
     290           0 :             throw libsumo::TraCIException(".. Answered with unknown result code(" + toString(resultType) + ") to command(" + toString(command) + "), [description: " + msg + "]");
     291             :     }
     292        7396 :     if ((cmdStart + cmdLength) != (int) inMsg.position()) {
     293           0 :         throw libsumo::TraCIException("#Error: command at position " + toString(cmdStart) + " has wrong length");
     294             :     }
     295        7396 : }
     296             : 
     297             : 
     298             : int
     299        1469 : TraCIAPI::check_commandGetResult(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
     300        1469 :     inMsg.position(); // respStart
     301        1469 :     int length = inMsg.readUnsignedByte();
     302        1469 :     if (length == 0) {
     303          53 :         length = inMsg.readInt();
     304             :     }
     305        1469 :     int cmdId = inMsg.readUnsignedByte();
     306        1469 :     if (!ignoreCommandId && cmdId != (command + 0x10)) {
     307           0 :         throw libsumo::TraCIException("#Error: received response with command id: " + toString(cmdId) + "but expected: " + toString(command + 0x10));
     308             :     }
     309        1469 :     if (expectedType >= 0) {
     310             :         // not called from the TraCITestClient but from within the TraCIAPI
     311         198 :         inMsg.readUnsignedByte(); // variableID
     312         198 :         inMsg.readString(); // objectID
     313         198 :         int valueDataType = inMsg.readUnsignedByte();
     314         198 :         if (valueDataType != expectedType) {
     315           0 :             throw libsumo::TraCIException("Expected " + toString(expectedType) + " but got " + toString(valueDataType));
     316             :         }
     317             :     }
     318        1469 :     return cmdId;
     319             : }
     320             : 
     321             : 
     322             : bool
     323         200 : TraCIAPI::processGet(int command, int expectedType, bool ignoreCommandId) {
     324         200 :     if (mySocket != nullptr) {
     325         200 :         mySocket->sendExact(myOutput);
     326         200 :         myInput.reset();
     327         200 :         check_resultState(myInput, command, ignoreCommandId);
     328         198 :         check_commandGetResult(myInput, command, expectedType, ignoreCommandId);
     329         198 :         return true;
     330             :     }
     331             :     return false;
     332             : }
     333             : 
     334             : 
     335             : bool
     336         125 : TraCIAPI::processSet(int command) {
     337         125 :     if (mySocket != nullptr) {
     338         125 :         mySocket->sendExact(myOutput);
     339         125 :         myInput.reset();
     340         125 :         check_resultState(myInput, command);
     341         124 :         return true;
     342             :     }
     343             :     return false;
     344             : }
     345             : 
     346             : 
     347             : void
     348          39 : TraCIAPI::readVariables(tcpip::Storage& inMsg, const std::string& objectID, int variableCount, libsumo::SubscriptionResults& into) {
     349          87 :     while (variableCount > 0) {
     350             : 
     351          48 :         const int variableID = inMsg.readUnsignedByte();
     352          48 :         const int status = inMsg.readUnsignedByte();
     353          48 :         const int type = inMsg.readUnsignedByte();
     354             : 
     355          48 :         if (status == libsumo::RTYPE_OK) {
     356          48 :             switch (type) {
     357          39 :                 case libsumo::TYPE_DOUBLE:
     358          39 :                     into[objectID][variableID] = std::make_shared<libsumo::TraCIDouble>(inMsg.readDouble());
     359          39 :                     break;
     360           9 :                 case libsumo::TYPE_STRING:
     361          27 :                     into[objectID][variableID] = std::make_shared<libsumo::TraCIString>(inMsg.readString());
     362           9 :                     break;
     363           0 :                 case libsumo::POSITION_2D: {
     364             :                     auto p = std::make_shared<libsumo::TraCIPosition>();
     365           0 :                     p->x = inMsg.readDouble();
     366           0 :                     p->y = inMsg.readDouble();
     367           0 :                     p->z = 0.;
     368           0 :                     into[objectID][variableID] = p;
     369             :                     break;
     370             :                 }
     371           0 :                 case libsumo::POSITION_3D: {
     372             :                     auto p = std::make_shared<libsumo::TraCIPosition>();
     373           0 :                     p->x = inMsg.readDouble();
     374           0 :                     p->y = inMsg.readDouble();
     375           0 :                     p->z = inMsg.readDouble();
     376           0 :                     into[objectID][variableID] = p;
     377             :                     break;
     378             :                 }
     379           0 :                 case libsumo::TYPE_COLOR: {
     380             :                     auto c = std::make_shared<libsumo::TraCIColor>();
     381           0 :                     c->r = (unsigned char)inMsg.readUnsignedByte();
     382           0 :                     c->g = (unsigned char)inMsg.readUnsignedByte();
     383           0 :                     c->b = (unsigned char)inMsg.readUnsignedByte();
     384           0 :                     c->a = (unsigned char)inMsg.readUnsignedByte();
     385           0 :                     into[objectID][variableID] = c;
     386             :                     break;
     387             :                 }
     388           0 :                 case libsumo::TYPE_INTEGER:
     389           0 :                     into[objectID][variableID] = std::make_shared<libsumo::TraCIInt>(inMsg.readInt());
     390           0 :                     break;
     391           0 :                 case libsumo::TYPE_STRINGLIST: {
     392             :                     auto sl = std::make_shared<libsumo::TraCIStringList>();
     393           0 :                     int n = inMsg.readInt();
     394           0 :                     for (int i = 0; i < n; ++i) {
     395           0 :                         sl->value.push_back(inMsg.readString());
     396             :                     }
     397           0 :                     into[objectID][variableID] = sl;
     398             :                 }
     399           0 :                 break;
     400             : 
     401             :                 // TODO Other data types
     402             : 
     403           0 :                 default:
     404           0 :                     throw libsumo::TraCIException("Unimplemented subscription type: " + toString(type));
     405             :             }
     406             :         } else {
     407           0 :             throw libsumo::TraCIException("Subscription response error: variableID=" + toString(variableID) + " status=" + toString(status));
     408             :         }
     409             : 
     410          48 :         variableCount--;
     411             :     }
     412          39 : }
     413             : 
     414             : 
     415             : void
     416           9 : TraCIAPI::readVariableSubscription(int cmdId, tcpip::Storage& inMsg) {
     417           9 :     const std::string objectID = inMsg.readString();
     418           9 :     const int variableCount = inMsg.readUnsignedByte();
     419           9 :     readVariables(inMsg, objectID, variableCount, myDomains[cmdId]->getModifiableSubscriptionResults());
     420           9 : }
     421             : 
     422             : 
     423             : void
     424          26 : TraCIAPI::readContextSubscription(int cmdId, tcpip::Storage& inMsg) {
     425          26 :     const std::string contextID = inMsg.readString();
     426          26 :     inMsg.readUnsignedByte(); // context domain
     427          26 :     const int variableCount = inMsg.readUnsignedByte();
     428          26 :     int numObjects = inMsg.readInt();
     429             : 
     430          56 :     while (numObjects > 0) {
     431          30 :         std::string objectID = inMsg.readString();
     432          30 :         readVariables(inMsg, objectID, variableCount, myDomains[cmdId]->getModifiableContextSubscriptionResults(contextID));
     433          30 :         numObjects--;
     434             :     }
     435          26 : }
     436             : 
     437             : 
     438             : void
     439          10 : TraCIAPI::simulationStep(double time) {
     440          10 :     send_commandSimulationStep(time);
     441          10 :     tcpip::Storage inMsg;
     442          10 :     check_resultState(inMsg, libsumo::CMD_SIMSTEP);
     443             : 
     444         170 :     for (auto it : myDomains) {
     445         160 :         it.second->clearSubscriptionResults();
     446             :     }
     447          10 :     int numSubs = inMsg.readInt();
     448          38 :     while (numSubs > 0) {
     449          28 :         int cmdId = check_commandGetResult(inMsg, 0, -1, true);
     450          28 :         if (cmdId >= libsumo::RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE && cmdId <= libsumo::RESPONSE_SUBSCRIBE_PERSON_VARIABLE) {
     451           7 :             readVariableSubscription(cmdId, inMsg);
     452             :         } else {
     453          21 :             readContextSubscription(cmdId + 0x50, inMsg);
     454             :         }
     455          28 :         numSubs--;
     456             :     }
     457          10 : }
     458             : 
     459             : 
     460             : void
     461           1 : TraCIAPI::load(const std::vector<std::string>& args) {
     462             :     int numChars = 0;
     463           8 :     for (int i = 0; i < (int)args.size(); ++i) {
     464           7 :         numChars += (int)args[i].size();
     465             :     }
     466           1 :     tcpip::Storage content;
     467           1 :     content.writeUnsignedByte(0);
     468           1 :     content.writeInt(1 + 4 + 1 + 1 + 4 + numChars + 4 * (int)args.size());
     469           1 :     content.writeUnsignedByte(libsumo::CMD_LOAD);
     470           1 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
     471           1 :     content.writeStringList(args);
     472           1 :     mySocket->sendExact(content);
     473           1 :     tcpip::Storage inMsg;
     474           1 :     check_resultState(inMsg, libsumo::CMD_LOAD);
     475           1 : }
     476             : 
     477             : 
     478             : std::pair<int, std::string>
     479           1 : TraCIAPI::getVersion() {
     480           1 :     tcpip::Storage content;
     481           1 :     content.writeUnsignedByte(2);
     482           1 :     content.writeUnsignedByte(libsumo::CMD_GETVERSION);
     483           1 :     mySocket->sendExact(content);
     484           1 :     tcpip::Storage inMsg;
     485           1 :     check_resultState(inMsg, libsumo::CMD_GETVERSION);
     486           1 :     inMsg.readUnsignedByte(); // msg length
     487           1 :     inMsg.readUnsignedByte(); // libsumo::CMD_GETVERSION again, see #7284
     488           1 :     const int traciVersion = inMsg.readInt(); // to fix evaluation order
     489           2 :     return std::make_pair(traciVersion, inMsg.readString());
     490           1 : }
     491             : 
     492             : 
     493             : // ---------------------------------------------------------------------------
     494             : // TraCIAPI::EdgeScope-methods
     495             : // ---------------------------------------------------------------------------
     496             : double
     497           1 : TraCIAPI::EdgeScope::getAdaptedTraveltime(const std::string& edgeID, double time) const {
     498           1 :     tcpip::Storage content;
     499           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
     500           1 :     content.writeDouble(time);
     501           2 :     return getDouble(libsumo::VAR_EDGE_TRAVELTIME, edgeID, &content);
     502           1 : }
     503             : 
     504             : double
     505           1 : TraCIAPI::EdgeScope::getEffort(const std::string& edgeID, double time) const {
     506           1 :     tcpip::Storage content;
     507           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
     508           1 :     content.writeDouble(time);
     509           2 :     return getDouble(libsumo::VAR_EDGE_EFFORT, edgeID, &content);
     510           1 : }
     511             : 
     512             : double
     513           0 : TraCIAPI::EdgeScope::getCO2Emission(const std::string& edgeID) const {
     514           0 :     return getDouble(libsumo::VAR_CO2EMISSION, edgeID);
     515             : }
     516             : 
     517             : 
     518             : double
     519           0 : TraCIAPI::EdgeScope::getCOEmission(const std::string& edgeID) const {
     520           0 :     return getDouble(libsumo::VAR_COEMISSION, edgeID);
     521             : }
     522             : 
     523             : double
     524           0 : TraCIAPI::EdgeScope::getHCEmission(const std::string& edgeID) const {
     525           0 :     return getDouble(libsumo::VAR_HCEMISSION, edgeID);
     526             : }
     527             : 
     528             : double
     529           0 : TraCIAPI::EdgeScope::getPMxEmission(const std::string& edgeID) const {
     530           0 :     return getDouble(libsumo::VAR_PMXEMISSION, edgeID);
     531             : }
     532             : 
     533             : double
     534           0 : TraCIAPI::EdgeScope::getNOxEmission(const std::string& edgeID) const {
     535           0 :     return getDouble(libsumo::VAR_NOXEMISSION, edgeID);
     536             : }
     537             : 
     538             : double
     539           0 : TraCIAPI::EdgeScope::getFuelConsumption(const std::string& edgeID) const {
     540           0 :     return getDouble(libsumo::VAR_FUELCONSUMPTION, edgeID);
     541             : }
     542             : 
     543             : double
     544           0 : TraCIAPI::EdgeScope::getNoiseEmission(const std::string& edgeID) const {
     545           0 :     return getDouble(libsumo::VAR_NOISEEMISSION, edgeID);
     546             : }
     547             : 
     548             : double
     549           0 : TraCIAPI::EdgeScope::getElectricityConsumption(const std::string& edgeID) const {
     550           0 :     return getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, edgeID);
     551             : }
     552             : 
     553             : double
     554           0 : TraCIAPI::EdgeScope::getLastStepMeanSpeed(const std::string& edgeID) const {
     555           0 :     return getDouble(libsumo::LAST_STEP_MEAN_SPEED, edgeID);
     556             : }
     557             : 
     558             : double
     559           0 : TraCIAPI::EdgeScope::getLastStepOccupancy(const std::string& edgeID) const {
     560           0 :     return getDouble(libsumo::LAST_STEP_OCCUPANCY, edgeID);
     561             : }
     562             : 
     563             : double
     564           0 : TraCIAPI::EdgeScope::getLastStepLength(const std::string& edgeID) const {
     565           0 :     return getDouble(libsumo::LAST_STEP_LENGTH, edgeID);
     566             : }
     567             : 
     568             : double
     569          48 : TraCIAPI::EdgeScope::getTraveltime(const std::string& edgeID) const {
     570          48 :     return getDouble(libsumo::VAR_CURRENT_TRAVELTIME, edgeID);
     571             : }
     572             : 
     573             : int
     574           0 : TraCIAPI::EdgeScope::getLastStepVehicleNumber(const std::string& edgeID) const {
     575           0 :     return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, edgeID);
     576             : }
     577             : 
     578             : double
     579           0 : TraCIAPI::EdgeScope::getLastStepHaltingNumber(const std::string& edgeID) const {
     580           0 :     return getInt(libsumo::LAST_STEP_VEHICLE_HALTING_NUMBER, edgeID);
     581             : }
     582             : 
     583             : std::vector<std::string>
     584           0 : TraCIAPI::EdgeScope::getLastStepVehicleIDs(const std::string& edgeID) const {
     585           0 :     return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, edgeID);
     586             : }
     587             : 
     588             : 
     589             : int
     590           1 : TraCIAPI::EdgeScope::getLaneNumber(const std::string& edgeID) const {
     591           1 :     return getInt(libsumo::VAR_LANE_INDEX, edgeID);
     592             : }
     593             : 
     594             : 
     595             : std::string
     596           1 : TraCIAPI::EdgeScope::getStreetName(const std::string& edgeID) const {
     597           1 :     return getString(libsumo::VAR_NAME, edgeID);
     598             : }
     599             : 
     600             : 
     601             : void
     602          48 : TraCIAPI::EdgeScope::adaptTraveltime(const std::string& edgeID, double time, double beginSeconds, double endSeconds) const {
     603          48 :     tcpip::Storage content;
     604          48 :     content.writeByte(libsumo::TYPE_COMPOUND);
     605          48 :     if (endSeconds != std::numeric_limits<double>::max()) {
     606           1 :         content.writeInt(3);
     607           1 :         content.writeByte(libsumo::TYPE_DOUBLE);
     608           1 :         content.writeDouble(beginSeconds);
     609           1 :         content.writeByte(libsumo::TYPE_DOUBLE);
     610           1 :         content.writeDouble(endSeconds);
     611             :     } else {
     612          47 :         content.writeInt(1);
     613             :     }
     614          48 :     content.writeByte(libsumo::TYPE_DOUBLE);
     615          48 :     content.writeDouble(time);
     616          48 :     myParent.createCommand(libsumo::CMD_SET_EDGE_VARIABLE, libsumo::VAR_EDGE_TRAVELTIME, edgeID, &content);
     617          48 :     myParent.processSet(libsumo::CMD_SET_EDGE_VARIABLE);
     618          48 : }
     619             : 
     620             : 
     621             : void
     622           1 : TraCIAPI::EdgeScope::setEffort(const std::string& edgeID, double effort, double beginSeconds, double endSeconds) const {
     623           1 :     tcpip::Storage content;
     624           1 :     content.writeByte(libsumo::TYPE_COMPOUND);
     625           1 :     if (endSeconds != std::numeric_limits<double>::max()) {
     626           1 :         content.writeInt(3);
     627           1 :         content.writeByte(libsumo::TYPE_DOUBLE);
     628           1 :         content.writeDouble(beginSeconds);
     629           1 :         content.writeByte(libsumo::TYPE_DOUBLE);
     630           1 :         content.writeDouble(endSeconds);
     631             :     } else {
     632           0 :         content.writeInt(1);
     633             :     }
     634           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
     635           1 :     content.writeDouble(effort);
     636           1 :     myParent.createCommand(libsumo::CMD_SET_EDGE_VARIABLE, libsumo::VAR_EDGE_EFFORT, edgeID, &content);
     637           1 :     myParent.processSet(libsumo::CMD_SET_EDGE_VARIABLE);
     638           1 : }
     639             : 
     640             : void
     641           1 : TraCIAPI::EdgeScope::setMaxSpeed(const std::string& edgeID, double speed) const {
     642           1 :     setDouble(libsumo::VAR_MAXSPEED, edgeID, speed);
     643           1 : }
     644             : 
     645             : 
     646             : // ---------------------------------------------------------------------------
     647             : // TraCIAPI::GUIScope-methods
     648             : // ---------------------------------------------------------------------------
     649             : double
     650           0 : TraCIAPI::GUIScope::getZoom(const std::string& viewID) const {
     651           0 :     return getDouble(libsumo::VAR_VIEW_ZOOM, viewID);
     652             : }
     653             : 
     654             : libsumo::TraCIPosition
     655           0 : TraCIAPI::GUIScope::getOffset(const std::string& viewID) const {
     656           0 :     return getPos(libsumo::VAR_VIEW_OFFSET, viewID);
     657             : }
     658             : 
     659             : std::string
     660           0 : TraCIAPI::GUIScope::getSchema(const std::string& viewID) const {
     661           0 :     return getString(libsumo::VAR_VIEW_SCHEMA, viewID);
     662             : }
     663             : 
     664             : libsumo::TraCIPositionVector
     665           0 : TraCIAPI::GUIScope::getBoundary(const std::string& viewID) const {
     666           0 :     return getPolygon(libsumo::VAR_VIEW_BOUNDARY, viewID);
     667             : }
     668             : 
     669             : 
     670             : void
     671           0 : TraCIAPI::GUIScope::setZoom(const std::string& viewID, double zoom) const {
     672           0 :     setDouble(libsumo::VAR_VIEW_ZOOM, viewID, zoom);
     673           0 : }
     674             : 
     675             : void
     676           0 : TraCIAPI::GUIScope::setOffset(const std::string& viewID, double x, double y) const {
     677           0 :     tcpip::Storage content;
     678           0 :     content.writeUnsignedByte(libsumo::POSITION_2D);
     679           0 :     content.writeDouble(x);
     680           0 :     content.writeDouble(y);
     681           0 :     myParent.createCommand(libsumo::CMD_SET_GUI_VARIABLE, libsumo::VAR_VIEW_OFFSET, viewID, &content);
     682           0 :     myParent.processSet(libsumo::CMD_SET_GUI_VARIABLE);
     683           0 : }
     684             : 
     685             : void
     686           1 : TraCIAPI::GUIScope::setSchema(const std::string& viewID, const std::string& schemeName) const {
     687           1 :     setString(libsumo::VAR_VIEW_SCHEMA, viewID, schemeName);
     688           0 : }
     689             : 
     690             : void
     691           0 : TraCIAPI::GUIScope::setBoundary(const std::string& viewID, double xmin, double ymin, double xmax, double ymax) const {
     692           0 :     tcpip::Storage content;
     693           0 :     content.writeUnsignedByte(libsumo::TYPE_POLYGON);
     694           0 :     content.writeByte(2);
     695           0 :     content.writeDouble(xmin);
     696           0 :     content.writeDouble(ymin);
     697           0 :     content.writeDouble(xmax);
     698           0 :     content.writeDouble(ymax);
     699           0 :     myParent.createCommand(libsumo::CMD_SET_GUI_VARIABLE, libsumo::VAR_VIEW_BOUNDARY, viewID, &content);
     700           0 :     myParent.processSet(libsumo::CMD_SET_GUI_VARIABLE);
     701           0 : }
     702             : 
     703             : void
     704           0 : TraCIAPI::GUIScope::screenshot(const std::string& viewID, const std::string& filename, const int width, const int height) const {
     705           0 :     tcpip::Storage content;
     706           0 :     content.writeByte(libsumo::TYPE_COMPOUND);
     707           0 :     content.writeInt(3);
     708           0 :     content.writeByte(libsumo::TYPE_STRING);
     709           0 :     content.writeString(filename);
     710           0 :     content.writeByte(libsumo::TYPE_INTEGER);
     711           0 :     content.writeInt(width);
     712           0 :     content.writeByte(libsumo::TYPE_INTEGER);
     713           0 :     content.writeInt(height);
     714           0 :     myParent.createCommand(libsumo::CMD_SET_GUI_VARIABLE, libsumo::VAR_SCREENSHOT, viewID, &content);
     715           0 :     myParent.processSet(libsumo::CMD_SET_GUI_VARIABLE);
     716           0 : }
     717             : 
     718             : void
     719           0 : TraCIAPI::GUIScope::trackVehicle(const std::string& viewID, const std::string& vehID) const {
     720           0 :     setString(libsumo::VAR_VIEW_SCHEMA, viewID, vehID);
     721           0 : }
     722             : 
     723             : 
     724             : // ---------------------------------------------------------------------------
     725             : // TraCIAPI::InductionLoopScope-methods
     726             : // ---------------------------------------------------------------------------
     727             : 
     728           0 : int TraCIAPI::InductionLoopScope::getIntervalVehicleNumber(const std::string &loopID) const {
     729           0 :     return getInt(libsumo::VAR_LAST_INTERVAL_NUMBER, loopID);
     730             : }
     731             : 
     732             : double
     733           0 : TraCIAPI::InductionLoopScope::getPosition(const std::string& loopID) const {
     734           0 :     return getDouble(libsumo::VAR_POSITION, loopID);
     735             : }
     736             : 
     737             : std::string
     738           0 : TraCIAPI::InductionLoopScope::getLaneID(const std::string& loopID) const {
     739           0 :     return getString(libsumo::VAR_LANE_ID, loopID);
     740             : }
     741             : 
     742             : int
     743           0 : TraCIAPI::InductionLoopScope::getLastStepVehicleNumber(const std::string& loopID) const {
     744           0 :     return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, loopID);
     745             : }
     746             : 
     747             : double
     748           0 : TraCIAPI::InductionLoopScope::getLastStepMeanSpeed(const std::string& loopID) const {
     749           0 :     return getDouble(libsumo::LAST_STEP_MEAN_SPEED, loopID);
     750             : }
     751             : 
     752             : std::vector<std::string>
     753           0 : TraCIAPI::InductionLoopScope::getLastStepVehicleIDs(const std::string& loopID) const {
     754           0 :     return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, loopID);
     755             : }
     756             : 
     757             : double
     758           0 : TraCIAPI::InductionLoopScope::getLastStepOccupancy(const std::string& loopID) const {
     759           0 :     return getDouble(libsumo::LAST_STEP_OCCUPANCY, loopID);
     760             : }
     761             : 
     762             : double
     763           0 : TraCIAPI::InductionLoopScope::getLastStepMeanLength(const std::string& loopID) const {
     764           0 :     return getDouble(libsumo::LAST_STEP_LENGTH, loopID);
     765             : }
     766             : 
     767             : double
     768           0 : TraCIAPI::InductionLoopScope::getTimeSinceDetection(const std::string& loopID) const {
     769           0 :     return getDouble(libsumo::LAST_STEP_TIME_SINCE_DETECTION, loopID);
     770             : }
     771             : 
     772             : 
     773             : std::vector<libsumo::TraCIVehicleData>
     774           1 : TraCIAPI::InductionLoopScope::getVehicleData(const std::string& loopID) const {
     775             :     std::vector<libsumo::TraCIVehicleData> result;
     776           1 :     myParent.createCommand(libsumo::CMD_GET_INDUCTIONLOOP_VARIABLE, libsumo::LAST_STEP_VEHICLE_DATA, loopID);
     777           1 :     if (myParent.processGet(libsumo::CMD_GET_INDUCTIONLOOP_VARIABLE, libsumo::TYPE_COMPOUND)) {
     778           1 :         myParent.myInput.readInt(); // components
     779             :         // number of items
     780           1 :         myParent.myInput.readUnsignedByte();
     781           1 :         const int n = myParent.myInput.readInt();
     782           1 :         for (int i = 0; i < n; ++i) {
     783             :             libsumo::TraCIVehicleData vd;
     784             : 
     785           0 :             myParent.myInput.readUnsignedByte();
     786           0 :             vd.id = myParent.myInput.readString();
     787             : 
     788           0 :             myParent.myInput.readUnsignedByte();
     789           0 :             vd.length = myParent.myInput.readDouble();
     790             : 
     791           0 :             myParent.myInput.readUnsignedByte();
     792           0 :             vd.entryTime = myParent.myInput.readDouble();
     793             : 
     794           0 :             myParent.myInput.readUnsignedByte();
     795           0 :             vd.leaveTime = myParent.myInput.readDouble();
     796             : 
     797           0 :             myParent.myInput.readUnsignedByte();
     798           0 :             vd.typeID = myParent.myInput.readString();
     799             : 
     800           0 :             result.push_back(vd);
     801           0 :         }
     802             :     }
     803           1 :     return result;
     804           0 : }
     805             : 
     806             : 
     807             : // ---------------------------------------------------------------------------
     808             : // TraCIAPI::JunctionScope-methods
     809             : // ---------------------------------------------------------------------------
     810             : libsumo::TraCIPosition
     811           0 : TraCIAPI::JunctionScope::getPosition(const std::string& junctionID) const {
     812           0 :     return getPos(libsumo::VAR_POSITION, junctionID);
     813             : }
     814             : 
     815             : libsumo::TraCIPositionVector
     816           1 : TraCIAPI::JunctionScope::getShape(const std::string& junctionID) const {
     817           1 :     return getPolygon(libsumo::VAR_SHAPE, junctionID);
     818             : }
     819             : 
     820             : 
     821             : // ---------------------------------------------------------------------------
     822             : // TraCIAPI::LaneScope-methods
     823             : // ---------------------------------------------------------------------------
     824             : double
     825           0 : TraCIAPI::LaneScope::getLength(const std::string& laneID) const {
     826           0 :     return getDouble(libsumo::VAR_LENGTH, laneID);
     827             : }
     828             : 
     829             : double
     830           2 : TraCIAPI::LaneScope::getMaxSpeed(const std::string& laneID) const {
     831           2 :     return getDouble(libsumo::VAR_MAXSPEED, laneID);
     832             : }
     833             : 
     834             : double
     835           0 : TraCIAPI::LaneScope::getWidth(const std::string& laneID) const {
     836           0 :     return getDouble(libsumo::VAR_WIDTH, laneID);
     837             : }
     838             : 
     839             : std::vector<std::string>
     840           0 : TraCIAPI::LaneScope::getAllowed(const std::string& laneID) const {
     841           0 :     return getStringVector(libsumo::LANE_ALLOWED, laneID);
     842             : }
     843             : 
     844             : std::vector<std::string>
     845           0 : TraCIAPI::LaneScope::getDisallowed(const std::string& laneID) const {
     846           0 :     return getStringVector(libsumo::LANE_DISALLOWED, laneID);
     847             : }
     848             : 
     849             : int
     850           1 : TraCIAPI::LaneScope::getLinkNumber(const std::string& laneID) const {
     851           1 :     return getInt(libsumo::LANE_LINK_NUMBER, laneID);
     852             : }
     853             : 
     854             : std::vector<libsumo::TraCIConnection>
     855           1 : TraCIAPI::LaneScope::getLinks(const std::string& laneID) const {
     856             :     std::vector<libsumo::TraCIConnection> ret;
     857           1 :     myParent.createCommand(libsumo::CMD_GET_LANE_VARIABLE, libsumo::LANE_LINKS, laneID);
     858           1 :     if (myParent.processGet(libsumo::CMD_GET_LANE_VARIABLE, libsumo::TYPE_COMPOUND)) {
     859           1 :         myParent.myInput.readUnsignedByte();
     860           1 :         myParent.myInput.readInt();
     861             : 
     862           1 :         int linkNo = myParent.myInput.readInt();
     863           5 :         for (int i = 0; i < linkNo; ++i) {
     864             : 
     865           4 :             myParent.myInput.readUnsignedByte();
     866           4 :             std::string approachedLane = myParent.myInput.readString();
     867             : 
     868           4 :             myParent.myInput.readUnsignedByte();
     869           4 :             std::string approachedLaneInternal = myParent.myInput.readString();
     870             : 
     871           4 :             myParent.myInput.readUnsignedByte();
     872           4 :             bool hasPrio = myParent.myInput.readUnsignedByte() != 0;
     873             : 
     874           4 :             myParent.myInput.readUnsignedByte();
     875           4 :             bool isOpen = myParent.myInput.readUnsignedByte() != 0;
     876             : 
     877           4 :             myParent.myInput.readUnsignedByte();
     878           4 :             bool hasFoe = myParent.myInput.readUnsignedByte() != 0;
     879             : 
     880           4 :             myParent.myInput.readUnsignedByte();
     881           4 :             std::string state = myParent.myInput.readString();
     882             : 
     883           4 :             myParent.myInput.readUnsignedByte();
     884           4 :             std::string direction = myParent.myInput.readString();
     885             : 
     886           4 :             myParent.myInput.readUnsignedByte();
     887           4 :             double length = myParent.myInput.readDouble();
     888             : 
     889           8 :             ret.push_back(libsumo::TraCIConnection(approachedLane,
     890             :                                                    hasPrio,
     891             :                                                    isOpen,
     892             :                                                    hasFoe,
     893             :                                                    approachedLaneInternal,
     894             :                                                    state,
     895             :                                                    direction,
     896             :                                                    length));
     897             : 
     898             :         }
     899             : 
     900             :     }
     901           1 :     return ret;
     902           0 : }
     903             : 
     904             : libsumo::TraCIPositionVector
     905           0 : TraCIAPI::LaneScope::getShape(const std::string& laneID) const {
     906           0 :     return getPolygon(libsumo::VAR_SHAPE, laneID);
     907             : }
     908             : 
     909             : std::string
     910           0 : TraCIAPI::LaneScope::getEdgeID(const std::string& laneID) const {
     911           0 :     return getString(libsumo::LANE_EDGE_ID, laneID);
     912             : }
     913             : 
     914             : double
     915           0 : TraCIAPI::LaneScope::getCO2Emission(const std::string& laneID) const {
     916           0 :     return getDouble(libsumo::VAR_CO2EMISSION, laneID);
     917             : }
     918             : 
     919             : double
     920           0 : TraCIAPI::LaneScope::getCOEmission(const std::string& laneID) const {
     921           0 :     return getDouble(libsumo::VAR_COEMISSION, laneID);
     922             : }
     923             : 
     924             : double
     925           0 : TraCIAPI::LaneScope::getHCEmission(const std::string& laneID) const {
     926           0 :     return getDouble(libsumo::VAR_HCEMISSION, laneID);
     927             : }
     928             : 
     929             : double
     930           0 : TraCIAPI::LaneScope::getPMxEmission(const std::string& laneID) const {
     931           0 :     return getDouble(libsumo::VAR_PMXEMISSION, laneID);
     932             : }
     933             : 
     934             : double
     935           0 : TraCIAPI::LaneScope::getNOxEmission(const std::string& laneID) const {
     936           0 :     return getDouble(libsumo::VAR_NOXEMISSION, laneID);
     937             : }
     938             : 
     939             : double
     940           0 : TraCIAPI::LaneScope::getFuelConsumption(const std::string& laneID) const {
     941           0 :     return getDouble(libsumo::VAR_FUELCONSUMPTION, laneID);
     942             : }
     943             : 
     944             : double
     945           0 : TraCIAPI::LaneScope::getNoiseEmission(const std::string& laneID) const {
     946           0 :     return getDouble(libsumo::VAR_NOISEEMISSION, laneID);
     947             : }
     948             : 
     949             : double
     950           0 : TraCIAPI::LaneScope::getElectricityConsumption(const std::string& laneID) const {
     951           0 :     return getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, laneID);
     952             : }
     953             : 
     954             : double
     955           0 : TraCIAPI::LaneScope::getLastStepMeanSpeed(const std::string& laneID) const {
     956           0 :     return getDouble(libsumo::LAST_STEP_MEAN_SPEED, laneID);
     957             : }
     958             : 
     959             : double
     960           0 : TraCIAPI::LaneScope::getLastStepOccupancy(const std::string& laneID) const {
     961           0 :     return getDouble(libsumo::LAST_STEP_OCCUPANCY, laneID);
     962             : }
     963             : 
     964             : double
     965           0 : TraCIAPI::LaneScope::getLastStepLength(const std::string& laneID) const {
     966           0 :     return getDouble(libsumo::LAST_STEP_LENGTH, laneID);
     967             : }
     968             : 
     969             : double
     970           0 : TraCIAPI::LaneScope::getTraveltime(const std::string& laneID) const {
     971           0 :     return getDouble(libsumo::VAR_CURRENT_TRAVELTIME, laneID);
     972             : }
     973             : 
     974             : int
     975           0 : TraCIAPI::LaneScope::getLastStepVehicleNumber(const std::string& laneID) const {
     976           0 :     return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, laneID);
     977             : }
     978             : 
     979             : int
     980           0 : TraCIAPI::LaneScope::getLastStepHaltingNumber(const std::string& laneID) const {
     981           0 :     return getInt(libsumo::LAST_STEP_VEHICLE_HALTING_NUMBER, laneID);
     982             : }
     983             : 
     984             : std::vector<std::string>
     985           0 : TraCIAPI::LaneScope::getLastStepVehicleIDs(const std::string& laneID) const {
     986           0 :     return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, laneID);
     987             : }
     988             : 
     989             : 
     990             : std::vector<std::string>
     991           4 : TraCIAPI::LaneScope::getFoes(const std::string& laneID, const std::string& toLaneID) const {
     992             :     std::vector<std::string> r;
     993           4 :     tcpip::Storage content;
     994           4 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
     995           4 :     content.writeString(toLaneID);
     996           4 :     myParent.createCommand(libsumo::CMD_GET_LANE_VARIABLE, libsumo::VAR_FOES, laneID, &content);
     997           4 :     if (myParent.processGet(libsumo::CMD_GET_LANE_VARIABLE, libsumo::TYPE_STRINGLIST)) {
     998           2 :         const int size = myParent.myInput.readInt();
     999          10 :         for (int i = 0; i < size; ++i) {
    1000          16 :             r.push_back(myParent.myInput.readString());
    1001             :         }
    1002             :     }
    1003           2 :     return r;
    1004           6 : }
    1005             : 
    1006             : std::vector<std::string>
    1007           2 : TraCIAPI::LaneScope::getInternalFoes(const std::string& laneID) const {
    1008           3 :     return getFoes(laneID, "");
    1009             : }
    1010             : 
    1011             : 
    1012             : void
    1013           0 : TraCIAPI::LaneScope::setAllowed(const std::string& laneID, const std::vector<std::string>& allowedClasses) const {
    1014           0 :     setStringVector(libsumo::LANE_ALLOWED, laneID, allowedClasses);
    1015           0 : }
    1016             : 
    1017             : void
    1018           0 : TraCIAPI::LaneScope::setDisallowed(const std::string& laneID, const std::vector<std::string>& disallowedClasses) const {
    1019           0 :     setStringVector(libsumo::LANE_DISALLOWED, laneID, disallowedClasses);
    1020           0 : }
    1021             : 
    1022             : void
    1023           1 : TraCIAPI::LaneScope::setMaxSpeed(const std::string& laneID, double speed) const {
    1024           1 :     setDouble(libsumo::VAR_MAXSPEED, laneID, speed);
    1025           1 : }
    1026             : 
    1027             : void
    1028           0 : TraCIAPI::LaneScope::setLength(const std::string& laneID, double length) const {
    1029           0 :     setDouble(libsumo::VAR_LENGTH, laneID, length);
    1030           0 : }
    1031             : 
    1032             : 
    1033             : // ---------------------------------------------------------------------------
    1034             : // TraCIAPI::LaneAreaDetector-methods
    1035             : // ---------------------------------------------------------------------------
    1036             : 
    1037             : 
    1038             : // ---------------------------------------------------------------------------
    1039             : // TraCIAPI::MeMeScope-methods
    1040             : // ---------------------------------------------------------------------------
    1041             : int
    1042           0 : TraCIAPI::MeMeScope::getLastStepVehicleNumber(const std::string& detID) const {
    1043           0 :     return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, detID);
    1044             : }
    1045             : 
    1046             : double
    1047           0 : TraCIAPI::MeMeScope::getLastStepMeanSpeed(const std::string& detID) const {
    1048           0 :     return getDouble(libsumo::LAST_STEP_MEAN_SPEED, detID);
    1049             : }
    1050             : 
    1051             : std::vector<std::string>
    1052           0 : TraCIAPI::MeMeScope::getLastStepVehicleIDs(const std::string& detID) const {
    1053           0 :     return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, detID);
    1054             : }
    1055             : 
    1056             : int
    1057           0 : TraCIAPI::MeMeScope::getLastStepHaltingNumber(const std::string& detID) const {
    1058           0 :     return getInt(libsumo::LAST_STEP_VEHICLE_HALTING_NUMBER, detID);
    1059             : }
    1060             : 
    1061             : std::vector<std::string>
    1062           0 : TraCIAPI::MeMeScope::getEntryLanes(const std::string& detID) const {
    1063           0 :     return getStringVector(libsumo::VAR_LANES, detID);
    1064             : }
    1065             : 
    1066             : std::vector<std::string>
    1067           0 : TraCIAPI::MeMeScope::getExitLanes(const std::string& detID) const {
    1068           0 :     return getStringVector(libsumo::VAR_EXIT_LANES, detID);
    1069             : }
    1070             : 
    1071             : std::vector<double>
    1072           0 : TraCIAPI::MeMeScope::getEntryPositions(const std::string& detID) const {
    1073           0 :     return getDoubleVector(libsumo::VAR_POSITION, detID);
    1074             : }
    1075             : 
    1076             : std::vector<double>
    1077           0 : TraCIAPI::MeMeScope::getExitPositions(const std::string& detID) const {
    1078           0 :     return getDoubleVector(libsumo::VAR_EXIT_POSITIONS, detID);
    1079             : }
    1080             : 
    1081             : // ---------------------------------------------------------------------------
    1082             : // TraCIAPI::POIScope-methods
    1083             : // ---------------------------------------------------------------------------
    1084             : std::string
    1085           0 : TraCIAPI::POIScope::getType(const std::string& poiID) const {
    1086           0 :     return getString(libsumo::VAR_TYPE, poiID);
    1087             : }
    1088             : 
    1089             : libsumo::TraCIPosition
    1090           1 : TraCIAPI::POIScope::getPosition(const std::string& poiID) const {
    1091           1 :     return getPos(libsumo::VAR_POSITION, poiID);
    1092             : }
    1093             : 
    1094             : libsumo::TraCIColor
    1095           1 : TraCIAPI::POIScope::getColor(const std::string& poiID) const {
    1096           1 :     return getCol(libsumo::VAR_COLOR, poiID);
    1097             : }
    1098             : 
    1099             : double
    1100           0 : TraCIAPI::POIScope::getWidth(const std::string& poiID) const {
    1101           0 :     return getDouble(libsumo::VAR_WIDTH, poiID);
    1102             : }
    1103             : 
    1104             : double
    1105           0 : TraCIAPI::POIScope::getHeight(const std::string& poiID) const {
    1106           0 :     return getDouble(libsumo::VAR_HEIGHT, poiID);
    1107             : }
    1108             : 
    1109             : double
    1110           0 : TraCIAPI::POIScope::getAngle(const std::string& poiID) const {
    1111           0 :     return getDouble(libsumo::VAR_ANGLE, poiID);
    1112             : }
    1113             : 
    1114             : std::string
    1115           0 : TraCIAPI::POIScope::getImageFile(const std::string& poiID) const {
    1116           0 :     return getString(libsumo::VAR_IMAGEFILE, poiID);
    1117             : }
    1118             : 
    1119             : 
    1120             : void
    1121           0 : TraCIAPI::POIScope::setType(const std::string& poiID, const std::string& setType) const {
    1122           0 :     setString(libsumo::VAR_TYPE, poiID, setType);
    1123           0 : }
    1124             : 
    1125             : 
    1126             : void
    1127           0 : TraCIAPI::POIScope::setPosition(const std::string& poiID, double x, double y) const {
    1128           0 :     tcpip::Storage content;
    1129           0 :     content.writeUnsignedByte(libsumo::POSITION_2D);
    1130           0 :     content.writeDouble(x);
    1131           0 :     content.writeDouble(y);
    1132           0 :     myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::VAR_POSITION, poiID, &content);
    1133           0 :     myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
    1134           0 : }
    1135             : 
    1136             : 
    1137             : void
    1138           0 : TraCIAPI::POIScope::setColor(const std::string& poiID, const libsumo::TraCIColor& c) const {
    1139           0 :     tcpip::Storage content;
    1140           0 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    1141           0 :     content.writeUnsignedByte(c.r);
    1142           0 :     content.writeUnsignedByte(c.g);
    1143           0 :     content.writeUnsignedByte(c.b);
    1144           0 :     content.writeUnsignedByte(c.a);
    1145           0 :     myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::VAR_COLOR, poiID, &content);
    1146           0 :     myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
    1147           0 : }
    1148             : 
    1149             : 
    1150             : void
    1151           0 : TraCIAPI::POIScope::setWidth(const std::string& poiID, double width) const {
    1152           0 :     setDouble(libsumo::VAR_WIDTH, poiID, width);
    1153           0 : }
    1154             : 
    1155             : 
    1156             : void
    1157           0 : TraCIAPI::POIScope::setHeight(const std::string& poiID, double height) const {
    1158           0 :     setDouble(libsumo::VAR_HEIGHT, poiID, height);
    1159           0 : }
    1160             : 
    1161             : 
    1162             : void
    1163           0 : TraCIAPI::POIScope::setAngle(const std::string& poiID, double angle) const {
    1164           0 :     setDouble(libsumo::VAR_ANGLE, poiID, angle);
    1165           0 : }
    1166             : 
    1167             : 
    1168             : void
    1169           0 : TraCIAPI::POIScope::setImageFile(const std::string& poiID, const std::string& imageFile) const {
    1170           0 :     setString(libsumo::VAR_IMAGEFILE, poiID, imageFile);
    1171           0 : }
    1172             : 
    1173             : 
    1174             : void
    1175           0 : TraCIAPI::POIScope::add(const std::string& poiID, double x, double y, const libsumo::TraCIColor& c, const std::string& type, int layer, const std::string& imgFile, double width, double height, double angle) const {
    1176           0 :     tcpip::Storage content;
    1177           0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1178           0 :     content.writeInt(8);
    1179           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1180           0 :     content.writeString(type);
    1181           0 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    1182           0 :     content.writeUnsignedByte(c.r);
    1183           0 :     content.writeUnsignedByte(c.g);
    1184           0 :     content.writeUnsignedByte(c.b);
    1185           0 :     content.writeUnsignedByte(c.a);
    1186           0 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1187           0 :     content.writeInt(layer);
    1188           0 :     content.writeUnsignedByte(libsumo::POSITION_2D);
    1189           0 :     content.writeDouble(x);
    1190           0 :     content.writeDouble(y);
    1191           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1192           0 :     content.writeString(imgFile);
    1193           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1194           0 :     content.writeDouble(width);
    1195           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1196           0 :     content.writeDouble(height);
    1197           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1198           0 :     content.writeDouble(angle);
    1199           0 :     myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::ADD, poiID, &content);
    1200           0 :     myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
    1201           0 : }
    1202             : 
    1203             : void
    1204           0 : TraCIAPI::POIScope::remove(const std::string& poiID, int layer) const {
    1205           0 :     tcpip::Storage content;
    1206           0 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1207           0 :     content.writeInt(layer);
    1208           0 :     myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::REMOVE, poiID, &content);
    1209           0 :     myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
    1210           0 : }
    1211             : 
    1212             : 
    1213             : // ---------------------------------------------------------------------------
    1214             : // TraCIAPI::PolygonScope-methods
    1215             : // ---------------------------------------------------------------------------
    1216             : double
    1217           1 : TraCIAPI::PolygonScope::getLineWidth(const std::string& polygonID) const {
    1218           1 :     return getDouble(libsumo::VAR_WIDTH, polygonID);
    1219             : }
    1220             : 
    1221             : bool
    1222           0 : TraCIAPI::PolygonScope::getFilled(const std::string& polygonID) const {
    1223           0 :     return getInt(libsumo::VAR_FILL, polygonID) != 0;
    1224             : }
    1225             : 
    1226             : std::string
    1227           0 : TraCIAPI::PolygonScope::getType(const std::string& polygonID) const {
    1228           0 :     return getString(libsumo::VAR_TYPE, polygonID);
    1229             : }
    1230             : 
    1231             : libsumo::TraCIPositionVector
    1232           2 : TraCIAPI::PolygonScope::getShape(const std::string& polygonID) const {
    1233           2 :     return getPolygon(libsumo::VAR_SHAPE, polygonID);
    1234             : }
    1235             : 
    1236             : libsumo::TraCIColor
    1237           1 : TraCIAPI::PolygonScope::getColor(const std::string& polygonID) const {
    1238           1 :     return getCol(libsumo::VAR_COLOR, polygonID);
    1239             : }
    1240             : 
    1241             : void
    1242           1 : TraCIAPI::PolygonScope::setLineWidth(const std::string& polygonID, const double lineWidth) const {
    1243           1 :     tcpip::Storage content;
    1244           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1245           1 :     content.writeDouble(lineWidth);
    1246           1 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_WIDTH, polygonID, &content);
    1247           1 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1248           1 : }
    1249             : 
    1250             : void
    1251           0 : TraCIAPI::PolygonScope::setType(const std::string& polygonID, const std::string& setType) const {
    1252           0 :     tcpip::Storage content;
    1253           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1254           0 :     content.writeString(setType);
    1255           0 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_TYPE, polygonID, &content);
    1256           0 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1257           0 : }
    1258             : 
    1259             : 
    1260             : void
    1261           1 : TraCIAPI::PolygonScope::setShape(const std::string& polygonID, const libsumo::TraCIPositionVector& shape) const {
    1262           1 :     tcpip::Storage content;
    1263           1 :     content.writeUnsignedByte(libsumo::TYPE_POLYGON);
    1264           1 :     if (shape.value.size() < 256) {
    1265           1 :         content.writeUnsignedByte((int)shape.value.size());
    1266             :     } else {
    1267           0 :         content.writeUnsignedByte(0);
    1268           0 :         content.writeInt((int)shape.value.size());
    1269             :     }
    1270           5 :     for (const libsumo::TraCIPosition& pos : shape.value) {
    1271           4 :         content.writeDouble(pos.x);
    1272           4 :         content.writeDouble(pos.y);
    1273             :     }
    1274           1 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_SHAPE, polygonID, &content);
    1275           1 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1276           1 : }
    1277             : 
    1278             : 
    1279             : void
    1280           0 : TraCIAPI::PolygonScope::setColor(const std::string& polygonID, const libsumo::TraCIColor& c) const {
    1281           0 :     tcpip::Storage content;
    1282           0 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    1283           0 :     content.writeUnsignedByte(c.r);
    1284           0 :     content.writeUnsignedByte(c.g);
    1285           0 :     content.writeUnsignedByte(c.b);
    1286           0 :     content.writeUnsignedByte(c.a);
    1287           0 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_COLOR, polygonID, &content);
    1288           0 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1289           0 : }
    1290             : 
    1291             : void
    1292           0 : TraCIAPI::PolygonScope::add(const std::string& polygonID, const libsumo::TraCIPositionVector& shape, const libsumo::TraCIColor& c, bool fill, const std::string& type, int layer) const {
    1293           0 :     tcpip::Storage content;
    1294           0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1295           0 :     content.writeInt(5);
    1296           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1297           0 :     content.writeString(type);
    1298           0 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    1299           0 :     content.writeUnsignedByte(c.r);
    1300           0 :     content.writeUnsignedByte(c.g);
    1301           0 :     content.writeUnsignedByte(c.b);
    1302           0 :     content.writeUnsignedByte(c.a);
    1303           0 :     content.writeUnsignedByte(libsumo::TYPE_UBYTE);
    1304           0 :     int f = fill ? 1 : 0;
    1305           0 :     content.writeUnsignedByte(f);
    1306           0 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1307           0 :     content.writeInt(layer);
    1308           0 :     content.writeUnsignedByte(libsumo::TYPE_POLYGON);
    1309           0 :     content.writeUnsignedByte((int)shape.value.size());
    1310           0 :     for (int i = 0; i < (int)shape.value.size(); ++i) {
    1311           0 :         content.writeDouble(shape.value[i].x);
    1312           0 :         content.writeDouble(shape.value[i].y);
    1313             :     }
    1314           0 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::ADD, polygonID, &content);
    1315           0 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1316           0 : }
    1317             : 
    1318             : void
    1319           0 : TraCIAPI::PolygonScope::remove(const std::string& polygonID, int layer) const {
    1320           0 :     tcpip::Storage content;
    1321           0 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1322           0 :     content.writeInt(layer);
    1323           0 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::REMOVE, polygonID, &content);
    1324           0 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1325           0 : }
    1326             : 
    1327             : 
    1328             : // ---------------------------------------------------------------------------
    1329             : // TraCIAPI::RouteScope-methods
    1330             : // ---------------------------------------------------------------------------
    1331             : std::vector<std::string>
    1332           0 : TraCIAPI::RouteScope::getEdges(const std::string& routeID) const {
    1333           0 :     return getStringVector(libsumo::VAR_EDGES, routeID);
    1334             : }
    1335             : 
    1336             : 
    1337             : void
    1338           2 : TraCIAPI::RouteScope::add(const std::string& routeID, const std::vector<std::string>& edges) const {
    1339           2 :     tcpip::Storage content;
    1340           2 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    1341           2 :     content.writeStringList(edges);
    1342           2 :     myParent.createCommand(libsumo::CMD_SET_ROUTE_VARIABLE, libsumo::ADD, routeID, &content);
    1343           2 :     myParent.processSet(libsumo::CMD_SET_ROUTE_VARIABLE);
    1344           2 : }
    1345             : 
    1346             : 
    1347             : // ---------------------------------------------------------------------------
    1348             : // TraCIAPI::SimulationScope-methods
    1349             : // ---------------------------------------------------------------------------
    1350             : int
    1351           4 : TraCIAPI::SimulationScope::getCurrentTime() const {
    1352           8 :     return getInt(libsumo::VAR_TIME_STEP, "");
    1353             : }
    1354             : 
    1355             : double
    1356           0 : TraCIAPI::SimulationScope::getTime() const {
    1357           0 :     return getDouble(libsumo::VAR_TIME, "");
    1358             : }
    1359             : 
    1360             : int
    1361           0 : TraCIAPI::SimulationScope::getLoadedNumber() const {
    1362           0 :     return (int) getInt(libsumo::VAR_LOADED_VEHICLES_NUMBER, "");
    1363             : }
    1364             : 
    1365             : std::vector<std::string>
    1366           0 : TraCIAPI::SimulationScope::getLoadedIDList() const {
    1367           0 :     return getStringVector(libsumo::VAR_LOADED_VEHICLES_IDS, "");
    1368             : }
    1369             : 
    1370             : int
    1371           0 : TraCIAPI::SimulationScope::getDepartedNumber() const {
    1372           0 :     return (int) getInt(libsumo::VAR_DEPARTED_VEHICLES_NUMBER, "");
    1373             : }
    1374             : 
    1375             : std::vector<std::string>
    1376           0 : TraCIAPI::SimulationScope::getDepartedIDList() const {
    1377           0 :     return getStringVector(libsumo::VAR_DEPARTED_VEHICLES_IDS, "");
    1378             : }
    1379             : 
    1380             : int
    1381           0 : TraCIAPI::SimulationScope::getArrivedNumber() const {
    1382           0 :     return (int) getInt(libsumo::VAR_ARRIVED_VEHICLES_NUMBER, "");
    1383             : }
    1384             : 
    1385             : std::vector<std::string>
    1386           0 : TraCIAPI::SimulationScope::getArrivedIDList() const {
    1387           0 :     return getStringVector(libsumo::VAR_ARRIVED_VEHICLES_IDS, "");
    1388             : }
    1389             : 
    1390             : int
    1391           0 : TraCIAPI::SimulationScope::getStartingTeleportNumber() const {
    1392           0 :     return (int) getInt(libsumo::VAR_TELEPORT_STARTING_VEHICLES_NUMBER, "");
    1393             : }
    1394             : 
    1395             : std::vector<std::string>
    1396           0 : TraCIAPI::SimulationScope::getStartingTeleportIDList() const {
    1397           0 :     return getStringVector(libsumo::VAR_TELEPORT_STARTING_VEHICLES_IDS, "");
    1398             : }
    1399             : 
    1400             : int
    1401           0 : TraCIAPI::SimulationScope::getEndingTeleportNumber() const {
    1402           0 :     return (int) getInt(libsumo::VAR_TELEPORT_ENDING_VEHICLES_NUMBER, "");
    1403             : }
    1404             : 
    1405             : std::vector<std::string>
    1406           0 : TraCIAPI::SimulationScope::getEndingTeleportIDList() const {
    1407           0 :     return getStringVector(libsumo::VAR_TELEPORT_ENDING_VEHICLES_IDS, "");
    1408             : }
    1409             : 
    1410             : int
    1411           0 : TraCIAPI::SimulationScope::getDepartedPersonNumber() const {
    1412           0 :     return (int)getInt(libsumo::VAR_DEPARTED_PERSONS_NUMBER, "");
    1413             : }
    1414             : 
    1415             : std::vector<std::string>
    1416           0 : TraCIAPI::SimulationScope::getDepartedPersonIDList() const {
    1417           0 :     return getStringVector(libsumo::VAR_DEPARTED_PERSONS_IDS, "");
    1418             : }
    1419             : 
    1420             : int
    1421           0 : TraCIAPI::SimulationScope::getArrivedPersonNumber() const {
    1422           0 :     return (int)getInt(libsumo::VAR_ARRIVED_PERSONS_NUMBER, "");
    1423             : }
    1424             : 
    1425             : std::vector<std::string>
    1426           0 : TraCIAPI::SimulationScope::getArrivedPersonIDList() const {
    1427           0 :     return getStringVector(libsumo::VAR_ARRIVED_PERSONS_IDS, "");
    1428             : }
    1429             : 
    1430             : double
    1431           1 : TraCIAPI::SimulationScope::getDeltaT() const {
    1432           2 :     return getDouble(libsumo::VAR_DELTA_T, "");
    1433             : }
    1434             : 
    1435             : libsumo::TraCIPositionVector
    1436           0 : TraCIAPI::SimulationScope::getNetBoundary() const {
    1437           0 :     return getPolygon(libsumo::VAR_NET_BOUNDING_BOX, "");
    1438             : }
    1439             : 
    1440             : 
    1441             : int
    1442           0 : TraCIAPI::SimulationScope::getMinExpectedNumber() const {
    1443           0 :     return getInt(libsumo::VAR_MIN_EXPECTED_VEHICLES, "");
    1444             : }
    1445             : 
    1446             : std::string
    1447           1 : TraCIAPI::SimulationScope::getOption(const std::string& option) const {
    1448           1 :     return getString(libsumo::VAR_OPTION, option);
    1449             : }
    1450             : 
    1451             : int
    1452           1 : TraCIAPI::SimulationScope::getBusStopWaiting(const std::string& stopID) const {
    1453           1 :     return (int) getInt(libsumo::VAR_BUS_STOP_WAITING, stopID);
    1454             : }
    1455             : 
    1456             : std::vector<std::string>
    1457           1 : TraCIAPI::SimulationScope::getBusStopWaitingIDList(const std::string& stopID) const {
    1458           1 :     return getStringVector(libsumo::VAR_BUS_STOP_WAITING_IDS, stopID);
    1459             : }
    1460             : 
    1461             : 
    1462             : libsumo::TraCIPosition
    1463           2 : TraCIAPI::SimulationScope::convert2D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) const {
    1464           2 :     const int posType = toGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D;
    1465           2 :     libsumo::TraCIPosition result;
    1466           2 :     tcpip::Storage content;
    1467           2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1468           2 :     content.writeInt(2);
    1469           2 :     content.writeByte(libsumo::POSITION_ROADMAP);
    1470           2 :     content.writeString(edgeID);
    1471           2 :     content.writeDouble(pos);
    1472           2 :     content.writeByte(laneIndex);
    1473           2 :     content.writeByte(libsumo::TYPE_UBYTE);
    1474           2 :     content.writeByte(posType);
    1475           2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
    1476           2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
    1477           2 :         result.x = myParent.myInput.readDouble();
    1478           2 :         result.y = myParent.myInput.readDouble();
    1479             :     }
    1480           2 :     return result;
    1481           2 : }
    1482             : 
    1483             : 
    1484             : libsumo::TraCIPosition
    1485           2 : TraCIAPI::SimulationScope::convert3D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) const {
    1486           2 :     const int posType = toGeo ? libsumo::POSITION_LON_LAT_ALT : libsumo::POSITION_3D;
    1487           2 :     libsumo::TraCIPosition result;
    1488           2 :     tcpip::Storage content;
    1489           2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1490           2 :     content.writeInt(2);
    1491           2 :     content.writeByte(libsumo::POSITION_ROADMAP);
    1492           2 :     content.writeString(edgeID);
    1493           2 :     content.writeDouble(pos);
    1494           2 :     content.writeByte(laneIndex);
    1495           2 :     content.writeByte(libsumo::TYPE_UBYTE);
    1496           2 :     content.writeByte(posType);
    1497           2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
    1498           2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
    1499           2 :         result.x = myParent.myInput.readDouble();
    1500           2 :         result.y = myParent.myInput.readDouble();
    1501           2 :         result.z = myParent.myInput.readDouble();
    1502             :     }
    1503           2 :     return result;
    1504           2 : }
    1505             : 
    1506             : 
    1507             : libsumo::TraCIRoadPosition
    1508           2 : TraCIAPI::SimulationScope::convertRoad(double x, double y, bool isGeo, const std::string& vClass) const {
    1509             :     libsumo::TraCIRoadPosition result;
    1510           2 :     tcpip::Storage content;
    1511           2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1512           2 :     content.writeInt(3);
    1513           4 :     content.writeByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
    1514           2 :     content.writeDouble(x);
    1515           2 :     content.writeDouble(y);
    1516           2 :     content.writeByte(libsumo::TYPE_UBYTE);
    1517           2 :     content.writeByte(libsumo::POSITION_ROADMAP);
    1518           2 :     content.writeByte(libsumo::TYPE_STRING);
    1519           2 :     content.writeString(vClass);
    1520           2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
    1521           2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_ROADMAP)) {
    1522           2 :         result.edgeID = myParent.myInput.readString();
    1523           2 :         result.pos = myParent.myInput.readDouble();
    1524           2 :         result.laneIndex = myParent.myInput.readUnsignedByte();
    1525             :     }
    1526           2 :     return result;
    1527           2 : }
    1528             : 
    1529             : 
    1530             : libsumo::TraCIPosition
    1531           2 : TraCIAPI::SimulationScope::convertGeo(double x, double y, bool fromGeo) const {
    1532           2 :     const int posType = fromGeo ? libsumo::POSITION_2D : libsumo::POSITION_LON_LAT;
    1533           2 :     libsumo::TraCIPosition result;
    1534           2 :     tcpip::Storage content;
    1535           2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1536           2 :     content.writeInt(2);
    1537           3 :     content.writeByte(fromGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
    1538           2 :     content.writeDouble(x);
    1539           2 :     content.writeDouble(y);
    1540           2 :     content.writeByte(libsumo::TYPE_UBYTE);
    1541           2 :     content.writeByte(posType);
    1542           2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
    1543           2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
    1544           2 :         result.x = myParent.myInput.readDouble();
    1545           2 :         result.y = myParent.myInput.readDouble();
    1546             :     }
    1547           2 :     return result;
    1548           2 : }
    1549             : 
    1550             : 
    1551             : double
    1552           2 : TraCIAPI::SimulationScope::getDistance2D(double x1, double y1, double x2, double y2, bool isGeo, bool isDriving) {
    1553           2 :     tcpip::Storage content;
    1554           2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1555           2 :     content.writeInt(3);
    1556           4 :     content.writeByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
    1557           2 :     content.writeDouble(x1);
    1558           2 :     content.writeDouble(y1);
    1559           2 :     content.writeByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
    1560           2 :     content.writeDouble(x2);
    1561           2 :     content.writeDouble(y2);
    1562           3 :     content.writeByte(isDriving ? libsumo::REQUEST_DRIVINGDIST : libsumo::REQUEST_AIRDIST);
    1563           2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::DISTANCE_REQUEST, "", &content);
    1564           2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::TYPE_DOUBLE)) {
    1565           2 :         return myParent.myInput.readDouble();
    1566             :     }
    1567             :     return 0.;
    1568           2 : }
    1569             : 
    1570             : 
    1571             : double
    1572           2 : TraCIAPI::SimulationScope::getDistanceRoad(const std::string& edgeID1, double pos1, const std::string& edgeID2, double pos2, bool isDriving) {
    1573           2 :     tcpip::Storage content;
    1574           2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1575           2 :     content.writeInt(3);
    1576           2 :     content.writeByte(libsumo::POSITION_ROADMAP);
    1577           2 :     content.writeString(edgeID1);
    1578           2 :     content.writeDouble(pos1);
    1579           2 :     content.writeByte(0); // lane
    1580           2 :     content.writeByte(libsumo::POSITION_ROADMAP);
    1581           2 :     content.writeString(edgeID2);
    1582           2 :     content.writeDouble(pos2);
    1583           2 :     content.writeByte(0); // lane
    1584           3 :     content.writeByte(isDriving ? libsumo::REQUEST_DRIVINGDIST : libsumo::REQUEST_AIRDIST);
    1585           2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::DISTANCE_REQUEST, "", &content);
    1586           2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::TYPE_DOUBLE)) {
    1587           2 :         return myParent.myInput.readDouble();
    1588             :     }
    1589             :     return 0.;
    1590           2 : }
    1591             : 
    1592             : 
    1593             : libsumo::TraCIStage
    1594           1 : TraCIAPI::SimulationScope::findRoute(const std::string& fromEdge, const std::string& toEdge, const std::string& vType, double pos, int routingMode) const {
    1595           1 :     tcpip::Storage content;
    1596           1 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1597           1 :     content.writeInt(5);
    1598           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1599           1 :     content.writeString(fromEdge);
    1600           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1601           1 :     content.writeString(toEdge);
    1602           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1603           1 :     content.writeString(vType);
    1604           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1605           1 :     content.writeDouble(pos);
    1606           1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1607           1 :     content.writeInt(routingMode);
    1608           2 :     return getTraCIStage(libsumo::FIND_ROUTE, "", &content);
    1609           1 : }
    1610             : 
    1611             : void
    1612           0 : TraCIAPI::SimulationScope::loadState(const std::string& path) const {
    1613           0 :     tcpip::Storage content;
    1614           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1615           0 :     content.writeString(path);
    1616           0 :     myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_LOAD_SIMSTATE, "", &content);
    1617           0 :     myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
    1618           0 : }
    1619             : 
    1620             : void
    1621           0 : TraCIAPI::SimulationScope::saveState(const std::string& destination) const {
    1622           0 :     tcpip::Storage content;
    1623           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1624           0 :     content.writeString(destination);
    1625           0 :     myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_SAVE_SIMSTATE, "", &content);
    1626           0 :     myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
    1627           0 : }
    1628             : 
    1629             : void
    1630           1 : TraCIAPI::SimulationScope::writeMessage(const std::string msg) {
    1631           1 :     tcpip::Storage content;
    1632           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1633           1 :     content.writeString(msg);
    1634           1 :     myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_MESSAGE, "", &content);
    1635           1 :     myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
    1636           1 : }
    1637             : 
    1638             : 
    1639             : // ---------------------------------------------------------------------------
    1640             : // TraCIAPI::TrafficLightScope-methods
    1641             : // ---------------------------------------------------------------------------
    1642             : std::string
    1643           3 : TraCIAPI::TrafficLightScope::getRedYellowGreenState(const std::string& tlsID) const {
    1644           3 :     return getString(libsumo::TL_RED_YELLOW_GREEN_STATE, tlsID);
    1645             : }
    1646             : 
    1647             : std::vector<libsumo::TraCILogic>
    1648           1 : TraCIAPI::TrafficLightScope::getAllProgramLogics(const std::string& tlsID) const {
    1649             :     std::vector<libsumo::TraCILogic> ret;
    1650           1 :     myParent.createCommand(libsumo::CMD_GET_TL_VARIABLE, libsumo::TL_COMPLETE_DEFINITION_RYG, tlsID);
    1651           1 :     if (myParent.processGet(libsumo::CMD_GET_TL_VARIABLE, libsumo::TYPE_COMPOUND)) {
    1652           1 :         const int logicNo = myParent.myInput.readInt();
    1653           3 :         for (int i = 0; i < logicNo; ++i) {
    1654           2 :             myParent.myInput.readUnsignedByte();
    1655           2 :             myParent.myInput.readInt();
    1656           2 :             myParent.myInput.readUnsignedByte();
    1657           2 :             const std::string programID = myParent.myInput.readString();
    1658           2 :             myParent.myInput.readUnsignedByte();
    1659           2 :             const int type = myParent.myInput.readInt();
    1660           2 :             myParent.myInput.readUnsignedByte();
    1661           2 :             const int phaseIndex = myParent.myInput.readInt();
    1662           2 :             myParent.myInput.readUnsignedByte();
    1663           2 :             const int phaseNumber = myParent.myInput.readInt();
    1664           2 :             libsumo::TraCILogic logic(programID, type, phaseIndex);
    1665          12 :             for (int j = 0; j < phaseNumber; j++) {
    1666          10 :                 myParent.myInput.readUnsignedByte();
    1667          10 :                 myParent.myInput.readInt();
    1668          10 :                 myParent.myInput.readUnsignedByte();
    1669          10 :                 const double duration = myParent.myInput.readDouble();
    1670          10 :                 myParent.myInput.readUnsignedByte();
    1671          10 :                 const std::string state = myParent.myInput.readString();
    1672          10 :                 myParent.myInput.readUnsignedByte();
    1673          10 :                 const double minDur = myParent.myInput.readDouble();
    1674          10 :                 myParent.myInput.readUnsignedByte();
    1675          10 :                 const double maxDur = myParent.myInput.readDouble();
    1676          10 :                 myParent.myInput.readUnsignedByte();
    1677          10 :                 const int numNext = myParent.myInput.readInt();
    1678             :                 std::vector<int> next;
    1679          10 :                 for (int k = 0; k < numNext; k++) {
    1680           0 :                     myParent.myInput.readUnsignedByte();
    1681           0 :                     next.push_back(myParent.myInput.readInt());
    1682             :                 }
    1683          10 :                 myParent.myInput.readUnsignedByte();
    1684          10 :                 const std::string name = myParent.myInput.readString();
    1685          10 :                 logic.phases.emplace_back(new libsumo::TraCIPhase(duration, state, minDur, maxDur, next, name));
    1686             :             }
    1687           2 :             myParent.myInput.readUnsignedByte();
    1688           2 :             const int paramNumber = myParent.myInput.readInt();
    1689           2 :             for (int j = 0; j < paramNumber; j++) {
    1690           0 :                 myParent.myInput.readUnsignedByte();
    1691           0 :                 const std::vector<std::string> par = myParent.myInput.readStringList();
    1692           0 :                 logic.subParameter[par[0]] = par[1];
    1693           0 :             }
    1694           2 :             ret.emplace_back(logic);
    1695           2 :         }
    1696             :     }
    1697           1 :     return ret;
    1698           0 : }
    1699             : 
    1700             : std::vector<std::string>
    1701           1 : TraCIAPI::TrafficLightScope::getControlledLanes(const std::string& tlsID) const {
    1702           1 :     return getStringVector(libsumo::TL_CONTROLLED_LANES, tlsID);
    1703             : }
    1704             : 
    1705             : std::vector<std::vector<libsumo::TraCILink> >
    1706           1 : TraCIAPI::TrafficLightScope::getControlledLinks(const std::string& tlsID) const {
    1707             :     std::vector<std::vector<libsumo::TraCILink> > result;
    1708           1 :     myParent.createCommand(libsumo::CMD_GET_TL_VARIABLE, libsumo::TL_CONTROLLED_LINKS, tlsID);
    1709           1 :     if (myParent.processGet(libsumo::CMD_GET_TL_VARIABLE, libsumo::TYPE_COMPOUND)) {
    1710             : 
    1711           1 :         myParent.myInput.readUnsignedByte();
    1712           1 :         myParent.myInput.readInt();
    1713             : 
    1714           1 :         int linkNo = myParent.myInput.readInt();
    1715           8 :         for (int i = 0; i < linkNo; ++i) {
    1716           7 :             myParent.myInput.readUnsignedByte();
    1717           7 :             int no = myParent.myInput.readInt();
    1718             :             std::vector<libsumo::TraCILink> ret;
    1719          14 :             for (int i1 = 0; i1 < no; ++i1) {
    1720           7 :                 myParent.myInput.readUnsignedByte();
    1721           7 :                 myParent.myInput.readInt();
    1722           7 :                 std::string from = myParent.myInput.readString();
    1723           7 :                 std::string to = myParent.myInput.readString();
    1724           7 :                 std::string via = myParent.myInput.readString();
    1725           7 :                 ret.emplace_back(libsumo::TraCILink(from, via, to));
    1726             :             }
    1727           7 :             result.emplace_back(ret);
    1728           7 :         }
    1729             :     }
    1730           1 :     return result;
    1731           0 : }
    1732             : 
    1733             : std::string
    1734           2 : TraCIAPI::TrafficLightScope::getProgram(const std::string& tlsID) const {
    1735           2 :     return getString(libsumo::TL_CURRENT_PROGRAM, tlsID);
    1736             : }
    1737             : 
    1738             : int
    1739           1 : TraCIAPI::TrafficLightScope::getPhase(const std::string& tlsID) const {
    1740           1 :     return getInt(libsumo::TL_CURRENT_PHASE, tlsID);
    1741             : }
    1742             : 
    1743             : std::string
    1744           1 : TraCIAPI::TrafficLightScope::getPhaseName(const std::string& tlsID) const {
    1745           1 :     return getString(libsumo::VAR_NAME, tlsID);
    1746             : }
    1747             : 
    1748             : double
    1749           1 : TraCIAPI::TrafficLightScope::getPhaseDuration(const std::string& tlsID) const {
    1750           1 :     return getDouble(libsumo::TL_PHASE_DURATION, tlsID);
    1751             : }
    1752             : 
    1753             : double
    1754           1 : TraCIAPI::TrafficLightScope::getNextSwitch(const std::string& tlsID) const {
    1755           1 :     return getDouble(libsumo::TL_NEXT_SWITCH, tlsID);
    1756             : }
    1757             : 
    1758             : 
    1759             : int
    1760           0 : TraCIAPI::TrafficLightScope::getServedPersonCount(const std::string& tlsID, int index) const {
    1761           0 :     tcpip::Storage content;
    1762           0 :     content.writeByte(libsumo::TYPE_INTEGER);
    1763           0 :     content.writeInt(index);
    1764           0 :     return getInt(libsumo::VAR_PERSON_NUMBER, tlsID, &content);
    1765           0 : }
    1766             : 
    1767             : 
    1768             : void
    1769           1 : TraCIAPI::TrafficLightScope::setRedYellowGreenState(const std::string& tlsID, const std::string& state) const {
    1770           1 :     tcpip::Storage content;
    1771           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1772           1 :     content.writeString(state);
    1773           1 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_RED_YELLOW_GREEN_STATE, tlsID, &content);
    1774           1 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1775           1 : }
    1776             : 
    1777             : void
    1778           1 : TraCIAPI::TrafficLightScope::setPhase(const std::string& tlsID, int index) const {
    1779           1 :     tcpip::Storage content;
    1780           1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1781           1 :     content.writeInt(index);
    1782           1 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PHASE_INDEX, tlsID, &content);
    1783           1 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1784           1 : }
    1785             : 
    1786             : void
    1787           1 : TraCIAPI::TrafficLightScope::setPhaseName(const std::string& tlsID, const std::string& name) const {
    1788           1 :     tcpip::Storage content;
    1789           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1790           1 :     content.writeString(name);
    1791           1 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::VAR_NAME, tlsID, &content);
    1792           1 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1793           1 : }
    1794             : 
    1795             : void
    1796           0 : TraCIAPI::TrafficLightScope::setProgram(const std::string& tlsID, const std::string& programID) const {
    1797           0 :     tcpip::Storage content;
    1798           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1799           0 :     content.writeString(programID);
    1800           0 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PROGRAM, tlsID, &content);
    1801           0 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1802           0 : }
    1803             : 
    1804             : void
    1805           0 : TraCIAPI::TrafficLightScope::setPhaseDuration(const std::string& tlsID, double phaseDuration) const {
    1806           0 :     tcpip::Storage content;
    1807           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1808           0 :     content.writeDouble(phaseDuration);
    1809           0 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PHASE_DURATION, tlsID, &content);
    1810           0 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1811           0 : }
    1812             : 
    1813             : void
    1814           1 : TraCIAPI::TrafficLightScope::setProgramLogic(const std::string& tlsID, const libsumo::TraCILogic& logic) const {
    1815           1 :     tcpip::Storage content;
    1816           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1817           1 :     content.writeInt(5);
    1818           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1819           1 :     content.writeString(logic.programID);
    1820           1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1821           1 :     content.writeInt(logic.type);
    1822           1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1823           1 :     content.writeInt(logic.currentPhaseIndex);
    1824           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1825           1 :     content.writeInt((int)logic.phases.size());
    1826           5 :     for (const std::shared_ptr<libsumo::TraCIPhase>& p : logic.phases) {
    1827           4 :         content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1828           4 :         content.writeInt(6);
    1829           4 :         content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1830           4 :         content.writeDouble(p->duration);
    1831           4 :         content.writeUnsignedByte(libsumo::TYPE_STRING);
    1832           4 :         content.writeString(p->state);
    1833           4 :         content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1834           4 :         content.writeDouble(p->minDur);
    1835           4 :         content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1836           4 :         content.writeDouble(p->maxDur);
    1837           4 :         content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1838           4 :         content.writeInt((int)p->next.size());
    1839           4 :         for (int n : p->next) {
    1840           0 :             content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1841           0 :             content.writeInt(n);
    1842             :         }
    1843           4 :         content.writeUnsignedByte(libsumo::TYPE_STRING);
    1844           4 :         content.writeString(p->name);
    1845             :     }
    1846           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1847           1 :     content.writeInt((int)logic.subParameter.size());
    1848           1 :     for (const auto& item : logic.subParameter) {
    1849           0 :         content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    1850           0 :         content.writeInt(2);
    1851           0 :         content.writeString(item.first);
    1852           0 :         content.writeString(item.second);
    1853             :     }
    1854           1 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_COMPLETE_PROGRAM_RYG, tlsID, &content);
    1855           1 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1856           1 : }
    1857             : 
    1858             : 
    1859             : // ---------------------------------------------------------------------------
    1860             : // TraCIAPI::VehicleTypeScope-methods
    1861             : // ---------------------------------------------------------------------------
    1862             : double
    1863           0 : TraCIAPI::VehicleTypeScope::getLength(const std::string& typeID) const {
    1864           0 :     return getDouble(libsumo::VAR_LENGTH, typeID);
    1865             : }
    1866             : 
    1867             : double
    1868           0 : TraCIAPI::VehicleTypeScope::getMaxSpeed(const std::string& typeID) const {
    1869           0 :     return getDouble(libsumo::VAR_MAXSPEED, typeID);
    1870             : }
    1871             : 
    1872             : double
    1873           0 : TraCIAPI::VehicleTypeScope::getSpeedFactor(const std::string& typeID) const {
    1874           0 :     return getDouble(libsumo::VAR_SPEED_FACTOR, typeID);
    1875             : }
    1876             : 
    1877             : double
    1878           0 : TraCIAPI::VehicleTypeScope::getSpeedDeviation(const std::string& typeID) const {
    1879           0 :     return getDouble(libsumo::VAR_SPEED_DEVIATION, typeID);
    1880             : }
    1881             : 
    1882             : double
    1883           2 : TraCIAPI::VehicleTypeScope::getAccel(const std::string& typeID) const {
    1884           2 :     return getDouble(libsumo::VAR_ACCEL, typeID);
    1885             : }
    1886             : 
    1887             : double
    1888           0 : TraCIAPI::VehicleTypeScope::getDecel(const std::string& typeID) const {
    1889           0 :     return getDouble(libsumo::VAR_DECEL, typeID);
    1890             : }
    1891             : 
    1892             : double
    1893           1 : TraCIAPI::VehicleTypeScope::getEmergencyDecel(const std::string& typeID) const {
    1894           1 :     return getDouble(libsumo::VAR_EMERGENCY_DECEL, typeID);
    1895             : }
    1896             : 
    1897             : double
    1898           1 : TraCIAPI::VehicleTypeScope::getApparentDecel(const std::string& typeID) const {
    1899           1 :     return getDouble(libsumo::VAR_APPARENT_DECEL, typeID);
    1900             : }
    1901             : 
    1902             : double
    1903           0 : TraCIAPI::VehicleTypeScope::getImperfection(const std::string& typeID) const {
    1904           0 :     return getDouble(libsumo::VAR_IMPERFECTION, typeID);
    1905             : }
    1906             : 
    1907             : double
    1908           0 : TraCIAPI::VehicleTypeScope::getTau(const std::string& typeID) const {
    1909           0 :     return getDouble(libsumo::VAR_TAU, typeID);
    1910             : }
    1911             : 
    1912             : std::string
    1913           0 : TraCIAPI::VehicleTypeScope::getVehicleClass(const std::string& typeID) const {
    1914           0 :     return getString(libsumo::VAR_VEHICLECLASS, typeID);
    1915             : }
    1916             : 
    1917             : std::string
    1918           0 : TraCIAPI::VehicleTypeScope::getEmissionClass(const std::string& typeID) const {
    1919           0 :     return getString(libsumo::VAR_EMISSIONCLASS, typeID);
    1920             : }
    1921             : 
    1922             : std::string
    1923           0 : TraCIAPI::VehicleTypeScope::getShapeClass(const std::string& typeID) const {
    1924           0 :     return getString(libsumo::VAR_SHAPECLASS, typeID);
    1925             : }
    1926             : 
    1927             : double
    1928           0 : TraCIAPI::VehicleTypeScope::getMinGap(const std::string& typeID) const {
    1929           0 :     return getDouble(libsumo::VAR_MINGAP, typeID);
    1930             : }
    1931             : 
    1932             : double
    1933           1 : TraCIAPI::VehicleTypeScope::getMinGapLat(const std::string& typeID) const {
    1934           1 :     return getDouble(libsumo::VAR_MINGAP_LAT, typeID);
    1935             : }
    1936             : 
    1937             : double
    1938           1 : TraCIAPI::VehicleTypeScope::getMaxSpeedLat(const std::string& typeID) const {
    1939           1 :     return getDouble(libsumo::VAR_MAXSPEED_LAT, typeID);
    1940             : }
    1941             : 
    1942             : std::string
    1943           1 : TraCIAPI::VehicleTypeScope::getLateralAlignment(const std::string& typeID) const {
    1944           1 :     return getString(libsumo::VAR_LATALIGNMENT, typeID);
    1945             : }
    1946             : 
    1947             : int
    1948           1 : TraCIAPI::VehicleTypeScope::getPersonCapacity(const std::string& typeID) const {
    1949           1 :     return getInt(libsumo::VAR_PERSON_CAPACITY, typeID);
    1950             : }
    1951             : 
    1952             : double
    1953           1 : TraCIAPI::VehicleTypeScope::getWidth(const std::string& typeID) const {
    1954           1 :     return getDouble(libsumo::VAR_WIDTH, typeID);
    1955             : }
    1956             : 
    1957             : double
    1958           1 : TraCIAPI::VehicleTypeScope::getHeight(const std::string& typeID) const {
    1959           1 :     return getDouble(libsumo::VAR_HEIGHT, typeID);
    1960             : }
    1961             : 
    1962             : libsumo::TraCIColor
    1963           0 : TraCIAPI::VehicleTypeScope::getColor(const std::string& typeID) const {
    1964           0 :     return getCol(libsumo::VAR_COLOR, typeID);
    1965             : }
    1966             : 
    1967             : 
    1968             : 
    1969             : void
    1970           0 : TraCIAPI::VehicleTypeScope::setLength(const std::string& typeID, double length) const {
    1971           0 :     tcpip::Storage content;
    1972           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1973           0 :     content.writeDouble(length);
    1974           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_LENGTH, typeID, &content);
    1975           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    1976           0 : }
    1977             : 
    1978             : void
    1979           0 : TraCIAPI::VehicleTypeScope::setMaxSpeed(const std::string& typeID, double speed) const {
    1980           0 :     tcpip::Storage content;
    1981           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1982           0 :     content.writeDouble(speed);
    1983           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MAXSPEED, typeID, &content);
    1984           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    1985           0 : }
    1986             : 
    1987             : void
    1988           0 : TraCIAPI::VehicleTypeScope::setVehicleClass(const std::string& typeID, const std::string& clazz) const {
    1989           0 :     tcpip::Storage content;
    1990           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1991           0 :     content.writeString(clazz);
    1992           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_VEHICLECLASS, typeID, &content);
    1993           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    1994           0 : }
    1995             : 
    1996             : void
    1997           0 : TraCIAPI::VehicleTypeScope::setSpeedFactor(const std::string& typeID, double factor) const {
    1998           0 :     tcpip::Storage content;
    1999           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2000           0 :     content.writeDouble(factor);
    2001           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SPEED_FACTOR, typeID, &content);
    2002           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2003           0 : }
    2004             : 
    2005             : void
    2006           0 : TraCIAPI::VehicleTypeScope::setSpeedDeviation(const std::string& typeID, double deviation) const {
    2007           0 :     tcpip::Storage content;
    2008           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2009           0 :     content.writeDouble(deviation);
    2010           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SPEED_DEVIATION, typeID, &content);
    2011           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2012           0 : }
    2013             : 
    2014             : 
    2015             : void
    2016           0 : TraCIAPI::VehicleTypeScope::setEmissionClass(const std::string& typeID, const std::string& clazz) const {
    2017           0 :     tcpip::Storage content;
    2018           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2019           0 :     content.writeString(clazz);
    2020           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_EMISSIONCLASS, typeID, &content);
    2021           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2022           0 : }
    2023             : 
    2024             : void
    2025           1 : TraCIAPI::VehicleTypeScope::setWidth(const std::string& typeID, double width) const {
    2026           1 :     tcpip::Storage content;
    2027           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2028           1 :     content.writeDouble(width);
    2029           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_WIDTH, typeID, &content);
    2030           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2031           1 : }
    2032             : 
    2033             : void
    2034           1 : TraCIAPI::VehicleTypeScope::setHeight(const std::string& typeID, double height) const {
    2035           1 :     tcpip::Storage content;
    2036           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2037           1 :     content.writeDouble(height);
    2038           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_HEIGHT, typeID, &content);
    2039           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2040           1 : }
    2041             : 
    2042             : void
    2043           0 : TraCIAPI::VehicleTypeScope::setMinGap(const std::string& typeID, double minGap) const {
    2044           0 :     tcpip::Storage content;
    2045           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2046           0 :     content.writeDouble(minGap);
    2047           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MINGAP, typeID, &content);
    2048           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2049           0 : }
    2050             : 
    2051             : 
    2052             : void
    2053           1 : TraCIAPI::VehicleTypeScope::setMinGapLat(const std::string& typeID, double minGapLat) const {
    2054           1 :     tcpip::Storage content;
    2055           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2056           1 :     content.writeDouble(minGapLat);
    2057           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MINGAP_LAT, typeID, &content);
    2058           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2059           1 : }
    2060             : 
    2061             : void
    2062           1 : TraCIAPI::VehicleTypeScope::setMaxSpeedLat(const std::string& typeID, double speed) const {
    2063           1 :     tcpip::Storage content;
    2064           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2065           1 :     content.writeDouble(speed);
    2066           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MAXSPEED_LAT, typeID, &content);
    2067           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2068           1 : }
    2069             : 
    2070             : void
    2071           1 : TraCIAPI::VehicleTypeScope::setLateralAlignment(const std::string& typeID, const std::string& latAlignment) const {
    2072           1 :     tcpip::Storage content;
    2073           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2074           1 :     content.writeString(latAlignment);
    2075           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_LATALIGNMENT, typeID, &content);
    2076           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2077           1 : }
    2078             : 
    2079             : void
    2080           1 : TraCIAPI::VehicleTypeScope::copy(const std::string& origTypeID, const std::string& newTypeID) const {
    2081           1 :     tcpip::Storage content;
    2082           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2083           1 :     content.writeString(newTypeID);
    2084           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::COPY, origTypeID, &content);
    2085           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2086           1 : }
    2087             : 
    2088             : void
    2089           0 : TraCIAPI::VehicleTypeScope::setShapeClass(const std::string& typeID, const std::string& clazz) const {
    2090           0 :     tcpip::Storage content;
    2091           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2092           0 :     content.writeString(clazz);
    2093           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SHAPECLASS, typeID, &content);
    2094           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2095           0 : }
    2096             : 
    2097             : void
    2098           1 : TraCIAPI::VehicleTypeScope::setAccel(const std::string& typeID, double accel) const {
    2099           1 :     tcpip::Storage content;
    2100           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2101           1 :     content.writeDouble(accel);
    2102           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_ACCEL, typeID, &content);
    2103           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2104           1 : }
    2105             : 
    2106             : void
    2107           0 : TraCIAPI::VehicleTypeScope::setDecel(const std::string& typeID, double decel) const {
    2108           0 :     tcpip::Storage content;
    2109           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2110           0 :     content.writeDouble(decel);
    2111           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_DECEL, typeID, &content);
    2112           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2113           0 : }
    2114             : 
    2115             : void
    2116           1 : TraCIAPI::VehicleTypeScope::setEmergencyDecel(const std::string& typeID, double decel) const {
    2117           1 :     tcpip::Storage content;
    2118           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2119           1 :     content.writeDouble(decel);
    2120           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_EMERGENCY_DECEL, typeID, &content);
    2121           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2122           1 : }
    2123             : 
    2124             : void
    2125           1 : TraCIAPI::VehicleTypeScope::setApparentDecel(const std::string& typeID, double decel) const {
    2126           1 :     tcpip::Storage content;
    2127           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2128           1 :     content.writeDouble(decel);
    2129           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_APPARENT_DECEL, typeID, &content);
    2130           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2131           1 : }
    2132             : 
    2133             : void
    2134           0 : TraCIAPI::VehicleTypeScope::setImperfection(const std::string& typeID, double imperfection) const {
    2135           0 :     tcpip::Storage content;
    2136           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2137           0 :     content.writeDouble(imperfection);
    2138           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_IMPERFECTION, typeID, &content);
    2139           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2140           0 : }
    2141             : 
    2142             : void
    2143           0 : TraCIAPI::VehicleTypeScope::setTau(const std::string& typeID, double tau) const {
    2144           0 :     tcpip::Storage content;
    2145           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2146           0 :     content.writeDouble(tau);
    2147           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_TAU, typeID, &content);
    2148           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2149           0 : }
    2150             : 
    2151             : void
    2152           0 : TraCIAPI::VehicleTypeScope::setColor(const std::string& typeID, const libsumo::TraCIColor& c) const {
    2153           0 :     tcpip::Storage content;
    2154           0 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    2155           0 :     content.writeUnsignedByte(c.r);
    2156           0 :     content.writeUnsignedByte(c.g);
    2157           0 :     content.writeUnsignedByte(c.b);
    2158           0 :     content.writeUnsignedByte(c.a);
    2159           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_COLOR, typeID, &content);
    2160           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2161           0 : }
    2162             : 
    2163             : 
    2164             : // ---------------------------------------------------------------------------
    2165             : // TraCIAPI::VehicleScope-methods
    2166             : // ---------------------------------------------------------------------------
    2167             : double
    2168           1 : TraCIAPI::VehicleScope::getSpeed(const std::string& vehicleID) const {
    2169           1 :     return getDouble(libsumo::VAR_SPEED, vehicleID);
    2170             : }
    2171             : 
    2172             : double
    2173           1 : TraCIAPI::VehicleScope::getLateralSpeed(const std::string& vehicleID) const {
    2174           1 :     return getDouble(libsumo::VAR_SPEED_LAT, vehicleID);
    2175             : }
    2176             : 
    2177             : double
    2178           1 : TraCIAPI::VehicleScope::getAcceleration(const std::string& vehicleID) const {
    2179           1 :     return getDouble(libsumo::VAR_ACCELERATION, vehicleID);
    2180             : }
    2181             : 
    2182             : double
    2183           1 : TraCIAPI::VehicleScope::getFollowSpeed(const std::string& vehicleID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) const {
    2184           1 :     tcpip::Storage content;
    2185           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2186           1 :     content.writeInt(5);
    2187           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2188           1 :     content.writeDouble(speed);
    2189           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2190           1 :     content.writeDouble(gap);
    2191           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2192           1 :     content.writeDouble(leaderSpeed);
    2193           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2194           1 :     content.writeDouble(leaderMaxDecel);
    2195           1 :     content.writeByte(libsumo::TYPE_STRING);
    2196           1 :     content.writeString(leaderID);
    2197           2 :     return getDouble(libsumo::VAR_FOLLOW_SPEED, vehicleID, &content);
    2198           1 : }
    2199             : 
    2200             : 
    2201             : double
    2202           1 : TraCIAPI::VehicleScope::getSecureGap(const std::string& vehicleID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) const {
    2203           1 :     tcpip::Storage content;
    2204           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2205           1 :     content.writeInt(4);
    2206           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2207           1 :     content.writeDouble(speed);
    2208           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2209           1 :     content.writeDouble(leaderSpeed);
    2210           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2211           1 :     content.writeDouble(leaderMaxDecel);
    2212           1 :     content.writeByte(libsumo::TYPE_STRING);
    2213           1 :     content.writeString(leaderID);
    2214           2 :     return getDouble(libsumo::VAR_SECURE_GAP, vehicleID, &content);
    2215           1 : }
    2216             : 
    2217             : double
    2218           1 : TraCIAPI::VehicleScope::getStopSpeed(const std::string& vehicleID, double speed, double gap) const {
    2219           1 :     tcpip::Storage content;
    2220           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2221           1 :     content.writeInt(2);
    2222           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2223           1 :     content.writeDouble(speed);
    2224           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2225           1 :     content.writeDouble(gap);
    2226           2 :     return getDouble(libsumo::VAR_STOP_SPEED, vehicleID, &content);
    2227           1 : }
    2228             : 
    2229             : 
    2230             : double
    2231           1 : TraCIAPI::VehicleScope::getMaxSpeed(const std::string& vehicleID) const {
    2232           1 :     return getDouble(libsumo::VAR_MAXSPEED, vehicleID);
    2233             : }
    2234             : 
    2235             : libsumo::TraCIPosition
    2236           0 : TraCIAPI::VehicleScope::getPosition(const std::string& vehicleID) const {
    2237           0 :     return getPos(libsumo::VAR_POSITION, vehicleID);
    2238             : }
    2239             : 
    2240             : libsumo::TraCIPosition
    2241           0 : TraCIAPI::VehicleScope::getPosition3D(const std::string& vehicleID) const {
    2242           0 :     return getPos3D(libsumo::VAR_POSITION3D, vehicleID);
    2243             : }
    2244             : 
    2245             : double
    2246           0 : TraCIAPI::VehicleScope::getAngle(const std::string& vehicleID) const {
    2247           0 :     return getDouble(libsumo::VAR_ANGLE, vehicleID);
    2248             : }
    2249             : 
    2250             : std::string
    2251           2 : TraCIAPI::VehicleScope::getRoadID(const std::string& vehicleID) const {
    2252           2 :     return getString(libsumo::VAR_ROAD_ID, vehicleID);
    2253             : }
    2254             : 
    2255             : std::string
    2256           2 : TraCIAPI::VehicleScope::getLaneID(const std::string& vehicleID) const {
    2257           2 :     return getString(libsumo::VAR_LANE_ID, vehicleID);
    2258             : }
    2259             : 
    2260             : int
    2261           0 : TraCIAPI::VehicleScope::getLaneIndex(const std::string& vehicleID) const {
    2262           0 :     return getInt(libsumo::VAR_LANE_INDEX, vehicleID);
    2263             : }
    2264             : 
    2265             : std::string
    2266           1 : TraCIAPI::VehicleScope::getTypeID(const std::string& vehicleID) const {
    2267           1 :     return getString(libsumo::VAR_TYPE, vehicleID);
    2268             : }
    2269             : 
    2270             : std::string
    2271           1 : TraCIAPI::VehicleScope::getRouteID(const std::string& vehicleID) const {
    2272           1 :     return getString(libsumo::VAR_ROUTE_ID, vehicleID);
    2273             : }
    2274             : 
    2275             : int
    2276           0 : TraCIAPI::VehicleScope::getRouteIndex(const std::string& vehicleID) const {
    2277           0 :     return getInt(libsumo::VAR_ROUTE_INDEX, vehicleID);
    2278             : }
    2279             : 
    2280             : 
    2281             : std::vector<std::string>
    2282           3 : TraCIAPI::VehicleScope::getRoute(const std::string& vehicleID) const {
    2283           3 :     return getStringVector(libsumo::VAR_EDGES, vehicleID);
    2284             : }
    2285             : 
    2286             : libsumo::TraCIColor
    2287           1 : TraCIAPI::VehicleScope::getColor(const std::string& vehicleID) const {
    2288           1 :     return getCol(libsumo::VAR_COLOR, vehicleID);
    2289             : }
    2290             : 
    2291             : double
    2292           1 : TraCIAPI::VehicleScope::getLanePosition(const std::string& vehicleID) const {
    2293           1 :     return getDouble(libsumo::VAR_LANEPOSITION, vehicleID);
    2294             : }
    2295             : 
    2296             : double
    2297           0 : TraCIAPI::VehicleScope::getDistance(const std::string& vehicleID) const {
    2298           0 :     return getDouble(libsumo::VAR_DISTANCE, vehicleID);
    2299             : }
    2300             : 
    2301             : int
    2302           1 : TraCIAPI::VehicleScope::getSignals(const std::string& vehicleID) const {
    2303           1 :     return getInt(libsumo::VAR_SIGNALS, vehicleID);
    2304             : }
    2305             : 
    2306             : double
    2307           1 : TraCIAPI::VehicleScope::getLateralLanePosition(const std::string& vehicleID) const {
    2308           1 :     return getDouble(libsumo::VAR_LANEPOSITION_LAT, vehicleID);
    2309             : }
    2310             : 
    2311             : double
    2312           0 : TraCIAPI::VehicleScope::getCO2Emission(const std::string& vehicleID) const {
    2313           0 :     return getDouble(libsumo::VAR_CO2EMISSION, vehicleID);
    2314             : }
    2315             : 
    2316             : double
    2317           0 : TraCIAPI::VehicleScope::getCOEmission(const std::string& vehicleID) const {
    2318           0 :     return getDouble(libsumo::VAR_COEMISSION, vehicleID);
    2319             : }
    2320             : 
    2321             : double
    2322           0 : TraCIAPI::VehicleScope::getHCEmission(const std::string& vehicleID) const {
    2323           0 :     return getDouble(libsumo::VAR_HCEMISSION, vehicleID);
    2324             : }
    2325             : 
    2326             : double
    2327           0 : TraCIAPI::VehicleScope::getPMxEmission(const std::string& vehicleID) const {
    2328           0 :     return getDouble(libsumo::VAR_PMXEMISSION, vehicleID);
    2329             : }
    2330             : 
    2331             : double
    2332           0 : TraCIAPI::VehicleScope::getNOxEmission(const std::string& vehicleID) const {
    2333           0 :     return getDouble(libsumo::VAR_NOXEMISSION, vehicleID);
    2334             : }
    2335             : 
    2336             : double
    2337           0 : TraCIAPI::VehicleScope::getFuelConsumption(const std::string& vehicleID) const {
    2338           0 :     return getDouble(libsumo::VAR_FUELCONSUMPTION, vehicleID);
    2339             : }
    2340             : 
    2341             : double
    2342           0 : TraCIAPI::VehicleScope::getNoiseEmission(const std::string& vehicleID) const {
    2343           0 :     return getDouble(libsumo::VAR_NOISEEMISSION, vehicleID);
    2344             : }
    2345             : 
    2346             : double
    2347           0 : TraCIAPI::VehicleScope::getElectricityConsumption(const std::string& vehicleID) const {
    2348           0 :     return getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, vehicleID);
    2349             : }
    2350             : 
    2351             : double
    2352           1 : TraCIAPI::VehicleScope::getWaitingTime(const std::string& vehID) const {
    2353           1 :     return getDouble(libsumo::VAR_WAITING_TIME, vehID);
    2354             : }
    2355             : 
    2356             : int
    2357           1 : TraCIAPI::VehicleScope::getLaneChangeMode(const std::string& vehID) const {
    2358           1 :     return getInt(libsumo::VAR_LANECHANGE_MODE, vehID);
    2359             : }
    2360             : 
    2361             : 
    2362             : int
    2363           2 : TraCIAPI::VehicleScope::getSpeedMode(const std::string& vehID) const {
    2364           2 :     return getInt(libsumo::VAR_SPEEDSETMODE, vehID);
    2365             : }
    2366             : 
    2367             : 
    2368             : double
    2369           1 : TraCIAPI::VehicleScope::getSlope(const std::string& vehID) const {
    2370           1 :     return getDouble(libsumo::VAR_SLOPE, vehID);
    2371             : }
    2372             : 
    2373             : 
    2374             : std::string
    2375           1 : TraCIAPI::VehicleScope::getLine(const std::string& typeID) const {
    2376           1 :     return getString(libsumo::VAR_LINE, typeID);
    2377             : }
    2378             : 
    2379             : std::vector<std::string>
    2380           1 : TraCIAPI::VehicleScope::getVia(const std::string& vehicleID) const {
    2381           1 :     return getStringVector(libsumo::VAR_VIA, vehicleID);
    2382             : }
    2383             : 
    2384             : std::string
    2385           0 : TraCIAPI::VehicleScope::getEmissionClass(const std::string& vehicleID) const {
    2386           0 :     return getString(libsumo::VAR_EMISSIONCLASS, vehicleID);
    2387             : }
    2388             : 
    2389             : std::string
    2390           1 : TraCIAPI::VehicleScope::getShapeClass(const std::string& vehicleID) const {
    2391           1 :     return getString(libsumo::VAR_SHAPECLASS, vehicleID);
    2392             : }
    2393             : 
    2394             : std::vector<libsumo::TraCINextTLSData>
    2395           1 : TraCIAPI::VehicleScope::getNextTLS(const std::string& vehID) const {
    2396             :     std::vector<libsumo::TraCINextTLSData> result;
    2397           1 :     myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_NEXT_TLS, vehID);
    2398           1 :     if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
    2399           1 :         myParent.myInput.readInt(); // components
    2400             :         // number of items
    2401           1 :         myParent.myInput.readUnsignedByte();
    2402           1 :         const int n = myParent.myInput.readInt();
    2403           2 :         for (int i = 0; i < n; ++i) {
    2404             :             libsumo::TraCINextTLSData d;
    2405           1 :             myParent.myInput.readUnsignedByte();
    2406           1 :             d.id = myParent.myInput.readString();
    2407             : 
    2408           1 :             myParent.myInput.readUnsignedByte();
    2409           1 :             d.tlIndex = myParent.myInput.readInt();
    2410             : 
    2411           1 :             myParent.myInput.readUnsignedByte();
    2412           1 :             d.dist = myParent.myInput.readDouble();
    2413             : 
    2414           1 :             myParent.myInput.readUnsignedByte();
    2415           1 :             d.state = (char)myParent.myInput.readByte();
    2416             : 
    2417           1 :             result.push_back(d);
    2418             :         }
    2419             :     }
    2420           1 :     return result;
    2421           0 : }
    2422             : 
    2423             : std::vector<libsumo::TraCIBestLanesData>
    2424           0 : TraCIAPI::VehicleScope::getBestLanes(const std::string& vehicleID) const {
    2425             :     std::vector<libsumo::TraCIBestLanesData> result;
    2426           0 :     myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_BEST_LANES, vehicleID);
    2427           0 :     if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
    2428           0 :         myParent.myInput.readInt();
    2429           0 :         myParent.myInput.readUnsignedByte();
    2430             : 
    2431           0 :         const int n = myParent.myInput.readInt(); // number of following edge information
    2432           0 :         for (int i = 0; i < n; ++i) {
    2433             :             libsumo::TraCIBestLanesData info;
    2434           0 :             myParent.myInput.readUnsignedByte();
    2435           0 :             info.laneID = myParent.myInput.readString();
    2436             : 
    2437           0 :             myParent.myInput.readUnsignedByte();
    2438           0 :             info.length = myParent.myInput.readDouble();
    2439             : 
    2440           0 :             myParent.myInput.readUnsignedByte();
    2441           0 :             info.occupation = myParent.myInput.readDouble();
    2442             : 
    2443           0 :             myParent.myInput.readUnsignedByte();
    2444           0 :             info.bestLaneOffset = myParent.myInput.readByte();
    2445             : 
    2446           0 :             myParent.myInput.readUnsignedByte();
    2447           0 :             info.allowsContinuation = (myParent.myInput.readUnsignedByte() == 1);
    2448             : 
    2449           0 :             myParent.myInput.readUnsignedByte();
    2450           0 :             const int m = myParent.myInput.readInt();
    2451           0 :             for (int j = 0; j < m; ++j) {
    2452           0 :                 info.continuationLanes.push_back(myParent.myInput.readString());
    2453             :             }
    2454             : 
    2455           0 :             result.push_back(info);
    2456           0 :         }
    2457             :     }
    2458           0 :     return result;
    2459           0 : }
    2460             : 
    2461             : 
    2462             : std::pair<std::string, double>
    2463           1 : TraCIAPI::VehicleScope::getLeader(const std::string& vehicleID, double dist) const {
    2464           1 :     tcpip::Storage content;
    2465           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2466           1 :     content.writeDouble(dist);
    2467           1 :     myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_LEADER, vehicleID, &content);
    2468           1 :     if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
    2469           1 :         myParent.myInput.readInt(); // components
    2470           1 :         myParent.myInput.readUnsignedByte();
    2471           1 :         const std::string leaderID = myParent.myInput.readString();
    2472           1 :         myParent.myInput.readUnsignedByte();
    2473           1 :         const double gap = myParent.myInput.readDouble();
    2474             :         return std::make_pair(leaderID, gap);
    2475             :     }
    2476             :     return std::make_pair("", libsumo::INVALID_DOUBLE_VALUE);
    2477           1 : }
    2478             : 
    2479             : 
    2480             : std::pair<std::string, double>
    2481           1 : TraCIAPI::VehicleScope::getFollower(const std::string& vehicleID, double dist) const {
    2482           1 :     tcpip::Storage content;
    2483           1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2484           1 :     content.writeDouble(dist);
    2485           1 :     myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_FOLLOWER, vehicleID, &content);
    2486           1 :     if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
    2487           1 :         myParent.myInput.readInt(); // components
    2488           1 :         myParent.myInput.readUnsignedByte();
    2489           1 :         const std::string leaderID = myParent.myInput.readString();
    2490           1 :         myParent.myInput.readUnsignedByte();
    2491           1 :         const double gap = myParent.myInput.readDouble();
    2492             :         return std::make_pair(leaderID, gap);
    2493             :     }
    2494             :     return std::make_pair("", libsumo::INVALID_DOUBLE_VALUE);
    2495           1 : }
    2496             : 
    2497             : 
    2498             : std::pair<int, int>
    2499           2 : TraCIAPI::VehicleScope::getLaneChangeState(const std::string& vehicleID, int direction) const {
    2500           2 :     tcpip::Storage content;
    2501           2 :     content.writeByte(libsumo::TYPE_INTEGER);
    2502           2 :     content.writeInt(direction);
    2503           2 :     myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
    2504           2 :     if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
    2505           2 :         myParent.myInput.readInt(); // components
    2506           2 :         myParent.myInput.readUnsignedByte();
    2507           2 :         const int stateWithoutTraCI = myParent.myInput.readInt();
    2508           2 :         myParent.myInput.readUnsignedByte();
    2509           2 :         const int state = myParent.myInput.readInt();
    2510             :         return std::make_pair(stateWithoutTraCI, state);
    2511             :     }
    2512           0 :     return std::make_pair(libsumo::INVALID_INT_VALUE, libsumo::INVALID_INT_VALUE);
    2513           2 : }
    2514             : 
    2515             : 
    2516             : int
    2517           1 : TraCIAPI::VehicleScope::getStopState(const std::string& vehicleID) const {
    2518           1 :     return getInt(libsumo::VAR_STOPSTATE, vehicleID);
    2519             : }
    2520             : 
    2521             : int
    2522           1 : TraCIAPI::VehicleScope::getRoutingMode(const std::string& vehicleID) const {
    2523           1 :     return getInt(libsumo::VAR_ROUTING_MODE, vehicleID);
    2524             : }
    2525             : 
    2526             : double
    2527           1 : TraCIAPI::VehicleScope::getStopDelay(const std::string& vehicleID) const {
    2528           1 :     return getDouble(libsumo::VAR_STOP_DELAY, vehicleID);
    2529             : }
    2530             : 
    2531             : double
    2532           0 : TraCIAPI::VehicleScope::getStopArrivalDelay(const std::string& vehicleID) const {
    2533           0 :     return getDouble(libsumo::VAR_STOP_ARRIVALDELAY, vehicleID);
    2534             : }
    2535             : 
    2536             : 
    2537             : double
    2538           0 : TraCIAPI::VehicleScope::getAccel(const std::string& vehicleID) const {
    2539           0 :     return getDouble(libsumo::VAR_ACCEL, vehicleID);
    2540             : }
    2541             : 
    2542             : double
    2543           0 : TraCIAPI::VehicleScope::getDecel(const std::string& vehicleID) const {
    2544           0 :     return getDouble(libsumo::VAR_DECEL, vehicleID);
    2545             : }
    2546             : 
    2547             : double
    2548           0 : TraCIAPI::VehicleScope::getTau(const std::string& vehicleID) const {
    2549           0 :     return getDouble(libsumo::VAR_TAU, vehicleID);
    2550             : }
    2551             : 
    2552             : double
    2553           0 : TraCIAPI::VehicleScope::getImperfection(const std::string& vehicleID) const {
    2554           0 :     return getDouble(libsumo::VAR_IMPERFECTION, vehicleID);
    2555             : }
    2556             : 
    2557             : double
    2558           0 : TraCIAPI::VehicleScope::getSpeedFactor(const std::string& vehicleID) const {
    2559           0 :     return getDouble(libsumo::VAR_SPEED_FACTOR, vehicleID);
    2560             : }
    2561             : 
    2562             : double
    2563           0 : TraCIAPI::VehicleScope::getSpeedDeviation(const std::string& vehicleID) const {
    2564           0 :     return getDouble(libsumo::VAR_SPEED_DEVIATION, vehicleID);
    2565             : }
    2566             : 
    2567             : std::string
    2568           0 : TraCIAPI::VehicleScope::getVehicleClass(const std::string& vehicleID) const {
    2569           0 :     return getString(libsumo::VAR_VEHICLECLASS, vehicleID);
    2570             : }
    2571             : 
    2572             : double
    2573           0 : TraCIAPI::VehicleScope::getMinGap(const std::string& vehicleID) const {
    2574           0 :     return getDouble(libsumo::VAR_MINGAP, vehicleID);
    2575             : }
    2576             : 
    2577             : double
    2578           0 : TraCIAPI::VehicleScope::getWidth(const std::string& vehicleID) const {
    2579           0 :     return getDouble(libsumo::VAR_WIDTH, vehicleID);
    2580             : }
    2581             : 
    2582             : double
    2583           0 : TraCIAPI::VehicleScope::getLength(const std::string& vehicleID) const {
    2584           0 :     return getDouble(libsumo::VAR_LENGTH, vehicleID);
    2585             : }
    2586             : 
    2587             : double
    2588           0 : TraCIAPI::VehicleScope::getHeight(const std::string& vehicleID) const {
    2589           0 :     return getDouble(libsumo::VAR_HEIGHT, vehicleID);
    2590             : }
    2591             : 
    2592             : double
    2593           1 : TraCIAPI::VehicleScope::getAccumulatedWaitingTime(const std::string& vehicleID) const {
    2594           1 :     return getDouble(libsumo::VAR_ACCUMULATED_WAITING_TIME, vehicleID);
    2595             : }
    2596             : 
    2597             : double
    2598           0 : TraCIAPI::VehicleScope::getAllowedSpeed(const std::string& vehicleID) const {
    2599           0 :     return getDouble(libsumo::VAR_ALLOWED_SPEED, vehicleID);
    2600             : }
    2601             : 
    2602             : int
    2603           0 : TraCIAPI::VehicleScope::getPersonNumber(const std::string& vehicleID) const {
    2604           0 :     return getInt(libsumo::VAR_PERSON_NUMBER, vehicleID);
    2605             : }
    2606             : 
    2607             : int
    2608           1 : TraCIAPI::VehicleScope::getPersonCapacity(const std::string& vehicleID) const {
    2609           1 :     return getInt(libsumo::VAR_PERSON_CAPACITY, vehicleID);
    2610             : }
    2611             : 
    2612             : std::vector<std::string>
    2613           0 : TraCIAPI::VehicleScope::getPersonIDList(const std::string& vehicleID) const {
    2614           0 :     return getStringVector(libsumo::LAST_STEP_PERSON_ID_LIST, vehicleID);
    2615             : }
    2616             : 
    2617             : double
    2618           0 : TraCIAPI::VehicleScope::getSpeedWithoutTraCI(const std::string& vehicleID) const {
    2619           0 :     return getDouble(libsumo::VAR_SPEED_WITHOUT_TRACI, vehicleID);
    2620             : }
    2621             : 
    2622             : bool
    2623           1 : TraCIAPI::VehicleScope::isRouteValid(const std::string& vehicleID) const {
    2624           1 :     return getInt(libsumo::VAR_ROUTE_VALID, vehicleID) != 0;
    2625             : }
    2626             : 
    2627             : double
    2628           0 : TraCIAPI::VehicleScope::getMaxSpeedLat(const std::string& vehicleID) const {
    2629           0 :     return getDouble(libsumo::VAR_MAXSPEED_LAT, vehicleID);
    2630             : }
    2631             : 
    2632             : double
    2633           0 : TraCIAPI::VehicleScope::getMinGapLat(const std::string& vehicleID) const {
    2634           0 :     return getDouble(libsumo::VAR_MINGAP_LAT, vehicleID);
    2635             : }
    2636             : 
    2637             : std::string
    2638           0 : TraCIAPI::VehicleScope::getLateralAlignment(const std::string& vehicleID) const {
    2639           0 :     return getString(libsumo::VAR_LATALIGNMENT, vehicleID);
    2640             : }
    2641             : 
    2642             : void
    2643           2 : TraCIAPI::VehicleScope::add(const std::string& vehicleID,
    2644             :                             const std::string& routeID,
    2645             :                             const std::string& typeID,
    2646             :                             std::string depart,
    2647             :                             const std::string& departLane,
    2648             :                             const std::string& departPos,
    2649             :                             const std::string& departSpeed,
    2650             :                             const std::string& arrivalLane,
    2651             :                             const std::string& arrivalPos,
    2652             :                             const std::string& arrivalSpeed,
    2653             :                             const std::string& fromTaz,
    2654             :                             const std::string& toTaz,
    2655             :                             const std::string& line,
    2656             :                             int personCapacity,
    2657             :                             int personNumber) const {
    2658             : 
    2659           2 :     if (depart == "-1") {
    2660           4 :         depart = toString(myParent.simulation.getCurrentTime() / 1000.0);
    2661             :     }
    2662           2 :     tcpip::Storage content;
    2663           2 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2664           2 :     content.writeInt(14);
    2665           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2666           2 :     content.writeString(routeID);
    2667           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2668           2 :     content.writeString(typeID);
    2669           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2670           2 :     content.writeString(depart);
    2671           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2672           2 :     content.writeString(departLane);
    2673           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2674           2 :     content.writeString(departPos);
    2675           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2676           2 :     content.writeString(departSpeed);
    2677             : 
    2678           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2679           2 :     content.writeString(arrivalLane);
    2680           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2681           2 :     content.writeString(arrivalPos);
    2682           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2683           2 :     content.writeString(arrivalSpeed);
    2684             : 
    2685           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2686           2 :     content.writeString(fromTaz);
    2687           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2688           2 :     content.writeString(toTaz);
    2689           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2690           2 :     content.writeString(line);
    2691             : 
    2692           2 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    2693           2 :     content.writeInt(personCapacity);
    2694           2 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    2695           2 :     content.writeInt(personNumber);
    2696             : 
    2697           2 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::ADD_FULL, vehicleID, &content);
    2698           2 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2699           2 : }
    2700             : 
    2701             : 
    2702             : void
    2703           1 : TraCIAPI::VehicleScope::remove(const std::string& vehicleID, char reason) const {
    2704           1 :     tcpip::Storage content;
    2705           1 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2706           1 :     content.writeUnsignedByte(reason);
    2707           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::REMOVE, vehicleID, &content);
    2708           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2709             : 
    2710           1 : }
    2711             : 
    2712             : 
    2713             : void
    2714           1 : TraCIAPI::VehicleScope::changeTarget(const std::string& vehicleID, const std::string& edgeID) const {
    2715           1 :     tcpip::Storage content;
    2716           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2717           1 :     content.writeString(edgeID);
    2718           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGETARGET, vehicleID, &content);
    2719           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2720           1 : }
    2721             : 
    2722             : 
    2723             : void
    2724           0 : TraCIAPI::VehicleScope::changeLane(const std::string& vehicleID, int laneIndex, double duration) const {
    2725           0 :     tcpip::Storage content;
    2726           0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2727           0 :     content.writeInt(2);
    2728           0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2729           0 :     content.writeByte(laneIndex);
    2730           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2731           0 :     content.writeDouble(duration);
    2732           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
    2733           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2734           0 : }
    2735             : 
    2736             : 
    2737             : void
    2738           0 : TraCIAPI::VehicleScope::changeLaneRelative(const std::string& vehicleID, int laneChange, double duration) const {
    2739           0 :     tcpip::Storage content;
    2740           0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2741           0 :     content.writeInt(3);
    2742           0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2743           0 :     content.writeByte(laneChange);
    2744           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2745           0 :     content.writeDouble(duration);
    2746           0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2747           0 :     content.writeByte(1);
    2748           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
    2749           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2750           0 : }
    2751             : 
    2752             : 
    2753             : void
    2754           0 : TraCIAPI::VehicleScope::changeSublane(const std::string& vehicleID, double latDist) const {
    2755           0 :     tcpip::Storage content;
    2756           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2757           0 :     content.writeDouble(latDist);
    2758           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGESUBLANE, vehicleID, &content);
    2759           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2760           0 : }
    2761             : 
    2762             : 
    2763             : void
    2764           1 : TraCIAPI::VehicleScope::setRouteID(const std::string& vehicleID, const std::string& routeID) const {
    2765           1 :     tcpip::Storage content;
    2766           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2767           1 :     content.writeString(routeID);
    2768           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTE_ID, vehicleID, &content);
    2769           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2770           1 : }
    2771             : 
    2772             : 
    2773             : void
    2774           1 : TraCIAPI::VehicleScope::setRoute(const std::string& vehicleID, const std::vector<std::string>& edges) const {
    2775           1 :     tcpip::Storage content;
    2776           1 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    2777           1 :     content.writeInt((int)edges.size());
    2778          11 :     for (int i = 0; i < (int)edges.size(); ++i) {
    2779          10 :         content.writeString(edges[i]);
    2780             :     }
    2781           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTE, vehicleID, &content);
    2782           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2783           1 : }
    2784             : 
    2785             : 
    2786             : void
    2787           1 : TraCIAPI::VehicleScope::rerouteTraveltime(const std::string& vehicleID, bool currentTravelTimes) const {
    2788           1 :     if (currentTravelTimes) {
    2789             :         // updated edge weights with current network traveltimes (at most once per simulation step)
    2790           1 :         std::vector<std::string> edges = myParent.edge.getIDList();
    2791          48 :         for (std::vector<std::string>::iterator it = edges.begin(); it != edges.end(); ++it) {
    2792          47 :             myParent.edge.adaptTraveltime(*it, myParent.edge.getTraveltime(*it));
    2793             :         }
    2794           1 :     }
    2795             : 
    2796           1 :     tcpip::Storage content;
    2797           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2798           1 :     content.writeInt(0);
    2799           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_REROUTE_TRAVELTIME, vehicleID, &content);
    2800           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2801           1 : }
    2802             : 
    2803             : void
    2804           1 : TraCIAPI::VehicleScope::moveTo(const std::string& vehicleID, const std::string& laneID, double position, int reason) const {
    2805           1 :     tcpip::Storage content;
    2806           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2807           1 :     content.writeInt(3);
    2808           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2809           1 :     content.writeString(laneID);
    2810           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2811           1 :     content.writeDouble(position);
    2812           1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    2813           1 :     content.writeInt(reason);
    2814           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MOVE_TO, vehicleID, &content);
    2815           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2816           1 : }
    2817             : 
    2818             : void
    2819           1 : TraCIAPI::VehicleScope::moveToXY(const std::string& vehicleID, const std::string& edgeID, const int lane, const double x, const double y, const double angle, const int keepRoute) const {
    2820           1 :     tcpip::Storage content;
    2821           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2822           1 :     content.writeInt(6);
    2823           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2824           1 :     content.writeString(edgeID);
    2825           1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    2826           1 :     content.writeInt(lane);
    2827           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2828           1 :     content.writeDouble(x);
    2829           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2830           1 :     content.writeDouble(y);
    2831           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2832           1 :     content.writeDouble(angle);
    2833           1 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2834           1 :     content.writeByte(keepRoute);
    2835           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::MOVE_TO_XY, vehicleID, &content);
    2836           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2837           1 : }
    2838             : 
    2839             : 
    2840             : void
    2841           0 : TraCIAPI::VehicleScope::slowDown(const std::string& vehicleID, double speed, double duration) const {
    2842           0 :     tcpip::Storage content;
    2843           0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2844           0 :     content.writeInt(2);
    2845           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2846           0 :     content.writeDouble(speed);
    2847           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2848           0 :     content.writeDouble(duration);
    2849           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_SLOWDOWN, vehicleID, &content);
    2850           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2851           0 : }
    2852             : 
    2853             : void
    2854           0 : TraCIAPI::VehicleScope::openGap(const std::string& vehicleID, double newTau, double duration, double changeRate, double maxDecel) const {
    2855           0 :     tcpip::Storage content;
    2856           0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2857           0 :     if (maxDecel > 0) {
    2858           0 :         content.writeInt(4);
    2859             :     } else {
    2860           0 :         content.writeInt(3);
    2861             :     }
    2862           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2863           0 :     content.writeDouble(newTau);
    2864           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2865           0 :     content.writeDouble(duration);
    2866           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2867           0 :     content.writeDouble(changeRate);
    2868           0 :     if (maxDecel > 0) {
    2869           0 :         content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2870           0 :         content.writeDouble(maxDecel);
    2871             :     }
    2872           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_OPENGAP, vehicleID, &content);
    2873           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2874           0 : }
    2875             : 
    2876             : void
    2877           0 : TraCIAPI::VehicleScope::setSpeed(const std::string& vehicleID, double speed) const {
    2878           0 :     tcpip::Storage content;
    2879           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2880           0 :     content.writeDouble(speed);
    2881           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEED, vehicleID, &content);
    2882           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2883           0 : }
    2884             : 
    2885             : void
    2886           0 : TraCIAPI::VehicleScope::setAcceleration(const std::string& vehicleID, double accel, double duration) const {
    2887           0 :     tcpip::Storage content;
    2888           0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2889           0 :     content.writeInt(2);
    2890           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2891           0 :     content.writeDouble(accel);
    2892           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2893           0 :     content.writeDouble(duration);
    2894           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ACCELERATION, vehicleID, &content);
    2895           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2896           0 : }
    2897             : 
    2898             : void
    2899           0 : TraCIAPI::VehicleScope::setPreviousSpeed(const std::string& vehicleID, double prevSpeed, double prevAcceleration) const {
    2900           0 :     tcpip::Storage content;
    2901           0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2902           0 :     content.writeInt(2);
    2903           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2904           0 :     content.writeDouble(prevSpeed);
    2905           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2906           0 :     content.writeDouble(prevAcceleration);
    2907           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_PREV_SPEED, vehicleID, &content);
    2908           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2909           0 : }
    2910             : 
    2911             : void
    2912           1 : TraCIAPI::VehicleScope::setLaneChangeMode(const std::string& vehicleID, int mode) const {
    2913           1 :     tcpip::Storage content;
    2914           1 :     content.writeByte(libsumo::TYPE_INTEGER);
    2915           1 :     content.writeInt(mode);
    2916           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_LANECHANGE_MODE, vehicleID, &content);
    2917           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2918           1 : }
    2919             : 
    2920             : void
    2921           1 : TraCIAPI::VehicleScope::setSpeedMode(const std::string& vehicleID, int mode) const {
    2922           1 :     tcpip::Storage content;
    2923           1 :     content.writeByte(libsumo::TYPE_INTEGER);
    2924           1 :     content.writeInt(mode);
    2925           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEEDSETMODE, vehicleID, &content);
    2926           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2927           1 : }
    2928             : 
    2929             : void
    2930           0 : TraCIAPI::VehicleScope::setStop(const std::string vehicleID, const std::string edgeID, const double endPos, const int laneIndex,
    2931             :                                 const double duration, const int flags, const double startPos, const double until) const {
    2932           0 :     tcpip::Storage content;
    2933           0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2934           0 :     content.writeInt(7);
    2935           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2936           0 :     content.writeString(edgeID);
    2937           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2938           0 :     content.writeDouble(endPos);
    2939           0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2940           0 :     content.writeByte(laneIndex);
    2941           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2942           0 :     content.writeDouble(duration);
    2943           0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2944           0 :     content.writeByte(flags);
    2945           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2946           0 :     content.writeDouble(startPos);
    2947           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2948           0 :     content.writeDouble(until);
    2949           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_STOP, vehicleID, &content);
    2950           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2951           0 : }
    2952             : 
    2953             : void
    2954           1 : TraCIAPI::VehicleScope::setType(const std::string& vehicleID, const std::string& typeID) const {
    2955           1 :     tcpip::Storage content;
    2956           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2957           1 :     content.writeString(typeID);
    2958           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_TYPE, vehicleID, &content);
    2959           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2960           1 : }
    2961             : 
    2962             : void
    2963           1 : TraCIAPI::VehicleScope::setSpeedFactor(const std::string& vehicleID, double factor) const {
    2964           1 :     tcpip::Storage content;
    2965           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2966           1 :     content.writeDouble(factor);
    2967           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEED_FACTOR, vehicleID, &content);
    2968           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2969           1 : }
    2970             : 
    2971             : void
    2972           0 : TraCIAPI::VehicleScope::setMinGap(const std::string& vehicleID, double minGap) const {
    2973           0 :     tcpip::Storage content;
    2974           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2975           0 :     content.writeDouble(minGap);
    2976           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MINGAP, vehicleID, &content);
    2977           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2978           0 : }
    2979             : 
    2980             : void
    2981           1 : TraCIAPI::VehicleScope::setMaxSpeed(const std::string& vehicleID, double speed) const {
    2982           1 :     tcpip::Storage content;
    2983           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2984           1 :     content.writeDouble(speed);
    2985           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MAXSPEED, vehicleID, &content);
    2986           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2987           1 : }
    2988             : 
    2989             : void
    2990           1 : TraCIAPI::VehicleScope::setColor(const std::string& vehicleID, const libsumo::TraCIColor& c) const {
    2991           1 :     tcpip::Storage content;
    2992           1 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    2993           1 :     content.writeUnsignedByte(c.r);
    2994           1 :     content.writeUnsignedByte(c.g);
    2995           1 :     content.writeUnsignedByte(c.b);
    2996           1 :     content.writeUnsignedByte(c.a);
    2997           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_COLOR, vehicleID, &content);
    2998           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2999           1 : }
    3000             : 
    3001             : void
    3002           1 : TraCIAPI::VehicleScope::setLine(const std::string& vehicleID, const std::string& line) const {
    3003           1 :     tcpip::Storage content;
    3004           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3005           1 :     content.writeString(line);
    3006           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_LINE, vehicleID, &content);
    3007           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3008           1 : }
    3009             : 
    3010             : void
    3011           1 : TraCIAPI::VehicleScope::setVia(const std::string& vehicleID, const std::vector<std::string>& via) const {
    3012           1 :     tcpip::Storage content;
    3013           1 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    3014           1 :     content.writeInt((int)via.size());
    3015           2 :     for (int i = 0; i < (int)via.size(); ++i) {
    3016           1 :         content.writeString(via[i]);
    3017             :     }
    3018           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_VIA, vehicleID, &content);
    3019           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3020           1 : }
    3021             : 
    3022             : void
    3023           1 : TraCIAPI::VehicleScope::setSignals(const std::string& vehicleID, int signals) const {
    3024           1 :     tcpip::Storage content;
    3025           1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3026           1 :     content.writeInt(signals);
    3027           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SIGNALS, vehicleID, &content);
    3028           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3029           1 : }
    3030             : 
    3031             : void
    3032           1 : TraCIAPI::VehicleScope::setRoutingMode(const std::string& vehicleID, int routingMode) const {
    3033           1 :     tcpip::Storage content;
    3034           1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3035           1 :     content.writeInt(routingMode);
    3036           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTING_MODE, vehicleID, &content);
    3037           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3038           1 : }
    3039             : 
    3040             : void
    3041           1 : TraCIAPI::VehicleScope::setShapeClass(const std::string& vehicleID, const std::string& clazz) const {
    3042           1 :     tcpip::Storage content;
    3043           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3044           1 :     content.writeString(clazz);
    3045           1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SHAPECLASS, vehicleID, &content);
    3046           1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3047           1 : }
    3048             : 
    3049             : 
    3050             : void
    3051           0 : TraCIAPI::VehicleScope::setEmissionClass(const std::string& vehicleID, const std::string& clazz) const {
    3052           0 :     tcpip::Storage content;
    3053           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3054           0 :     content.writeString(clazz);
    3055           0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_EMISSIONCLASS, vehicleID, &content);
    3056           0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3057           0 : }
    3058             : 
    3059             : void
    3060           1 : TraCIAPI::VehicleScope::addSubscriptionFilterLanes(const std::vector<int>& lanes,
    3061             :         bool noOpposite, double downstreamDist, double upstreamDist) const {
    3062           1 :     addSubscriptionFilterByteList(libsumo::FILTER_TYPE_LANES, lanes);
    3063           1 :     if (noOpposite) {
    3064           0 :         addSubscriptionFilterNoOpposite();
    3065             :     }
    3066           1 :     if (downstreamDist >= 0) {
    3067           0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    3068             :     }
    3069           1 :     if (upstreamDist >= 0) {
    3070           0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    3071             :     }
    3072           1 : }
    3073             : 
    3074             : 
    3075             : void
    3076           1 : TraCIAPI::VehicleScope::addSubscriptionFilterNoOpposite() const {
    3077           1 :     addSubscriptionFilterEmpty(libsumo::FILTER_TYPE_NOOPPOSITE);
    3078           1 : }
    3079             : 
    3080             : void
    3081           1 : TraCIAPI::VehicleScope::addSubscriptionFilterDownstreamDistance(double dist) const {
    3082           1 :     addSubscriptionFilterFloat(libsumo::FILTER_TYPE_DOWNSTREAM_DIST, dist);
    3083           1 : }
    3084             : 
    3085             : void
    3086           1 : TraCIAPI::VehicleScope::addSubscriptionFilterUpstreamDistance(double dist) const {
    3087           1 :     addSubscriptionFilterFloat(libsumo::FILTER_TYPE_UPSTREAM_DIST, dist);
    3088           1 : }
    3089             : 
    3090             : 
    3091             : void
    3092           1 : TraCIAPI::VehicleScope::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) const {
    3093           1 :     addSubscriptionFilterLeadFollow(std::vector<int>({0}));
    3094           1 :     if (downstreamDist >= 0) {
    3095           0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    3096             :     }
    3097           1 :     if (upstreamDist >= 0) {
    3098           0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    3099             :     }
    3100           1 : }
    3101             : 
    3102             : void
    3103           1 : TraCIAPI::VehicleScope::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) const {
    3104           1 :     if (abs(direction) != 1) {
    3105           0 :         std::cerr << "Ignoring lane change subscription filter with non-neighboring lane offset direction " << direction << "\n";
    3106           0 :         return;
    3107             :     }
    3108           1 :     addSubscriptionFilterLeadFollow(std::vector<int>({0, direction}));
    3109           1 :     if (noOpposite) {
    3110           0 :         addSubscriptionFilterNoOpposite();
    3111             :     }
    3112           1 :     if (downstreamDist >= 0) {
    3113           0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    3114             :     }
    3115           1 :     if (upstreamDist >= 0) {
    3116           0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    3117             :     }
    3118             : }
    3119             : 
    3120             : void
    3121           3 : TraCIAPI::VehicleScope::addSubscriptionFilterLeadFollow(const std::vector<int>& lanes) const {
    3122           3 :     addSubscriptionFilterEmpty(libsumo::FILTER_TYPE_LEAD_FOLLOW);
    3123           3 :     addSubscriptionFilterByteList(libsumo::FILTER_TYPE_LANES, lanes);
    3124           3 : }
    3125             : 
    3126             : void
    3127           1 : TraCIAPI::VehicleScope::addSubscriptionFilterTurn(double downstreamDist, double foeDistToJunction) const {
    3128           1 :     addSubscriptionFilterFloat(libsumo::FILTER_TYPE_TURN, foeDistToJunction);
    3129           1 :     if (downstreamDist >= 0) {
    3130           0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    3131             :     }
    3132           1 : }
    3133             : 
    3134             : 
    3135             : void
    3136           1 : TraCIAPI::VehicleScope::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) const {
    3137           1 :     addSubscriptionFilterStringList(libsumo::FILTER_TYPE_VCLASS, vClasses);
    3138           1 : }
    3139             : 
    3140             : 
    3141             : void
    3142           1 : TraCIAPI::VehicleScope::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) const {
    3143           1 :     addSubscriptionFilterStringList(libsumo::FILTER_TYPE_VTYPE, vTypes);
    3144           1 : }
    3145             : 
    3146             : 
    3147             : void
    3148           1 : TraCIAPI::VehicleScope::addSubscriptionFilterFieldOfVision(double angle) const {
    3149           1 :     addSubscriptionFilterFloat(libsumo::FILTER_TYPE_FIELD_OF_VISION, angle);
    3150           1 : }
    3151             : 
    3152             : void
    3153           1 : TraCIAPI::VehicleScope::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) const {
    3154           1 :     addSubscriptionFilterFloat(libsumo::FILTER_TYPE_LATERAL_DIST, lateralDist);
    3155           1 :     if (downstreamDist >= 0) {
    3156           0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    3157             :     }
    3158           1 :     if (upstreamDist >= 0) {
    3159           0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    3160             :     }
    3161           1 : }
    3162             : 
    3163             : void
    3164           4 : TraCIAPI::VehicleScope::addSubscriptionFilterEmpty(int filterType) const {
    3165           4 :     myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType);
    3166           4 :     myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
    3167           4 : }
    3168             : 
    3169             : void
    3170           5 : TraCIAPI::VehicleScope::addSubscriptionFilterFloat(int filterType, double val) const {
    3171           5 :     tcpip::Storage content;
    3172           5 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3173           5 :     content.writeDouble(val);
    3174           5 :     myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
    3175           5 :     myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
    3176           5 : }
    3177             : 
    3178             : 
    3179             : void
    3180           2 : TraCIAPI::VehicleScope::addSubscriptionFilterStringList(int filterType, const std::vector<std::string>& vals) const {
    3181           2 :     tcpip::Storage content;
    3182           2 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    3183           2 :     content.writeStringList(vals);
    3184           2 :     myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
    3185           2 :     myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
    3186           2 : }
    3187             : 
    3188             : 
    3189             : void
    3190           4 : TraCIAPI::VehicleScope::addSubscriptionFilterByteList(int filterType, const std::vector<int>& vals) const {
    3191           4 :     tcpip::Storage content;
    3192           4 :     content.writeUnsignedByte((int)vals.size());
    3193          13 :     for (int i : vals)  {
    3194           9 :         content.writeByte(i);
    3195             :     }
    3196           4 :     myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
    3197           4 :     myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
    3198           4 : }
    3199             : 
    3200             : 
    3201             : // ---------------------------------------------------------------------------
    3202             : // TraCIAPI::PersonScope-methods
    3203             : // ---------------------------------------------------------------------------
    3204             : double
    3205           1 : TraCIAPI::PersonScope::getSpeed(const std::string& personID) const {
    3206           1 :     return getDouble(libsumo::VAR_SPEED, personID);
    3207             : }
    3208             : 
    3209             : libsumo::TraCIPosition
    3210           1 : TraCIAPI::PersonScope::getPosition(const std::string& personID) const {
    3211           1 :     return getPos(libsumo::VAR_POSITION, personID);
    3212             : }
    3213             : 
    3214             : libsumo::TraCIPosition
    3215           1 : TraCIAPI::PersonScope::getPosition3D(const std::string& personID) const {
    3216           1 :     return getPos3D(libsumo::VAR_POSITION3D, personID);
    3217             : }
    3218             : 
    3219             : double
    3220           1 : TraCIAPI::PersonScope::getAngle(const std::string& personID) const {
    3221           1 :     return getDouble(libsumo::VAR_ANGLE, personID);
    3222             : }
    3223             : 
    3224             : double
    3225           1 : TraCIAPI::PersonScope::getSlope(const std::string& personID) const {
    3226           1 :     return getDouble(libsumo::VAR_SLOPE, personID);
    3227             : }
    3228             : 
    3229             : double
    3230           1 : TraCIAPI::PersonScope::getLanePosition(const std::string& personID) const {
    3231           1 :     return getDouble(libsumo::VAR_LANEPOSITION, personID);
    3232             : }
    3233             : 
    3234             : libsumo::TraCIColor
    3235           1 : TraCIAPI::PersonScope::getColor(const std::string& personID) const {
    3236           1 :     return getCol(libsumo::VAR_COLOR, personID);
    3237             : }
    3238             : 
    3239             : double
    3240           1 : TraCIAPI::PersonScope::getLength(const std::string& personID) const {
    3241           1 :     return getDouble(libsumo::VAR_LENGTH, personID);
    3242             : }
    3243             : 
    3244             : std::string
    3245           1 : TraCIAPI::PersonScope::getRoadID(const std::string& personID) const {
    3246           1 :     return getString(libsumo::VAR_ROAD_ID, personID);
    3247             : }
    3248             : 
    3249             : std::string
    3250           1 : TraCIAPI::PersonScope::getLaneID(const std::string& personID) const {
    3251           1 :     return getString(libsumo::VAR_LANE_ID, personID);
    3252             : }
    3253             : 
    3254             : std::string
    3255           1 : TraCIAPI::PersonScope::getTypeID(const std::string& personID) const {
    3256           1 :     return getString(libsumo::VAR_TYPE, personID);
    3257             : }
    3258             : 
    3259             : double
    3260           0 : TraCIAPI::PersonScope::getSpeedFactor(const std::string& personID) const {
    3261           0 :     return getDouble(libsumo::VAR_SPEED_FACTOR, personID);
    3262             : }
    3263             : 
    3264             : double
    3265           1 : TraCIAPI::PersonScope::getWaitingTime(const std::string& personID) const {
    3266           1 :     return getDouble(libsumo::VAR_WAITING_TIME, personID);
    3267             : }
    3268             : 
    3269             : std::string
    3270           1 : TraCIAPI::PersonScope::getNextEdge(const std::string& personID) const {
    3271           1 :     return getString(libsumo::VAR_NEXT_EDGE, personID);
    3272             : }
    3273             : 
    3274             : 
    3275             : std::string
    3276           1 : TraCIAPI::PersonScope::getVehicle(const std::string& personID) const {
    3277           1 :     return getString(libsumo::VAR_VEHICLE, personID);
    3278             : }
    3279             : 
    3280             : int
    3281           7 : TraCIAPI::PersonScope::getRemainingStages(const std::string& personID) const {
    3282           7 :     return getInt(libsumo::VAR_STAGES_REMAINING, personID);
    3283             : }
    3284             : 
    3285             : libsumo::TraCIStage
    3286           2 : TraCIAPI::PersonScope::getStage(const std::string& personID, int nextStageIndex) const {
    3287           2 :     tcpip::Storage content;
    3288           2 :     content.writeByte(libsumo::TYPE_INTEGER);
    3289           2 :     content.writeInt(nextStageIndex);
    3290           4 :     return getTraCIStage(libsumo::VAR_STAGE, personID, &content);
    3291           2 : }
    3292             : 
    3293             : std::vector<std::string>
    3294           3 : TraCIAPI::PersonScope::getEdges(const std::string& personID, int nextStageIndex) const {
    3295           3 :     tcpip::Storage content;
    3296           3 :     content.writeByte(libsumo::TYPE_INTEGER);
    3297           3 :     content.writeInt(nextStageIndex);
    3298           6 :     return getStringVector(libsumo::VAR_EDGES, personID, &content);
    3299           3 : }
    3300             : 
    3301             : void
    3302           1 : TraCIAPI::PersonScope::removeStages(const std::string& personID) const {
    3303             :     // remove all stages after the current and then abort the current stage
    3304           3 :     while (getRemainingStages(personID) > 1) {
    3305           2 :         removeStage(personID, 1);
    3306             :     }
    3307           1 :     removeStage(personID, 0);
    3308           1 : }
    3309             : 
    3310             : 
    3311             : void
    3312           1 : TraCIAPI::PersonScope::rerouteTraveltime(const std::string& personID) const {
    3313           1 :     tcpip::Storage content;
    3314           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3315           1 :     content.writeInt(0);
    3316           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::CMD_REROUTE_TRAVELTIME, personID, &content);
    3317           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3318           1 : }
    3319             : 
    3320             : 
    3321             : void
    3322           1 : TraCIAPI::PersonScope::add(const std::string& personID, const std::string& edgeID, double pos, double depart, const std::string typeID) {
    3323           1 :     tcpip::Storage content;
    3324           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3325           1 :     content.writeInt(4);
    3326           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3327           1 :     content.writeString(typeID);
    3328           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3329           1 :     content.writeString(edgeID);
    3330           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3331           1 :     content.writeDouble(depart);
    3332           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3333           1 :     content.writeDouble(pos);
    3334           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::ADD, personID, &content);
    3335           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3336           1 : }
    3337             : 
    3338             : void
    3339           1 : TraCIAPI::PersonScope::appendStage(const std::string& personID, const libsumo::TraCIStage& stage) {
    3340           1 :     tcpip::Storage content;
    3341           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3342           1 :     content.writeInt(13);
    3343           1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3344           1 :     content.writeInt(stage.type);
    3345           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3346           1 :     content.writeString(stage.vType);
    3347           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3348           1 :     content.writeString(stage.line);
    3349           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3350           1 :     content.writeString(stage.destStop);
    3351           1 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    3352           1 :     content.writeStringList(stage.edges);
    3353           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3354           1 :     content.writeDouble(stage.travelTime);
    3355           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3356           1 :     content.writeDouble(stage.cost);
    3357           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3358           1 :     content.writeDouble(stage.length);
    3359           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3360           1 :     content.writeString(stage.intended);
    3361           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3362           1 :     content.writeDouble(stage.depart);
    3363           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3364           1 :     content.writeDouble(stage.departPos);
    3365           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3366           1 :     content.writeDouble(stage.arrivalPos);
    3367           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3368           1 :     content.writeString(stage.description);
    3369           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
    3370           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3371           1 : }
    3372             : 
    3373             : 
    3374             : void
    3375           1 : TraCIAPI::PersonScope::appendWaitingStage(const std::string& personID, double duration, const std::string& description, const std::string& stopID) {
    3376           1 :     tcpip::Storage content;
    3377           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3378           1 :     content.writeInt(4);
    3379           1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3380           1 :     content.writeInt(libsumo::STAGE_WAITING);
    3381           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3382           1 :     content.writeDouble(duration);
    3383           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3384           1 :     content.writeString(description);
    3385           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3386           1 :     content.writeString(stopID);
    3387           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
    3388           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3389           1 : }
    3390             : 
    3391             : void
    3392           2 : TraCIAPI::PersonScope::appendWalkingStage(const std::string& personID, const std::vector<std::string>& edges, double arrivalPos, double duration, double speed, const std::string& stopID) {
    3393           2 :     tcpip::Storage content;
    3394           2 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3395           2 :     content.writeInt(6);
    3396           2 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3397           2 :     content.writeInt(libsumo::STAGE_WALKING);
    3398           2 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    3399           2 :     content.writeStringList(edges);
    3400           2 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3401           2 :     content.writeDouble(arrivalPos);
    3402           2 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3403           2 :     content.writeDouble(duration);
    3404           2 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3405           2 :     content.writeDouble(speed);
    3406           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3407           2 :     content.writeString(stopID);
    3408           2 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
    3409           2 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3410           2 : }
    3411             : 
    3412             : void
    3413           1 : TraCIAPI::PersonScope::appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID) {
    3414           1 :     tcpip::Storage content;
    3415           1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3416           1 :     content.writeInt(4);
    3417           1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3418           1 :     content.writeInt(libsumo::STAGE_DRIVING);
    3419           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3420           1 :     content.writeString(toEdge);
    3421           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3422           1 :     content.writeString(lines);
    3423           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3424           1 :     content.writeString(stopID);
    3425           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
    3426           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3427           1 : }
    3428             : 
    3429             : void
    3430           4 : TraCIAPI::PersonScope::removeStage(const std::string& personID, int nextStageIndex) const {
    3431           4 :     tcpip::Storage content;
    3432           4 :     content.writeByte(libsumo::TYPE_INTEGER);
    3433           4 :     content.writeInt(nextStageIndex);
    3434           4 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::REMOVE_STAGE, personID, &content);
    3435           4 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3436           4 : }
    3437             : 
    3438             : void
    3439           0 : TraCIAPI::PersonScope::moveTo(const std::string& personID, const std::string& edgeID, double position) const {
    3440           0 :     tcpip::Storage content;
    3441           0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3442           0 :     content.writeInt(2);
    3443           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3444           0 :     content.writeString(edgeID);
    3445           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3446           0 :     content.writeDouble(position);
    3447           0 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_MOVE_TO, personID, &content);
    3448           0 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3449           0 : }
    3450             : 
    3451             : void
    3452           0 : TraCIAPI::PersonScope::moveToXY(const std::string& personID, const std::string& edgeID, const double x, const double y, double angle, const int keepRoute) const {
    3453           0 :     tcpip::Storage content;
    3454           0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3455           0 :     content.writeInt(5);
    3456           0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3457           0 :     content.writeString(edgeID);
    3458           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3459           0 :     content.writeDouble(x);
    3460           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3461           0 :     content.writeDouble(y);
    3462           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3463           0 :     content.writeDouble(angle);
    3464           0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    3465           0 :     content.writeByte(keepRoute);
    3466           0 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::MOVE_TO_XY, personID, &content);
    3467           0 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3468           0 : }
    3469             : 
    3470             : void
    3471           1 : TraCIAPI::PersonScope::setSpeed(const std::string& personID, double speed) const {
    3472           1 :     tcpip::Storage content;
    3473           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3474           1 :     content.writeDouble(speed);
    3475           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_SPEED, personID, &content);
    3476           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3477           1 : }
    3478             : 
    3479             : 
    3480             : void
    3481           1 : TraCIAPI::PersonScope::setType(const std::string& personID, const std::string& typeID) const {
    3482           1 :     tcpip::Storage content;
    3483           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3484           1 :     content.writeString(typeID);
    3485           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_TYPE, personID, &content);
    3486           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3487           1 : }
    3488             : 
    3489             : void
    3490           0 : TraCIAPI::PersonScope::setSpeedFactor(const std::string& personID, double factor) const {
    3491           0 :     tcpip::Storage content;
    3492           0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3493           0 :     content.writeDouble(factor);
    3494           0 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_SPEED_FACTOR, personID, &content);
    3495           0 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3496           0 : }
    3497             : 
    3498             : void
    3499           1 : TraCIAPI::PersonScope::setLength(const std::string& personID, double length) const {
    3500           1 :     tcpip::Storage content;
    3501           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3502           1 :     content.writeDouble(length);
    3503           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_LENGTH, personID, &content);
    3504           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3505           1 : }
    3506             : 
    3507             : 
    3508             : void
    3509           1 : TraCIAPI::PersonScope::setWidth(const std::string& personID, double width) const {
    3510           1 :     tcpip::Storage content;
    3511           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3512           1 :     content.writeDouble(width);
    3513           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_WIDTH, personID, &content);
    3514           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3515           1 : }
    3516             : 
    3517             : void
    3518           1 : TraCIAPI::PersonScope::setHeight(const std::string& personID, double height) const {
    3519           1 :     tcpip::Storage content;
    3520           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3521           1 :     content.writeDouble(height);
    3522           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_HEIGHT, personID, &content);
    3523           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3524           1 : }
    3525             : 
    3526             : void
    3527           1 : TraCIAPI::PersonScope::setMinGap(const std::string& personID, double minGap) const {
    3528           1 :     tcpip::Storage content;
    3529           1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3530           1 :     content.writeDouble(minGap);
    3531           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_MINGAP, personID, &content);
    3532           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3533           1 : }
    3534             : 
    3535             : 
    3536             : void
    3537           1 : TraCIAPI::PersonScope::setColor(const std::string& personID, const libsumo::TraCIColor& c) const {
    3538           1 :     tcpip::Storage content;
    3539           1 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    3540           1 :     content.writeUnsignedByte(c.r);
    3541           1 :     content.writeUnsignedByte(c.g);
    3542           1 :     content.writeUnsignedByte(c.b);
    3543           1 :     content.writeUnsignedByte(c.a);
    3544           1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_COLOR, personID, &content);
    3545           1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3546           1 : }
    3547             : 
    3548             : 
    3549             : // ---------------------------------------------------------------------------
    3550             : // TraCIAPI::TraCIScopeWrapper-methods
    3551             : // ---------------------------------------------------------------------------
    3552             : 
    3553             : int
    3554           0 : TraCIAPI::TraCIScopeWrapper::getUnsignedByte(int var, const std::string& id, tcpip::Storage* add) const {
    3555           0 :     myParent.createCommand(myCmdGetID, var, id, add);
    3556           0 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_UBYTE)) {
    3557           0 :         return myParent.myInput.readUnsignedByte();
    3558             :     }
    3559             :     return libsumo::INVALID_INT_VALUE;
    3560             : }
    3561             : 
    3562             : 
    3563             : int
    3564           0 : TraCIAPI::TraCIScopeWrapper::getByte(int var, const std::string& id, tcpip::Storage* add) const {
    3565           0 :     myParent.createCommand(myCmdGetID, var, id, add);
    3566           0 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_BYTE)) {
    3567           0 :         return myParent.myInput.readByte();
    3568             :     }
    3569             :     return libsumo::INVALID_INT_VALUE;
    3570             : }
    3571             : 
    3572             : 
    3573             : 
    3574             : int
    3575          31 : TraCIAPI::TraCIScopeWrapper::getInt(int var, const std::string& id, tcpip::Storage* add) const {
    3576          31 :     myParent.createCommand(myCmdGetID, var, id, add);
    3577          31 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_INTEGER)) {
    3578          31 :         return myParent.myInput.readInt();
    3579             :     }
    3580             :     return libsumo::INVALID_INT_VALUE;
    3581             : }
    3582             : 
    3583             : 
    3584             : double
    3585          83 : TraCIAPI::TraCIScopeWrapper::getDouble(int var, const std::string& id, tcpip::Storage* add) const {
    3586          83 :     myParent.createCommand(myCmdGetID, var, id, add);
    3587          83 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_DOUBLE)) {
    3588          83 :         return myParent.myInput.readDouble();
    3589             :     }
    3590             :     return libsumo::INVALID_DOUBLE_VALUE;
    3591             : }
    3592             : 
    3593             : 
    3594             : libsumo::TraCIPositionVector
    3595           3 : TraCIAPI::TraCIScopeWrapper::getPolygon(int var, const std::string& id, tcpip::Storage* add) const {
    3596             :     libsumo::TraCIPositionVector ret;
    3597           3 :     myParent.createCommand(myCmdGetID, var, id, add);
    3598           3 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_POLYGON)) {
    3599           3 :         int size = myParent.myInput.readUnsignedByte();
    3600           3 :         if (size == 0) {
    3601           0 :             size = myParent.myInput.readInt();
    3602             :         }
    3603          20 :         for (int i = 0; i < size; ++i) {
    3604          17 :             libsumo::TraCIPosition p;
    3605          17 :             p.x = myParent.myInput.readDouble();
    3606          17 :             p.y = myParent.myInput.readDouble();
    3607          17 :             p.z = 0.;
    3608          17 :             ret.value.push_back(p);
    3609             :         }
    3610             :     }
    3611           3 :     return ret;
    3612             : }
    3613             : 
    3614             : 
    3615             : libsumo::TraCIPosition
    3616           2 : TraCIAPI::TraCIScopeWrapper::getPos(int var, const std::string& id, tcpip::Storage* add) const {
    3617           2 :     libsumo::TraCIPosition p;
    3618           2 :     myParent.createCommand(myCmdGetID, var, id, add);
    3619           2 :     if (myParent.processGet(myCmdGetID, libsumo::POSITION_2D)) {
    3620           2 :         p.x = myParent.myInput.readDouble();
    3621           2 :         p.y = myParent.myInput.readDouble();
    3622           2 :         p.z = 0;
    3623             :     }
    3624           2 :     return p;
    3625             : }
    3626             : 
    3627             : 
    3628             : libsumo::TraCIPosition
    3629           1 : TraCIAPI::TraCIScopeWrapper::getPos3D(int var, const std::string& id, tcpip::Storage* add) const {
    3630           1 :     libsumo::TraCIPosition p;
    3631           1 :     myParent.createCommand(myCmdGetID, var, id, add);
    3632           1 :     if (myParent.processGet(myCmdGetID, libsumo::POSITION_3D)) {
    3633           1 :         p.x = myParent.myInput.readDouble();
    3634           1 :         p.y = myParent.myInput.readDouble();
    3635           1 :         p.z = myParent.myInput.readDouble();
    3636             :     }
    3637           1 :     return p;
    3638             : }
    3639             : 
    3640             : 
    3641             : std::string
    3642          25 : TraCIAPI::TraCIScopeWrapper::getString(int var, const std::string& id, tcpip::Storage* add) const {
    3643          25 :     myParent.createCommand(myCmdGetID, var, id, add);
    3644          25 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_STRING)) {
    3645          25 :         return myParent.myInput.readString();
    3646             :     }
    3647           0 :     return "";
    3648             : }
    3649             : 
    3650             : 
    3651             : std::vector<std::string>
    3652          22 : TraCIAPI::TraCIScopeWrapper::getStringVector(int var, const std::string& id, tcpip::Storage* add) const {
    3653             :     std::vector<std::string> r;
    3654          22 :     myParent.createCommand(myCmdGetID, var, id, add);
    3655          22 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_STRINGLIST)) {
    3656          22 :         const int size = myParent.myInput.readInt();
    3657         320 :         for (int i = 0; i < size; ++i) {
    3658         596 :             r.push_back(myParent.myInput.readString());
    3659             :         }
    3660             :     }
    3661          22 :     return r;
    3662           0 : }
    3663             : 
    3664             : 
    3665             : std::vector<double>
    3666           0 : TraCIAPI::TraCIScopeWrapper::getDoubleVector(int var, const std::string& id, tcpip::Storage* add) const {
    3667             :     std::vector<double> r;
    3668           0 :     myParent.createCommand(myCmdGetID, var, id, add);
    3669           0 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_DOUBLELIST)) {
    3670           0 :         const int size = myParent.myInput.readInt();
    3671           0 :         for (int i = 0; i < size; ++i) {
    3672           0 :             r.push_back(myParent.myInput.readDouble());
    3673             :         }
    3674             :     }
    3675           0 :     return r;
    3676             : }
    3677             : 
    3678             : 
    3679             : libsumo::TraCIColor
    3680           4 : TraCIAPI::TraCIScopeWrapper::getCol(int var, const std::string& id, tcpip::Storage* add) const {
    3681             :     libsumo::TraCIColor c;
    3682           4 :     myParent.createCommand(myCmdGetID, var, id, add);
    3683           4 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_COLOR)) {
    3684           4 :         c.r = (unsigned char)myParent.myInput.readUnsignedByte();
    3685           4 :         c.g = (unsigned char)myParent.myInput.readUnsignedByte();
    3686           4 :         c.b = (unsigned char)myParent.myInput.readUnsignedByte();
    3687           4 :         c.a = (unsigned char)myParent.myInput.readUnsignedByte();
    3688             :     }
    3689           4 :     return c;
    3690             : }
    3691             : 
    3692             : 
    3693             : libsumo::TraCIStage
    3694           3 : TraCIAPI::TraCIScopeWrapper::getTraCIStage(int var, const std::string& id, tcpip::Storage* add) const {
    3695           6 :     libsumo::TraCIStage s;
    3696           3 :     myParent.createCommand(myCmdGetID, var, id, add);
    3697           3 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_COMPOUND)) {
    3698           3 :         myParent.myInput.readInt(); // components
    3699           3 :         myParent.myInput.readUnsignedByte();
    3700           3 :         s.type = myParent.myInput.readInt();
    3701             : 
    3702           3 :         myParent.myInput.readUnsignedByte();
    3703           3 :         s.vType = myParent.myInput.readString();
    3704             : 
    3705           3 :         myParent.myInput.readUnsignedByte();
    3706           3 :         s.line = myParent.myInput.readString();
    3707             : 
    3708           3 :         myParent.myInput.readUnsignedByte();
    3709           3 :         s.destStop = myParent.myInput.readString();
    3710             : 
    3711           3 :         myParent.myInput.readUnsignedByte();
    3712           3 :         s.edges = myParent.myInput.readStringList();
    3713             : 
    3714           3 :         myParent.myInput.readUnsignedByte();
    3715           3 :         s.travelTime = myParent.myInput.readDouble();
    3716             : 
    3717           3 :         myParent.myInput.readUnsignedByte();
    3718           3 :         s.cost = myParent.myInput.readDouble();
    3719             : 
    3720           3 :         myParent.myInput.readUnsignedByte();
    3721           3 :         s.length = myParent.myInput.readDouble();
    3722             : 
    3723           3 :         myParent.myInput.readUnsignedByte();
    3724           3 :         s.intended = myParent.myInput.readString();
    3725             : 
    3726           3 :         myParent.myInput.readUnsignedByte();
    3727           3 :         s.depart = myParent.myInput.readDouble();
    3728             : 
    3729           3 :         myParent.myInput.readUnsignedByte();
    3730           3 :         s.departPos = myParent.myInput.readDouble();
    3731             : 
    3732           3 :         myParent.myInput.readUnsignedByte();
    3733           3 :         s.arrivalPos = myParent.myInput.readDouble();
    3734             : 
    3735           3 :         myParent.myInput.readUnsignedByte();
    3736           6 :         s.description = myParent.myInput.readString();
    3737             :     }
    3738           3 :     return s;
    3739           0 : }
    3740             : 
    3741             : 
    3742             : std::vector<std::string>
    3743          13 : TraCIAPI::TraCIScopeWrapper::getIDList() const {
    3744          26 :     return getStringVector(libsumo::TRACI_ID_LIST, "");
    3745             : }
    3746             : 
    3747             : 
    3748             : int
    3749           7 : TraCIAPI::TraCIScopeWrapper::getIDCount() const {
    3750          14 :     return getInt(libsumo::ID_COUNT, "");
    3751             : }
    3752             : 
    3753             : 
    3754             : std::string
    3755           3 : TraCIAPI::TraCIScopeWrapper::getParameter(const std::string& objectID, const std::string& key) const {
    3756           3 :     tcpip::Storage content;
    3757           3 :     content.writeByte(libsumo::TYPE_STRING);
    3758           3 :     content.writeString(key);
    3759           6 :     return getString(libsumo::VAR_PARAMETER, objectID, &content);
    3760           3 : }
    3761             : 
    3762             : 
    3763             : std::pair<std::string, std::string>
    3764           1 : TraCIAPI::TraCIScopeWrapper::getParameterWithKey(const std::string& objectID, const std::string& key) const {
    3765           1 :     tcpip::Storage content;
    3766           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3767           1 :     content.writeString(key);
    3768             : 
    3769           1 :     myParent.createCommand(myCmdGetID, libsumo::VAR_PARAMETER_WITH_KEY, objectID, &content);
    3770           1 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_COMPOUND)) {
    3771           1 :         myParent.myInput.readInt();  // number of components
    3772           1 :         myParent.myInput.readUnsignedByte();
    3773           1 :         const std::string returnedKey = myParent.myInput.readString();
    3774           1 :         myParent.myInput.readUnsignedByte();
    3775           1 :         const std::string value = myParent.myInput.readString();
    3776             :         return std::make_pair(returnedKey, value);
    3777             :     }
    3778           0 :     return std::make_pair(key, "");
    3779           1 : }
    3780             : 
    3781             : 
    3782             : void
    3783           2 : TraCIAPI::TraCIScopeWrapper::setParameter(const std::string& objectID, const std::string& key, const std::string& value) const {
    3784           2 :     tcpip::Storage content;
    3785           2 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3786           2 :     content.writeInt(2);
    3787           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3788           2 :     content.writeString(key);
    3789           2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3790           2 :     content.writeString(value);
    3791           2 :     myParent.createCommand(myCmdSetID, libsumo::VAR_PARAMETER, objectID, &content);
    3792           2 :     myParent.processSet(myCmdSetID);
    3793           2 : }
    3794             : 
    3795             : 
    3796             : void
    3797           0 : TraCIAPI::TraCIScopeWrapper::setInt(int var, const std::string& id, int value) const {
    3798           0 :     tcpip::Storage content;
    3799           0 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3800           0 :     content.writeInt(value);
    3801           0 :     myParent.createCommand(myCmdSetID, var, id, &content);
    3802           0 :     myParent.processSet(myCmdSetID);
    3803           0 : }
    3804             : 
    3805             : 
    3806             : void
    3807           2 : TraCIAPI::TraCIScopeWrapper::setDouble(int var, const std::string& id, double value) const {
    3808           2 :     tcpip::Storage content;
    3809           2 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3810           2 :     content.writeDouble(value);
    3811           2 :     myParent.createCommand(myCmdSetID, var, id, &content);
    3812           2 :     myParent.processSet(myCmdSetID);
    3813           2 : }
    3814             : 
    3815             : 
    3816             : void
    3817           1 : TraCIAPI::TraCIScopeWrapper::setString(int var, const std::string& id, const std::string& value) const {
    3818           1 :     tcpip::Storage content;
    3819           1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3820           1 :     content.writeString(value);
    3821           1 :     myParent.createCommand(myCmdSetID, var, id, &content);
    3822           1 :     myParent.processSet(myCmdSetID);
    3823           1 : }
    3824             : 
    3825             : 
    3826             : void
    3827           0 : TraCIAPI::TraCIScopeWrapper::setStringVector(int var, const std::string& id, const std::vector<std::string>& value) const {
    3828           0 :     tcpip::Storage content;
    3829           0 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    3830           0 :     content.writeInt((int)value.size());
    3831           0 :     for (const std::string& s : value) {
    3832           0 :         content.writeString(s);
    3833             :     }
    3834           0 :     myParent.createCommand(myCmdSetID, var, id, &content);
    3835           0 :     myParent.processSet(myCmdSetID);
    3836           0 : }
    3837             : 
    3838             : 
    3839             : void
    3840           2 : TraCIAPI::TraCIScopeWrapper::subscribe(const std::string& objID, const std::vector<int>& vars, double beginTime, double endTime) const {
    3841           2 :     myParent.send_commandSubscribeObjectVariable(mySubscribeID, objID, beginTime, endTime, vars);
    3842           2 :     tcpip::Storage inMsg;
    3843           2 :     myParent.check_resultState(inMsg, mySubscribeID);
    3844           2 :     if (vars.size() > 0) {
    3845           2 :         myParent.check_commandGetResult(inMsg, mySubscribeID);
    3846           2 :         myParent.readVariableSubscription(mySubscribeID + 0x10, inMsg);
    3847             :     }
    3848           2 : }
    3849             : 
    3850             : 
    3851             : void
    3852           5 : TraCIAPI::TraCIScopeWrapper::subscribeContext(const std::string& objID, int domain, double range, const std::vector<int>& vars, double beginTime, double endTime) const {
    3853           5 :     myParent.send_commandSubscribeObjectContext(myContextSubscribeID, objID, beginTime, endTime, domain, range, vars);
    3854           5 :     tcpip::Storage inMsg;
    3855           5 :     myParent.check_resultState(inMsg, myContextSubscribeID);
    3856           5 :     myParent.check_commandGetResult(inMsg, myContextSubscribeID);
    3857           5 :     myParent.readContextSubscription(myContextSubscribeID + 0x60, inMsg);
    3858           5 : }
    3859             : 
    3860             : 
    3861             : const libsumo::SubscriptionResults
    3862           0 : TraCIAPI::TraCIScopeWrapper::getAllSubscriptionResults() const {
    3863           0 :     return mySubscriptionResults;
    3864             : }
    3865             : 
    3866             : 
    3867             : const libsumo::TraCIResults
    3868           1 : TraCIAPI::TraCIScopeWrapper::getSubscriptionResults(const std::string& objID) const {
    3869           1 :     if (mySubscriptionResults.find(objID) != mySubscriptionResults.end()) {
    3870             :         return mySubscriptionResults.find(objID)->second;
    3871             :     } else {
    3872           0 :         return libsumo::TraCIResults();
    3873             :     }
    3874             : }
    3875             : 
    3876             : 
    3877             : const libsumo::ContextSubscriptionResults
    3878           0 : TraCIAPI::TraCIScopeWrapper::getAllContextSubscriptionResults() const {
    3879           0 :     return myContextSubscriptionResults;
    3880             : }
    3881             : 
    3882             : 
    3883             : const libsumo::SubscriptionResults
    3884           2 : TraCIAPI::TraCIScopeWrapper::getContextSubscriptionResults(const std::string& objID) const {
    3885           2 :     if (myContextSubscriptionResults.find(objID) != myContextSubscriptionResults.end()) {
    3886             :         return myContextSubscriptionResults.find(objID)->second;
    3887             :     } else {
    3888           0 :         return libsumo::SubscriptionResults();
    3889             :     }
    3890             : }
    3891             : 
    3892             : 
    3893             : void
    3894         160 : TraCIAPI::TraCIScopeWrapper::clearSubscriptionResults() {
    3895             :     mySubscriptionResults.clear();
    3896             :     myContextSubscriptionResults.clear();
    3897         160 : }
    3898             : 
    3899             : 
    3900             : libsumo::SubscriptionResults&
    3901           9 : TraCIAPI::TraCIScopeWrapper::getModifiableSubscriptionResults() {
    3902           9 :     return mySubscriptionResults;
    3903             : }
    3904             : 
    3905             : 
    3906             : libsumo::SubscriptionResults&
    3907          30 : TraCIAPI::TraCIScopeWrapper::getModifiableContextSubscriptionResults(const std::string& objID) {
    3908          30 :     return myContextSubscriptionResults[objID];
    3909             : }
    3910             : 
    3911             : 
    3912             : /****************************************************************************/

Generated by: LCOV version 1.14