LCOV - code coverage report
Current view: top level - src/libtraci - Simulation.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 96.9 % 259 251
Test Date: 2025-11-13 15:38:19 Functions: 88.6 % 79 70

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2017-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    Simulation.cpp
      15              : /// @author  Laura Bieker-Walz
      16              : /// @author  Robert Hilbrich
      17              : /// @date    15.09.2017
      18              : ///
      19              : // C++ TraCI client API implementation
      20              : /****************************************************************************/
      21              : #include <config.h>
      22              : #include <cstdlib>
      23              : 
      24              : #include <foreign/tcpip/socket.h>
      25              : #define LIBTRACI 1
      26              : #include "Connection.h"
      27              : #include "Domain.h"
      28              : #include <libsumo/StorageHelper.h>
      29              : #include <libsumo/GUI.h>
      30              : #include <libsumo/Simulation.h>
      31              : 
      32              : 
      33              : namespace libtraci {
      34              : 
      35              : typedef Domain<libsumo::CMD_GET_SIM_VARIABLE, libsumo::CMD_SET_SIM_VARIABLE> Dom;
      36              : 
      37              : 
      38              : // ===========================================================================
      39              : // static member definitions
      40              : // ===========================================================================
      41              : std::pair<int, std::string>
      42          784 : Simulation::init(int port, int numRetries, const std::string& host, const std::string& label, FILE* const pipe) {
      43          784 :     Connection::connect(host, port, numRetries, label, pipe);
      44          782 :     switchConnection(label);
      45          782 :     return getVersion();
      46              : }
      47              : 
      48              : 
      49              : std::pair<int, std::string>
      50          608 : Simulation::start(const std::vector<std::string>& cmd, int port, int numRetries, const std::string& label, const bool verbose,
      51              :                   const std::string& /* traceFile */, bool /* traceGetters */, void* /* _stdout */) {
      52          608 :     if (port == -1) {
      53          595 :         port = tcpip::Socket::getFreeSocketPort();
      54              :     }
      55          608 :     std::ostringstream oss;
      56         5002 :     for (const std::string& s : cmd) {
      57         4394 :         oss << s << " ";
      58              :     }
      59          608 :     oss << "--remote-port " << port << " 2>&1";
      60              : #ifndef WIN32
      61          608 :     oss << " &";
      62              : #endif
      63          608 :     if (verbose) {
      64            0 :         std::cout << "Calling " << oss.str() << std::endl;
      65              :     }
      66              : #ifdef WIN32
      67              :     FILE* pipe = _popen(oss.str().c_str(), "r");
      68              : #else
      69          608 :     FILE* pipe = popen(oss.str().c_str(), "r");
      70              : #endif
      71         1216 :     return init(port, numRetries, "localhost", label, pipe);
      72          608 : }
      73              : 
      74              : 
      75              : bool
      76            0 : Simulation::isLibsumo() {
      77            0 :     return false;
      78              : }
      79              : 
      80              : 
      81              : bool
      82            2 : Simulation::hasGUI() {
      83              :     try {
      84            2 :         GUI::getIDList();
      85            1 :         return true;
      86            1 :     } catch (libsumo::TraCIException&) {
      87              :         return false;
      88            1 :     }
      89              : }
      90              : 
      91              : 
      92              : void
      93          796 : Simulation::switchConnection(const std::string& label) {
      94              :     Connection::switchCon(label);
      95          796 : }
      96              : 
      97              : 
      98              : const std::string&
      99            0 : Simulation::getLabel() {
     100            0 :     return Connection::getActive().getLabel();
     101              : }
     102              : 
     103              : 
     104              : void
     105          119 : Simulation::setOrder(int order) {
     106          119 :     Connection::getActive().setOrder(order);
     107          119 : }
     108              : 
     109              : 
     110              : void
     111            4 : Simulation::load(const std::vector<std::string>& args) {
     112            4 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     113            4 :     tcpip::Storage content;
     114            4 :     content.writeUnsignedByte(libsumo::TYPE_STRINGLIST);
     115            4 :     content.writeStringList(args);
     116            4 :     Connection::getActive().doCommand(libsumo::CMD_LOAD, -1, "", &content);
     117            8 : }
     118              : 
     119              : 
     120              : bool
     121            4 : Simulation::isLoaded() {
     122            4 :     return Connection::isActive();
     123              : }
     124              : 
     125              : 
     126              : void
     127       139126 : Simulation::step(const double time) {
     128       139126 :     Connection::getActive().simulationStep(time);
     129       139122 : }
     130              : 
     131              : 
     132              : void
     133            2 : Simulation::executeMove() {
     134            2 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     135            4 :     Connection::getActive().doCommand(libsumo::CMD_EXECUTEMOVE);
     136            2 : }
     137              : 
     138              : 
     139              : void
     140          777 : Simulation::close(const std::string& /* reason */) {
     141          777 :     Connection::getActive().close();
     142          777 : }
     143              : 
     144              : 
     145              : std::pair<int, std::string>
     146          783 : Simulation::getVersion() {
     147          783 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     148          783 :     tcpip::Storage& inMsg = Connection::getActive().doCommand(libsumo::CMD_GETVERSION);
     149          782 :     inMsg.readUnsignedByte(); // msg length
     150          782 :     inMsg.readUnsignedByte(); // libsumo::CMD_GETVERSION again, see #7284
     151          782 :     const int traciVersion = inMsg.readInt(); // to fix evaluation order
     152         1565 :     return std::make_pair(traciVersion, inMsg.readString());
     153              : }
     154              : 
     155              : 
     156              : std::string
     157            1 : Simulation::getOption(const std::string& option) {
     158            1 :     return Dom::getString(libsumo::VAR_OPTION, option);
     159              : }
     160              : 
     161              : 
     162              : int
     163            0 : Simulation::getCurrentTime() {
     164            0 :     return Dom::getInt(libsumo::VAR_TIME_STEP, "");
     165              : }
     166              : 
     167              : 
     168              : double
     169        70000 : Simulation::getTime() {
     170       139998 :     return Dom::getDouble(libsumo::VAR_TIME, "");
     171              : }
     172              : 
     173              : 
     174              : double
     175            1 : Simulation::getEndTime() {
     176            2 :     return Dom::getDouble(libsumo::VAR_END, "");
     177              : }
     178              : 
     179              : 
     180              : int
     181            4 : Simulation::getLoadedNumber() {
     182            8 :     return Dom::getInt(libsumo::VAR_LOADED_VEHICLES_NUMBER, "");
     183              : }
     184              : 
     185              : 
     186              : std::vector<std::string>
     187            4 : Simulation::getLoadedIDList() {
     188            8 :     return Dom::getStringVector(libsumo::VAR_LOADED_VEHICLES_IDS, "");
     189              : }
     190              : 
     191              : 
     192              : int
     193        15800 : Simulation::getDepartedNumber() {
     194        31600 :     return Dom::getInt(libsumo::VAR_DEPARTED_VEHICLES_NUMBER, "");
     195              : }
     196              : 
     197              : 
     198              : std::vector<std::string>
     199         4126 : Simulation::getDepartedIDList() {
     200         8252 :     return Dom::getStringVector(libsumo::VAR_DEPARTED_VEHICLES_IDS, "");
     201              : }
     202              : 
     203              : 
     204              : int
     205          340 : Simulation::getArrivedNumber() {
     206          680 :     return Dom::getInt(libsumo::VAR_ARRIVED_VEHICLES_NUMBER, "");
     207              : }
     208              : 
     209              : 
     210              : std::vector<std::string>
     211         3995 : Simulation::getArrivedIDList() {
     212         7990 :     return Dom::getStringVector(libsumo::VAR_ARRIVED_VEHICLES_IDS, "");
     213              : }
     214              : 
     215              : 
     216              : int
     217            4 : Simulation::getParkingStartingVehiclesNumber() {
     218            8 :     return Dom::getInt(libsumo::VAR_PARKING_STARTING_VEHICLES_NUMBER, "");
     219              : }
     220              : 
     221              : 
     222              : std::vector<std::string>
     223            4 : Simulation::getParkingStartingVehiclesIDList() {
     224            8 :     return Dom::getStringVector(libsumo::VAR_PARKING_STARTING_VEHICLES_IDS, "");
     225              : }
     226              : 
     227              : 
     228              : int
     229            4 : Simulation::getParkingEndingVehiclesNumber() {
     230            8 :     return Dom::getInt(libsumo::VAR_PARKING_ENDING_VEHICLES_NUMBER, "");
     231              : }
     232              : 
     233              : 
     234              : std::vector<std::string>
     235            4 : Simulation::getParkingEndingVehiclesIDList() {
     236            8 :     return Dom::getStringVector(libsumo::VAR_PARKING_ENDING_VEHICLES_IDS, "");
     237              : }
     238              : 
     239              : 
     240              : int
     241            4 : Simulation::getStopStartingVehiclesNumber() {
     242            8 :     return Dom::getInt(libsumo::VAR_STOP_STARTING_VEHICLES_NUMBER, "");
     243              : }
     244              : 
     245              : 
     246              : std::vector<std::string>
     247            4 : Simulation::getStopStartingVehiclesIDList() {
     248            8 :     return Dom::getStringVector(libsumo::VAR_STOP_STARTING_VEHICLES_IDS, "");
     249              : }
     250              : 
     251              : 
     252              : int
     253            4 : Simulation::getStopEndingVehiclesNumber() {
     254            8 :     return Dom::getInt(libsumo::VAR_STOP_ENDING_VEHICLES_NUMBER, "");
     255              : }
     256              : 
     257              : 
     258              : std::vector<std::string>
     259            4 : Simulation::getStopEndingVehiclesIDList() {
     260            8 :     return Dom::getStringVector(libsumo::VAR_STOP_ENDING_VEHICLES_IDS, "");
     261              : }
     262              : 
     263              : 
     264              : int
     265           16 : Simulation::getCollidingVehiclesNumber() {
     266           32 :     return Dom::getInt(libsumo::VAR_COLLIDING_VEHICLES_NUMBER, "");
     267              : }
     268              : 
     269              : 
     270              : std::vector<std::string>
     271            4 : Simulation::getCollidingVehiclesIDList() {
     272            8 :     return Dom::getStringVector(libsumo::VAR_COLLIDING_VEHICLES_IDS, "");
     273              : }
     274              : 
     275              : 
     276              : int
     277           16 : Simulation::getEmergencyStoppingVehiclesNumber() {
     278           32 :     return Dom::getInt(libsumo::VAR_EMERGENCYSTOPPING_VEHICLES_NUMBER, "");
     279              : }
     280              : 
     281              : 
     282              : std::vector<std::string>
     283            4 : Simulation::getEmergencyStoppingVehiclesIDList() {
     284            8 :     return Dom::getStringVector(libsumo::VAR_EMERGENCYSTOPPING_VEHICLES_IDS, "");
     285              : }
     286              : 
     287              : 
     288              : int
     289            4 : Simulation::getStartingTeleportNumber() {
     290            8 :     return Dom::getInt(libsumo::VAR_TELEPORT_STARTING_VEHICLES_NUMBER, "");
     291              : }
     292              : 
     293              : 
     294              : std::vector<std::string>
     295            4 : Simulation::getStartingTeleportIDList() {
     296            8 :     return Dom::getStringVector(libsumo::VAR_TELEPORT_STARTING_VEHICLES_IDS, "");
     297              : }
     298              : 
     299              : 
     300              : int
     301            4 : Simulation::getEndingTeleportNumber() {
     302            8 :     return Dom::getInt(libsumo::VAR_TELEPORT_ENDING_VEHICLES_NUMBER, "");
     303              : }
     304              : 
     305              : 
     306              : std::vector<std::string>
     307            4 : Simulation::getEndingTeleportIDList() {
     308            8 :     return Dom::getStringVector(libsumo::VAR_TELEPORT_ENDING_VEHICLES_IDS, "");
     309              : }
     310              : 
     311              : 
     312              : int
     313            3 : Simulation::getDepartedPersonNumber() {
     314            6 :     return Dom::getInt(libsumo::VAR_DEPARTED_PERSONS_NUMBER, "");
     315              : }
     316              : 
     317              : 
     318              : std::vector<std::string>
     319            3 : Simulation::getDepartedPersonIDList() {
     320            6 :     return Dom::getStringVector(libsumo::VAR_DEPARTED_PERSONS_IDS, "");
     321              : }
     322              : 
     323              : 
     324              : int
     325            3 : Simulation::getArrivedPersonNumber() {
     326            6 :     return Dom::getInt(libsumo::VAR_ARRIVED_PERSONS_NUMBER, "");
     327              : }
     328              : 
     329              : 
     330              : std::vector<std::string>
     331            3 : Simulation::getArrivedPersonIDList() {
     332            6 :     return Dom::getStringVector(libsumo::VAR_ARRIVED_PERSONS_IDS, "");
     333              : }
     334              : 
     335              : 
     336              : std::vector<std::string>
     337            1 : Simulation::getBusStopIDList() {
     338            2 :     return Dom::getStringVector(libsumo::VAR_BUS_STOP_ID_LIST, "");
     339              : }
     340              : 
     341              : int
     342            2 : Simulation::getBusStopWaiting(const std::string& stopID) {
     343            2 :     return Dom::getInt(libsumo::VAR_BUS_STOP_WAITING, stopID);
     344              : }
     345              : 
     346              : std::vector<std::string>
     347           31 : Simulation::getBusStopWaitingIDList(const std::string& stopID) {
     348           31 :     return Dom::getStringVector(libsumo::VAR_BUS_STOP_WAITING_IDS, stopID);
     349              : }
     350              : 
     351              : 
     352              : std::vector<std::string>
     353            6 : Simulation::getPendingVehicles() {
     354           12 :     return Dom::getStringVector(libsumo::VAR_PENDING_VEHICLES, "");
     355              : }
     356              : 
     357              : 
     358              : std::vector<libsumo::TraCICollision>
     359           68 : Simulation::getCollisions() {
     360           68 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     361          136 :     tcpip::Storage& ret = Dom::get(libsumo::VAR_COLLISIONS, "");
     362              :     std::vector<libsumo::TraCICollision> result;
     363           68 :     ret.readInt();
     364          136 :     StoHelp::readCollisionVector(ret, result);
     365           68 :     return result;
     366            0 : }
     367              : 
     368              : 
     369              : double
     370            1 : Simulation::getScale() {
     371            2 :     return Dom::getDouble(libsumo::VAR_SCALE, "");
     372              : }
     373              : 
     374              : 
     375              : double
     376           37 : Simulation::getDeltaT() {
     377           74 :     return Dom::getDouble(libsumo::VAR_DELTA_T, "");
     378              : }
     379              : 
     380              : 
     381              : libsumo::TraCIPositionVector
     382            1 : Simulation::getNetBoundary() {
     383            2 :     return Dom::getPolygon(libsumo::VAR_NET_BOUNDING_BOX, "");
     384              : }
     385              : 
     386              : 
     387              : int
     388        54169 : Simulation::getMinExpectedNumber() {
     389       108337 :     return Dom::getInt(libsumo::VAR_MIN_EXPECTED_VEHICLES, "");
     390              : }
     391              : 
     392              : 
     393              : libsumo::TraCIPosition
     394           45 : Simulation::convert2D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) {
     395           45 :     tcpip::Storage content;
     396              :     StoHelp::writeCompound(content, 2);
     397           45 :     content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
     398           45 :     content.writeString(edgeID);
     399           45 :     content.writeDouble(pos);
     400           45 :     content.writeUnsignedByte(laneIndex);
     401           45 :     content.writeUnsignedByte(libsumo::TYPE_UBYTE);
     402           89 :     content.writeUnsignedByte(toGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
     403           90 :     return Dom::getPos(libsumo::POSITION_CONVERSION, "", &content, toGeo);
     404           45 : }
     405              : 
     406              : 
     407              : libsumo::TraCIPosition
     408            2 : Simulation::convert3D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) {
     409            2 :     tcpip::Storage content;
     410              :     StoHelp::writeCompound(content, 2);
     411            2 :     content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
     412            2 :     content.writeString(edgeID);
     413            2 :     content.writeDouble(pos);
     414            2 :     content.writeUnsignedByte(laneIndex);
     415            2 :     content.writeUnsignedByte(libsumo::TYPE_UBYTE);
     416            3 :     content.writeUnsignedByte(toGeo ? libsumo::POSITION_LON_LAT_ALT : libsumo::POSITION_3D);
     417            4 :     return Dom::getPos3D(libsumo::POSITION_CONVERSION, "", &content, toGeo);
     418            2 : }
     419              : 
     420              : 
     421              : libsumo::TraCIRoadPosition
     422           26 : Simulation::convertRoad(double x, double y, bool isGeo, const std::string& vClass) {
     423           26 :     tcpip::Storage content;
     424              :     StoHelp::writeCompound(content, 3);
     425           49 :     content.writeUnsignedByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
     426           26 :     content.writeDouble(x);
     427           26 :     content.writeDouble(y);
     428           26 :     content.writeUnsignedByte(libsumo::TYPE_UBYTE);
     429           26 :     content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
     430              :     StoHelp::writeTypedString(content, vClass);
     431           26 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     432           26 :     tcpip::Storage& ret = Dom::get(libsumo::POSITION_CONVERSION, "", &content, libsumo::POSITION_ROADMAP);
     433           26 :     libsumo::TraCIRoadPosition result;
     434           26 :     result.edgeID = ret.readString();
     435           26 :     result.pos = ret.readDouble();
     436           26 :     result.laneIndex = ret.readByte();
     437           26 :     return result;
     438           26 : }
     439              : 
     440              : 
     441              : libsumo::TraCIPosition
     442            5 : Simulation::convertGeo(double x, double y, bool fromGeo) {
     443            5 :     tcpip::Storage content;
     444              :     StoHelp::writeCompound(content, 2);
     445            9 :     content.writeUnsignedByte(fromGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
     446            5 :     content.writeDouble(x);
     447            5 :     content.writeDouble(y);
     448            5 :     content.writeUnsignedByte(libsumo::TYPE_UBYTE);
     449            9 :     content.writeUnsignedByte(fromGeo ? libsumo::POSITION_2D : libsumo::POSITION_LON_LAT);
     450           10 :     return Dom::getPos(libsumo::POSITION_CONVERSION, "", &content, !fromGeo);
     451            5 : }
     452              : 
     453              : 
     454              : double
     455           37 : Simulation::getDistance2D(double x1, double y1, double x2, double y2, bool isGeo, bool isDriving) {
     456           37 :     tcpip::Storage content;
     457              :     StoHelp::writeCompound(content, 3);
     458           73 :     content.writeUnsignedByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
     459           37 :     content.writeDouble(x1);
     460           37 :     content.writeDouble(y1);
     461           37 :     content.writeUnsignedByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
     462           37 :     content.writeDouble(x2);
     463           37 :     content.writeDouble(y2);
     464           39 :     content.writeUnsignedByte(isDriving ? libsumo::REQUEST_DRIVINGDIST : libsumo::REQUEST_AIRDIST);
     465           74 :     return Dom::getDouble(libsumo::DISTANCE_REQUEST, "", &content);
     466           37 : }
     467              : 
     468              : 
     469              : double
     470           44 : Simulation::getDistanceRoad(const std::string& edgeID1, double pos1, const std::string& edgeID2, double pos2, bool isDriving) {
     471           44 :     tcpip::Storage content;
     472              :     StoHelp::writeCompound(content, 3);
     473           44 :     content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
     474           44 :     content.writeString(edgeID1);
     475           44 :     content.writeDouble(pos1);
     476           44 :     content.writeUnsignedByte(0);
     477           44 :     content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
     478           44 :     content.writeString(edgeID2);
     479           44 :     content.writeDouble(pos2);
     480           44 :     content.writeUnsignedByte(0);
     481           79 :     content.writeUnsignedByte(isDriving ? libsumo::REQUEST_DRIVINGDIST : libsumo::REQUEST_AIRDIST);
     482           88 :     return Dom::getDouble(libsumo::DISTANCE_REQUEST, "", &content);
     483           44 : }
     484              : 
     485              : 
     486              : libsumo::TraCIStage
     487            5 : Simulation::findRoute(const std::string& fromEdge, const std::string& toEdge, const std::string& vType, const double depart, const int routingMode) {
     488            5 :     tcpip::Storage content;
     489              :     StoHelp::writeCompound(content, 5);
     490              :     StoHelp::writeTypedString(content, fromEdge);
     491              :     StoHelp::writeTypedString(content, toEdge);
     492              :     StoHelp::writeTypedString(content, vType);
     493              :     StoHelp::writeTypedDouble(content, depart);
     494              :     StoHelp::writeTypedInt(content, routingMode);
     495            8 :     return Dom::getTraCIStage(libsumo::FIND_ROUTE, "", &content);
     496            5 : }
     497              : 
     498              : 
     499              : std::vector<libsumo::TraCIStage>
     500           79 : Simulation::findIntermodalRoute(const std::string& fromEdge, const std::string& toEdge,
     501              :                                 const std::string& modes, double depart, const int routingMode, double speed, double walkFactor,
     502              :                                 double departPos, double arrivalPos, const double departPosLat,
     503              :                                 const std::string& pType, const std::string& vType, const std::string& destStop) {
     504           79 :     tcpip::Storage content;
     505              :     StoHelp::writeCompound(content, 13);
     506              :     StoHelp::writeTypedString(content, fromEdge);
     507              :     StoHelp::writeTypedString(content, toEdge);
     508              :     StoHelp::writeTypedString(content, modes);
     509              :     StoHelp::writeTypedDouble(content, depart);
     510              :     StoHelp::writeTypedInt(content, routingMode);
     511              :     StoHelp::writeTypedDouble(content, speed);
     512              :     StoHelp::writeTypedDouble(content, walkFactor);
     513              :     StoHelp::writeTypedDouble(content, departPos);
     514              :     StoHelp::writeTypedDouble(content, arrivalPos);
     515              :     StoHelp::writeTypedDouble(content, departPosLat);
     516              :     StoHelp::writeTypedString(content, pType);
     517              :     StoHelp::writeTypedString(content, vType);
     518              :     StoHelp::writeTypedString(content, destStop);
     519           79 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     520           81 :     tcpip::Storage& result = Dom::get(libsumo::FIND_INTERMODAL_ROUTE, "", &content);
     521           77 :     int numStages = result.readInt();
     522              :     std::vector<libsumo::TraCIStage> ret;
     523          234 :     while (numStages-- > 0) {
     524          314 :         libsumo::TraCIStage s;
     525          157 :         StoHelp::readCompound(result, 13);
     526          157 :         s.type = StoHelp::readTypedInt(result);
     527          157 :         s.vType = StoHelp::readTypedString(result);
     528          157 :         s.line = StoHelp::readTypedString(result);
     529          157 :         s.destStop = StoHelp::readTypedString(result);
     530          157 :         s.edges = StoHelp::readTypedStringList(result);
     531          157 :         s.travelTime = StoHelp::readTypedDouble(result);
     532          157 :         s.cost = StoHelp::readTypedDouble(result);
     533          157 :         s.length = StoHelp::readTypedDouble(result);
     534          157 :         s.intended = StoHelp::readTypedString(result);
     535          157 :         s.depart = StoHelp::readTypedDouble(result);
     536          157 :         s.departPos = StoHelp::readTypedDouble(result);
     537          157 :         s.arrivalPos = StoHelp::readTypedDouble(result);
     538          157 :         s.description = StoHelp::readTypedString(result);
     539          157 :         ret.emplace_back(s);
     540          157 :     }
     541           77 :     return ret;
     542           79 : }
     543              : 
     544          763 : LIBTRACI_PARAMETER_IMPLEMENTATION(Simulation, SIM)
     545              : 
     546              : void
     547            1 : Simulation::setScale(double value) {
     548            1 :     Dom::setDouble(libsumo::VAR_SCALE, "", value);
     549            1 : }
     550              : 
     551              : void
     552            1 : Simulation::clearPending(const std::string& routeID) {
     553            1 :     Dom::setString(libsumo::CMD_CLEAR_PENDING_VEHICLES, "", routeID);
     554            1 : }
     555              : 
     556              : 
     557              : void
     558           17 : Simulation::saveState(const std::string& fileName) {
     559           17 :     Dom::setString(libsumo::CMD_SAVE_SIMSTATE, "", fileName);
     560           17 : }
     561              : 
     562              : double
     563           38 : Simulation::loadState(const std::string& fileName) {
     564           38 :     Dom::setString(libsumo::CMD_LOAD_SIMSTATE, "", fileName);
     565           36 :     return 0.;
     566              : }
     567              : 
     568              : void
     569            1 : Simulation::writeMessage(const std::string& msg) {
     570            1 :     Dom::setString(libsumo::CMD_MESSAGE, "", msg);
     571            1 : }
     572              : 
     573              : 
     574              : void
     575           52 : Simulation::subscribe(const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& parameters) {
     576           52 :     libtraci::Connection::getActive().subscribe(libsumo::CMD_SUBSCRIBE_SIM_VARIABLE, "", begin, end, -1, -1, varIDs, parameters);
     577           42 : }
     578              : 
     579              : 
     580              : const libsumo::TraCIResults
     581          513 : Simulation::getSubscriptionResults() {
     582         1539 :     return libtraci::Connection::getActive().getAllSubscriptionResults(libsumo::RESPONSE_SUBSCRIBE_SIM_VARIABLE)[""];
     583              : }
     584              : 
     585              : 
     586          311 : LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(Simulation, SIM)
     587              : 
     588              : }
     589              : 
     590              : 
     591              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1