LCOV - code coverage report
Current view: top level - src/utils/traci - TraCIAPI.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 63.7 % 2367 1507
Test Date: 2025-06-03 15:29:59 Functions: 53.0 % 404 214

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2012-2025 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         1924 : TraCIAPI::createCommand(int cmdID, int varID, const std::string& objID, tcpip::Storage* add) const {
     160         1924 :     myOutput.reset();
     161              :     // command length
     162         1924 :     int length = 1 + 1 + 1 + 4 + (int) objID.length();
     163         1924 :     if (add != nullptr) {
     164          512 :         length += (int)add->size();
     165              :     }
     166         1924 :     if (length <= 255) {
     167         1923 :         myOutput.writeUnsignedByte(length);
     168              :     } else {
     169            1 :         myOutput.writeUnsignedByte(0);
     170            1 :         myOutput.writeInt(length + 4);
     171              :     }
     172         1924 :     myOutput.writeUnsignedByte(cmdID);
     173         1924 :     myOutput.writeUnsignedByte(varID);
     174         1924 :     myOutput.writeString(objID);
     175              :     // additional values
     176         1924 :     if (add != nullptr) {
     177          512 :         myOutput.writeStorage(*add);
     178              :     }
     179         1924 : }
     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         7636 : TraCIAPI::check_resultState(tcpip::Storage& inMsg, int command, bool ignoreCommandId, std::string* acknowledgement) const {
     266         7636 :     mySocket->receiveExact(inMsg);
     267              :     int cmdLength;
     268              :     int cmdId;
     269              :     int resultType;
     270              :     int cmdStart;
     271              :     std::string msg;
     272              :     try {
     273         7635 :         cmdStart = inMsg.position();
     274         7635 :         cmdLength = inMsg.readUnsignedByte();
     275         7635 :         cmdId = inMsg.readUnsignedByte();
     276         7635 :         if (command != cmdId && !ignoreCommandId) {
     277            0 :             throw libsumo::TraCIException("#Error: received status response to command: " + toString(cmdId) + " but expected: " + toString(command));
     278              :         }
     279         7635 :         resultType = inMsg.readUnsignedByte();
     280         7635 :         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         7635 :     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         7474 :         case libsumo::RTYPE_OK:
     290         7474 :             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         7474 :     if ((cmdStart + cmdLength) != (int) inMsg.position()) {
     298            0 :         throw libsumo::TraCIException("#Error: command at position " + toString(cmdStart) + " has wrong length");
     299              :     }
     300         7474 : }
     301              : 
     302              : 
     303              : int
     304         1483 : TraCIAPI::check_commandGetResult(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
     305         1483 :     inMsg.position(); // respStart
     306         1483 :     int length = inMsg.readUnsignedByte();
     307         1483 :     if (length == 0) {
     308           53 :         length = inMsg.readInt();
     309              :     }
     310         1483 :     int cmdId = inMsg.readUnsignedByte();
     311         1483 :     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         1483 :     if (expectedType >= 0) {
     315              :         // not called from the TraCITestClient but from within the TraCIAPI
     316          198 :         inMsg.readUnsignedByte(); // variableID
     317          198 :         inMsg.readString(); // objectID
     318          198 :         int valueDataType = inMsg.readUnsignedByte();
     319          198 :         if (valueDataType != expectedType) {
     320            0 :             throw libsumo::TraCIException("Expected " + toString(expectedType) + " but got " + toString(valueDataType));
     321              :         }
     322              :     }
     323         1483 :     return cmdId;
     324              : }
     325              : 
     326              : 
     327              : bool
     328          200 : TraCIAPI::processGet(int command, int expectedType, bool ignoreCommandId) {
     329          200 :     if (mySocket != nullptr) {
     330          200 :         mySocket->sendExact(myOutput);
     331          200 :         myInput.reset();
     332          200 :         check_resultState(myInput, command, ignoreCommandId);
     333          198 :         check_commandGetResult(myInput, command, expectedType, ignoreCommandId);
     334          198 :         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              : bool
    1227            0 : TraCIAPI::PolygonScope::getFilled(const std::string& polygonID) const {
    1228            0 :     return getInt(libsumo::VAR_FILL, polygonID) != 0;
    1229              : }
    1230              : 
    1231              : std::string
    1232            0 : TraCIAPI::PolygonScope::getType(const std::string& polygonID) const {
    1233            0 :     return getString(libsumo::VAR_TYPE, polygonID);
    1234              : }
    1235              : 
    1236              : libsumo::TraCIPositionVector
    1237            2 : TraCIAPI::PolygonScope::getShape(const std::string& polygonID) const {
    1238            2 :     return getPolygon(libsumo::VAR_SHAPE, polygonID);
    1239              : }
    1240              : 
    1241              : libsumo::TraCIColor
    1242            1 : TraCIAPI::PolygonScope::getColor(const std::string& polygonID) const {
    1243            1 :     return getCol(libsumo::VAR_COLOR, polygonID);
    1244              : }
    1245              : 
    1246              : void
    1247            1 : TraCIAPI::PolygonScope::setLineWidth(const std::string& polygonID, const double lineWidth) const {
    1248            1 :     tcpip::Storage content;
    1249            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1250            1 :     content.writeDouble(lineWidth);
    1251            1 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_WIDTH, polygonID, &content);
    1252            1 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1253            1 : }
    1254              : 
    1255              : void
    1256            0 : TraCIAPI::PolygonScope::setType(const std::string& polygonID, const std::string& setType) const {
    1257            0 :     tcpip::Storage content;
    1258            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1259            0 :     content.writeString(setType);
    1260            0 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_TYPE, polygonID, &content);
    1261            0 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1262            0 : }
    1263              : 
    1264              : 
    1265              : void
    1266            1 : TraCIAPI::PolygonScope::setShape(const std::string& polygonID, const libsumo::TraCIPositionVector& shape) const {
    1267            1 :     tcpip::Storage content;
    1268            1 :     content.writeUnsignedByte(libsumo::TYPE_POLYGON);
    1269            1 :     if (shape.value.size() < 256) {
    1270            1 :         content.writeUnsignedByte((int)shape.value.size());
    1271              :     } else {
    1272            0 :         content.writeUnsignedByte(0);
    1273            0 :         content.writeInt((int)shape.value.size());
    1274              :     }
    1275            5 :     for (const libsumo::TraCIPosition& pos : shape.value) {
    1276            4 :         content.writeDouble(pos.x);
    1277            4 :         content.writeDouble(pos.y);
    1278              :     }
    1279            1 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_SHAPE, polygonID, &content);
    1280            1 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1281            1 : }
    1282              : 
    1283              : 
    1284              : void
    1285            0 : TraCIAPI::PolygonScope::setColor(const std::string& polygonID, const libsumo::TraCIColor& c) const {
    1286            0 :     tcpip::Storage content;
    1287            0 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    1288            0 :     content.writeUnsignedByte(c.r);
    1289            0 :     content.writeUnsignedByte(c.g);
    1290            0 :     content.writeUnsignedByte(c.b);
    1291            0 :     content.writeUnsignedByte(c.a);
    1292            0 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_COLOR, polygonID, &content);
    1293            0 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1294            0 : }
    1295              : 
    1296              : void
    1297            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 {
    1298            0 :     tcpip::Storage content;
    1299            0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1300            0 :     content.writeInt(5);
    1301            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1302            0 :     content.writeString(type);
    1303            0 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    1304            0 :     content.writeUnsignedByte(c.r);
    1305            0 :     content.writeUnsignedByte(c.g);
    1306            0 :     content.writeUnsignedByte(c.b);
    1307            0 :     content.writeUnsignedByte(c.a);
    1308            0 :     content.writeUnsignedByte(libsumo::TYPE_UBYTE);
    1309            0 :     int f = fill ? 1 : 0;
    1310            0 :     content.writeUnsignedByte(f);
    1311            0 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1312            0 :     content.writeInt(layer);
    1313            0 :     content.writeUnsignedByte(libsumo::TYPE_POLYGON);
    1314            0 :     content.writeUnsignedByte((int)shape.value.size());
    1315            0 :     for (int i = 0; i < (int)shape.value.size(); ++i) {
    1316            0 :         content.writeDouble(shape.value[i].x);
    1317            0 :         content.writeDouble(shape.value[i].y);
    1318              :     }
    1319            0 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::ADD, polygonID, &content);
    1320            0 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1321            0 : }
    1322              : 
    1323              : void
    1324            0 : TraCIAPI::PolygonScope::remove(const std::string& polygonID, int layer) const {
    1325            0 :     tcpip::Storage content;
    1326            0 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1327            0 :     content.writeInt(layer);
    1328            0 :     myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::REMOVE, polygonID, &content);
    1329            0 :     myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
    1330            0 : }
    1331              : 
    1332              : 
    1333              : // ---------------------------------------------------------------------------
    1334              : // TraCIAPI::RouteScope-methods
    1335              : // ---------------------------------------------------------------------------
    1336              : std::vector<std::string>
    1337            0 : TraCIAPI::RouteScope::getEdges(const std::string& routeID) const {
    1338            0 :     return getStringVector(libsumo::VAR_EDGES, routeID);
    1339              : }
    1340              : 
    1341              : 
    1342              : void
    1343            2 : TraCIAPI::RouteScope::add(const std::string& routeID, const std::vector<std::string>& edges) const {
    1344            2 :     tcpip::Storage content;
    1345            2 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    1346            2 :     content.writeStringList(edges);
    1347            2 :     myParent.createCommand(libsumo::CMD_SET_ROUTE_VARIABLE, libsumo::ADD, routeID, &content);
    1348            2 :     myParent.processSet(libsumo::CMD_SET_ROUTE_VARIABLE);
    1349            2 : }
    1350              : 
    1351              : 
    1352              : // ---------------------------------------------------------------------------
    1353              : // TraCIAPI::SimulationScope-methods
    1354              : // ---------------------------------------------------------------------------
    1355              : int
    1356            4 : TraCIAPI::SimulationScope::getCurrentTime() const {
    1357            8 :     return getInt(libsumo::VAR_TIME_STEP, "");
    1358              : }
    1359              : 
    1360              : double
    1361            0 : TraCIAPI::SimulationScope::getTime() const {
    1362            0 :     return getDouble(libsumo::VAR_TIME, "");
    1363              : }
    1364              : 
    1365              : int
    1366            0 : TraCIAPI::SimulationScope::getLoadedNumber() const {
    1367            0 :     return (int) getInt(libsumo::VAR_LOADED_VEHICLES_NUMBER, "");
    1368              : }
    1369              : 
    1370              : std::vector<std::string>
    1371            0 : TraCIAPI::SimulationScope::getLoadedIDList() const {
    1372            0 :     return getStringVector(libsumo::VAR_LOADED_VEHICLES_IDS, "");
    1373              : }
    1374              : 
    1375              : int
    1376            0 : TraCIAPI::SimulationScope::getDepartedNumber() const {
    1377            0 :     return (int) getInt(libsumo::VAR_DEPARTED_VEHICLES_NUMBER, "");
    1378              : }
    1379              : 
    1380              : std::vector<std::string>
    1381            0 : TraCIAPI::SimulationScope::getDepartedIDList() const {
    1382            0 :     return getStringVector(libsumo::VAR_DEPARTED_VEHICLES_IDS, "");
    1383              : }
    1384              : 
    1385              : int
    1386            0 : TraCIAPI::SimulationScope::getArrivedNumber() const {
    1387            0 :     return (int) getInt(libsumo::VAR_ARRIVED_VEHICLES_NUMBER, "");
    1388              : }
    1389              : 
    1390              : std::vector<std::string>
    1391            0 : TraCIAPI::SimulationScope::getArrivedIDList() const {
    1392            0 :     return getStringVector(libsumo::VAR_ARRIVED_VEHICLES_IDS, "");
    1393              : }
    1394              : 
    1395              : int
    1396            0 : TraCIAPI::SimulationScope::getStartingTeleportNumber() const {
    1397            0 :     return (int) getInt(libsumo::VAR_TELEPORT_STARTING_VEHICLES_NUMBER, "");
    1398              : }
    1399              : 
    1400              : std::vector<std::string>
    1401            0 : TraCIAPI::SimulationScope::getStartingTeleportIDList() const {
    1402            0 :     return getStringVector(libsumo::VAR_TELEPORT_STARTING_VEHICLES_IDS, "");
    1403              : }
    1404              : 
    1405              : int
    1406            0 : TraCIAPI::SimulationScope::getEndingTeleportNumber() const {
    1407            0 :     return (int) getInt(libsumo::VAR_TELEPORT_ENDING_VEHICLES_NUMBER, "");
    1408              : }
    1409              : 
    1410              : std::vector<std::string>
    1411            0 : TraCIAPI::SimulationScope::getEndingTeleportIDList() const {
    1412            0 :     return getStringVector(libsumo::VAR_TELEPORT_ENDING_VEHICLES_IDS, "");
    1413              : }
    1414              : 
    1415              : int
    1416            0 : TraCIAPI::SimulationScope::getDepartedPersonNumber() const {
    1417            0 :     return (int)getInt(libsumo::VAR_DEPARTED_PERSONS_NUMBER, "");
    1418              : }
    1419              : 
    1420              : std::vector<std::string>
    1421            0 : TraCIAPI::SimulationScope::getDepartedPersonIDList() const {
    1422            0 :     return getStringVector(libsumo::VAR_DEPARTED_PERSONS_IDS, "");
    1423              : }
    1424              : 
    1425              : int
    1426            0 : TraCIAPI::SimulationScope::getArrivedPersonNumber() const {
    1427            0 :     return (int)getInt(libsumo::VAR_ARRIVED_PERSONS_NUMBER, "");
    1428              : }
    1429              : 
    1430              : std::vector<std::string>
    1431            0 : TraCIAPI::SimulationScope::getArrivedPersonIDList() const {
    1432            0 :     return getStringVector(libsumo::VAR_ARRIVED_PERSONS_IDS, "");
    1433              : }
    1434              : 
    1435              : double
    1436            1 : TraCIAPI::SimulationScope::getDeltaT() const {
    1437            2 :     return getDouble(libsumo::VAR_DELTA_T, "");
    1438              : }
    1439              : 
    1440              : libsumo::TraCIPositionVector
    1441            0 : TraCIAPI::SimulationScope::getNetBoundary() const {
    1442            0 :     return getPolygon(libsumo::VAR_NET_BOUNDING_BOX, "");
    1443              : }
    1444              : 
    1445              : 
    1446              : int
    1447            0 : TraCIAPI::SimulationScope::getMinExpectedNumber() const {
    1448            0 :     return getInt(libsumo::VAR_MIN_EXPECTED_VEHICLES, "");
    1449              : }
    1450              : 
    1451              : std::string
    1452            1 : TraCIAPI::SimulationScope::getOption(const std::string& option) const {
    1453            1 :     return getString(libsumo::VAR_OPTION, option);
    1454              : }
    1455              : 
    1456              : int
    1457            1 : TraCIAPI::SimulationScope::getBusStopWaiting(const std::string& stopID) const {
    1458            1 :     return (int) getInt(libsumo::VAR_BUS_STOP_WAITING, stopID);
    1459              : }
    1460              : 
    1461              : std::vector<std::string>
    1462            1 : TraCIAPI::SimulationScope::getBusStopWaitingIDList(const std::string& stopID) const {
    1463            1 :     return getStringVector(libsumo::VAR_BUS_STOP_WAITING_IDS, stopID);
    1464              : }
    1465              : 
    1466              : 
    1467              : libsumo::TraCIPosition
    1468            2 : TraCIAPI::SimulationScope::convert2D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) const {
    1469            2 :     const int posType = toGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D;
    1470            2 :     libsumo::TraCIPosition result;
    1471            2 :     tcpip::Storage content;
    1472            2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1473            2 :     content.writeInt(2);
    1474            2 :     content.writeByte(libsumo::POSITION_ROADMAP);
    1475            2 :     content.writeString(edgeID);
    1476            2 :     content.writeDouble(pos);
    1477            2 :     content.writeByte(laneIndex);
    1478            2 :     content.writeByte(libsumo::TYPE_UBYTE);
    1479            2 :     content.writeByte(posType);
    1480            2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
    1481            2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
    1482            2 :         result.x = myParent.myInput.readDouble();
    1483            2 :         result.y = myParent.myInput.readDouble();
    1484              :     }
    1485            2 :     return result;
    1486            2 : }
    1487              : 
    1488              : 
    1489              : libsumo::TraCIPosition
    1490            2 : TraCIAPI::SimulationScope::convert3D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) const {
    1491            2 :     const int posType = toGeo ? libsumo::POSITION_LON_LAT_ALT : libsumo::POSITION_3D;
    1492            2 :     libsumo::TraCIPosition result;
    1493            2 :     tcpip::Storage content;
    1494            2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1495            2 :     content.writeInt(2);
    1496            2 :     content.writeByte(libsumo::POSITION_ROADMAP);
    1497            2 :     content.writeString(edgeID);
    1498            2 :     content.writeDouble(pos);
    1499            2 :     content.writeByte(laneIndex);
    1500            2 :     content.writeByte(libsumo::TYPE_UBYTE);
    1501            2 :     content.writeByte(posType);
    1502            2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
    1503            2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
    1504            2 :         result.x = myParent.myInput.readDouble();
    1505            2 :         result.y = myParent.myInput.readDouble();
    1506            2 :         result.z = myParent.myInput.readDouble();
    1507              :     }
    1508            2 :     return result;
    1509            2 : }
    1510              : 
    1511              : 
    1512              : libsumo::TraCIRoadPosition
    1513            2 : TraCIAPI::SimulationScope::convertRoad(double x, double y, bool isGeo, const std::string& vClass) const {
    1514            2 :     libsumo::TraCIRoadPosition result;
    1515            2 :     tcpip::Storage content;
    1516            2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1517            2 :     content.writeInt(3);
    1518            4 :     content.writeByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
    1519            2 :     content.writeDouble(x);
    1520            2 :     content.writeDouble(y);
    1521            2 :     content.writeByte(libsumo::TYPE_UBYTE);
    1522            2 :     content.writeByte(libsumo::POSITION_ROADMAP);
    1523            2 :     content.writeByte(libsumo::TYPE_STRING);
    1524            2 :     content.writeString(vClass);
    1525            2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
    1526            2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_ROADMAP)) {
    1527            2 :         result.edgeID = myParent.myInput.readString();
    1528            2 :         result.pos = myParent.myInput.readDouble();
    1529            2 :         result.laneIndex = myParent.myInput.readUnsignedByte();
    1530              :     }
    1531            2 :     return result;
    1532            2 : }
    1533              : 
    1534              : 
    1535              : libsumo::TraCIPosition
    1536            2 : TraCIAPI::SimulationScope::convertGeo(double x, double y, bool fromGeo) const {
    1537            2 :     const int posType = fromGeo ? libsumo::POSITION_2D : libsumo::POSITION_LON_LAT;
    1538            2 :     libsumo::TraCIPosition result;
    1539            2 :     tcpip::Storage content;
    1540            2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1541            2 :     content.writeInt(2);
    1542            3 :     content.writeByte(fromGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
    1543            2 :     content.writeDouble(x);
    1544            2 :     content.writeDouble(y);
    1545            2 :     content.writeByte(libsumo::TYPE_UBYTE);
    1546            2 :     content.writeByte(posType);
    1547            2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
    1548            2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
    1549            2 :         result.x = myParent.myInput.readDouble();
    1550            2 :         result.y = myParent.myInput.readDouble();
    1551              :     }
    1552            2 :     return result;
    1553            2 : }
    1554              : 
    1555              : 
    1556              : double
    1557            2 : TraCIAPI::SimulationScope::getDistance2D(double x1, double y1, double x2, double y2, bool isGeo, bool isDriving) {
    1558            2 :     tcpip::Storage content;
    1559            2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1560            2 :     content.writeInt(3);
    1561            4 :     content.writeByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
    1562            2 :     content.writeDouble(x1);
    1563            2 :     content.writeDouble(y1);
    1564            2 :     content.writeByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
    1565            2 :     content.writeDouble(x2);
    1566            2 :     content.writeDouble(y2);
    1567            3 :     content.writeByte(isDriving ? libsumo::REQUEST_DRIVINGDIST : libsumo::REQUEST_AIRDIST);
    1568            2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::DISTANCE_REQUEST, "", &content);
    1569            2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::TYPE_DOUBLE)) {
    1570            2 :         return myParent.myInput.readDouble();
    1571              :     }
    1572              :     return 0.;
    1573            2 : }
    1574              : 
    1575              : 
    1576              : double
    1577            2 : TraCIAPI::SimulationScope::getDistanceRoad(const std::string& edgeID1, double pos1, const std::string& edgeID2, double pos2, bool isDriving) {
    1578            2 :     tcpip::Storage content;
    1579            2 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1580            2 :     content.writeInt(3);
    1581            2 :     content.writeByte(libsumo::POSITION_ROADMAP);
    1582            2 :     content.writeString(edgeID1);
    1583            2 :     content.writeDouble(pos1);
    1584            2 :     content.writeByte(0); // lane
    1585            2 :     content.writeByte(libsumo::POSITION_ROADMAP);
    1586            2 :     content.writeString(edgeID2);
    1587            2 :     content.writeDouble(pos2);
    1588            2 :     content.writeByte(0); // lane
    1589            3 :     content.writeByte(isDriving ? libsumo::REQUEST_DRIVINGDIST : libsumo::REQUEST_AIRDIST);
    1590            2 :     myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::DISTANCE_REQUEST, "", &content);
    1591            2 :     if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::TYPE_DOUBLE)) {
    1592            2 :         return myParent.myInput.readDouble();
    1593              :     }
    1594              :     return 0.;
    1595            2 : }
    1596              : 
    1597              : 
    1598              : libsumo::TraCIStage
    1599            1 : TraCIAPI::SimulationScope::findRoute(const std::string& fromEdge, const std::string& toEdge, const std::string& vType, double pos, int routingMode) const {
    1600            1 :     tcpip::Storage content;
    1601            1 :     content.writeByte(libsumo::TYPE_COMPOUND);
    1602            1 :     content.writeInt(5);
    1603            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1604            1 :     content.writeString(fromEdge);
    1605            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1606            1 :     content.writeString(toEdge);
    1607            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1608            1 :     content.writeString(vType);
    1609            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1610            1 :     content.writeDouble(pos);
    1611            1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1612            1 :     content.writeInt(routingMode);
    1613            2 :     return getTraCIStage(libsumo::FIND_ROUTE, "", &content);
    1614            1 : }
    1615              : 
    1616              : void
    1617            0 : TraCIAPI::SimulationScope::loadState(const std::string& path) const {
    1618            0 :     tcpip::Storage content;
    1619            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1620            0 :     content.writeString(path);
    1621            0 :     myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_LOAD_SIMSTATE, "", &content);
    1622            0 :     myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
    1623            0 : }
    1624              : 
    1625              : void
    1626            0 : TraCIAPI::SimulationScope::saveState(const std::string& destination) const {
    1627            0 :     tcpip::Storage content;
    1628            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1629            0 :     content.writeString(destination);
    1630            0 :     myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_SAVE_SIMSTATE, "", &content);
    1631            0 :     myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
    1632            0 : }
    1633              : 
    1634              : void
    1635            1 : TraCIAPI::SimulationScope::writeMessage(const std::string msg) {
    1636            1 :     tcpip::Storage content;
    1637            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1638            1 :     content.writeString(msg);
    1639            1 :     myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_MESSAGE, "", &content);
    1640            1 :     myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
    1641            1 : }
    1642              : 
    1643              : 
    1644              : // ---------------------------------------------------------------------------
    1645              : // TraCIAPI::TrafficLightScope-methods
    1646              : // ---------------------------------------------------------------------------
    1647              : std::string
    1648            3 : TraCIAPI::TrafficLightScope::getRedYellowGreenState(const std::string& tlsID) const {
    1649            3 :     return getString(libsumo::TL_RED_YELLOW_GREEN_STATE, tlsID);
    1650              : }
    1651              : 
    1652              : std::vector<libsumo::TraCILogic>
    1653            1 : TraCIAPI::TrafficLightScope::getAllProgramLogics(const std::string& tlsID) const {
    1654              :     std::vector<libsumo::TraCILogic> ret;
    1655            1 :     myParent.createCommand(libsumo::CMD_GET_TL_VARIABLE, libsumo::TL_COMPLETE_DEFINITION_RYG, tlsID);
    1656            1 :     if (myParent.processGet(libsumo::CMD_GET_TL_VARIABLE, libsumo::TYPE_COMPOUND)) {
    1657            1 :         const int logicNo = myParent.myInput.readInt();
    1658            3 :         for (int i = 0; i < logicNo; ++i) {
    1659            2 :             myParent.myInput.readUnsignedByte();
    1660            2 :             myParent.myInput.readInt();
    1661            2 :             myParent.myInput.readUnsignedByte();
    1662            2 :             const std::string programID = myParent.myInput.readString();
    1663            2 :             myParent.myInput.readUnsignedByte();
    1664            2 :             const int type = myParent.myInput.readInt();
    1665            2 :             myParent.myInput.readUnsignedByte();
    1666            2 :             const int phaseIndex = myParent.myInput.readInt();
    1667            2 :             myParent.myInput.readUnsignedByte();
    1668            2 :             const int phaseNumber = myParent.myInput.readInt();
    1669            2 :             libsumo::TraCILogic logic(programID, type, phaseIndex);
    1670           12 :             for (int j = 0; j < phaseNumber; j++) {
    1671           10 :                 myParent.myInput.readUnsignedByte();
    1672           10 :                 myParent.myInput.readInt();
    1673           10 :                 myParent.myInput.readUnsignedByte();
    1674           10 :                 const double duration = myParent.myInput.readDouble();
    1675           10 :                 myParent.myInput.readUnsignedByte();
    1676           10 :                 const std::string state = myParent.myInput.readString();
    1677           10 :                 myParent.myInput.readUnsignedByte();
    1678           10 :                 const double minDur = myParent.myInput.readDouble();
    1679           10 :                 myParent.myInput.readUnsignedByte();
    1680           10 :                 const double maxDur = myParent.myInput.readDouble();
    1681           10 :                 myParent.myInput.readUnsignedByte();
    1682           10 :                 const int numNext = myParent.myInput.readInt();
    1683              :                 std::vector<int> next;
    1684           10 :                 for (int k = 0; k < numNext; k++) {
    1685            0 :                     myParent.myInput.readUnsignedByte();
    1686            0 :                     next.push_back(myParent.myInput.readInt());
    1687              :                 }
    1688           10 :                 myParent.myInput.readUnsignedByte();
    1689           10 :                 const std::string name = myParent.myInput.readString();
    1690           20 :                 logic.phases.emplace_back(new libsumo::TraCIPhase(duration, state, minDur, maxDur, next, name));
    1691           10 :             }
    1692            2 :             myParent.myInput.readUnsignedByte();
    1693            2 :             const int paramNumber = myParent.myInput.readInt();
    1694            2 :             for (int j = 0; j < paramNumber; j++) {
    1695            0 :                 myParent.myInput.readUnsignedByte();
    1696            0 :                 const std::vector<std::string> par = myParent.myInput.readStringList();
    1697            0 :                 logic.subParameter[par[0]] = par[1];
    1698            0 :             }
    1699            2 :             ret.emplace_back(logic);
    1700            2 :         }
    1701              :     }
    1702            1 :     return ret;
    1703            0 : }
    1704              : 
    1705              : std::vector<std::string>
    1706            1 : TraCIAPI::TrafficLightScope::getControlledLanes(const std::string& tlsID) const {
    1707            1 :     return getStringVector(libsumo::TL_CONTROLLED_LANES, tlsID);
    1708              : }
    1709              : 
    1710              : std::vector<std::vector<libsumo::TraCILink> >
    1711            1 : TraCIAPI::TrafficLightScope::getControlledLinks(const std::string& tlsID) const {
    1712              :     std::vector<std::vector<libsumo::TraCILink> > result;
    1713            1 :     myParent.createCommand(libsumo::CMD_GET_TL_VARIABLE, libsumo::TL_CONTROLLED_LINKS, tlsID);
    1714            1 :     if (myParent.processGet(libsumo::CMD_GET_TL_VARIABLE, libsumo::TYPE_COMPOUND)) {
    1715              : 
    1716            1 :         myParent.myInput.readUnsignedByte();
    1717            1 :         myParent.myInput.readInt();
    1718              : 
    1719            1 :         int linkNo = myParent.myInput.readInt();
    1720            8 :         for (int i = 0; i < linkNo; ++i) {
    1721            7 :             myParent.myInput.readUnsignedByte();
    1722            7 :             int no = myParent.myInput.readInt();
    1723              :             std::vector<libsumo::TraCILink> ret;
    1724           14 :             for (int i1 = 0; i1 < no; ++i1) {
    1725            7 :                 myParent.myInput.readUnsignedByte();
    1726            7 :                 myParent.myInput.readInt();
    1727            7 :                 std::string from = myParent.myInput.readString();
    1728            7 :                 std::string to = myParent.myInput.readString();
    1729            7 :                 std::string via = myParent.myInput.readString();
    1730            7 :                 ret.emplace_back(libsumo::TraCILink(from, via, to));
    1731              :             }
    1732            7 :             result.emplace_back(ret);
    1733            7 :         }
    1734              :     }
    1735            1 :     return result;
    1736            0 : }
    1737              : 
    1738              : std::string
    1739            2 : TraCIAPI::TrafficLightScope::getProgram(const std::string& tlsID) const {
    1740            2 :     return getString(libsumo::TL_CURRENT_PROGRAM, tlsID);
    1741              : }
    1742              : 
    1743              : int
    1744            1 : TraCIAPI::TrafficLightScope::getPhase(const std::string& tlsID) const {
    1745            1 :     return getInt(libsumo::TL_CURRENT_PHASE, tlsID);
    1746              : }
    1747              : 
    1748              : std::string
    1749            1 : TraCIAPI::TrafficLightScope::getPhaseName(const std::string& tlsID) const {
    1750            1 :     return getString(libsumo::VAR_NAME, tlsID);
    1751              : }
    1752              : 
    1753              : double
    1754            1 : TraCIAPI::TrafficLightScope::getPhaseDuration(const std::string& tlsID) const {
    1755            1 :     return getDouble(libsumo::TL_PHASE_DURATION, tlsID);
    1756              : }
    1757              : 
    1758              : double
    1759            1 : TraCIAPI::TrafficLightScope::getNextSwitch(const std::string& tlsID) const {
    1760            1 :     return getDouble(libsumo::TL_NEXT_SWITCH, tlsID);
    1761              : }
    1762              : 
    1763              : 
    1764              : int
    1765            0 : TraCIAPI::TrafficLightScope::getServedPersonCount(const std::string& tlsID, int index) const {
    1766            0 :     tcpip::Storage content;
    1767            0 :     content.writeByte(libsumo::TYPE_INTEGER);
    1768            0 :     content.writeInt(index);
    1769            0 :     return getInt(libsumo::VAR_PERSON_NUMBER, tlsID, &content);
    1770            0 : }
    1771              : 
    1772              : 
    1773              : void
    1774            1 : TraCIAPI::TrafficLightScope::setRedYellowGreenState(const std::string& tlsID, const std::string& state) const {
    1775            1 :     tcpip::Storage content;
    1776            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1777            1 :     content.writeString(state);
    1778            1 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_RED_YELLOW_GREEN_STATE, tlsID, &content);
    1779            1 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1780            1 : }
    1781              : 
    1782              : void
    1783            1 : TraCIAPI::TrafficLightScope::setPhase(const std::string& tlsID, int index) const {
    1784            1 :     tcpip::Storage content;
    1785            1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1786            1 :     content.writeInt(index);
    1787            1 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PHASE_INDEX, tlsID, &content);
    1788            1 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1789            1 : }
    1790              : 
    1791              : void
    1792            1 : TraCIAPI::TrafficLightScope::setPhaseName(const std::string& tlsID, const std::string& name) const {
    1793            1 :     tcpip::Storage content;
    1794            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1795            1 :     content.writeString(name);
    1796            1 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::VAR_NAME, tlsID, &content);
    1797            1 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1798            1 : }
    1799              : 
    1800              : void
    1801            0 : TraCIAPI::TrafficLightScope::setProgram(const std::string& tlsID, const std::string& programID) const {
    1802            0 :     tcpip::Storage content;
    1803            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1804            0 :     content.writeString(programID);
    1805            0 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PROGRAM, tlsID, &content);
    1806            0 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1807            0 : }
    1808              : 
    1809              : void
    1810            0 : TraCIAPI::TrafficLightScope::setPhaseDuration(const std::string& tlsID, double phaseDuration) const {
    1811            0 :     tcpip::Storage content;
    1812            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1813            0 :     content.writeDouble(phaseDuration);
    1814            0 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PHASE_DURATION, tlsID, &content);
    1815            0 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1816            0 : }
    1817              : 
    1818              : void
    1819            1 : TraCIAPI::TrafficLightScope::setProgramLogic(const std::string& tlsID, const libsumo::TraCILogic& logic) const {
    1820            1 :     tcpip::Storage content;
    1821            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1822            1 :     content.writeInt(5);
    1823            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1824            1 :     content.writeString(logic.programID);
    1825            1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1826            1 :     content.writeInt(logic.type);
    1827            1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1828            1 :     content.writeInt(logic.currentPhaseIndex);
    1829            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1830            1 :     content.writeInt((int)logic.phases.size());
    1831            5 :     for (const std::shared_ptr<libsumo::TraCIPhase>& p : logic.phases) {
    1832            4 :         content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1833            4 :         content.writeInt(6);
    1834            4 :         content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1835            4 :         content.writeDouble(p->duration);
    1836            4 :         content.writeUnsignedByte(libsumo::TYPE_STRING);
    1837            4 :         content.writeString(p->state);
    1838            4 :         content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1839            4 :         content.writeDouble(p->minDur);
    1840            4 :         content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1841            4 :         content.writeDouble(p->maxDur);
    1842            4 :         content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1843            4 :         content.writeInt((int)p->next.size());
    1844            4 :         for (int n : p->next) {
    1845            0 :             content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    1846            0 :             content.writeInt(n);
    1847              :         }
    1848            4 :         content.writeUnsignedByte(libsumo::TYPE_STRING);
    1849            4 :         content.writeString(p->name);
    1850              :     }
    1851            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    1852            1 :     content.writeInt((int)logic.subParameter.size());
    1853            1 :     for (const auto& item : logic.subParameter) {
    1854            0 :         content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    1855            0 :         content.writeInt(2);
    1856            0 :         content.writeString(item.first);
    1857            0 :         content.writeString(item.second);
    1858              :     }
    1859            1 :     myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_COMPLETE_PROGRAM_RYG, tlsID, &content);
    1860            1 :     myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
    1861            1 : }
    1862              : 
    1863              : 
    1864              : // ---------------------------------------------------------------------------
    1865              : // TraCIAPI::VehicleTypeScope-methods
    1866              : // ---------------------------------------------------------------------------
    1867              : double
    1868            0 : TraCIAPI::VehicleTypeScope::getLength(const std::string& typeID) const {
    1869            0 :     return getDouble(libsumo::VAR_LENGTH, typeID);
    1870              : }
    1871              : 
    1872              : double
    1873            0 : TraCIAPI::VehicleTypeScope::getMaxSpeed(const std::string& typeID) const {
    1874            0 :     return getDouble(libsumo::VAR_MAXSPEED, typeID);
    1875              : }
    1876              : 
    1877              : double
    1878            0 : TraCIAPI::VehicleTypeScope::getSpeedFactor(const std::string& typeID) const {
    1879            0 :     return getDouble(libsumo::VAR_SPEED_FACTOR, typeID);
    1880              : }
    1881              : 
    1882              : double
    1883            0 : TraCIAPI::VehicleTypeScope::getSpeedDeviation(const std::string& typeID) const {
    1884            0 :     return getDouble(libsumo::VAR_SPEED_DEVIATION, typeID);
    1885              : }
    1886              : 
    1887              : double
    1888            2 : TraCIAPI::VehicleTypeScope::getAccel(const std::string& typeID) const {
    1889            2 :     return getDouble(libsumo::VAR_ACCEL, typeID);
    1890              : }
    1891              : 
    1892              : double
    1893            0 : TraCIAPI::VehicleTypeScope::getDecel(const std::string& typeID) const {
    1894            0 :     return getDouble(libsumo::VAR_DECEL, typeID);
    1895              : }
    1896              : 
    1897              : double
    1898            1 : TraCIAPI::VehicleTypeScope::getEmergencyDecel(const std::string& typeID) const {
    1899            1 :     return getDouble(libsumo::VAR_EMERGENCY_DECEL, typeID);
    1900              : }
    1901              : 
    1902              : double
    1903            1 : TraCIAPI::VehicleTypeScope::getApparentDecel(const std::string& typeID) const {
    1904            1 :     return getDouble(libsumo::VAR_APPARENT_DECEL, typeID);
    1905              : }
    1906              : 
    1907              : double
    1908            0 : TraCIAPI::VehicleTypeScope::getImperfection(const std::string& typeID) const {
    1909            0 :     return getDouble(libsumo::VAR_IMPERFECTION, typeID);
    1910              : }
    1911              : 
    1912              : double
    1913            0 : TraCIAPI::VehicleTypeScope::getTau(const std::string& typeID) const {
    1914            0 :     return getDouble(libsumo::VAR_TAU, typeID);
    1915              : }
    1916              : 
    1917              : std::string
    1918            0 : TraCIAPI::VehicleTypeScope::getVehicleClass(const std::string& typeID) const {
    1919            0 :     return getString(libsumo::VAR_VEHICLECLASS, typeID);
    1920              : }
    1921              : 
    1922              : std::string
    1923            0 : TraCIAPI::VehicleTypeScope::getEmissionClass(const std::string& typeID) const {
    1924            0 :     return getString(libsumo::VAR_EMISSIONCLASS, typeID);
    1925              : }
    1926              : 
    1927              : std::string
    1928            0 : TraCIAPI::VehicleTypeScope::getShapeClass(const std::string& typeID) const {
    1929            0 :     return getString(libsumo::VAR_SHAPECLASS, typeID);
    1930              : }
    1931              : 
    1932              : double
    1933            0 : TraCIAPI::VehicleTypeScope::getMinGap(const std::string& typeID) const {
    1934            0 :     return getDouble(libsumo::VAR_MINGAP, typeID);
    1935              : }
    1936              : 
    1937              : double
    1938            1 : TraCIAPI::VehicleTypeScope::getMinGapLat(const std::string& typeID) const {
    1939            1 :     return getDouble(libsumo::VAR_MINGAP_LAT, typeID);
    1940              : }
    1941              : 
    1942              : double
    1943            1 : TraCIAPI::VehicleTypeScope::getMaxSpeedLat(const std::string& typeID) const {
    1944            1 :     return getDouble(libsumo::VAR_MAXSPEED_LAT, typeID);
    1945              : }
    1946              : 
    1947              : std::string
    1948            1 : TraCIAPI::VehicleTypeScope::getLateralAlignment(const std::string& typeID) const {
    1949            1 :     return getString(libsumo::VAR_LATALIGNMENT, typeID);
    1950              : }
    1951              : 
    1952              : int
    1953            1 : TraCIAPI::VehicleTypeScope::getPersonCapacity(const std::string& typeID) const {
    1954            1 :     return getInt(libsumo::VAR_PERSON_CAPACITY, typeID);
    1955              : }
    1956              : 
    1957              : double
    1958            1 : TraCIAPI::VehicleTypeScope::getWidth(const std::string& typeID) const {
    1959            1 :     return getDouble(libsumo::VAR_WIDTH, typeID);
    1960              : }
    1961              : 
    1962              : double
    1963            1 : TraCIAPI::VehicleTypeScope::getHeight(const std::string& typeID) const {
    1964            1 :     return getDouble(libsumo::VAR_HEIGHT, typeID);
    1965              : }
    1966              : 
    1967              : libsumo::TraCIColor
    1968            0 : TraCIAPI::VehicleTypeScope::getColor(const std::string& typeID) const {
    1969            0 :     return getCol(libsumo::VAR_COLOR, typeID);
    1970              : }
    1971              : 
    1972              : 
    1973              : 
    1974              : void
    1975            0 : TraCIAPI::VehicleTypeScope::setLength(const std::string& typeID, double length) const {
    1976            0 :     tcpip::Storage content;
    1977            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1978            0 :     content.writeDouble(length);
    1979            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_LENGTH, typeID, &content);
    1980            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    1981            0 : }
    1982              : 
    1983              : void
    1984            0 : TraCIAPI::VehicleTypeScope::setMaxSpeed(const std::string& typeID, double speed) const {
    1985            0 :     tcpip::Storage content;
    1986            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    1987            0 :     content.writeDouble(speed);
    1988            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MAXSPEED, typeID, &content);
    1989            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    1990            0 : }
    1991              : 
    1992              : void
    1993            0 : TraCIAPI::VehicleTypeScope::setVehicleClass(const std::string& typeID, const std::string& clazz) const {
    1994            0 :     tcpip::Storage content;
    1995            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    1996            0 :     content.writeString(clazz);
    1997            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_VEHICLECLASS, typeID, &content);
    1998            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    1999            0 : }
    2000              : 
    2001              : void
    2002            0 : TraCIAPI::VehicleTypeScope::setSpeedFactor(const std::string& typeID, double factor) const {
    2003            0 :     tcpip::Storage content;
    2004            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2005            0 :     content.writeDouble(factor);
    2006            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SPEED_FACTOR, typeID, &content);
    2007            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2008            0 : }
    2009              : 
    2010              : void
    2011            0 : TraCIAPI::VehicleTypeScope::setSpeedDeviation(const std::string& typeID, double deviation) const {
    2012            0 :     tcpip::Storage content;
    2013            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2014            0 :     content.writeDouble(deviation);
    2015            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SPEED_DEVIATION, typeID, &content);
    2016            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2017            0 : }
    2018              : 
    2019              : 
    2020              : void
    2021            0 : TraCIAPI::VehicleTypeScope::setEmissionClass(const std::string& typeID, const std::string& clazz) const {
    2022            0 :     tcpip::Storage content;
    2023            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2024            0 :     content.writeString(clazz);
    2025            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_EMISSIONCLASS, typeID, &content);
    2026            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2027            0 : }
    2028              : 
    2029              : void
    2030            1 : TraCIAPI::VehicleTypeScope::setWidth(const std::string& typeID, double width) const {
    2031            1 :     tcpip::Storage content;
    2032            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2033            1 :     content.writeDouble(width);
    2034            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_WIDTH, typeID, &content);
    2035            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2036            1 : }
    2037              : 
    2038              : void
    2039            1 : TraCIAPI::VehicleTypeScope::setHeight(const std::string& typeID, double height) const {
    2040            1 :     tcpip::Storage content;
    2041            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2042            1 :     content.writeDouble(height);
    2043            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_HEIGHT, typeID, &content);
    2044            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2045            1 : }
    2046              : 
    2047              : void
    2048            0 : TraCIAPI::VehicleTypeScope::setMinGap(const std::string& typeID, double minGap) const {
    2049            0 :     tcpip::Storage content;
    2050            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2051            0 :     content.writeDouble(minGap);
    2052            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MINGAP, typeID, &content);
    2053            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2054            0 : }
    2055              : 
    2056              : 
    2057              : void
    2058            1 : TraCIAPI::VehicleTypeScope::setMinGapLat(const std::string& typeID, double minGapLat) const {
    2059            1 :     tcpip::Storage content;
    2060            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2061            1 :     content.writeDouble(minGapLat);
    2062            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MINGAP_LAT, typeID, &content);
    2063            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2064            1 : }
    2065              : 
    2066              : void
    2067            1 : TraCIAPI::VehicleTypeScope::setMaxSpeedLat(const std::string& typeID, double speed) const {
    2068            1 :     tcpip::Storage content;
    2069            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2070            1 :     content.writeDouble(speed);
    2071            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MAXSPEED_LAT, typeID, &content);
    2072            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2073            1 : }
    2074              : 
    2075              : void
    2076            1 : TraCIAPI::VehicleTypeScope::setLateralAlignment(const std::string& typeID, const std::string& latAlignment) const {
    2077            1 :     tcpip::Storage content;
    2078            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2079            1 :     content.writeString(latAlignment);
    2080            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_LATALIGNMENT, typeID, &content);
    2081            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2082            1 : }
    2083              : 
    2084              : void
    2085            1 : TraCIAPI::VehicleTypeScope::copy(const std::string& origTypeID, const std::string& newTypeID) const {
    2086            1 :     tcpip::Storage content;
    2087            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2088            1 :     content.writeString(newTypeID);
    2089            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::COPY, origTypeID, &content);
    2090            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2091            1 : }
    2092              : 
    2093              : void
    2094            0 : TraCIAPI::VehicleTypeScope::setShapeClass(const std::string& typeID, const std::string& clazz) const {
    2095            0 :     tcpip::Storage content;
    2096            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2097            0 :     content.writeString(clazz);
    2098            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SHAPECLASS, typeID, &content);
    2099            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2100            0 : }
    2101              : 
    2102              : void
    2103            1 : TraCIAPI::VehicleTypeScope::setAccel(const std::string& typeID, double accel) const {
    2104            1 :     tcpip::Storage content;
    2105            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2106            1 :     content.writeDouble(accel);
    2107            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_ACCEL, typeID, &content);
    2108            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2109            1 : }
    2110              : 
    2111              : void
    2112            0 : TraCIAPI::VehicleTypeScope::setDecel(const std::string& typeID, double decel) const {
    2113            0 :     tcpip::Storage content;
    2114            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2115            0 :     content.writeDouble(decel);
    2116            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_DECEL, typeID, &content);
    2117            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2118            0 : }
    2119              : 
    2120              : void
    2121            1 : TraCIAPI::VehicleTypeScope::setEmergencyDecel(const std::string& typeID, double decel) const {
    2122            1 :     tcpip::Storage content;
    2123            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2124            1 :     content.writeDouble(decel);
    2125            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_EMERGENCY_DECEL, typeID, &content);
    2126            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2127            1 : }
    2128              : 
    2129              : void
    2130            1 : TraCIAPI::VehicleTypeScope::setApparentDecel(const std::string& typeID, double decel) const {
    2131            1 :     tcpip::Storage content;
    2132            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2133            1 :     content.writeDouble(decel);
    2134            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_APPARENT_DECEL, typeID, &content);
    2135            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2136            1 : }
    2137              : 
    2138              : void
    2139            0 : TraCIAPI::VehicleTypeScope::setImperfection(const std::string& typeID, double imperfection) const {
    2140            0 :     tcpip::Storage content;
    2141            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2142            0 :     content.writeDouble(imperfection);
    2143            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_IMPERFECTION, typeID, &content);
    2144            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2145            0 : }
    2146              : 
    2147              : void
    2148            0 : TraCIAPI::VehicleTypeScope::setTau(const std::string& typeID, double tau) const {
    2149            0 :     tcpip::Storage content;
    2150            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2151            0 :     content.writeDouble(tau);
    2152            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_TAU, typeID, &content);
    2153            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2154            0 : }
    2155              : 
    2156              : void
    2157            0 : TraCIAPI::VehicleTypeScope::setColor(const std::string& typeID, const libsumo::TraCIColor& c) const {
    2158            0 :     tcpip::Storage content;
    2159            0 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    2160            0 :     content.writeUnsignedByte(c.r);
    2161            0 :     content.writeUnsignedByte(c.g);
    2162            0 :     content.writeUnsignedByte(c.b);
    2163            0 :     content.writeUnsignedByte(c.a);
    2164            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_COLOR, typeID, &content);
    2165            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
    2166            0 : }
    2167              : 
    2168              : 
    2169              : // ---------------------------------------------------------------------------
    2170              : // TraCIAPI::VehicleScope-methods
    2171              : // ---------------------------------------------------------------------------
    2172              : double
    2173            1 : TraCIAPI::VehicleScope::getSpeed(const std::string& vehicleID) const {
    2174            1 :     return getDouble(libsumo::VAR_SPEED, vehicleID);
    2175              : }
    2176              : 
    2177              : double
    2178            1 : TraCIAPI::VehicleScope::getLateralSpeed(const std::string& vehicleID) const {
    2179            1 :     return getDouble(libsumo::VAR_SPEED_LAT, vehicleID);
    2180              : }
    2181              : 
    2182              : double
    2183            1 : TraCIAPI::VehicleScope::getAcceleration(const std::string& vehicleID) const {
    2184            1 :     return getDouble(libsumo::VAR_ACCELERATION, vehicleID);
    2185              : }
    2186              : 
    2187              : double
    2188            1 : TraCIAPI::VehicleScope::getFollowSpeed(const std::string& vehicleID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) const {
    2189            1 :     tcpip::Storage content;
    2190            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2191            1 :     content.writeInt(5);
    2192            1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2193            1 :     content.writeDouble(speed);
    2194            1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2195            1 :     content.writeDouble(gap);
    2196            1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2197            1 :     content.writeDouble(leaderSpeed);
    2198            1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2199            1 :     content.writeDouble(leaderMaxDecel);
    2200            1 :     content.writeByte(libsumo::TYPE_STRING);
    2201            1 :     content.writeString(leaderID);
    2202            2 :     return getDouble(libsumo::VAR_FOLLOW_SPEED, vehicleID, &content);
    2203            1 : }
    2204              : 
    2205              : 
    2206              : double
    2207            1 : TraCIAPI::VehicleScope::getSecureGap(const std::string& vehicleID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) const {
    2208            1 :     tcpip::Storage content;
    2209            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2210            1 :     content.writeInt(4);
    2211            1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2212            1 :     content.writeDouble(speed);
    2213            1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2214            1 :     content.writeDouble(leaderSpeed);
    2215            1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2216            1 :     content.writeDouble(leaderMaxDecel);
    2217            1 :     content.writeByte(libsumo::TYPE_STRING);
    2218            1 :     content.writeString(leaderID);
    2219            2 :     return getDouble(libsumo::VAR_SECURE_GAP, vehicleID, &content);
    2220            1 : }
    2221              : 
    2222              : double
    2223            1 : TraCIAPI::VehicleScope::getStopSpeed(const std::string& vehicleID, double speed, double gap) const {
    2224            1 :     tcpip::Storage content;
    2225            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2226            1 :     content.writeInt(2);
    2227            1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2228            1 :     content.writeDouble(speed);
    2229            1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2230            1 :     content.writeDouble(gap);
    2231            2 :     return getDouble(libsumo::VAR_STOP_SPEED, vehicleID, &content);
    2232            1 : }
    2233              : 
    2234              : 
    2235              : double
    2236            1 : TraCIAPI::VehicleScope::getMaxSpeed(const std::string& vehicleID) const {
    2237            1 :     return getDouble(libsumo::VAR_MAXSPEED, vehicleID);
    2238              : }
    2239              : 
    2240              : libsumo::TraCIPosition
    2241            0 : TraCIAPI::VehicleScope::getPosition(const std::string& vehicleID) const {
    2242            0 :     return getPos(libsumo::VAR_POSITION, vehicleID);
    2243              : }
    2244              : 
    2245              : libsumo::TraCIPosition
    2246            0 : TraCIAPI::VehicleScope::getPosition3D(const std::string& vehicleID) const {
    2247            0 :     return getPos3D(libsumo::VAR_POSITION3D, vehicleID);
    2248              : }
    2249              : 
    2250              : double
    2251            0 : TraCIAPI::VehicleScope::getAngle(const std::string& vehicleID) const {
    2252            0 :     return getDouble(libsumo::VAR_ANGLE, vehicleID);
    2253              : }
    2254              : 
    2255              : std::string
    2256            2 : TraCIAPI::VehicleScope::getRoadID(const std::string& vehicleID) const {
    2257            2 :     return getString(libsumo::VAR_ROAD_ID, vehicleID);
    2258              : }
    2259              : 
    2260              : std::string
    2261            2 : TraCIAPI::VehicleScope::getLaneID(const std::string& vehicleID) const {
    2262            2 :     return getString(libsumo::VAR_LANE_ID, vehicleID);
    2263              : }
    2264              : 
    2265              : int
    2266            0 : TraCIAPI::VehicleScope::getLaneIndex(const std::string& vehicleID) const {
    2267            0 :     return getInt(libsumo::VAR_LANE_INDEX, vehicleID);
    2268              : }
    2269              : 
    2270              : std::string
    2271            1 : TraCIAPI::VehicleScope::getTypeID(const std::string& vehicleID) const {
    2272            1 :     return getString(libsumo::VAR_TYPE, vehicleID);
    2273              : }
    2274              : 
    2275              : std::string
    2276            1 : TraCIAPI::VehicleScope::getRouteID(const std::string& vehicleID) const {
    2277            1 :     return getString(libsumo::VAR_ROUTE_ID, vehicleID);
    2278              : }
    2279              : 
    2280              : int
    2281            0 : TraCIAPI::VehicleScope::getRouteIndex(const std::string& vehicleID) const {
    2282            0 :     return getInt(libsumo::VAR_ROUTE_INDEX, vehicleID);
    2283              : }
    2284              : 
    2285              : 
    2286              : std::vector<std::string>
    2287            3 : TraCIAPI::VehicleScope::getRoute(const std::string& vehicleID) const {
    2288            3 :     return getStringVector(libsumo::VAR_EDGES, vehicleID);
    2289              : }
    2290              : 
    2291              : libsumo::TraCIColor
    2292            1 : TraCIAPI::VehicleScope::getColor(const std::string& vehicleID) const {
    2293            1 :     return getCol(libsumo::VAR_COLOR, vehicleID);
    2294              : }
    2295              : 
    2296              : double
    2297            1 : TraCIAPI::VehicleScope::getLanePosition(const std::string& vehicleID) const {
    2298            1 :     return getDouble(libsumo::VAR_LANEPOSITION, vehicleID);
    2299              : }
    2300              : 
    2301              : double
    2302            0 : TraCIAPI::VehicleScope::getDistance(const std::string& vehicleID) const {
    2303            0 :     return getDouble(libsumo::VAR_DISTANCE, vehicleID);
    2304              : }
    2305              : 
    2306              : int
    2307            1 : TraCIAPI::VehicleScope::getSignals(const std::string& vehicleID) const {
    2308            1 :     return getInt(libsumo::VAR_SIGNALS, vehicleID);
    2309              : }
    2310              : 
    2311              : double
    2312            1 : TraCIAPI::VehicleScope::getLateralLanePosition(const std::string& vehicleID) const {
    2313            1 :     return getDouble(libsumo::VAR_LANEPOSITION_LAT, vehicleID);
    2314              : }
    2315              : 
    2316              : double
    2317            0 : TraCIAPI::VehicleScope::getCO2Emission(const std::string& vehicleID) const {
    2318            0 :     return getDouble(libsumo::VAR_CO2EMISSION, vehicleID);
    2319              : }
    2320              : 
    2321              : double
    2322            0 : TraCIAPI::VehicleScope::getCOEmission(const std::string& vehicleID) const {
    2323            0 :     return getDouble(libsumo::VAR_COEMISSION, vehicleID);
    2324              : }
    2325              : 
    2326              : double
    2327            0 : TraCIAPI::VehicleScope::getHCEmission(const std::string& vehicleID) const {
    2328            0 :     return getDouble(libsumo::VAR_HCEMISSION, vehicleID);
    2329              : }
    2330              : 
    2331              : double
    2332            0 : TraCIAPI::VehicleScope::getPMxEmission(const std::string& vehicleID) const {
    2333            0 :     return getDouble(libsumo::VAR_PMXEMISSION, vehicleID);
    2334              : }
    2335              : 
    2336              : double
    2337            0 : TraCIAPI::VehicleScope::getNOxEmission(const std::string& vehicleID) const {
    2338            0 :     return getDouble(libsumo::VAR_NOXEMISSION, vehicleID);
    2339              : }
    2340              : 
    2341              : double
    2342            0 : TraCIAPI::VehicleScope::getFuelConsumption(const std::string& vehicleID) const {
    2343            0 :     return getDouble(libsumo::VAR_FUELCONSUMPTION, vehicleID);
    2344              : }
    2345              : 
    2346              : double
    2347            0 : TraCIAPI::VehicleScope::getNoiseEmission(const std::string& vehicleID) const {
    2348            0 :     return getDouble(libsumo::VAR_NOISEEMISSION, vehicleID);
    2349              : }
    2350              : 
    2351              : double
    2352            0 : TraCIAPI::VehicleScope::getElectricityConsumption(const std::string& vehicleID) const {
    2353            0 :     return getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, vehicleID);
    2354              : }
    2355              : 
    2356              : double
    2357            1 : TraCIAPI::VehicleScope::getWaitingTime(const std::string& vehID) const {
    2358            1 :     return getDouble(libsumo::VAR_WAITING_TIME, vehID);
    2359              : }
    2360              : 
    2361              : int
    2362            1 : TraCIAPI::VehicleScope::getLaneChangeMode(const std::string& vehID) const {
    2363            1 :     return getInt(libsumo::VAR_LANECHANGE_MODE, vehID);
    2364              : }
    2365              : 
    2366              : 
    2367              : int
    2368            2 : TraCIAPI::VehicleScope::getSpeedMode(const std::string& vehID) const {
    2369            2 :     return getInt(libsumo::VAR_SPEEDSETMODE, vehID);
    2370              : }
    2371              : 
    2372              : 
    2373              : double
    2374            1 : TraCIAPI::VehicleScope::getSlope(const std::string& vehID) const {
    2375            1 :     return getDouble(libsumo::VAR_SLOPE, vehID);
    2376              : }
    2377              : 
    2378              : 
    2379              : std::string
    2380            1 : TraCIAPI::VehicleScope::getLine(const std::string& typeID) const {
    2381            1 :     return getString(libsumo::VAR_LINE, typeID);
    2382              : }
    2383              : 
    2384              : std::vector<std::string>
    2385            1 : TraCIAPI::VehicleScope::getVia(const std::string& vehicleID) const {
    2386            1 :     return getStringVector(libsumo::VAR_VIA, vehicleID);
    2387              : }
    2388              : 
    2389              : std::string
    2390            0 : TraCIAPI::VehicleScope::getEmissionClass(const std::string& vehicleID) const {
    2391            0 :     return getString(libsumo::VAR_EMISSIONCLASS, vehicleID);
    2392              : }
    2393              : 
    2394              : std::string
    2395            1 : TraCIAPI::VehicleScope::getShapeClass(const std::string& vehicleID) const {
    2396            1 :     return getString(libsumo::VAR_SHAPECLASS, vehicleID);
    2397              : }
    2398              : 
    2399              : std::vector<libsumo::TraCINextTLSData>
    2400            1 : TraCIAPI::VehicleScope::getNextTLS(const std::string& vehID) const {
    2401              :     std::vector<libsumo::TraCINextTLSData> result;
    2402            1 :     myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_NEXT_TLS, vehID);
    2403            1 :     if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
    2404            1 :         myParent.myInput.readInt(); // components
    2405              :         // number of items
    2406            1 :         myParent.myInput.readUnsignedByte();
    2407            1 :         const int n = myParent.myInput.readInt();
    2408            2 :         for (int i = 0; i < n; ++i) {
    2409              :             libsumo::TraCINextTLSData d;
    2410            1 :             myParent.myInput.readUnsignedByte();
    2411            1 :             d.id = myParent.myInput.readString();
    2412              : 
    2413            1 :             myParent.myInput.readUnsignedByte();
    2414            1 :             d.tlIndex = myParent.myInput.readInt();
    2415              : 
    2416            1 :             myParent.myInput.readUnsignedByte();
    2417            1 :             d.dist = myParent.myInput.readDouble();
    2418              : 
    2419            1 :             myParent.myInput.readUnsignedByte();
    2420            1 :             d.state = (char)myParent.myInput.readByte();
    2421              : 
    2422            1 :             result.push_back(d);
    2423              :         }
    2424              :     }
    2425            1 :     return result;
    2426            0 : }
    2427              : 
    2428              : std::vector<libsumo::TraCIBestLanesData>
    2429            0 : TraCIAPI::VehicleScope::getBestLanes(const std::string& vehicleID) const {
    2430              :     std::vector<libsumo::TraCIBestLanesData> result;
    2431            0 :     myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_BEST_LANES, vehicleID);
    2432            0 :     if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
    2433            0 :         myParent.myInput.readInt();
    2434            0 :         myParent.myInput.readUnsignedByte();
    2435              : 
    2436            0 :         const int n = myParent.myInput.readInt(); // number of following edge information
    2437            0 :         for (int i = 0; i < n; ++i) {
    2438              :             libsumo::TraCIBestLanesData info;
    2439            0 :             myParent.myInput.readUnsignedByte();
    2440            0 :             info.laneID = myParent.myInput.readString();
    2441              : 
    2442            0 :             myParent.myInput.readUnsignedByte();
    2443            0 :             info.length = myParent.myInput.readDouble();
    2444              : 
    2445            0 :             myParent.myInput.readUnsignedByte();
    2446            0 :             info.occupation = myParent.myInput.readDouble();
    2447              : 
    2448            0 :             myParent.myInput.readUnsignedByte();
    2449            0 :             info.bestLaneOffset = myParent.myInput.readByte();
    2450              : 
    2451            0 :             myParent.myInput.readUnsignedByte();
    2452            0 :             info.allowsContinuation = (myParent.myInput.readUnsignedByte() == 1);
    2453              : 
    2454            0 :             myParent.myInput.readUnsignedByte();
    2455            0 :             const int m = myParent.myInput.readInt();
    2456            0 :             for (int j = 0; j < m; ++j) {
    2457            0 :                 info.continuationLanes.push_back(myParent.myInput.readString());
    2458              :             }
    2459              : 
    2460            0 :             result.push_back(info);
    2461              :         }
    2462              :     }
    2463            0 :     return result;
    2464            0 : }
    2465              : 
    2466              : 
    2467              : std::pair<std::string, double>
    2468            1 : TraCIAPI::VehicleScope::getLeader(const std::string& vehicleID, double dist) const {
    2469            1 :     tcpip::Storage content;
    2470            1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2471            1 :     content.writeDouble(dist);
    2472            1 :     myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_LEADER, vehicleID, &content);
    2473            1 :     if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
    2474            1 :         myParent.myInput.readInt(); // components
    2475            1 :         myParent.myInput.readUnsignedByte();
    2476            1 :         const std::string leaderID = myParent.myInput.readString();
    2477            1 :         myParent.myInput.readUnsignedByte();
    2478            1 :         const double gap = myParent.myInput.readDouble();
    2479              :         return std::make_pair(leaderID, gap);
    2480              :     }
    2481              :     return std::make_pair("", libsumo::INVALID_DOUBLE_VALUE);
    2482            1 : }
    2483              : 
    2484              : 
    2485              : std::pair<std::string, double>
    2486            1 : TraCIAPI::VehicleScope::getFollower(const std::string& vehicleID, double dist) const {
    2487            1 :     tcpip::Storage content;
    2488            1 :     content.writeByte(libsumo::TYPE_DOUBLE);
    2489            1 :     content.writeDouble(dist);
    2490            1 :     myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_FOLLOWER, vehicleID, &content);
    2491            1 :     if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
    2492            1 :         myParent.myInput.readInt(); // components
    2493            1 :         myParent.myInput.readUnsignedByte();
    2494            1 :         const std::string leaderID = myParent.myInput.readString();
    2495            1 :         myParent.myInput.readUnsignedByte();
    2496            1 :         const double gap = myParent.myInput.readDouble();
    2497              :         return std::make_pair(leaderID, gap);
    2498              :     }
    2499              :     return std::make_pair("", libsumo::INVALID_DOUBLE_VALUE);
    2500            1 : }
    2501              : 
    2502              : 
    2503              : std::pair<int, int>
    2504            2 : TraCIAPI::VehicleScope::getLaneChangeState(const std::string& vehicleID, int direction) const {
    2505            2 :     tcpip::Storage content;
    2506            2 :     content.writeByte(libsumo::TYPE_INTEGER);
    2507            2 :     content.writeInt(direction);
    2508            2 :     myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
    2509            2 :     if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
    2510            2 :         myParent.myInput.readInt(); // components
    2511            2 :         myParent.myInput.readUnsignedByte();
    2512            2 :         const int stateWithoutTraCI = myParent.myInput.readInt();
    2513            2 :         myParent.myInput.readUnsignedByte();
    2514            2 :         const int state = myParent.myInput.readInt();
    2515              :         return std::make_pair(stateWithoutTraCI, state);
    2516              :     }
    2517            0 :     return std::make_pair(libsumo::INVALID_INT_VALUE, libsumo::INVALID_INT_VALUE);
    2518            2 : }
    2519              : 
    2520              : 
    2521              : int
    2522            1 : TraCIAPI::VehicleScope::getStopState(const std::string& vehicleID) const {
    2523            1 :     return getInt(libsumo::VAR_STOPSTATE, vehicleID);
    2524              : }
    2525              : 
    2526              : int
    2527            1 : TraCIAPI::VehicleScope::getRoutingMode(const std::string& vehicleID) const {
    2528            1 :     return getInt(libsumo::VAR_ROUTING_MODE, vehicleID);
    2529              : }
    2530              : 
    2531              : double
    2532            1 : TraCIAPI::VehicleScope::getStopDelay(const std::string& vehicleID) const {
    2533            1 :     return getDouble(libsumo::VAR_STOP_DELAY, vehicleID);
    2534              : }
    2535              : 
    2536              : double
    2537            0 : TraCIAPI::VehicleScope::getStopArrivalDelay(const std::string& vehicleID) const {
    2538            0 :     return getDouble(libsumo::VAR_STOP_ARRIVALDELAY, vehicleID);
    2539              : }
    2540              : 
    2541              : 
    2542              : double
    2543            0 : TraCIAPI::VehicleScope::getAccel(const std::string& vehicleID) const {
    2544            0 :     return getDouble(libsumo::VAR_ACCEL, vehicleID);
    2545              : }
    2546              : 
    2547              : double
    2548            0 : TraCIAPI::VehicleScope::getDecel(const std::string& vehicleID) const {
    2549            0 :     return getDouble(libsumo::VAR_DECEL, vehicleID);
    2550              : }
    2551              : 
    2552              : double
    2553            0 : TraCIAPI::VehicleScope::getTau(const std::string& vehicleID) const {
    2554            0 :     return getDouble(libsumo::VAR_TAU, vehicleID);
    2555              : }
    2556              : 
    2557              : double
    2558            0 : TraCIAPI::VehicleScope::getImperfection(const std::string& vehicleID) const {
    2559            0 :     return getDouble(libsumo::VAR_IMPERFECTION, vehicleID);
    2560              : }
    2561              : 
    2562              : double
    2563            0 : TraCIAPI::VehicleScope::getSpeedFactor(const std::string& vehicleID) const {
    2564            0 :     return getDouble(libsumo::VAR_SPEED_FACTOR, vehicleID);
    2565              : }
    2566              : 
    2567              : double
    2568            0 : TraCIAPI::VehicleScope::getSpeedDeviation(const std::string& vehicleID) const {
    2569            0 :     return getDouble(libsumo::VAR_SPEED_DEVIATION, vehicleID);
    2570              : }
    2571              : 
    2572              : std::string
    2573            0 : TraCIAPI::VehicleScope::getVehicleClass(const std::string& vehicleID) const {
    2574            0 :     return getString(libsumo::VAR_VEHICLECLASS, vehicleID);
    2575              : }
    2576              : 
    2577              : double
    2578            0 : TraCIAPI::VehicleScope::getMinGap(const std::string& vehicleID) const {
    2579            0 :     return getDouble(libsumo::VAR_MINGAP, vehicleID);
    2580              : }
    2581              : 
    2582              : double
    2583            0 : TraCIAPI::VehicleScope::getWidth(const std::string& vehicleID) const {
    2584            0 :     return getDouble(libsumo::VAR_WIDTH, vehicleID);
    2585              : }
    2586              : 
    2587              : double
    2588            0 : TraCIAPI::VehicleScope::getLength(const std::string& vehicleID) const {
    2589            0 :     return getDouble(libsumo::VAR_LENGTH, vehicleID);
    2590              : }
    2591              : 
    2592              : double
    2593            0 : TraCIAPI::VehicleScope::getHeight(const std::string& vehicleID) const {
    2594            0 :     return getDouble(libsumo::VAR_HEIGHT, vehicleID);
    2595              : }
    2596              : 
    2597              : double
    2598            1 : TraCIAPI::VehicleScope::getAccumulatedWaitingTime(const std::string& vehicleID) const {
    2599            1 :     return getDouble(libsumo::VAR_ACCUMULATED_WAITING_TIME, vehicleID);
    2600              : }
    2601              : 
    2602              : double
    2603            0 : TraCIAPI::VehicleScope::getAllowedSpeed(const std::string& vehicleID) const {
    2604            0 :     return getDouble(libsumo::VAR_ALLOWED_SPEED, vehicleID);
    2605              : }
    2606              : 
    2607              : int
    2608            0 : TraCIAPI::VehicleScope::getPersonNumber(const std::string& vehicleID) const {
    2609            0 :     return getInt(libsumo::VAR_PERSON_NUMBER, vehicleID);
    2610              : }
    2611              : 
    2612              : int
    2613            1 : TraCIAPI::VehicleScope::getPersonCapacity(const std::string& vehicleID) const {
    2614            1 :     return getInt(libsumo::VAR_PERSON_CAPACITY, vehicleID);
    2615              : }
    2616              : 
    2617              : std::vector<std::string>
    2618            0 : TraCIAPI::VehicleScope::getPersonIDList(const std::string& vehicleID) const {
    2619            0 :     return getStringVector(libsumo::LAST_STEP_PERSON_ID_LIST, vehicleID);
    2620              : }
    2621              : 
    2622              : double
    2623            0 : TraCIAPI::VehicleScope::getSpeedWithoutTraCI(const std::string& vehicleID) const {
    2624            0 :     return getDouble(libsumo::VAR_SPEED_WITHOUT_TRACI, vehicleID);
    2625              : }
    2626              : 
    2627              : bool
    2628            1 : TraCIAPI::VehicleScope::isRouteValid(const std::string& vehicleID) const {
    2629            1 :     return getInt(libsumo::VAR_ROUTE_VALID, vehicleID) != 0;
    2630              : }
    2631              : 
    2632              : double
    2633            0 : TraCIAPI::VehicleScope::getMaxSpeedLat(const std::string& vehicleID) const {
    2634            0 :     return getDouble(libsumo::VAR_MAXSPEED_LAT, vehicleID);
    2635              : }
    2636              : 
    2637              : double
    2638            0 : TraCIAPI::VehicleScope::getMinGapLat(const std::string& vehicleID) const {
    2639            0 :     return getDouble(libsumo::VAR_MINGAP_LAT, vehicleID);
    2640              : }
    2641              : 
    2642              : std::string
    2643            0 : TraCIAPI::VehicleScope::getLateralAlignment(const std::string& vehicleID) const {
    2644            0 :     return getString(libsumo::VAR_LATALIGNMENT, vehicleID);
    2645              : }
    2646              : 
    2647              : void
    2648            2 : TraCIAPI::VehicleScope::add(const std::string& vehicleID,
    2649              :                             const std::string& routeID,
    2650              :                             const std::string& typeID,
    2651              :                             std::string depart,
    2652              :                             const std::string& departLane,
    2653              :                             const std::string& departPos,
    2654              :                             const std::string& departSpeed,
    2655              :                             const std::string& arrivalLane,
    2656              :                             const std::string& arrivalPos,
    2657              :                             const std::string& arrivalSpeed,
    2658              :                             const std::string& fromTaz,
    2659              :                             const std::string& toTaz,
    2660              :                             const std::string& line,
    2661              :                             int personCapacity,
    2662              :                             int personNumber) const {
    2663              : 
    2664            2 :     if (depart == "-1") {
    2665            4 :         depart = toString(myParent.simulation.getCurrentTime() / 1000.0);
    2666              :     }
    2667            2 :     tcpip::Storage content;
    2668            2 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2669            2 :     content.writeInt(14);
    2670            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2671            2 :     content.writeString(routeID);
    2672            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2673            2 :     content.writeString(typeID);
    2674            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2675            2 :     content.writeString(depart);
    2676            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2677            2 :     content.writeString(departLane);
    2678            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2679            2 :     content.writeString(departPos);
    2680            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2681            2 :     content.writeString(departSpeed);
    2682              : 
    2683            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2684            2 :     content.writeString(arrivalLane);
    2685            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2686            2 :     content.writeString(arrivalPos);
    2687            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2688            2 :     content.writeString(arrivalSpeed);
    2689              : 
    2690            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2691            2 :     content.writeString(fromTaz);
    2692            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2693            2 :     content.writeString(toTaz);
    2694            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2695            2 :     content.writeString(line);
    2696              : 
    2697            2 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    2698            2 :     content.writeInt(personCapacity);
    2699            2 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    2700            2 :     content.writeInt(personNumber);
    2701              : 
    2702            2 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::ADD_FULL, vehicleID, &content);
    2703            2 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2704            2 : }
    2705              : 
    2706              : 
    2707              : void
    2708            1 : TraCIAPI::VehicleScope::remove(const std::string& vehicleID, char reason) const {
    2709            1 :     tcpip::Storage content;
    2710            1 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2711            1 :     content.writeUnsignedByte(reason);
    2712            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::REMOVE, vehicleID, &content);
    2713            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2714              : 
    2715            1 : }
    2716              : 
    2717              : 
    2718              : void
    2719            1 : TraCIAPI::VehicleScope::changeTarget(const std::string& vehicleID, const std::string& edgeID) const {
    2720            1 :     tcpip::Storage content;
    2721            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2722            1 :     content.writeString(edgeID);
    2723            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGETARGET, vehicleID, &content);
    2724            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2725            1 : }
    2726              : 
    2727              : 
    2728              : void
    2729            0 : TraCIAPI::VehicleScope::changeLane(const std::string& vehicleID, int laneIndex, double duration) const {
    2730            0 :     tcpip::Storage content;
    2731            0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2732            0 :     content.writeInt(2);
    2733            0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2734            0 :     content.writeByte(laneIndex);
    2735            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2736            0 :     content.writeDouble(duration);
    2737            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
    2738            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2739            0 : }
    2740              : 
    2741              : 
    2742              : void
    2743            0 : TraCIAPI::VehicleScope::changeLaneRelative(const std::string& vehicleID, int laneChange, double duration) const {
    2744            0 :     tcpip::Storage content;
    2745            0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2746            0 :     content.writeInt(3);
    2747            0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2748            0 :     content.writeByte(laneChange);
    2749            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2750            0 :     content.writeDouble(duration);
    2751            0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2752            0 :     content.writeByte(1);
    2753            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
    2754            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2755            0 : }
    2756              : 
    2757              : 
    2758              : void
    2759            0 : TraCIAPI::VehicleScope::changeSublane(const std::string& vehicleID, double latDist) const {
    2760            0 :     tcpip::Storage content;
    2761            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2762            0 :     content.writeDouble(latDist);
    2763            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGESUBLANE, vehicleID, &content);
    2764            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2765            0 : }
    2766              : 
    2767              : 
    2768              : void
    2769            1 : TraCIAPI::VehicleScope::setRouteID(const std::string& vehicleID, const std::string& routeID) const {
    2770            1 :     tcpip::Storage content;
    2771            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2772            1 :     content.writeString(routeID);
    2773            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTE_ID, vehicleID, &content);
    2774            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2775            1 : }
    2776              : 
    2777              : 
    2778              : void
    2779            1 : TraCIAPI::VehicleScope::setRoute(const std::string& vehicleID, const std::vector<std::string>& edges) const {
    2780            1 :     tcpip::Storage content;
    2781            1 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    2782            1 :     content.writeInt((int)edges.size());
    2783           11 :     for (int i = 0; i < (int)edges.size(); ++i) {
    2784           10 :         content.writeString(edges[i]);
    2785              :     }
    2786            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTE, vehicleID, &content);
    2787            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2788            1 : }
    2789              : 
    2790              : 
    2791              : void
    2792            1 : TraCIAPI::VehicleScope::rerouteTraveltime(const std::string& vehicleID, bool currentTravelTimes) const {
    2793            1 :     if (currentTravelTimes) {
    2794              :         // updated edge weights with current network traveltimes (at most once per simulation step)
    2795            1 :         std::vector<std::string> edges = myParent.edge.getIDList();
    2796           48 :         for (std::vector<std::string>::iterator it = edges.begin(); it != edges.end(); ++it) {
    2797           47 :             myParent.edge.adaptTraveltime(*it, myParent.edge.getTraveltime(*it));
    2798              :         }
    2799            1 :     }
    2800              : 
    2801            1 :     tcpip::Storage content;
    2802            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2803            1 :     content.writeInt(0);
    2804            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_REROUTE_TRAVELTIME, vehicleID, &content);
    2805            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2806            1 : }
    2807              : 
    2808              : void
    2809            1 : TraCIAPI::VehicleScope::moveTo(const std::string& vehicleID, const std::string& laneID, double position, int reason) const {
    2810            1 :     tcpip::Storage content;
    2811            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2812            1 :     content.writeInt(3);
    2813            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2814            1 :     content.writeString(laneID);
    2815            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2816            1 :     content.writeDouble(position);
    2817            1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    2818            1 :     content.writeInt(reason);
    2819            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MOVE_TO, vehicleID, &content);
    2820            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2821            1 : }
    2822              : 
    2823              : void
    2824            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 {
    2825            1 :     tcpip::Storage content;
    2826            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2827            1 :     content.writeInt(6);
    2828            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2829            1 :     content.writeString(edgeID);
    2830            1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    2831            1 :     content.writeInt(lane);
    2832            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2833            1 :     content.writeDouble(x);
    2834            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2835            1 :     content.writeDouble(y);
    2836            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2837            1 :     content.writeDouble(angle);
    2838            1 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2839            1 :     content.writeByte(keepRoute);
    2840            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::MOVE_TO_XY, vehicleID, &content);
    2841            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2842            1 : }
    2843              : 
    2844              : 
    2845              : void
    2846            0 : TraCIAPI::VehicleScope::slowDown(const std::string& vehicleID, double speed, double duration) const {
    2847            0 :     tcpip::Storage content;
    2848            0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2849            0 :     content.writeInt(2);
    2850            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2851            0 :     content.writeDouble(speed);
    2852            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2853            0 :     content.writeDouble(duration);
    2854            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_SLOWDOWN, vehicleID, &content);
    2855            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2856            0 : }
    2857              : 
    2858              : void
    2859            0 : TraCIAPI::VehicleScope::openGap(const std::string& vehicleID, double newTau, double duration, double changeRate, double maxDecel) const {
    2860            0 :     tcpip::Storage content;
    2861            0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2862            0 :     if (maxDecel > 0) {
    2863            0 :         content.writeInt(4);
    2864              :     } else {
    2865            0 :         content.writeInt(3);
    2866              :     }
    2867            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2868            0 :     content.writeDouble(newTau);
    2869            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2870            0 :     content.writeDouble(duration);
    2871            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2872            0 :     content.writeDouble(changeRate);
    2873            0 :     if (maxDecel > 0) {
    2874            0 :         content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2875            0 :         content.writeDouble(maxDecel);
    2876              :     }
    2877            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_OPENGAP, vehicleID, &content);
    2878            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2879            0 : }
    2880              : 
    2881              : void
    2882            0 : TraCIAPI::VehicleScope::setSpeed(const std::string& vehicleID, double speed) const {
    2883            0 :     tcpip::Storage content;
    2884            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2885            0 :     content.writeDouble(speed);
    2886            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEED, vehicleID, &content);
    2887            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2888            0 : }
    2889              : 
    2890              : void
    2891            0 : TraCIAPI::VehicleScope::setAcceleration(const std::string& vehicleID, double accel, double duration) const {
    2892            0 :     tcpip::Storage content;
    2893            0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2894            0 :     content.writeInt(2);
    2895            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2896            0 :     content.writeDouble(accel);
    2897            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2898            0 :     content.writeDouble(duration);
    2899            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ACCELERATION, vehicleID, &content);
    2900            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2901            0 : }
    2902              : 
    2903              : void
    2904            0 : TraCIAPI::VehicleScope::setPreviousSpeed(const std::string& vehicleID, double prevSpeed, double prevAcceleration) const {
    2905            0 :     tcpip::Storage content;
    2906            0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2907            0 :     content.writeInt(2);
    2908            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2909            0 :     content.writeDouble(prevSpeed);
    2910            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2911            0 :     content.writeDouble(prevAcceleration);
    2912            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_PREV_SPEED, vehicleID, &content);
    2913            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2914            0 : }
    2915              : 
    2916              : void
    2917            1 : TraCIAPI::VehicleScope::setLaneChangeMode(const std::string& vehicleID, int mode) const {
    2918            1 :     tcpip::Storage content;
    2919            1 :     content.writeByte(libsumo::TYPE_INTEGER);
    2920            1 :     content.writeInt(mode);
    2921            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_LANECHANGE_MODE, vehicleID, &content);
    2922            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2923            1 : }
    2924              : 
    2925              : void
    2926            1 : TraCIAPI::VehicleScope::setSpeedMode(const std::string& vehicleID, int mode) const {
    2927            1 :     tcpip::Storage content;
    2928            1 :     content.writeByte(libsumo::TYPE_INTEGER);
    2929            1 :     content.writeInt(mode);
    2930            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEEDSETMODE, vehicleID, &content);
    2931            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2932            1 : }
    2933              : 
    2934              : void
    2935            0 : TraCIAPI::VehicleScope::setStop(const std::string vehicleID, const std::string edgeID, const double endPos, const int laneIndex,
    2936              :                                 const double duration, const int flags, const double startPos, const double until) const {
    2937            0 :     tcpip::Storage content;
    2938            0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    2939            0 :     content.writeInt(7);
    2940            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2941            0 :     content.writeString(edgeID);
    2942            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2943            0 :     content.writeDouble(endPos);
    2944            0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2945            0 :     content.writeByte(laneIndex);
    2946            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2947            0 :     content.writeDouble(duration);
    2948            0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    2949            0 :     content.writeByte(flags);
    2950            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2951            0 :     content.writeDouble(startPos);
    2952            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2953            0 :     content.writeDouble(until);
    2954            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_STOP, vehicleID, &content);
    2955            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2956            0 : }
    2957              : 
    2958              : void
    2959            1 : TraCIAPI::VehicleScope::setType(const std::string& vehicleID, const std::string& typeID) const {
    2960            1 :     tcpip::Storage content;
    2961            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    2962            1 :     content.writeString(typeID);
    2963            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_TYPE, vehicleID, &content);
    2964            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2965            1 : }
    2966              : 
    2967              : void
    2968            1 : TraCIAPI::VehicleScope::setSpeedFactor(const std::string& vehicleID, double factor) const {
    2969            1 :     tcpip::Storage content;
    2970            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2971            1 :     content.writeDouble(factor);
    2972            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEED_FACTOR, vehicleID, &content);
    2973            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2974            1 : }
    2975              : 
    2976              : void
    2977            0 : TraCIAPI::VehicleScope::setMinGap(const std::string& vehicleID, double minGap) const {
    2978            0 :     tcpip::Storage content;
    2979            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2980            0 :     content.writeDouble(minGap);
    2981            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MINGAP, vehicleID, &content);
    2982            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2983            0 : }
    2984              : 
    2985              : void
    2986            1 : TraCIAPI::VehicleScope::setMaxSpeed(const std::string& vehicleID, double speed) const {
    2987            1 :     tcpip::Storage content;
    2988            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    2989            1 :     content.writeDouble(speed);
    2990            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MAXSPEED, vehicleID, &content);
    2991            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    2992            1 : }
    2993              : 
    2994              : void
    2995            1 : TraCIAPI::VehicleScope::setColor(const std::string& vehicleID, const libsumo::TraCIColor& c) const {
    2996            1 :     tcpip::Storage content;
    2997            1 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    2998            1 :     content.writeUnsignedByte(c.r);
    2999            1 :     content.writeUnsignedByte(c.g);
    3000            1 :     content.writeUnsignedByte(c.b);
    3001            1 :     content.writeUnsignedByte(c.a);
    3002            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_COLOR, vehicleID, &content);
    3003            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3004            1 : }
    3005              : 
    3006              : void
    3007            1 : TraCIAPI::VehicleScope::setLine(const std::string& vehicleID, const std::string& line) const {
    3008            1 :     tcpip::Storage content;
    3009            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3010            1 :     content.writeString(line);
    3011            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_LINE, vehicleID, &content);
    3012            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3013            1 : }
    3014              : 
    3015              : void
    3016            1 : TraCIAPI::VehicleScope::setVia(const std::string& vehicleID, const std::vector<std::string>& via) const {
    3017            1 :     tcpip::Storage content;
    3018            1 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    3019            1 :     content.writeInt((int)via.size());
    3020            2 :     for (int i = 0; i < (int)via.size(); ++i) {
    3021            1 :         content.writeString(via[i]);
    3022              :     }
    3023            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_VIA, vehicleID, &content);
    3024            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3025            1 : }
    3026              : 
    3027              : void
    3028            1 : TraCIAPI::VehicleScope::setSignals(const std::string& vehicleID, int signals) const {
    3029            1 :     tcpip::Storage content;
    3030            1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3031            1 :     content.writeInt(signals);
    3032            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SIGNALS, vehicleID, &content);
    3033            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3034            1 : }
    3035              : 
    3036              : void
    3037            1 : TraCIAPI::VehicleScope::setRoutingMode(const std::string& vehicleID, int routingMode) const {
    3038            1 :     tcpip::Storage content;
    3039            1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3040            1 :     content.writeInt(routingMode);
    3041            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTING_MODE, vehicleID, &content);
    3042            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3043            1 : }
    3044              : 
    3045              : void
    3046            1 : TraCIAPI::VehicleScope::setShapeClass(const std::string& vehicleID, const std::string& clazz) const {
    3047            1 :     tcpip::Storage content;
    3048            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3049            1 :     content.writeString(clazz);
    3050            1 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SHAPECLASS, vehicleID, &content);
    3051            1 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3052            1 : }
    3053              : 
    3054              : 
    3055              : void
    3056            0 : TraCIAPI::VehicleScope::setEmissionClass(const std::string& vehicleID, const std::string& clazz) const {
    3057            0 :     tcpip::Storage content;
    3058            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3059            0 :     content.writeString(clazz);
    3060            0 :     myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_EMISSIONCLASS, vehicleID, &content);
    3061            0 :     myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
    3062            0 : }
    3063              : 
    3064              : void
    3065            1 : TraCIAPI::VehicleScope::addSubscriptionFilterLanes(const std::vector<int>& lanes,
    3066              :         bool noOpposite, double downstreamDist, double upstreamDist) const {
    3067            1 :     addSubscriptionFilterByteList(libsumo::FILTER_TYPE_LANES, lanes);
    3068            1 :     if (noOpposite) {
    3069            0 :         addSubscriptionFilterNoOpposite();
    3070              :     }
    3071            1 :     if (downstreamDist >= 0) {
    3072            0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    3073              :     }
    3074            1 :     if (upstreamDist >= 0) {
    3075            0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    3076              :     }
    3077            1 : }
    3078              : 
    3079              : 
    3080              : void
    3081            1 : TraCIAPI::VehicleScope::addSubscriptionFilterNoOpposite() const {
    3082            1 :     addSubscriptionFilterEmpty(libsumo::FILTER_TYPE_NOOPPOSITE);
    3083            1 : }
    3084              : 
    3085              : void
    3086            1 : TraCIAPI::VehicleScope::addSubscriptionFilterDownstreamDistance(double dist) const {
    3087            1 :     addSubscriptionFilterFloat(libsumo::FILTER_TYPE_DOWNSTREAM_DIST, dist);
    3088            1 : }
    3089              : 
    3090              : void
    3091            1 : TraCIAPI::VehicleScope::addSubscriptionFilterUpstreamDistance(double dist) const {
    3092            1 :     addSubscriptionFilterFloat(libsumo::FILTER_TYPE_UPSTREAM_DIST, dist);
    3093            1 : }
    3094              : 
    3095              : 
    3096              : void
    3097            1 : TraCIAPI::VehicleScope::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) const {
    3098            1 :     addSubscriptionFilterLeadFollow(std::vector<int>({0}));
    3099            1 :     if (downstreamDist >= 0) {
    3100            0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    3101              :     }
    3102            1 :     if (upstreamDist >= 0) {
    3103            0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    3104              :     }
    3105            1 : }
    3106              : 
    3107              : void
    3108            1 : TraCIAPI::VehicleScope::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) const {
    3109            1 :     if (abs(direction) != 1) {
    3110            0 :         std::cerr << "Ignoring lane change subscription filter with non-neighboring lane offset direction " << direction << "\n";
    3111            0 :         return;
    3112              :     }
    3113            1 :     addSubscriptionFilterLeadFollow(std::vector<int>({0, direction}));
    3114            1 :     if (noOpposite) {
    3115            0 :         addSubscriptionFilterNoOpposite();
    3116              :     }
    3117            1 :     if (downstreamDist >= 0) {
    3118            0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    3119              :     }
    3120            1 :     if (upstreamDist >= 0) {
    3121            0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    3122              :     }
    3123              : }
    3124              : 
    3125              : void
    3126            3 : TraCIAPI::VehicleScope::addSubscriptionFilterLeadFollow(const std::vector<int>& lanes) const {
    3127            3 :     addSubscriptionFilterEmpty(libsumo::FILTER_TYPE_LEAD_FOLLOW);
    3128            3 :     addSubscriptionFilterByteList(libsumo::FILTER_TYPE_LANES, lanes);
    3129            3 : }
    3130              : 
    3131              : void
    3132            1 : TraCIAPI::VehicleScope::addSubscriptionFilterTurn(double downstreamDist, double foeDistToJunction) const {
    3133            1 :     addSubscriptionFilterFloat(libsumo::FILTER_TYPE_TURN, foeDistToJunction);
    3134            1 :     if (downstreamDist >= 0) {
    3135            0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    3136              :     }
    3137            1 : }
    3138              : 
    3139              : 
    3140              : void
    3141            1 : TraCIAPI::VehicleScope::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) const {
    3142            1 :     addSubscriptionFilterStringList(libsumo::FILTER_TYPE_VCLASS, vClasses);
    3143            1 : }
    3144              : 
    3145              : 
    3146              : void
    3147            1 : TraCIAPI::VehicleScope::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) const {
    3148            1 :     addSubscriptionFilterStringList(libsumo::FILTER_TYPE_VTYPE, vTypes);
    3149            1 : }
    3150              : 
    3151              : 
    3152              : void
    3153            1 : TraCIAPI::VehicleScope::addSubscriptionFilterFieldOfVision(double angle) const {
    3154            1 :     addSubscriptionFilterFloat(libsumo::FILTER_TYPE_FIELD_OF_VISION, angle);
    3155            1 : }
    3156              : 
    3157              : void
    3158            1 : TraCIAPI::VehicleScope::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) const {
    3159            1 :     addSubscriptionFilterFloat(libsumo::FILTER_TYPE_LATERAL_DIST, lateralDist);
    3160            1 :     if (downstreamDist >= 0) {
    3161            0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    3162              :     }
    3163            1 :     if (upstreamDist >= 0) {
    3164            0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    3165              :     }
    3166            1 : }
    3167              : 
    3168              : void
    3169            4 : TraCIAPI::VehicleScope::addSubscriptionFilterEmpty(int filterType) const {
    3170            4 :     myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType);
    3171            4 :     myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
    3172            4 : }
    3173              : 
    3174              : void
    3175            5 : TraCIAPI::VehicleScope::addSubscriptionFilterFloat(int filterType, double val) const {
    3176            5 :     tcpip::Storage content;
    3177            5 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3178            5 :     content.writeDouble(val);
    3179            5 :     myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
    3180            5 :     myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
    3181            5 : }
    3182              : 
    3183              : 
    3184              : void
    3185            2 : TraCIAPI::VehicleScope::addSubscriptionFilterStringList(int filterType, const std::vector<std::string>& vals) const {
    3186            2 :     tcpip::Storage content;
    3187            2 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    3188            2 :     content.writeStringList(vals);
    3189            2 :     myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
    3190            2 :     myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
    3191            2 : }
    3192              : 
    3193              : 
    3194              : void
    3195            4 : TraCIAPI::VehicleScope::addSubscriptionFilterByteList(int filterType, const std::vector<int>& vals) const {
    3196            4 :     tcpip::Storage content;
    3197            4 :     content.writeUnsignedByte((int)vals.size());
    3198           13 :     for (int i : vals)  {
    3199            9 :         content.writeByte(i);
    3200              :     }
    3201            4 :     myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
    3202            4 :     myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
    3203            4 : }
    3204              : 
    3205              : 
    3206              : // ---------------------------------------------------------------------------
    3207              : // TraCIAPI::PersonScope-methods
    3208              : // ---------------------------------------------------------------------------
    3209              : double
    3210            1 : TraCIAPI::PersonScope::getSpeed(const std::string& personID) const {
    3211            1 :     return getDouble(libsumo::VAR_SPEED, personID);
    3212              : }
    3213              : 
    3214              : libsumo::TraCIPosition
    3215            1 : TraCIAPI::PersonScope::getPosition(const std::string& personID) const {
    3216            1 :     return getPos(libsumo::VAR_POSITION, personID);
    3217              : }
    3218              : 
    3219              : libsumo::TraCIPosition
    3220            1 : TraCIAPI::PersonScope::getPosition3D(const std::string& personID) const {
    3221            1 :     return getPos3D(libsumo::VAR_POSITION3D, personID);
    3222              : }
    3223              : 
    3224              : double
    3225            1 : TraCIAPI::PersonScope::getAngle(const std::string& personID) const {
    3226            1 :     return getDouble(libsumo::VAR_ANGLE, personID);
    3227              : }
    3228              : 
    3229              : double
    3230            1 : TraCIAPI::PersonScope::getSlope(const std::string& personID) const {
    3231            1 :     return getDouble(libsumo::VAR_SLOPE, personID);
    3232              : }
    3233              : 
    3234              : double
    3235            1 : TraCIAPI::PersonScope::getLanePosition(const std::string& personID) const {
    3236            1 :     return getDouble(libsumo::VAR_LANEPOSITION, personID);
    3237              : }
    3238              : 
    3239              : libsumo::TraCIColor
    3240            1 : TraCIAPI::PersonScope::getColor(const std::string& personID) const {
    3241            1 :     return getCol(libsumo::VAR_COLOR, personID);
    3242              : }
    3243              : 
    3244              : double
    3245            1 : TraCIAPI::PersonScope::getLength(const std::string& personID) const {
    3246            1 :     return getDouble(libsumo::VAR_LENGTH, personID);
    3247              : }
    3248              : 
    3249              : std::string
    3250            1 : TraCIAPI::PersonScope::getRoadID(const std::string& personID) const {
    3251            1 :     return getString(libsumo::VAR_ROAD_ID, personID);
    3252              : }
    3253              : 
    3254              : std::string
    3255            1 : TraCIAPI::PersonScope::getLaneID(const std::string& personID) const {
    3256            1 :     return getString(libsumo::VAR_LANE_ID, personID);
    3257              : }
    3258              : 
    3259              : std::string
    3260            1 : TraCIAPI::PersonScope::getTypeID(const std::string& personID) const {
    3261            1 :     return getString(libsumo::VAR_TYPE, personID);
    3262              : }
    3263              : 
    3264              : double
    3265            0 : TraCIAPI::PersonScope::getSpeedFactor(const std::string& personID) const {
    3266            0 :     return getDouble(libsumo::VAR_SPEED_FACTOR, personID);
    3267              : }
    3268              : 
    3269              : double
    3270            1 : TraCIAPI::PersonScope::getWaitingTime(const std::string& personID) const {
    3271            1 :     return getDouble(libsumo::VAR_WAITING_TIME, personID);
    3272              : }
    3273              : 
    3274              : std::string
    3275            1 : TraCIAPI::PersonScope::getNextEdge(const std::string& personID) const {
    3276            1 :     return getString(libsumo::VAR_NEXT_EDGE, personID);
    3277              : }
    3278              : 
    3279              : 
    3280              : std::string
    3281            1 : TraCIAPI::PersonScope::getVehicle(const std::string& personID) const {
    3282            1 :     return getString(libsumo::VAR_VEHICLE, personID);
    3283              : }
    3284              : 
    3285              : int
    3286            7 : TraCIAPI::PersonScope::getRemainingStages(const std::string& personID) const {
    3287            7 :     return getInt(libsumo::VAR_STAGES_REMAINING, personID);
    3288              : }
    3289              : 
    3290              : libsumo::TraCIStage
    3291            2 : TraCIAPI::PersonScope::getStage(const std::string& personID, int nextStageIndex) const {
    3292            2 :     tcpip::Storage content;
    3293            2 :     content.writeByte(libsumo::TYPE_INTEGER);
    3294            2 :     content.writeInt(nextStageIndex);
    3295            4 :     return getTraCIStage(libsumo::VAR_STAGE, personID, &content);
    3296            2 : }
    3297              : 
    3298              : std::vector<std::string>
    3299            3 : TraCIAPI::PersonScope::getEdges(const std::string& personID, int nextStageIndex) const {
    3300            3 :     tcpip::Storage content;
    3301            3 :     content.writeByte(libsumo::TYPE_INTEGER);
    3302            3 :     content.writeInt(nextStageIndex);
    3303            6 :     return getStringVector(libsumo::VAR_EDGES, personID, &content);
    3304            3 : }
    3305              : 
    3306              : void
    3307            1 : TraCIAPI::PersonScope::removeStages(const std::string& personID) const {
    3308              :     // remove all stages after the current and then abort the current stage
    3309            3 :     while (getRemainingStages(personID) > 1) {
    3310            2 :         removeStage(personID, 1);
    3311              :     }
    3312            1 :     removeStage(personID, 0);
    3313            1 : }
    3314              : 
    3315              : 
    3316              : void
    3317            1 : TraCIAPI::PersonScope::rerouteTraveltime(const std::string& personID) const {
    3318            1 :     tcpip::Storage content;
    3319            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3320            1 :     content.writeInt(0);
    3321            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::CMD_REROUTE_TRAVELTIME, personID, &content);
    3322            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3323            1 : }
    3324              : 
    3325              : 
    3326              : void
    3327            1 : TraCIAPI::PersonScope::add(const std::string& personID, const std::string& edgeID, double pos, double depart, const std::string typeID) {
    3328            1 :     tcpip::Storage content;
    3329            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3330            1 :     content.writeInt(4);
    3331            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3332            1 :     content.writeString(typeID);
    3333            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3334            1 :     content.writeString(edgeID);
    3335            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3336            1 :     content.writeDouble(depart);
    3337            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3338            1 :     content.writeDouble(pos);
    3339            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::ADD, personID, &content);
    3340            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3341            1 : }
    3342              : 
    3343              : void
    3344            1 : TraCIAPI::PersonScope::appendStage(const std::string& personID, const libsumo::TraCIStage& stage) {
    3345            1 :     tcpip::Storage content;
    3346            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3347            1 :     content.writeInt(13);
    3348            1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3349            1 :     content.writeInt(stage.type);
    3350            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3351            1 :     content.writeString(stage.vType);
    3352            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3353            1 :     content.writeString(stage.line);
    3354            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3355            1 :     content.writeString(stage.destStop);
    3356            1 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    3357            1 :     content.writeStringList(stage.edges);
    3358            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3359            1 :     content.writeDouble(stage.travelTime);
    3360            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3361            1 :     content.writeDouble(stage.cost);
    3362            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3363            1 :     content.writeDouble(stage.length);
    3364            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3365            1 :     content.writeString(stage.intended);
    3366            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3367            1 :     content.writeDouble(stage.depart);
    3368            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3369            1 :     content.writeDouble(stage.departPos);
    3370            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3371            1 :     content.writeDouble(stage.arrivalPos);
    3372            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3373            1 :     content.writeString(stage.description);
    3374            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
    3375            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3376            1 : }
    3377              : 
    3378              : 
    3379              : void
    3380            1 : TraCIAPI::PersonScope::appendWaitingStage(const std::string& personID, double duration, const std::string& description, const std::string& stopID) {
    3381            1 :     tcpip::Storage content;
    3382            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3383            1 :     content.writeInt(4);
    3384            1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3385            1 :     content.writeInt(libsumo::STAGE_WAITING);
    3386            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3387            1 :     content.writeDouble(duration);
    3388            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3389            1 :     content.writeString(description);
    3390            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3391            1 :     content.writeString(stopID);
    3392            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
    3393            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3394            1 : }
    3395              : 
    3396              : void
    3397            2 : TraCIAPI::PersonScope::appendWalkingStage(const std::string& personID, const std::vector<std::string>& edges, double arrivalPos, double duration, double speed, const std::string& stopID) {
    3398            2 :     tcpip::Storage content;
    3399            2 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3400            2 :     content.writeInt(6);
    3401            2 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3402            2 :     content.writeInt(libsumo::STAGE_WALKING);
    3403            2 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    3404            2 :     content.writeStringList(edges);
    3405            2 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3406            2 :     content.writeDouble(arrivalPos);
    3407            2 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3408            2 :     content.writeDouble(duration);
    3409            2 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3410            2 :     content.writeDouble(speed);
    3411            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3412            2 :     content.writeString(stopID);
    3413            2 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
    3414            2 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3415            2 : }
    3416              : 
    3417              : void
    3418            1 : TraCIAPI::PersonScope::appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID) {
    3419            1 :     tcpip::Storage content;
    3420            1 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3421            1 :     content.writeInt(4);
    3422            1 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3423            1 :     content.writeInt(libsumo::STAGE_DRIVING);
    3424            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3425            1 :     content.writeString(toEdge);
    3426            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3427            1 :     content.writeString(lines);
    3428            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3429            1 :     content.writeString(stopID);
    3430            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
    3431            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3432            1 : }
    3433              : 
    3434              : void
    3435            4 : TraCIAPI::PersonScope::removeStage(const std::string& personID, int nextStageIndex) const {
    3436            4 :     tcpip::Storage content;
    3437            4 :     content.writeByte(libsumo::TYPE_INTEGER);
    3438            4 :     content.writeInt(nextStageIndex);
    3439            4 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::REMOVE_STAGE, personID, &content);
    3440            4 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3441            4 : }
    3442              : 
    3443              : void
    3444            0 : TraCIAPI::PersonScope::moveTo(const std::string& personID, const std::string& edgeID, double position) const {
    3445            0 :     tcpip::Storage content;
    3446            0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3447            0 :     content.writeInt(2);
    3448            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3449            0 :     content.writeString(edgeID);
    3450            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3451            0 :     content.writeDouble(position);
    3452            0 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_MOVE_TO, personID, &content);
    3453            0 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3454            0 : }
    3455              : 
    3456              : void
    3457            0 : TraCIAPI::PersonScope::moveToXY(const std::string& personID, const std::string& edgeID, const double x, const double y, double angle, const int keepRoute) const {
    3458            0 :     tcpip::Storage content;
    3459            0 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3460            0 :     content.writeInt(5);
    3461            0 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3462            0 :     content.writeString(edgeID);
    3463            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3464            0 :     content.writeDouble(x);
    3465            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3466            0 :     content.writeDouble(y);
    3467            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3468            0 :     content.writeDouble(angle);
    3469            0 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    3470            0 :     content.writeByte(keepRoute);
    3471            0 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::MOVE_TO_XY, personID, &content);
    3472            0 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3473            0 : }
    3474              : 
    3475              : void
    3476            1 : TraCIAPI::PersonScope::setSpeed(const std::string& personID, double speed) const {
    3477            1 :     tcpip::Storage content;
    3478            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3479            1 :     content.writeDouble(speed);
    3480            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_SPEED, personID, &content);
    3481            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3482            1 : }
    3483              : 
    3484              : 
    3485              : void
    3486            1 : TraCIAPI::PersonScope::setType(const std::string& personID, const std::string& typeID) const {
    3487            1 :     tcpip::Storage content;
    3488            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3489            1 :     content.writeString(typeID);
    3490            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_TYPE, personID, &content);
    3491            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3492            1 : }
    3493              : 
    3494              : void
    3495            0 : TraCIAPI::PersonScope::setSpeedFactor(const std::string& personID, double factor) const {
    3496            0 :     tcpip::Storage content;
    3497            0 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3498            0 :     content.writeDouble(factor);
    3499            0 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_SPEED_FACTOR, personID, &content);
    3500            0 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3501            0 : }
    3502              : 
    3503              : void
    3504            1 : TraCIAPI::PersonScope::setLength(const std::string& personID, double length) const {
    3505            1 :     tcpip::Storage content;
    3506            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3507            1 :     content.writeDouble(length);
    3508            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_LENGTH, personID, &content);
    3509            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3510            1 : }
    3511              : 
    3512              : 
    3513              : void
    3514            1 : TraCIAPI::PersonScope::setWidth(const std::string& personID, double width) const {
    3515            1 :     tcpip::Storage content;
    3516            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3517            1 :     content.writeDouble(width);
    3518            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_WIDTH, personID, &content);
    3519            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3520            1 : }
    3521              : 
    3522              : void
    3523            1 : TraCIAPI::PersonScope::setHeight(const std::string& personID, double height) const {
    3524            1 :     tcpip::Storage content;
    3525            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3526            1 :     content.writeDouble(height);
    3527            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_HEIGHT, personID, &content);
    3528            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3529            1 : }
    3530              : 
    3531              : void
    3532            1 : TraCIAPI::PersonScope::setMinGap(const std::string& personID, double minGap) const {
    3533            1 :     tcpip::Storage content;
    3534            1 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3535            1 :     content.writeDouble(minGap);
    3536            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_MINGAP, personID, &content);
    3537            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3538            1 : }
    3539              : 
    3540              : 
    3541              : void
    3542            1 : TraCIAPI::PersonScope::setColor(const std::string& personID, const libsumo::TraCIColor& c) const {
    3543            1 :     tcpip::Storage content;
    3544            1 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    3545            1 :     content.writeUnsignedByte(c.r);
    3546            1 :     content.writeUnsignedByte(c.g);
    3547            1 :     content.writeUnsignedByte(c.b);
    3548            1 :     content.writeUnsignedByte(c.a);
    3549            1 :     myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_COLOR, personID, &content);
    3550            1 :     myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
    3551            1 : }
    3552              : 
    3553              : 
    3554              : // ---------------------------------------------------------------------------
    3555              : // TraCIAPI::TraCIScopeWrapper-methods
    3556              : // ---------------------------------------------------------------------------
    3557              : 
    3558              : int
    3559            0 : TraCIAPI::TraCIScopeWrapper::getUnsignedByte(int var, const std::string& id, tcpip::Storage* add) const {
    3560            0 :     myParent.createCommand(myCmdGetID, var, id, add);
    3561            0 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_UBYTE)) {
    3562            0 :         return myParent.myInput.readUnsignedByte();
    3563              :     }
    3564              :     return libsumo::INVALID_INT_VALUE;
    3565              : }
    3566              : 
    3567              : 
    3568              : int
    3569            0 : TraCIAPI::TraCIScopeWrapper::getByte(int var, const std::string& id, tcpip::Storage* add) const {
    3570            0 :     myParent.createCommand(myCmdGetID, var, id, add);
    3571            0 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_BYTE)) {
    3572            0 :         return myParent.myInput.readByte();
    3573              :     }
    3574              :     return libsumo::INVALID_INT_VALUE;
    3575              : }
    3576              : 
    3577              : 
    3578              : 
    3579              : int
    3580           31 : TraCIAPI::TraCIScopeWrapper::getInt(int var, const std::string& id, tcpip::Storage* add) const {
    3581           31 :     myParent.createCommand(myCmdGetID, var, id, add);
    3582           31 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_INTEGER)) {
    3583           31 :         return myParent.myInput.readInt();
    3584              :     }
    3585              :     return libsumo::INVALID_INT_VALUE;
    3586              : }
    3587              : 
    3588              : 
    3589              : double
    3590           83 : TraCIAPI::TraCIScopeWrapper::getDouble(int var, const std::string& id, tcpip::Storage* add) const {
    3591           83 :     myParent.createCommand(myCmdGetID, var, id, add);
    3592           83 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_DOUBLE)) {
    3593           83 :         return myParent.myInput.readDouble();
    3594              :     }
    3595              :     return libsumo::INVALID_DOUBLE_VALUE;
    3596              : }
    3597              : 
    3598              : 
    3599              : libsumo::TraCIPositionVector
    3600            3 : TraCIAPI::TraCIScopeWrapper::getPolygon(int var, const std::string& id, tcpip::Storage* add) const {
    3601              :     libsumo::TraCIPositionVector ret;
    3602            3 :     myParent.createCommand(myCmdGetID, var, id, add);
    3603            3 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_POLYGON)) {
    3604            3 :         int size = myParent.myInput.readUnsignedByte();
    3605            3 :         if (size == 0) {
    3606            0 :             size = myParent.myInput.readInt();
    3607              :         }
    3608           20 :         for (int i = 0; i < size; ++i) {
    3609           17 :             libsumo::TraCIPosition p;
    3610           17 :             p.x = myParent.myInput.readDouble();
    3611           17 :             p.y = myParent.myInput.readDouble();
    3612           17 :             p.z = 0.;
    3613           17 :             ret.value.push_back(p);
    3614              :         }
    3615              :     }
    3616            3 :     return ret;
    3617              : }
    3618              : 
    3619              : 
    3620              : libsumo::TraCIPosition
    3621            2 : TraCIAPI::TraCIScopeWrapper::getPos(int var, const std::string& id, tcpip::Storage* add) const {
    3622            2 :     libsumo::TraCIPosition p;
    3623            2 :     myParent.createCommand(myCmdGetID, var, id, add);
    3624            2 :     if (myParent.processGet(myCmdGetID, libsumo::POSITION_2D)) {
    3625            2 :         p.x = myParent.myInput.readDouble();
    3626            2 :         p.y = myParent.myInput.readDouble();
    3627            2 :         p.z = 0;
    3628              :     }
    3629            2 :     return p;
    3630              : }
    3631              : 
    3632              : 
    3633              : libsumo::TraCIPosition
    3634            1 : TraCIAPI::TraCIScopeWrapper::getPos3D(int var, const std::string& id, tcpip::Storage* add) const {
    3635            1 :     libsumo::TraCIPosition p;
    3636            1 :     myParent.createCommand(myCmdGetID, var, id, add);
    3637            1 :     if (myParent.processGet(myCmdGetID, libsumo::POSITION_3D)) {
    3638            1 :         p.x = myParent.myInput.readDouble();
    3639            1 :         p.y = myParent.myInput.readDouble();
    3640            1 :         p.z = myParent.myInput.readDouble();
    3641              :     }
    3642            1 :     return p;
    3643              : }
    3644              : 
    3645              : 
    3646              : std::string
    3647           25 : TraCIAPI::TraCIScopeWrapper::getString(int var, const std::string& id, tcpip::Storage* add) const {
    3648           25 :     myParent.createCommand(myCmdGetID, var, id, add);
    3649           25 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_STRING)) {
    3650           25 :         return myParent.myInput.readString();
    3651              :     }
    3652            0 :     return "";
    3653              : }
    3654              : 
    3655              : 
    3656              : std::vector<std::string>
    3657           22 : TraCIAPI::TraCIScopeWrapper::getStringVector(int var, const std::string& id, tcpip::Storage* add) const {
    3658              :     std::vector<std::string> r;
    3659           22 :     myParent.createCommand(myCmdGetID, var, id, add);
    3660           22 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_STRINGLIST)) {
    3661           22 :         const int size = myParent.myInput.readInt();
    3662          320 :         for (int i = 0; i < size; ++i) {
    3663          596 :             r.push_back(myParent.myInput.readString());
    3664              :         }
    3665              :     }
    3666           22 :     return r;
    3667            0 : }
    3668              : 
    3669              : 
    3670              : std::vector<double>
    3671            0 : TraCIAPI::TraCIScopeWrapper::getDoubleVector(int var, const std::string& id, tcpip::Storage* add) const {
    3672              :     std::vector<double> r;
    3673            0 :     myParent.createCommand(myCmdGetID, var, id, add);
    3674            0 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_DOUBLELIST)) {
    3675            0 :         const int size = myParent.myInput.readInt();
    3676            0 :         for (int i = 0; i < size; ++i) {
    3677            0 :             r.push_back(myParent.myInput.readDouble());
    3678              :         }
    3679              :     }
    3680            0 :     return r;
    3681            0 : }
    3682              : 
    3683              : 
    3684              : libsumo::TraCIColor
    3685            4 : TraCIAPI::TraCIScopeWrapper::getCol(int var, const std::string& id, tcpip::Storage* add) const {
    3686              :     libsumo::TraCIColor c;
    3687            4 :     myParent.createCommand(myCmdGetID, var, id, add);
    3688            4 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_COLOR)) {
    3689            4 :         c.r = (unsigned char)myParent.myInput.readUnsignedByte();
    3690            4 :         c.g = (unsigned char)myParent.myInput.readUnsignedByte();
    3691            4 :         c.b = (unsigned char)myParent.myInput.readUnsignedByte();
    3692            4 :         c.a = (unsigned char)myParent.myInput.readUnsignedByte();
    3693              :     }
    3694            4 :     return c;
    3695              : }
    3696              : 
    3697              : 
    3698              : libsumo::TraCIStage
    3699            3 : TraCIAPI::TraCIScopeWrapper::getTraCIStage(int var, const std::string& id, tcpip::Storage* add) const {
    3700            6 :     libsumo::TraCIStage s;
    3701            3 :     myParent.createCommand(myCmdGetID, var, id, add);
    3702            3 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_COMPOUND)) {
    3703            3 :         myParent.myInput.readInt(); // components
    3704            3 :         myParent.myInput.readUnsignedByte();
    3705            3 :         s.type = myParent.myInput.readInt();
    3706              : 
    3707            3 :         myParent.myInput.readUnsignedByte();
    3708            3 :         s.vType = myParent.myInput.readString();
    3709              : 
    3710            3 :         myParent.myInput.readUnsignedByte();
    3711            3 :         s.line = myParent.myInput.readString();
    3712              : 
    3713            3 :         myParent.myInput.readUnsignedByte();
    3714            3 :         s.destStop = myParent.myInput.readString();
    3715              : 
    3716            3 :         myParent.myInput.readUnsignedByte();
    3717            3 :         s.edges = myParent.myInput.readStringList();
    3718              : 
    3719            3 :         myParent.myInput.readUnsignedByte();
    3720            3 :         s.travelTime = myParent.myInput.readDouble();
    3721              : 
    3722            3 :         myParent.myInput.readUnsignedByte();
    3723            3 :         s.cost = myParent.myInput.readDouble();
    3724              : 
    3725            3 :         myParent.myInput.readUnsignedByte();
    3726            3 :         s.length = myParent.myInput.readDouble();
    3727              : 
    3728            3 :         myParent.myInput.readUnsignedByte();
    3729            3 :         s.intended = myParent.myInput.readString();
    3730              : 
    3731            3 :         myParent.myInput.readUnsignedByte();
    3732            3 :         s.depart = myParent.myInput.readDouble();
    3733              : 
    3734            3 :         myParent.myInput.readUnsignedByte();
    3735            3 :         s.departPos = myParent.myInput.readDouble();
    3736              : 
    3737            3 :         myParent.myInput.readUnsignedByte();
    3738            3 :         s.arrivalPos = myParent.myInput.readDouble();
    3739              : 
    3740            3 :         myParent.myInput.readUnsignedByte();
    3741            6 :         s.description = myParent.myInput.readString();
    3742              :     }
    3743            3 :     return s;
    3744            0 : }
    3745              : 
    3746              : 
    3747              : std::vector<std::string>
    3748           13 : TraCIAPI::TraCIScopeWrapper::getIDList() const {
    3749           26 :     return getStringVector(libsumo::TRACI_ID_LIST, "");
    3750              : }
    3751              : 
    3752              : 
    3753              : int
    3754            7 : TraCIAPI::TraCIScopeWrapper::getIDCount() const {
    3755           14 :     return getInt(libsumo::ID_COUNT, "");
    3756              : }
    3757              : 
    3758              : 
    3759              : std::string
    3760            3 : TraCIAPI::TraCIScopeWrapper::getParameter(const std::string& objectID, const std::string& key) const {
    3761            3 :     tcpip::Storage content;
    3762            3 :     content.writeByte(libsumo::TYPE_STRING);
    3763            3 :     content.writeString(key);
    3764            6 :     return getString(libsumo::VAR_PARAMETER, objectID, &content);
    3765            3 : }
    3766              : 
    3767              : 
    3768              : std::pair<std::string, std::string>
    3769            1 : TraCIAPI::TraCIScopeWrapper::getParameterWithKey(const std::string& objectID, const std::string& key) const {
    3770            1 :     tcpip::Storage content;
    3771            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3772            1 :     content.writeString(key);
    3773              : 
    3774            1 :     myParent.createCommand(myCmdGetID, libsumo::VAR_PARAMETER_WITH_KEY, objectID, &content);
    3775            1 :     if (myParent.processGet(myCmdGetID, libsumo::TYPE_COMPOUND)) {
    3776            1 :         myParent.myInput.readInt();  // number of components
    3777            1 :         myParent.myInput.readUnsignedByte();
    3778            1 :         const std::string returnedKey = myParent.myInput.readString();
    3779            1 :         myParent.myInput.readUnsignedByte();
    3780            1 :         const std::string value = myParent.myInput.readString();
    3781              :         return std::make_pair(returnedKey, value);
    3782              :     }
    3783            0 :     return std::make_pair(key, "");
    3784            1 : }
    3785              : 
    3786              : 
    3787              : void
    3788            2 : TraCIAPI::TraCIScopeWrapper::setParameter(const std::string& objectID, const std::string& key, const std::string& value) const {
    3789            2 :     tcpip::Storage content;
    3790            2 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
    3791            2 :     content.writeInt(2);
    3792            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3793            2 :     content.writeString(key);
    3794            2 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3795            2 :     content.writeString(value);
    3796            2 :     myParent.createCommand(myCmdSetID, libsumo::VAR_PARAMETER, objectID, &content);
    3797            2 :     myParent.processSet(myCmdSetID);
    3798            2 : }
    3799              : 
    3800              : 
    3801              : void
    3802            0 : TraCIAPI::TraCIScopeWrapper::setInt(int var, const std::string& id, int value) const {
    3803            0 :     tcpip::Storage content;
    3804            0 :     content.writeUnsignedByte(libsumo::TYPE_INTEGER);
    3805            0 :     content.writeInt(value);
    3806            0 :     myParent.createCommand(myCmdSetID, var, id, &content);
    3807            0 :     myParent.processSet(myCmdSetID);
    3808            0 : }
    3809              : 
    3810              : 
    3811              : void
    3812            2 : TraCIAPI::TraCIScopeWrapper::setDouble(int var, const std::string& id, double value) const {
    3813            2 :     tcpip::Storage content;
    3814            2 :     content.writeUnsignedByte(libsumo::TYPE_DOUBLE);
    3815            2 :     content.writeDouble(value);
    3816            2 :     myParent.createCommand(myCmdSetID, var, id, &content);
    3817            2 :     myParent.processSet(myCmdSetID);
    3818            2 : }
    3819              : 
    3820              : 
    3821              : void
    3822            1 : TraCIAPI::TraCIScopeWrapper::setString(int var, const std::string& id, const std::string& value) const {
    3823            1 :     tcpip::Storage content;
    3824            1 :     content.writeUnsignedByte(libsumo::TYPE_STRING);
    3825            1 :     content.writeString(value);
    3826            1 :     myParent.createCommand(myCmdSetID, var, id, &content);
    3827            1 :     myParent.processSet(myCmdSetID);
    3828            1 : }
    3829              : 
    3830              : 
    3831              : void
    3832            0 : TraCIAPI::TraCIScopeWrapper::setStringVector(int var, const std::string& id, const std::vector<std::string>& value) const {
    3833            0 :     tcpip::Storage content;
    3834            0 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
    3835            0 :     content.writeInt((int)value.size());
    3836            0 :     for (const std::string& s : value) {
    3837            0 :         content.writeString(s);
    3838              :     }
    3839            0 :     myParent.createCommand(myCmdSetID, var, id, &content);
    3840            0 :     myParent.processSet(myCmdSetID);
    3841            0 : }
    3842              : 
    3843              : 
    3844              : void
    3845            2 : TraCIAPI::TraCIScopeWrapper::subscribe(const std::string& objID, const std::vector<int>& vars, double beginTime, double endTime) const {
    3846            2 :     myParent.send_commandSubscribeObjectVariable(mySubscribeID, objID, beginTime, endTime, vars);
    3847            2 :     tcpip::Storage inMsg;
    3848            2 :     myParent.check_resultState(inMsg, mySubscribeID);
    3849            2 :     if (vars.size() > 0) {
    3850            2 :         myParent.check_commandGetResult(inMsg, mySubscribeID);
    3851            2 :         myParent.readVariableSubscription(mySubscribeID + 0x10, inMsg);
    3852              :     }
    3853            2 : }
    3854              : 
    3855              : 
    3856              : void
    3857            5 : TraCIAPI::TraCIScopeWrapper::subscribeContext(const std::string& objID, int domain, double range, const std::vector<int>& vars, double beginTime, double endTime) const {
    3858            5 :     myParent.send_commandSubscribeObjectContext(myContextSubscribeID, objID, beginTime, endTime, domain, range, vars);
    3859            5 :     tcpip::Storage inMsg;
    3860            5 :     myParent.check_resultState(inMsg, myContextSubscribeID);
    3861            5 :     myParent.check_commandGetResult(inMsg, myContextSubscribeID);
    3862            5 :     myParent.readContextSubscription(myContextSubscribeID + 0x60, inMsg);
    3863            5 : }
    3864              : 
    3865              : 
    3866              : const libsumo::SubscriptionResults
    3867            0 : TraCIAPI::TraCIScopeWrapper::getAllSubscriptionResults() const {
    3868            0 :     return mySubscriptionResults;
    3869              : }
    3870              : 
    3871              : 
    3872              : const libsumo::TraCIResults
    3873            1 : TraCIAPI::TraCIScopeWrapper::getSubscriptionResults(const std::string& objID) const {
    3874            1 :     if (mySubscriptionResults.find(objID) != mySubscriptionResults.end()) {
    3875              :         return mySubscriptionResults.find(objID)->second;
    3876              :     } else {
    3877            0 :         return libsumo::TraCIResults();
    3878              :     }
    3879              : }
    3880              : 
    3881              : 
    3882              : const libsumo::ContextSubscriptionResults
    3883            0 : TraCIAPI::TraCIScopeWrapper::getAllContextSubscriptionResults() const {
    3884            0 :     return myContextSubscriptionResults;
    3885              : }
    3886              : 
    3887              : 
    3888              : const libsumo::SubscriptionResults
    3889            2 : TraCIAPI::TraCIScopeWrapper::getContextSubscriptionResults(const std::string& objID) const {
    3890            2 :     if (myContextSubscriptionResults.find(objID) != myContextSubscriptionResults.end()) {
    3891              :         return myContextSubscriptionResults.find(objID)->second;
    3892              :     } else {
    3893            0 :         return libsumo::SubscriptionResults();
    3894              :     }
    3895              : }
    3896              : 
    3897              : 
    3898              : void
    3899          160 : TraCIAPI::TraCIScopeWrapper::clearSubscriptionResults() {
    3900              :     mySubscriptionResults.clear();
    3901              :     myContextSubscriptionResults.clear();
    3902          160 : }
    3903              : 
    3904              : 
    3905              : libsumo::SubscriptionResults&
    3906            9 : TraCIAPI::TraCIScopeWrapper::getModifiableSubscriptionResults() {
    3907            9 :     return mySubscriptionResults;
    3908              : }
    3909              : 
    3910              : 
    3911              : libsumo::SubscriptionResults&
    3912           30 : TraCIAPI::TraCIScopeWrapper::getModifiableContextSubscriptionResults(const std::string& objID) {
    3913           30 :     return myContextSubscriptionResults[objID];
    3914              : }
    3915              : 
    3916              : 
    3917              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1