LCOV - code coverage report
Current view: top level - src/libtraci - Simulation.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 96.7 % 270 261
Test Date: 2024-10-24 15:46:30 Functions: 87.3 % 79 69

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2017-2024 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    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          638 : Simulation::init(int port, int numRetries, const std::string& host, const std::string& label, FILE* const pipe) {
      43          638 :     Connection::connect(host, port, numRetries, label, pipe);
      44          636 :     switchConnection(label);
      45          636 :     return getVersion();
      46              : }
      47              : 
      48              : 
      49              : std::pair<int, std::string>
      50          582 : 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          582 :     if (port == -1) {
      53          569 :         port = tcpip::Socket::getFreeSocketPort();
      54              :     }
      55          582 :     std::ostringstream oss;
      56         4766 :     for (const std::string& s : cmd) {
      57         4184 :         oss << s << " ";
      58              :     }
      59          582 :     oss << "--remote-port " << port << " 2>&1";
      60              : #ifndef WIN32
      61          582 :     oss << " &";
      62              : #endif
      63          582 :     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          582 :     FILE* pipe = popen(oss.str().c_str(), "r");
      70              : #endif
      71         1164 :     return init(port, numRetries, "localhost", label, pipe);
      72          582 : }
      73              : 
      74              : 
      75              : bool
      76            0 : Simulation::isLibsumo() {
      77            0 :     return false;
      78              : }
      79              : 
      80              : 
      81              : bool
      82            1 : Simulation::hasGUI() {
      83              :     try {
      84            1 :         GUI::getIDList();
      85            0 :         return true;
      86            1 :     } catch (libsumo::TraCIException&) {
      87              :         return false;
      88            1 :     }
      89              : }
      90              : 
      91              : 
      92              : void
      93          650 : Simulation::switchConnection(const std::string& label) {
      94              :     Connection::switchCon(label);
      95          650 : }
      96              : 
      97              : 
      98              : const std::string&
      99            0 : Simulation::getLabel() {
     100            0 :     return Connection::getActive().getLabel();
     101              : }
     102              : 
     103              : 
     104              : void
     105            2 : Simulation::setOrder(int order) {
     106            2 :     Connection::getActive().setOrder(order);
     107            2 : }
     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       105191 : Simulation::step(const double time) {
     128       105191 :     Connection::getActive().simulationStep(time);
     129       105191 : }
     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          631 : Simulation::close(const std::string& /* reason */) {
     141          631 :     Connection::getActive().close();
     142          631 : }
     143              : 
     144              : 
     145              : std::pair<int, std::string>
     146          637 : Simulation::getVersion() {
     147          637 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     148          637 :     tcpip::Storage& inMsg = Connection::getActive().doCommand(libsumo::CMD_GETVERSION);
     149          637 :     inMsg.readUnsignedByte(); // msg length
     150          637 :     inMsg.readUnsignedByte(); // libsumo::CMD_GETVERSION again, see #7284
     151          637 :     const int traciVersion = inMsg.readInt(); // to fix evaluation order
     152         1274 :     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        67631 : Simulation::getTime() {
     170       135260 :     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          628 : Simulation::getDepartedNumber() {
     194         1256 :     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          342 : Simulation::getArrivedNumber() {
     206          684 :     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 :     StoHelp::readCompound(ret);
     364           68 :     int numCollisions = ret.readInt();
     365           73 :     while (numCollisions-- > 0) {
     366              :         libsumo::TraCICollision c;
     367            5 :         c.collider = StoHelp::readTypedString(ret);
     368            5 :         c.victim = StoHelp::readTypedString(ret);
     369            5 :         c.colliderType = StoHelp::readTypedString(ret);
     370            5 :         c.victimType = StoHelp::readTypedString(ret);
     371            5 :         c.colliderSpeed = StoHelp::readTypedDouble(ret);
     372            5 :         c.victimSpeed = StoHelp::readTypedDouble(ret);
     373            5 :         c.type = StoHelp::readTypedString(ret);
     374            5 :         c.lane = StoHelp::readTypedString(ret);
     375            5 :         c.pos = StoHelp::readTypedDouble(ret);
     376            5 :         result.emplace_back(c);
     377            5 :     }
     378           68 :     return result;
     379            0 : }
     380              : 
     381              : 
     382              : double
     383            1 : Simulation::getScale() {
     384            2 :     return Dom::getDouble(libsumo::VAR_SCALE, "");
     385              : }
     386              : 
     387              : 
     388              : double
     389           37 : Simulation::getDeltaT() {
     390           74 :     return Dom::getDouble(libsumo::VAR_DELTA_T, "");
     391              : }
     392              : 
     393              : 
     394              : libsumo::TraCIPositionVector
     395            1 : Simulation::getNetBoundary() {
     396            2 :     return Dom::getPolygon(libsumo::VAR_NET_BOUNDING_BOX, "");
     397              : }
     398              : 
     399              : 
     400              : int
     401        42898 : Simulation::getMinExpectedNumber() {
     402        85795 :     return Dom::getInt(libsumo::VAR_MIN_EXPECTED_VEHICLES, "");
     403              : }
     404              : 
     405              : 
     406              : libsumo::TraCIPosition
     407           44 : Simulation::convert2D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) {
     408           44 :     tcpip::Storage content;
     409              :     StoHelp::writeCompound(content, 2);
     410           44 :     content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
     411           44 :     content.writeString(edgeID);
     412           44 :     content.writeDouble(pos);
     413           44 :     content.writeUnsignedByte(laneIndex);
     414           44 :     content.writeUnsignedByte(libsumo::TYPE_UBYTE);
     415           87 :     content.writeUnsignedByte(toGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
     416           88 :     return Dom::getPos(libsumo::POSITION_CONVERSION, "", &content, toGeo);
     417           44 : }
     418              : 
     419              : 
     420              : libsumo::TraCIPosition
     421            2 : Simulation::convert3D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) {
     422            2 :     tcpip::Storage content;
     423              :     StoHelp::writeCompound(content, 2);
     424            2 :     content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
     425            2 :     content.writeString(edgeID);
     426            2 :     content.writeDouble(pos);
     427            2 :     content.writeUnsignedByte(laneIndex);
     428            2 :     content.writeUnsignedByte(libsumo::TYPE_UBYTE);
     429            3 :     content.writeUnsignedByte(toGeo ? libsumo::POSITION_LON_LAT_ALT : libsumo::POSITION_3D);
     430            4 :     return Dom::getPos3D(libsumo::POSITION_CONVERSION, "", &content, toGeo);
     431            2 : }
     432              : 
     433              : 
     434              : libsumo::TraCIRoadPosition
     435           25 : Simulation::convertRoad(double x, double y, bool isGeo, const std::string& vClass) {
     436           25 :     tcpip::Storage content;
     437              :     StoHelp::writeCompound(content, 3);
     438           47 :     content.writeUnsignedByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
     439           25 :     content.writeDouble(x);
     440           25 :     content.writeDouble(y);
     441           25 :     content.writeUnsignedByte(libsumo::TYPE_UBYTE);
     442           25 :     content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
     443              :     StoHelp::writeTypedString(content, vClass);
     444           25 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     445           50 :     tcpip::Storage& ret = Dom::get(libsumo::POSITION_CONVERSION, "", &content, libsumo::POSITION_ROADMAP);
     446              :     libsumo::TraCIRoadPosition result;
     447           25 :     result.edgeID = ret.readString();
     448           25 :     result.pos = ret.readDouble();
     449           25 :     result.laneIndex = ret.readByte();
     450           25 :     return result;
     451           25 : }
     452              : 
     453              : 
     454              : libsumo::TraCIPosition
     455            5 : Simulation::convertGeo(double x, double y, bool fromGeo) {
     456            5 :     tcpip::Storage content;
     457              :     StoHelp::writeCompound(content, 2);
     458            9 :     content.writeUnsignedByte(fromGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
     459            5 :     content.writeDouble(x);
     460            5 :     content.writeDouble(y);
     461            5 :     content.writeUnsignedByte(libsumo::TYPE_UBYTE);
     462            9 :     content.writeUnsignedByte(fromGeo ? libsumo::POSITION_2D : libsumo::POSITION_LON_LAT);
     463           10 :     return Dom::getPos(libsumo::POSITION_CONVERSION, "", &content, !fromGeo);
     464            5 : }
     465              : 
     466              : 
     467              : double
     468           37 : Simulation::getDistance2D(double x1, double y1, double x2, double y2, bool isGeo, bool isDriving) {
     469           37 :     tcpip::Storage content;
     470              :     StoHelp::writeCompound(content, 3);
     471           73 :     content.writeUnsignedByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
     472           37 :     content.writeDouble(x1);
     473           37 :     content.writeDouble(y1);
     474           37 :     content.writeUnsignedByte(isGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D);
     475           37 :     content.writeDouble(x2);
     476           37 :     content.writeDouble(y2);
     477           39 :     content.writeUnsignedByte(isDriving ? libsumo::REQUEST_DRIVINGDIST : libsumo::REQUEST_AIRDIST);
     478           74 :     return Dom::getDouble(libsumo::DISTANCE_REQUEST, "", &content);
     479           37 : }
     480              : 
     481              : 
     482              : double
     483           44 : Simulation::getDistanceRoad(const std::string& edgeID1, double pos1, const std::string& edgeID2, double pos2, bool isDriving) {
     484           44 :     tcpip::Storage content;
     485              :     StoHelp::writeCompound(content, 3);
     486           44 :     content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
     487           44 :     content.writeString(edgeID1);
     488           44 :     content.writeDouble(pos1);
     489           44 :     content.writeUnsignedByte(0);
     490           44 :     content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
     491           44 :     content.writeString(edgeID2);
     492           44 :     content.writeDouble(pos2);
     493           44 :     content.writeUnsignedByte(0);
     494           79 :     content.writeUnsignedByte(isDriving ? libsumo::REQUEST_DRIVINGDIST : libsumo::REQUEST_AIRDIST);
     495           88 :     return Dom::getDouble(libsumo::DISTANCE_REQUEST, "", &content);
     496           44 : }
     497              : 
     498              : 
     499              : libsumo::TraCIStage
     500            5 : Simulation::findRoute(const std::string& fromEdge, const std::string& toEdge, const std::string& vType, const double depart, const int routingMode) {
     501            5 :     tcpip::Storage content;
     502              :     StoHelp::writeCompound(content, 5);
     503              :     StoHelp::writeTypedString(content, fromEdge);
     504              :     StoHelp::writeTypedString(content, toEdge);
     505              :     StoHelp::writeTypedString(content, vType);
     506              :     StoHelp::writeTypedDouble(content, depart);
     507              :     StoHelp::writeTypedInt(content, routingMode);
     508            8 :     return Dom::getTraCIStage(libsumo::FIND_ROUTE, "", &content);
     509            5 : }
     510              : 
     511              : 
     512              : std::vector<libsumo::TraCIStage>
     513           79 : Simulation::findIntermodalRoute(const std::string& fromEdge, const std::string& toEdge,
     514              :                                 const std::string& modes, double depart, const int routingMode, double speed, double walkFactor,
     515              :                                 double departPos, double arrivalPos, const double departPosLat,
     516              :                                 const std::string& pType, const std::string& vType, const std::string& destStop) {
     517           79 :     tcpip::Storage content;
     518              :     StoHelp::writeCompound(content, 13);
     519              :     StoHelp::writeTypedString(content, fromEdge);
     520              :     StoHelp::writeTypedString(content, toEdge);
     521              :     StoHelp::writeTypedString(content, modes);
     522              :     StoHelp::writeTypedDouble(content, depart);
     523              :     StoHelp::writeTypedInt(content, routingMode);
     524              :     StoHelp::writeTypedDouble(content, speed);
     525              :     StoHelp::writeTypedDouble(content, walkFactor);
     526              :     StoHelp::writeTypedDouble(content, departPos);
     527              :     StoHelp::writeTypedDouble(content, arrivalPos);
     528              :     StoHelp::writeTypedDouble(content, departPosLat);
     529              :     StoHelp::writeTypedString(content, pType);
     530              :     StoHelp::writeTypedString(content, vType);
     531              :     StoHelp::writeTypedString(content, destStop);
     532           79 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     533           81 :     tcpip::Storage& result = Dom::get(libsumo::FIND_INTERMODAL_ROUTE, "", &content);
     534           77 :     int numStages = result.readInt();
     535              :     std::vector<libsumo::TraCIStage> ret;
     536          234 :     while (numStages-- > 0) {
     537          314 :         libsumo::TraCIStage s;
     538          157 :         StoHelp::readCompound(result, 13);
     539          157 :         s.type = StoHelp::readTypedInt(result);
     540          157 :         s.vType = StoHelp::readTypedString(result);
     541          157 :         s.line = StoHelp::readTypedString(result);
     542          157 :         s.destStop = StoHelp::readTypedString(result);
     543          157 :         s.edges = StoHelp::readTypedStringList(result);
     544          157 :         s.travelTime = StoHelp::readTypedDouble(result);
     545          157 :         s.cost = StoHelp::readTypedDouble(result);
     546          157 :         s.length = StoHelp::readTypedDouble(result);
     547          157 :         s.intended = StoHelp::readTypedString(result);
     548          157 :         s.depart = StoHelp::readTypedDouble(result);
     549          157 :         s.departPos = StoHelp::readTypedDouble(result);
     550          157 :         s.arrivalPos = StoHelp::readTypedDouble(result);
     551          157 :         s.description = StoHelp::readTypedString(result);
     552          157 :         ret.emplace_back(s);
     553          157 :     }
     554           77 :     return ret;
     555           79 : }
     556              : 
     557          763 : LIBTRACI_PARAMETER_IMPLEMENTATION(Simulation, SIM)
     558              : 
     559              : void
     560            1 : Simulation::setScale(double value) {
     561            1 :     Dom::setDouble(libsumo::VAR_SCALE, "", value);
     562            1 : }
     563              : 
     564              : void
     565            1 : Simulation::clearPending(const std::string& routeID) {
     566            1 :     Dom::setString(libsumo::CMD_CLEAR_PENDING_VEHICLES, "", routeID);
     567            1 : }
     568              : 
     569              : 
     570              : void
     571           15 : Simulation::saveState(const std::string& fileName) {
     572           15 :     Dom::setString(libsumo::CMD_SAVE_SIMSTATE, "", fileName);
     573           15 : }
     574              : 
     575              : double
     576           38 : Simulation::loadState(const std::string& fileName) {
     577           38 :     Dom::setString(libsumo::CMD_LOAD_SIMSTATE, "", fileName);
     578           36 :     return 0.;
     579              : }
     580              : 
     581              : void
     582            1 : Simulation::writeMessage(const std::string& msg) {
     583            1 :     Dom::setString(libsumo::CMD_MESSAGE, "", msg);
     584            1 : }
     585              : 
     586              : 
     587              : void
     588            2 : Simulation::subscribe(const std::vector<int>& varIDs, double begin, double end, const libsumo::TraCIResults& params) {
     589            2 :     libtraci::Connection::getActive().subscribe(libsumo::CMD_SUBSCRIBE_SIM_VARIABLE, "", begin, end, -1, -1, varIDs, params);
     590            2 : }
     591              : 
     592              : 
     593              : const libsumo::TraCIResults
     594           29 : Simulation::getSubscriptionResults() {
     595           87 :     return libtraci::Connection::getActive().getAllSubscriptionResults(libsumo::RESPONSE_SUBSCRIBE_SIM_VARIABLE)[""];
     596              : }
     597              : 
     598              : 
     599          207 : LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(Simulation, SIM)
     600              : 
     601              : }
     602              : 
     603              : 
     604              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1