LCOV - code coverage report
Current view: top level - src/utils/traci - TraCIAPI.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 63.5 % 2376 1509
Test Date: 2026-07-26 16:30:20 Functions: 53.0 % 406 215

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

Generated by: LCOV version 2.0-1