LCOV - code coverage report
Current view: top level - src/libtraci - Vehicle.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 97.9 % 585 573
Test Date: 2026-10-12 15:53:19 Functions: 99.5 % 184 183

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2017-2026 German Aerospace Center (DLR) and others.
       4              : // This program and the accompanying materials are made available under the
       5              : // terms of the Eclipse Public License 2.0 which is available at
       6              : // https://www.eclipse.org/legal/epl-2.0/
       7              : // This Source Code may also be made available under the following Secondary
       8              : // Licenses when the conditions for such availability set forth in the Eclipse
       9              : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10              : // or later which is available at
      11              : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12              : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13              : /****************************************************************************/
      14              : /// @file    Vehicle.cpp
      15              : /// @author  Jakob Erdmann
      16              : /// @author  Michael Behrisch
      17              : /// @author  Mirko Barthauer
      18              : /// @date    30.05.2012
      19              : ///
      20              : // C++ TraCI client API implementation
      21              : /****************************************************************************/
      22              : #include <config.h>
      23              : #include <sstream>
      24              : 
      25              : #define LIBTRACI 1
      26              : #include <libsumo/StorageHelper.h>
      27              : #include <libsumo/Vehicle.h>
      28              : #include "Domain.h"
      29              : 
      30              : namespace libtraci {
      31              : 
      32              : typedef Domain<libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::CMD_SET_VEHICLE_VARIABLE> Dom;
      33              : 
      34              : 
      35              : // ===========================================================================
      36              : // static member definitions
      37              : // ===========================================================================
      38              : std::vector<std::string>
      39        42370 : Vehicle::getIDList() {
      40        84739 :     return Dom::getStringVector(libsumo::TRACI_ID_LIST, "");
      41              : }
      42              : 
      43              : 
      44              : int
      45           31 : Vehicle::getIDCount() {
      46           62 :     return Dom::getInt(libsumo::ID_COUNT, "");
      47              : }
      48              : 
      49              : 
      50        32971 : LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(Vehicle, VEHICLE)
      51         1224 : LIBTRACI_PARAMETER_IMPLEMENTATION(Vehicle, VEHICLE)
      52              : 
      53              : double
      54         5159 : Vehicle::getSpeed(const std::string& vehID) {
      55         5159 :     return Dom::getDouble(libsumo::VAR_SPEED, vehID);
      56              : }
      57              : 
      58              : double
      59           18 : Vehicle::getLateralSpeed(const std::string& vehID) {
      60           18 :     return Dom::getDouble(libsumo::VAR_SPEED_LAT, vehID);
      61              : }
      62              : 
      63              : double
      64         1176 : Vehicle::getAcceleration(const std::string& vehID) {
      65         1176 :     return Dom::getDouble(libsumo::VAR_ACCELERATION, vehID);
      66              : }
      67              : 
      68              : 
      69              : double
      70         1028 : Vehicle::getSpeedWithoutTraCI(const std::string& vehID) {
      71         1028 :     return Dom::getDouble(libsumo::VAR_SPEED_WITHOUT_TRACI, vehID);
      72              : }
      73              : 
      74              : 
      75              : libsumo::TraCIPosition
      76       331143 : Vehicle::getPosition(const std::string& vehID, const bool includeZ) {
      77       331143 :     return includeZ ? getPosition3D(vehID) : Dom::getPos(libsumo::VAR_POSITION, vehID);
      78              : }
      79              : 
      80              : 
      81              : libsumo::TraCIPosition
      82          399 : Vehicle::getPosition3D(const std::string& vehID) {
      83          399 :     return Dom::getPos3D(libsumo::VAR_POSITION3D, vehID);
      84              : }
      85              : 
      86              : 
      87              : double
      88          102 : Vehicle::getAngle(const std::string& vehID) {
      89          102 :     return Dom::getDouble(libsumo::VAR_ANGLE, vehID);
      90              : }
      91              : 
      92              : 
      93              : double
      94            2 : Vehicle::getSlope(const std::string& vehID) {
      95            2 :     return Dom::getDouble(libsumo::VAR_SLOPE, vehID);
      96              : }
      97              : 
      98              : 
      99              : std::string
     100         1019 : Vehicle::getRoadID(const std::string& vehID) {
     101         1019 :     return Dom::getString(libsumo::VAR_ROAD_ID, vehID);
     102              : }
     103              : 
     104              : 
     105              : double
     106           18 : Vehicle::getDeparture(const std::string& vehID) {
     107           18 :     return Dom::getDouble(libsumo::VAR_DEPARTURE, vehID);
     108              : }
     109              : 
     110              : 
     111              : double
     112           18 : Vehicle::getDepartDelay(const std::string& vehID) {
     113           18 :     return Dom::getDouble(libsumo::VAR_DEPART_DELAY, vehID);
     114              : }
     115              : 
     116              : 
     117              : std::string
     118         3362 : Vehicle::getLaneID(const std::string& vehID) {
     119         3362 :     return Dom::getString(libsumo::VAR_LANE_ID, vehID);
     120              : }
     121              : 
     122              : 
     123              : std::string
     124            5 : Vehicle::getShadowLaneID(const std::string& vehID) {
     125            5 :     return Dom::getString(libsumo::VAR_SHADOW_LANE_ID, vehID);
     126              : }
     127              : 
     128              : 
     129              : int
     130         1258 : Vehicle::getLaneIndex(const std::string& vehID) {
     131         1258 :     return Dom::getInt(libsumo::VAR_LANE_INDEX, vehID);
     132              : }
     133              : 
     134              : 
     135              : std::string
     136           24 : Vehicle::getSegmentID(const std::string& vehID) {
     137           24 :     return Dom::getString(libsumo::VAR_SEGMENT_ID, vehID);
     138              : }
     139              : 
     140              : 
     141              : int
     142           23 : Vehicle::getSegmentIndex(const std::string& vehID) {
     143           23 :     return Dom::getInt(libsumo::VAR_SEGMENT_INDEX, vehID);
     144              : }
     145              : 
     146              : 
     147              : std::string
     148           83 : Vehicle::getTypeID(const std::string& vehID) {
     149           83 :     return Dom::getString(libsumo::VAR_TYPE, vehID);
     150              : }
     151              : 
     152              : 
     153              : std::string
     154           26 : Vehicle::getRouteID(const std::string& vehID) {
     155           26 :     return Dom::getString(libsumo::VAR_ROUTE_ID, vehID);
     156              : }
     157              : 
     158              : 
     159              : int
     160          992 : Vehicle::getRouteIndex(const std::string& vehID) {
     161          992 :     return Dom::getInt(libsumo::VAR_ROUTE_INDEX, vehID);
     162              : }
     163              : 
     164              : 
     165              : libsumo::TraCIColor
     166           40 : Vehicle::getColor(const std::string& vehID) {
     167           40 :     return Dom::getCol(libsumo::VAR_COLOR, vehID);
     168              : }
     169              : 
     170              : double
     171         4747 : Vehicle::getLanePosition(const std::string& vehID) {
     172         4747 :     return Dom::getDouble(libsumo::VAR_LANEPOSITION, vehID);
     173              : }
     174              : 
     175              : double
     176          798 : Vehicle::getLateralLanePosition(const std::string& vehID) {
     177          798 :     return Dom::getDouble(libsumo::VAR_LANEPOSITION_LAT, vehID);
     178              : }
     179              : 
     180              : double
     181           98 : Vehicle::getCO2Emission(const std::string& vehID) {
     182           98 :     return Dom::getDouble(libsumo::VAR_CO2EMISSION, vehID);
     183              : }
     184              : 
     185              : double
     186           18 : Vehicle::getCOEmission(const std::string& vehID) {
     187           18 :     return Dom::getDouble(libsumo::VAR_COEMISSION, vehID);
     188              : }
     189              : 
     190              : double
     191           18 : Vehicle::getHCEmission(const std::string& vehID) {
     192           18 :     return Dom::getDouble(libsumo::VAR_HCEMISSION, vehID);
     193              : }
     194              : 
     195              : double
     196           18 : Vehicle::getPMxEmission(const std::string& vehID) {
     197           18 :     return Dom::getDouble(libsumo::VAR_PMXEMISSION, vehID);
     198              : }
     199              : 
     200              : double
     201           18 : Vehicle::getNOxEmission(const std::string& vehID) {
     202           18 :     return Dom::getDouble(libsumo::VAR_NOXEMISSION, vehID);
     203              : }
     204              : 
     205              : double
     206           88 : Vehicle::getFuelConsumption(const std::string& vehID) {
     207           88 :     return Dom::getDouble(libsumo::VAR_FUELCONSUMPTION, vehID);
     208              : }
     209              : 
     210              : double
     211           18 : Vehicle::getNoiseEmission(const std::string& vehID) {
     212           18 :     return Dom::getDouble(libsumo::VAR_NOISEEMISSION, vehID);
     213              : }
     214              : 
     215              : double
     216           38 : Vehicle::getElectricityConsumption(const std::string& vehID) {
     217           38 :     return Dom::getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, vehID);
     218              : }
     219              : 
     220              : int
     221           18 : Vehicle::getPersonNumber(const std::string& vehID) {
     222           18 :     return Dom::getInt(libsumo::VAR_PERSON_NUMBER, vehID);
     223              : }
     224              : 
     225              : int
     226           18 : Vehicle::getPersonCapacity(const std::string& vehID) {
     227           18 :     return Dom::getInt(libsumo::VAR_PERSON_CAPACITY, vehID);
     228              : }
     229              : 
     230              : 
     231              : double
     232           18 : Vehicle::getBoardingDuration(const std::string& vehID) {
     233           18 :     return Dom::getDouble(libsumo::VAR_BOARDING_DURATION, vehID);
     234              : }
     235              : 
     236              : 
     237              : double
     238           24 : Vehicle::getImpatience(const std::string& vehID) {
     239           24 :     return Dom::getDouble(libsumo::VAR_IMPATIENCE, vehID);
     240              : }
     241              : 
     242              : 
     243              : std::vector<std::string>
     244           40 : Vehicle::getPersonIDList(const std::string& vehID) {
     245           40 :     return Dom::getStringVector(libsumo::LAST_STEP_PERSON_ID_LIST, vehID);
     246              : }
     247              : 
     248              : std::pair<std::string, double>
     249         6177 : Vehicle::getLeader(const std::string& vehID, double dist) {
     250         6177 :     tcpip::Storage content;
     251              :     StoHelp::writeTypedDouble(content, dist);
     252         6177 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     253              :     tcpip::Storage& ret = Dom::get(libsumo::VAR_LEADER, vehID, &content);
     254         6177 :     ret.readInt(); // components
     255         6177 :     ret.readUnsignedByte();
     256         6177 :     const std::string leaderID = ret.readString();
     257         6177 :     ret.readUnsignedByte();
     258         6177 :     const double gap = ret.readDouble();
     259         6177 :     return std::make_pair(leaderID, gap);
     260         6177 : }
     261              : 
     262              : 
     263              : std::pair<std::string, double>
     264           59 : Vehicle::getFollower(const std::string& vehID, double dist) {
     265           59 :     tcpip::Storage content;
     266              :     StoHelp::writeTypedDouble(content, dist);
     267           59 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     268              :     tcpip::Storage& ret = Dom::get(libsumo::VAR_FOLLOWER, vehID, &content);
     269           58 :     ret.readInt(); // components
     270           59 :     const std::string leaderID = StoHelp::readTypedString(ret);
     271          174 :     return std::make_pair(leaderID, StoHelp::readTypedDouble(ret));
     272           59 : }
     273              : 
     274              : 
     275              : std::vector<libsumo::TraCIJunctionFoe>
     276           30 : Vehicle::getJunctionFoes(const std::string& vehID, double dist) {
     277              :     std::vector<libsumo::TraCIJunctionFoe> result;
     278           30 :     tcpip::Storage content;
     279              :     StoHelp::writeTypedDouble(content, dist);
     280           30 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     281              :     tcpip::Storage& ret = Dom::get(libsumo::VAR_FOES, vehID, &content);
     282           30 :     ret.readInt(); // compound size
     283           60 :     StoHelp::readJunctionFoeVector(ret, result);
     284           30 :     return result;
     285           30 : }
     286              : 
     287              : 
     288              : double
     289           50 : Vehicle::getWaitingTime(const std::string& vehID) {
     290           50 :     return Dom::getDouble(libsumo::VAR_WAITING_TIME, vehID);
     291              : }
     292              : 
     293              : 
     294              : double
     295           25 : Vehicle::getAccumulatedWaitingTime(const std::string& vehID) {
     296           25 :     return Dom::getDouble(libsumo::VAR_ACCUMULATED_WAITING_TIME, vehID);
     297              : }
     298              : 
     299              : 
     300              : double
     301           23 : Vehicle::getAdaptedTraveltime(const std::string& vehID, double time, const std::string& edgeID) {
     302           23 :     tcpip::Storage content;
     303              :     StoHelp::writeCompound(content, 2);
     304              :     StoHelp::writeTypedDouble(content, time);
     305              :     StoHelp::writeTypedString(content, edgeID);
     306           46 :     return Dom::getDouble(libsumo::VAR_EDGE_TRAVELTIME, vehID, &content);
     307           23 : }
     308              : 
     309              : 
     310              : double
     311           22 : Vehicle::getEffort(const std::string& vehID, double time, const std::string& edgeID) {
     312           22 :     tcpip::Storage content;
     313              :     StoHelp::writeCompound(content, 2);
     314              :     StoHelp::writeTypedDouble(content, time);
     315              :     StoHelp::writeTypedString(content, edgeID);
     316           44 :     return Dom::getDouble(libsumo::VAR_EDGE_EFFORT, vehID, &content);
     317           22 : }
     318              : 
     319              : 
     320              : bool
     321           18 : Vehicle::isRouteValid(const std::string& vehID) {
     322           18 :     return Dom::getInt(libsumo::VAR_ROUTE_VALID, vehID) != 0;
     323              : }
     324              : 
     325              : 
     326              : std::vector<std::string>
     327         1047 : Vehicle::getRoute(const std::string& vehID) {
     328         1047 :     return Dom::getStringVector(libsumo::VAR_EDGES, vehID);
     329              : }
     330              : 
     331              : 
     332              : int
     333           18 : Vehicle::getSignals(const std::string& vehID) {
     334           18 :     return Dom::getInt(libsumo::VAR_SIGNALS, vehID);
     335              : }
     336              : 
     337              : 
     338              : std::vector<libsumo::TraCIBestLanesData>
     339           18 : Vehicle::getBestLanes(const std::string& vehID) {
     340           18 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     341              :     std::vector<libsumo::TraCIBestLanesData> result;
     342              :     tcpip::Storage& ret = Dom::get(libsumo::VAR_BEST_LANES, vehID);
     343           18 :     ret.readInt();
     344           36 :     StoHelp::readBestLanesVector(ret, result);
     345           18 :     return result;
     346            0 : }
     347              : 
     348              : 
     349              : std::vector<libsumo::TraCINextTLSData>
     350          276 : Vehicle::getNextTLS(const std::string& vehID) {
     351          276 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     352              :     std::vector<libsumo::TraCINextTLSData> result;
     353              :     tcpip::Storage& ret = Dom::get(libsumo::VAR_NEXT_TLS, vehID);
     354          273 :     ret.readInt(); // components
     355          546 :     StoHelp::readTLSDataVector(ret, result);
     356          273 :     return result;
     357            3 : }
     358              : 
     359              : std::vector<libsumo::TraCINextStopData>
     360           26 : Vehicle::getNextStops(const std::string& vehID) {
     361           26 :     return getStops(vehID, 0);
     362              : }
     363              : 
     364              : std::vector<libsumo::TraCIConnection>
     365            1 : Vehicle::getNextLinks(const std::string& vehID) {
     366            1 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     367              :     std::vector<libsumo::TraCIConnection> result;
     368              :     tcpip::Storage& ret = Dom::get(libsumo::VAR_NEXT_LINKS, vehID);
     369            1 :     ret.readInt(); // components
     370              :     // number of items
     371            1 :     const int linkNo = StoHelp::readTypedInt(ret);
     372            3 :     for (int i = 0; i < linkNo; ++i) {
     373              :         libsumo::TraCIConnection con;
     374            2 :         StoHelp::readConnection(ret, con);
     375            2 :         result.emplace_back(con);
     376            2 :     }
     377            1 :     return result;
     378            0 : }
     379              : 
     380              : std::vector<libsumo::TraCINextStopData>
     381          742 : Vehicle::getStops(const std::string& vehID, int limit) {
     382              :     std::vector<libsumo::TraCINextStopData> result;
     383          742 :     tcpip::Storage content;
     384              :     StoHelp::writeTypedInt(content, limit);
     385          742 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     386              :     tcpip::Storage& ret = Dom::get(libsumo::VAR_NEXT_STOPS2, vehID, &content);
     387          741 :     ret.readInt(); // components
     388         1483 :     StoHelp::readStopVector(ret, result);
     389          741 :     return result;
     390          743 : }
     391              : 
     392              : std::string
     393           91 : Vehicle::getStopParameter(const std::string& vehID, int nextStopIndex, const std::string& param, bool customParam) {
     394           91 :     tcpip::Storage content;
     395              :     StoHelp::writeCompound(content, 3);
     396              :     StoHelp::writeTypedInt(content, nextStopIndex);
     397              :     StoHelp::writeTypedString(content, param);
     398           91 :     StoHelp::writeTypedByte(content, customParam);
     399          182 :     return Dom::getString(libsumo::VAR_STOP_PARAMETER, vehID, &content);
     400           91 : }
     401              : 
     402              : int
     403          346 : Vehicle::getStopState(const std::string& vehID) {
     404          346 :     return Dom::getInt(libsumo::VAR_STOPSTATE, vehID);
     405              : }
     406              : 
     407              : 
     408              : double
     409          128 : Vehicle::getDistance(const std::string& vehID) {
     410          128 :     return Dom::getDouble(libsumo::VAR_DISTANCE, vehID);
     411              : }
     412              : 
     413              : 
     414              : double
     415          683 : Vehicle::getDrivingDistance(const std::string& vehID, const std::string& edgeID, double pos, int laneIndex) {
     416          683 :     tcpip::Storage content;
     417              :     StoHelp::writeCompound(content, 2);
     418          683 :     content.writeUnsignedByte(libsumo::POSITION_ROADMAP);
     419          683 :     content.writeString(edgeID);
     420          683 :     content.writeDouble(pos);
     421          683 :     content.writeUnsignedByte(laneIndex);
     422          683 :     content.writeUnsignedByte(libsumo::REQUEST_DRIVINGDIST);
     423         1366 :     return Dom::getDouble(libsumo::DISTANCE_REQUEST, vehID, &content);
     424          683 : }
     425              : 
     426              : 
     427              : double
     428           18 : Vehicle::getDrivingDistance2D(const std::string& vehID, double x, double y) {
     429           18 :     tcpip::Storage content;
     430              :     StoHelp::writeCompound(content, 2);
     431           18 :     content.writeUnsignedByte(libsumo::POSITION_2D);
     432           18 :     content.writeDouble(x);
     433           18 :     content.writeDouble(y);
     434           18 :     content.writeUnsignedByte(libsumo::REQUEST_DRIVINGDIST);
     435           36 :     return Dom::getDouble(libsumo::DISTANCE_REQUEST, vehID, &content);
     436           18 : }
     437              : 
     438              : 
     439              : double
     440           18 : Vehicle::getReferenceDistance(const std::string& vehID) {
     441           18 :     return Dom::getDouble(libsumo::VAR_REFERENCE_DISTANCE, vehID);
     442              : }
     443              : 
     444              : 
     445              : double
     446           18 : Vehicle::getAllowedSpeed(const std::string& vehID) {
     447           18 :     return Dom::getDouble(libsumo::VAR_ALLOWED_SPEED, vehID);
     448              : }
     449              : 
     450              : 
     451              : double
     452           49 : Vehicle::getSpeedFactor(const std::string& vehID) {
     453           49 :     return Dom::getDouble(libsumo::VAR_SPEED_FACTOR, vehID);
     454              : }
     455              : 
     456              : 
     457              : int
     458           15 : Vehicle::getSpeedMode(const std::string& vehID) {
     459           15 :     return Dom::getInt(libsumo::VAR_SPEEDSETMODE, vehID);
     460              : }
     461              : 
     462              : 
     463              : int
     464           15 : Vehicle::getLaneChangeMode(const std::string& vehID) {
     465           15 :     return Dom::getInt(libsumo::VAR_LANECHANGE_MODE, vehID);
     466              : }
     467              : 
     468              : 
     469              : int
     470           18 : Vehicle::getRoutingMode(const std::string& vehID) {
     471           18 :     return Dom::getInt(libsumo::VAR_ROUTING_MODE, vehID);
     472              : }
     473              : 
     474              : 
     475              : std::string
     476           18 : Vehicle::getLine(const std::string& vehID) {
     477           18 :     return Dom::getString(libsumo::VAR_LINE, vehID);
     478              : }
     479              : 
     480              : 
     481              : 
     482              : std::vector<std::string>
     483           18 : Vehicle::getVia(const std::string& vehID) {
     484           18 :     return Dom::getStringVector(libsumo::VAR_VIA, vehID);
     485              : }
     486              : 
     487              : 
     488              : std::pair<int, int>
     489         3493 : Vehicle::getLaneChangeState(const std::string& vehID, int direction) {
     490         3493 :     tcpip::Storage content;
     491              :     StoHelp::writeTypedInt(content, direction);
     492         3493 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     493              :     tcpip::Storage& ret = Dom::get(libsumo::CMD_CHANGELANE, vehID, &content);
     494         3493 :     ret.readInt(); // components
     495         3493 :     const int stateWithoutTraCI = StoHelp::readTypedInt(ret);
     496         6986 :     const int state = StoHelp::readTypedInt(ret);
     497         3493 :     return std::make_pair(stateWithoutTraCI, state);
     498         3493 : }
     499              : 
     500              : 
     501              : std::vector<std::pair<std::string, double> >
     502          856 : Vehicle::getNeighbors(const std::string& vehID, const int mode) {
     503              :     std::vector<std::pair<std::string, double> > neighs;
     504          856 :     tcpip::Storage content;
     505          856 :     content.writeUnsignedByte(libsumo::TYPE_UBYTE);
     506          856 :     content.writeUnsignedByte(mode);
     507          856 :     std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
     508              :     tcpip::Storage& ret = Dom::get(libsumo::VAR_NEIGHBORS, vehID, &content);
     509          856 :     const int items = ret.readInt(); // components
     510         1328 :     for (int i = 0; i < items; i++) {
     511          472 :         const std::string neighID = ret.readString();
     512          472 :         neighs.emplace_back(neighID, ret.readDouble());
     513              :     }
     514          856 :     return neighs;
     515          856 : }
     516              : 
     517              : 
     518              : double
     519          177 : Vehicle::getFollowSpeed(const std::string& vehID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
     520          177 :     tcpip::Storage content;
     521              :     StoHelp::writeCompound(content, 5);
     522              :     StoHelp::writeTypedDouble(content, speed);
     523              :     StoHelp::writeTypedDouble(content, gap);
     524              :     StoHelp::writeTypedDouble(content, leaderSpeed);
     525              :     StoHelp::writeTypedDouble(content, leaderMaxDecel);
     526              :     StoHelp::writeTypedString(content, leaderID);
     527          354 :     return Dom::getDouble(libsumo::VAR_FOLLOW_SPEED, vehID, &content);
     528          177 : }
     529              : 
     530              : 
     531              : double
     532            2 : Vehicle::getSecureGap(const std::string& vehID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) {
     533            2 :     tcpip::Storage content;
     534              :     StoHelp::writeCompound(content, 4);
     535              :     StoHelp::writeTypedDouble(content, speed);
     536              :     StoHelp::writeTypedDouble(content, leaderSpeed);
     537              :     StoHelp::writeTypedDouble(content, leaderMaxDecel);
     538              :     StoHelp::writeTypedString(content, leaderID);
     539            4 :     return Dom::getDouble(libsumo::VAR_SECURE_GAP, vehID, &content);
     540            2 : }
     541              : 
     542              : 
     543              : double
     544            2 : Vehicle::getStopSpeed(const std::string& vehID, const double speed, double gap) {
     545            2 :     tcpip::Storage content;
     546              :     StoHelp::writeCompound(content, 2);
     547              :     StoHelp::writeTypedDouble(content, speed);
     548              :     StoHelp::writeTypedDouble(content, gap);
     549            4 :     return Dom::getDouble(libsumo::VAR_STOP_SPEED, vehID, &content);
     550            2 : }
     551              : 
     552              : double
     553          125 : Vehicle::getStopDelay(const std::string& vehID) {
     554          125 :     return Dom::getDouble(libsumo::VAR_STOP_DELAY, vehID);
     555              : }
     556              : 
     557              : double
     558          125 : Vehicle::getStopArrivalDelay(const std::string& vehID) {
     559          125 :     return Dom::getDouble(libsumo::VAR_STOP_ARRIVALDELAY, vehID);
     560              : }
     561              : 
     562              : double
     563           18 : Vehicle::getTimeLoss(const std::string& vehID) {
     564           18 :     return Dom::getDouble(libsumo::VAR_TIMELOSS, vehID);
     565              : }
     566              : 
     567              : std::vector<std::string>
     568         1962 : Vehicle::getTaxiFleet(int taxiState) {
     569         1962 :     tcpip::Storage content;
     570              :     StoHelp::writeTypedInt(content, taxiState);
     571         3924 :     return Dom::getStringVector(libsumo::VAR_TAXI_FLEET, "", &content);
     572         1962 : }
     573              : 
     574              : std::vector<std::string>
     575           46 : Vehicle::getLoadedIDList() {
     576           92 :     return Dom::getStringVector(libsumo::VAR_LOADED_LIST, "");
     577              : }
     578              : 
     579              : std::vector<std::string>
     580           36 : Vehicle::getTeleportingIDList() {
     581           72 :     return Dom::getStringVector(libsumo::VAR_TELEPORTING_LIST, "");
     582              : }
     583              : 
     584              : std::string
     585           38 : Vehicle::getEmissionClass(const std::string& vehID) {
     586           38 :     return Dom::getString(libsumo::VAR_EMISSIONCLASS, vehID);
     587              : }
     588              : 
     589              : std::string
     590           18 : Vehicle::getShapeClass(const std::string& vehID) {
     591           18 :     return Dom::getString(libsumo::VAR_SHAPECLASS, vehID);
     592              : }
     593              : 
     594              : 
     595              : double
     596           20 : Vehicle::getLength(const std::string& vehID) {
     597           20 :     return Dom::getDouble(libsumo::VAR_LENGTH, vehID);
     598              : }
     599              : 
     600              : 
     601              : double
     602           20 : Vehicle::getAccel(const std::string& vehID) {
     603           20 :     return Dom::getDouble(libsumo::VAR_ACCEL, vehID);
     604              : }
     605              : 
     606              : 
     607              : double
     608          201 : Vehicle::getDecel(const std::string& vehID) {
     609          201 :     return Dom::getDouble(libsumo::VAR_DECEL, vehID);
     610              : }
     611              : 
     612              : 
     613           22 : double Vehicle::getEmergencyDecel(const std::string& vehID) {
     614           22 :     return Dom::getDouble(libsumo::VAR_EMERGENCY_DECEL, vehID);
     615              : }
     616              : 
     617              : 
     618           20 : double Vehicle::getApparentDecel(const std::string& vehID) {
     619           20 :     return Dom::getDouble(libsumo::VAR_APPARENT_DECEL, vehID);
     620              : }
     621              : 
     622              : 
     623           20 : double Vehicle::getActionStepLength(const std::string& vehID) {
     624           20 :     return Dom::getDouble(libsumo::VAR_ACTIONSTEPLENGTH, vehID);
     625              : }
     626              : 
     627              : 
     628           18 : double Vehicle::getLastActionTime(const std::string& vehID) {
     629           18 :     return Dom::getDouble(libsumo::VAR_LASTACTIONTIME, vehID);
     630              : }
     631              : 
     632              : 
     633              : double
     634           20 : Vehicle::getTau(const std::string& vehID) {
     635           20 :     return Dom::getDouble(libsumo::VAR_TAU, vehID);
     636              : }
     637              : 
     638              : 
     639              : double
     640           22 : Vehicle::getImperfection(const std::string& vehID) {
     641           22 :     return Dom::getDouble(libsumo::VAR_IMPERFECTION, vehID);
     642              : }
     643              : 
     644              : 
     645              : double
     646           18 : Vehicle::getSpeedDeviation(const std::string& vehID) {
     647           18 :     return Dom::getDouble(libsumo::VAR_SPEED_DEVIATION, vehID);
     648              : }
     649              : 
     650              : 
     651              : std::string
     652           18 : Vehicle::getVehicleClass(const std::string& vehID) {
     653           18 :     return Dom::getString(libsumo::VAR_VEHICLECLASS, vehID);
     654              : }
     655              : 
     656              : 
     657              : double
     658           59 : Vehicle::getMinGap(const std::string& vehID) {
     659           59 :     return Dom::getDouble(libsumo::VAR_MINGAP, vehID);
     660              : }
     661              : 
     662              : 
     663              : double
     664           18 : Vehicle::getMinGapLat(const std::string& vehID) {
     665           18 :     return Dom::getDouble(libsumo::VAR_MINGAP_LAT, vehID);
     666              : }
     667              : 
     668              : 
     669              : double
     670           20 : Vehicle::getMaxSpeed(const std::string& vehID) {
     671           20 :     return Dom::getDouble(libsumo::VAR_MAXSPEED, vehID);
     672              : }
     673              : 
     674              : 
     675              : double
     676           18 : Vehicle::getMaxSpeedLat(const std::string& vehID) {
     677           18 :     return Dom::getDouble(libsumo::VAR_MAXSPEED_LAT, vehID);
     678              : }
     679              : 
     680              : 
     681              : std::string
     682           18 : Vehicle::getLateralAlignment(const std::string& vehID) {
     683           18 :     return Dom::getString(libsumo::VAR_LATALIGNMENT, vehID);
     684              : }
     685              : 
     686              : 
     687              : double
     688           20 : Vehicle::getWidth(const std::string& vehID) {
     689           20 :     return Dom::getDouble(libsumo::VAR_WIDTH, vehID);
     690              : }
     691              : 
     692              : 
     693              : double
     694           18 : Vehicle::getHeight(const std::string& vehID) {
     695           18 :     return Dom::getDouble(libsumo::VAR_HEIGHT, vehID);
     696              : }
     697              : 
     698              : 
     699              : double
     700           22 : Vehicle::getMass(const std::string& vehID) {
     701           22 :     return Dom::getDouble(libsumo::VAR_MASS, vehID);
     702              : }
     703              : 
     704              : 
     705              : void
     706           49 : Vehicle::setStop(const std::string& vehID,
     707              :                  const std::string& edgeID,
     708              :                  double pos,
     709              :                  int laneIndex,
     710              :                  double duration,
     711              :                  int flags,
     712              :                  double startPos,
     713              :                  double until) {
     714           49 :     tcpip::Storage content;
     715              :     StoHelp::writeCompound(content, 7);
     716              :     StoHelp::writeTypedString(content, edgeID);
     717              :     StoHelp::writeTypedDouble(content, pos);
     718              :     StoHelp::writeTypedByte(content, laneIndex);
     719              :     StoHelp::writeTypedDouble(content, duration);
     720              :     StoHelp::writeTypedByte(content, flags);
     721              :     StoHelp::writeTypedDouble(content, startPos);
     722              :     StoHelp::writeTypedDouble(content, until);
     723           49 :     Dom::set(libsumo::CMD_STOP, vehID, &content);
     724           49 : }
     725              : 
     726              : 
     727              : void
     728           43 : Vehicle::replaceStop(const std::string& vehID,
     729              :                      int nextStopIndex,
     730              :                      const std::string& edgeID,
     731              :                      double pos,
     732              :                      int laneIndex,
     733              :                      double duration,
     734              :                      int flags,
     735              :                      double startPos,
     736              :                      double until,
     737              :                      int teleport) {
     738           43 :     tcpip::Storage content;
     739              :     StoHelp::writeCompound(content, 9);
     740              :     StoHelp::writeTypedString(content, edgeID);
     741              :     StoHelp::writeTypedDouble(content, pos);
     742              :     StoHelp::writeTypedByte(content, laneIndex);
     743              :     StoHelp::writeTypedDouble(content, duration);
     744              :     StoHelp::writeTypedInt(content, flags);
     745              :     StoHelp::writeTypedDouble(content, startPos);
     746              :     StoHelp::writeTypedDouble(content, until);
     747              :     StoHelp::writeTypedInt(content, nextStopIndex);
     748              :     StoHelp::writeTypedByte(content, teleport);
     749           43 :     Dom::set(libsumo::CMD_REPLACE_STOP, vehID, &content);
     750           43 : }
     751              : 
     752              : 
     753              : void
     754           47 : Vehicle::insertStop(const std::string& vehID,
     755              :                     int nextStopIndex,
     756              :                     const std::string& edgeID,
     757              :                     double pos,
     758              :                     int laneIndex,
     759              :                     double duration,
     760              :                     int flags,
     761              :                     double startPos,
     762              :                     double until,
     763              :                     int teleport) {
     764           47 :     tcpip::Storage content;
     765              :     StoHelp::writeCompound(content, 9);
     766              :     StoHelp::writeTypedString(content, edgeID);
     767              :     StoHelp::writeTypedDouble(content, pos);
     768              :     StoHelp::writeTypedByte(content, laneIndex);
     769              :     StoHelp::writeTypedDouble(content, duration);
     770              :     StoHelp::writeTypedInt(content, flags);
     771              :     StoHelp::writeTypedDouble(content, startPos);
     772              :     StoHelp::writeTypedDouble(content, until);
     773              :     StoHelp::writeTypedInt(content, nextStopIndex);
     774              :     StoHelp::writeTypedByte(content, teleport);
     775           47 :     Dom::set(libsumo::CMD_INSERT_STOP, vehID, &content);
     776           47 : }
     777              : 
     778              : 
     779              : void
     780           38 : Vehicle::setStopParameter(const std::string& vehID, int nextStopIndex,
     781              :                           const std::string& param, const std::string& value,
     782              :                           bool customParam) {
     783           38 :     tcpip::Storage content;
     784              :     StoHelp::writeCompound(content, 4);
     785              :     StoHelp::writeTypedInt(content, nextStopIndex);
     786              :     StoHelp::writeTypedString(content, param);
     787              :     StoHelp::writeTypedString(content, value);
     788           38 :     StoHelp::writeTypedByte(content, customParam);
     789           38 :     Dom::set(libsumo::VAR_STOP_PARAMETER, vehID, &content);
     790           38 : }
     791              : 
     792              : 
     793              : void
     794            4 : Vehicle::rerouteParkingArea(const std::string& vehID, const std::string& parkingAreaID) {
     795            4 :     tcpip::Storage content;
     796              :     StoHelp::writeCompound(content, 1);
     797              :     StoHelp::writeTypedString(content, parkingAreaID);
     798            4 :     Dom::set(libsumo::CMD_REROUTE_TO_PARKING, vehID, &content);
     799            4 : }
     800              : 
     801              : 
     802              : void
     803            2 : Vehicle::resume(const std::string& vehID) {
     804            2 :     tcpip::Storage content;
     805              :     StoHelp::writeCompound(content, 0);
     806            2 :     Dom::set(libsumo::CMD_RESUME, vehID, &content);
     807            2 : }
     808              : 
     809              : 
     810              : void
     811            9 : Vehicle::changeTarget(const std::string& vehID, const std::string& edgeID) {
     812            9 :     Dom::setString(libsumo::CMD_CHANGETARGET, vehID, edgeID);
     813            7 : }
     814              : 
     815              : 
     816              : void
     817         2223 : Vehicle::changeLane(const std::string& vehID, int laneIndex, double duration) {
     818         2223 :     tcpip::Storage content;
     819              :     StoHelp::writeCompound(content, 2);
     820              :     StoHelp::writeTypedByte(content, laneIndex);
     821              :     StoHelp::writeTypedDouble(content, duration);
     822         2223 :     Dom::set(libsumo::CMD_CHANGELANE, vehID, &content);
     823         2223 : }
     824              : 
     825              : void
     826           55 : Vehicle::changeLaneRelative(const std::string& vehID, int indexOffset, double duration) {
     827           55 :     tcpip::Storage content;
     828              :     StoHelp::writeCompound(content, 3);
     829              :     StoHelp::writeTypedByte(content, indexOffset);
     830              :     StoHelp::writeTypedDouble(content, duration);
     831              :     StoHelp::writeTypedByte(content, 1);
     832           55 :     Dom::set(libsumo::CMD_CHANGELANE, vehID, &content);
     833           55 : }
     834              : 
     835              : 
     836              : void
     837           75 : Vehicle::changeSublane(const std::string& vehID, double latDist) {
     838           75 :     Dom::setDouble(libsumo::CMD_CHANGESUBLANE, vehID, latDist);
     839           75 : }
     840              : 
     841              : 
     842              : void
     843         7488 : Vehicle::add(const std::string& vehID,
     844              :              const std::string& routeID,
     845              :              const std::string& typeID,
     846              :              const std::string& depart,
     847              :              const std::string& departLane,
     848              :              const std::string& departPos,
     849              :              const std::string& departSpeed,
     850              :              const std::string& arrivalLane,
     851              :              const std::string& arrivalPos,
     852              :              const std::string& arrivalSpeed,
     853              :              const std::string& fromTaz,
     854              :              const std::string& toTaz,
     855              :              const std::string& line,
     856              :              int personCapacity,
     857              :              int personNumber) {
     858         7488 :     tcpip::Storage content;
     859              :     StoHelp::writeCompound(content, 14);
     860              :     StoHelp::writeTypedString(content, routeID);
     861              :     StoHelp::writeTypedString(content, typeID);
     862              :     StoHelp::writeTypedString(content, depart);
     863              :     StoHelp::writeTypedString(content, departLane);
     864              :     StoHelp::writeTypedString(content, departPos);
     865              :     StoHelp::writeTypedString(content, departSpeed);
     866              : 
     867              :     StoHelp::writeTypedString(content, arrivalLane);
     868              :     StoHelp::writeTypedString(content, arrivalPos);
     869              :     StoHelp::writeTypedString(content, arrivalSpeed);
     870              : 
     871              :     StoHelp::writeTypedString(content, fromTaz);
     872              :     StoHelp::writeTypedString(content, toTaz);
     873              :     StoHelp::writeTypedString(content, line);
     874              : 
     875              :     StoHelp::writeTypedInt(content, personCapacity);
     876              :     StoHelp::writeTypedInt(content, personNumber);
     877              : 
     878         7488 :     Dom::set(libsumo::ADD_FULL, vehID, &content);
     879         7488 : }
     880              : 
     881              : 
     882              : void
     883         1016 : Vehicle::moveToXY(const std::string& vehID, const std::string& edgeID, const int laneIndex,
     884              :                   const double x, const double y, double angle, const int keepRoute, double matchThreshold) {
     885         1016 :     tcpip::Storage content;
     886              :     StoHelp::writeCompound(content, 7);
     887              :     StoHelp::writeTypedString(content, edgeID);
     888              :     StoHelp::writeTypedInt(content, laneIndex);
     889              :     StoHelp::writeTypedDouble(content, x);
     890              :     StoHelp::writeTypedDouble(content, y);
     891              :     StoHelp::writeTypedDouble(content, angle);
     892              :     StoHelp::writeTypedByte(content, keepRoute);
     893              :     StoHelp::writeTypedDouble(content, matchThreshold);
     894         1016 :     Dom::set(libsumo::MOVE_TO_XY, vehID, &content);
     895         1016 : }
     896              : 
     897              : void
     898            8 : Vehicle::slowDown(const std::string& vehID, double speed, double duration) {
     899            8 :     tcpip::Storage content;
     900              :     StoHelp::writeCompound(content, 2);
     901              :     StoHelp::writeTypedDouble(content, speed);
     902              :     StoHelp::writeTypedDouble(content, duration);
     903            8 :     Dom::set(libsumo::CMD_SLOWDOWN, vehID, &content);
     904            8 : }
     905              : 
     906              : void
     907           17 : Vehicle::openGap(const std::string& vehID, double newTimeHeadway, double newSpaceHeadway, double duration, double changeRate, double maxDecel, const std::string& referenceVehID) {
     908           17 :     tcpip::Storage content;
     909           17 :     StoHelp::writeCompound(content, referenceVehID != "" ? 6 : 5);
     910              :     StoHelp::writeTypedDouble(content, newTimeHeadway);
     911              :     StoHelp::writeTypedDouble(content, newSpaceHeadway);
     912              :     StoHelp::writeTypedDouble(content, duration);
     913              :     StoHelp::writeTypedDouble(content, changeRate);
     914              :     StoHelp::writeTypedDouble(content, maxDecel);
     915           17 :     if (referenceVehID != "") {
     916              :         StoHelp::writeTypedString(content, referenceVehID);
     917              :     }
     918           17 :     Dom::set(libsumo::CMD_OPENGAP, vehID, &content);
     919           17 : }
     920              : 
     921              : void
     922            2 : Vehicle::deactivateGapControl(const std::string& vehID) {
     923            2 :     openGap(vehID, -1, -1, -1, -1);
     924            2 : }
     925              : 
     926              : void
     927            0 : Vehicle::requestToC(const std::string& vehID, double leadTime) {
     928            0 :     std::ostringstream oss;
     929              :     oss.setf(std::ios::fixed, std::ios::floatfield);
     930              :     oss << std::setprecision(2);
     931              :     oss << leadTime;
     932            0 :     setParameter(vehID, "device.toc.requestToC", oss.str());
     933            0 : }
     934              : 
     935              : void
     936          974 : Vehicle::setSpeed(const std::string& vehID, double speed) {
     937          974 :     Dom::setDouble(libsumo::VAR_SPEED, vehID, speed);
     938          974 : }
     939              : 
     940              : void
     941            3 : Vehicle::setAcceleration(const std::string& vehID, double acceleration, double duration) {
     942            3 :     tcpip::Storage content;
     943              :     StoHelp::writeCompound(content, 2);
     944              :     StoHelp::writeTypedDouble(content, acceleration);
     945              :     StoHelp::writeTypedDouble(content, duration);
     946            3 :     Dom::set(libsumo::VAR_ACCELERATION, vehID, &content);
     947            3 : }
     948              : 
     949              : void
     950           49 : Vehicle::setPreviousSpeed(const std::string& vehID, double prevSpeed, double prevAcceleration) {
     951           49 :     tcpip::Storage content;
     952              :     StoHelp::writeCompound(content, 2);
     953              :     StoHelp::writeTypedDouble(content, prevSpeed);
     954              :     StoHelp::writeTypedDouble(content, prevAcceleration);
     955           49 :     Dom::set(libsumo::VAR_PREV_SPEED, vehID, &content);
     956           49 : }
     957              : 
     958              : void
     959          762 : Vehicle::setSpeedMode(const std::string& vehID, int speedMode) {
     960          762 :     Dom::setInt(libsumo::VAR_SPEEDSETMODE, vehID, speedMode);
     961          762 : }
     962              : 
     963              : void
     964          108 : Vehicle::setLaneChangeMode(const std::string& vehID, int laneChangeMode) {
     965          108 :     Dom::setInt(libsumo::VAR_LANECHANGE_MODE, vehID, laneChangeMode);
     966          108 : }
     967              : 
     968              : void
     969           23 : Vehicle::setRoutingMode(const std::string& vehID, int routingMode) {
     970           23 :     Dom::setInt(libsumo::VAR_ROUTING_MODE, vehID, routingMode);
     971           23 : }
     972              : 
     973              : void
     974           74 : Vehicle::setType(const std::string& vehID, const std::string& typeID) {
     975           74 :     Dom::setString(libsumo::VAR_TYPE, vehID, typeID);
     976           74 : }
     977              : 
     978              : void
     979            5 : Vehicle::setRouteID(const std::string& vehID, const std::string& routeID) {
     980            5 :     Dom::setString(libsumo::VAR_ROUTE_ID, vehID, routeID);
     981            5 : }
     982              : 
     983              : void
     984            1 : Vehicle::setRoute(const std::string& vehID, const std::string& edgeID) {
     985            3 :     setRoute(vehID, std::vector<std::string>({edgeID}));
     986            0 : }
     987              : 
     988              : void
     989            7 : Vehicle::setRoute(const std::string& vehID, const std::vector<std::string>& edgeIDs) {
     990            7 :     Dom::setStringVector(libsumo::VAR_ROUTE, vehID, edgeIDs);
     991            6 : }
     992              : 
     993              : void
     994            2 : Vehicle::setLateralLanePosition(const std::string& vehID, double posLat) {
     995            2 :     Dom::setDouble(libsumo::VAR_LANEPOSITION_LAT, vehID, posLat);
     996            2 : }
     997              : 
     998              : void
     999           67 : Vehicle::updateBestLanes(const std::string& vehID) {
    1000           67 :     tcpip::Storage content;
    1001           67 :     Dom::set(libsumo::VAR_UPDATE_BESTLANES, vehID, &content);
    1002           67 : }
    1003              : 
    1004              : 
    1005              : void
    1006           39 : Vehicle::setAdaptedTraveltime(const std::string& vehID, const std::string& edgeID,
    1007              :                               double time, double begSeconds, double endSeconds) {
    1008           39 :     tcpip::Storage content;
    1009           39 :     if (time == libsumo::INVALID_DOUBLE_VALUE) {
    1010              :         // reset
    1011              :         StoHelp::writeCompound(content, 1);
    1012              :         StoHelp::writeTypedString(content, edgeID);
    1013           37 :     } else if (begSeconds == libsumo::INVALID_DOUBLE_VALUE) {
    1014              :         // set value for the whole simulation
    1015              :         StoHelp::writeCompound(content, 2);
    1016              :         StoHelp::writeTypedString(content, edgeID);
    1017              :         StoHelp::writeTypedDouble(content, time);
    1018              :     } else {
    1019              :         StoHelp::writeCompound(content, 4);
    1020              :         StoHelp::writeTypedDouble(content, begSeconds);
    1021              :         StoHelp::writeTypedDouble(content, endSeconds);
    1022              :         StoHelp::writeTypedString(content, edgeID);
    1023              :         StoHelp::writeTypedDouble(content, time);
    1024              :     }
    1025           39 :     Dom::set(libsumo::VAR_EDGE_TRAVELTIME, vehID, &content);
    1026           39 : }
    1027              : 
    1028              : 
    1029              : void
    1030            6 : Vehicle::setEffort(const std::string& vehID, const std::string& edgeID,
    1031              :                    double effort, double begSeconds, double endSeconds) {
    1032            6 :     tcpip::Storage content;
    1033            6 :     if (effort == libsumo::INVALID_DOUBLE_VALUE) {
    1034              :         // reset
    1035              :         StoHelp::writeCompound(content, 1);
    1036              :         StoHelp::writeTypedString(content, edgeID);
    1037            4 :     } else if (begSeconds == libsumo::INVALID_DOUBLE_VALUE) {
    1038              :         // set value for the whole simulation
    1039              :         StoHelp::writeCompound(content, 2);
    1040              :         StoHelp::writeTypedString(content, edgeID);
    1041              :         StoHelp::writeTypedDouble(content, effort);
    1042              :     } else {
    1043              :         StoHelp::writeCompound(content, 4);
    1044              :         StoHelp::writeTypedDouble(content, begSeconds);
    1045              :         StoHelp::writeTypedDouble(content, endSeconds);
    1046              :         StoHelp::writeTypedString(content, edgeID);
    1047              :         StoHelp::writeTypedDouble(content, effort);
    1048              :     }
    1049            6 :     Dom::set(libsumo::VAR_EDGE_EFFORT, vehID, &content);
    1050            6 : }
    1051              : 
    1052              : 
    1053              : void
    1054           75 : Vehicle::rerouteTraveltime(const std::string& vehID, const bool /* currentTravelTimes */) {
    1055           75 :     tcpip::Storage content;
    1056              :     StoHelp::writeCompound(content, 0);
    1057           75 :     Dom::set(libsumo::CMD_REROUTE_TRAVELTIME, vehID, &content);
    1058           75 : }
    1059              : 
    1060              : 
    1061              : void
    1062            2 : Vehicle::rerouteEffort(const std::string& vehID) {
    1063            2 :     tcpip::Storage content;
    1064              :     StoHelp::writeCompound(content, 0);
    1065            2 :     Dom::set(libsumo::CMD_REROUTE_EFFORT, vehID, &content);
    1066            2 : }
    1067              : 
    1068              : 
    1069              : void
    1070            4 : Vehicle::setSignals(const std::string& vehID, int signals) {
    1071            4 :     Dom::setInt(libsumo::VAR_SIGNALS, vehID, signals);
    1072            4 : }
    1073              : 
    1074              : 
    1075              : void
    1076          103 : Vehicle::moveTo(const std::string& vehID, const std::string& laneID, double pos, int reason) {
    1077          103 :     tcpip::Storage content;
    1078              :     StoHelp::writeCompound(content, 3);
    1079              :     StoHelp::writeTypedString(content, laneID);
    1080              :     StoHelp::writeTypedDouble(content, pos);
    1081              :     StoHelp::writeTypedInt(content, reason);
    1082          103 :     Dom::set(libsumo::VAR_MOVE_TO, vehID, &content);
    1083          103 : }
    1084              : 
    1085              : 
    1086              : void
    1087            4 : Vehicle::setActionStepLength(const std::string& vehID, double actionStepLength, bool resetActionOffset) {
    1088              :     //if (actionStepLength < 0) {
    1089              :     //    raise TraCIException("Invalid value for actionStepLength. Given value must be non-negative.")
    1090              :     //{
    1091              :     // Use negative value to indicate resetActionOffset == False
    1092            4 :     if (!resetActionOffset) {
    1093            2 :         actionStepLength *= -1;
    1094              :     }
    1095            4 :     Dom::setDouble(libsumo::VAR_ACTIONSTEPLENGTH, vehID, actionStepLength);
    1096            4 : }
    1097              : 
    1098              : 
    1099              : void
    1100            4 : Vehicle::remove(const std::string& vehID, char reason) {
    1101            4 :     tcpip::Storage content;
    1102            4 :     content.writeUnsignedByte(libsumo::TYPE_BYTE);
    1103            4 :     content.writeUnsignedByte(reason);
    1104            4 :     Dom::set(libsumo::REMOVE, vehID, &content);
    1105            4 : }
    1106              : 
    1107              : 
    1108              : void
    1109           44 : Vehicle::setColor(const std::string& vehID, const libsumo::TraCIColor& color) {
    1110           44 :     Dom::setCol(libsumo::VAR_COLOR, vehID, color);
    1111           44 : }
    1112              : 
    1113              : 
    1114              : void
    1115         2048 : Vehicle::setSpeedFactor(const std::string& vehID, double factor) {
    1116         2048 :     Dom::setDouble(libsumo::VAR_SPEED_FACTOR, vehID, factor);
    1117         2048 : }
    1118              : 
    1119              : 
    1120              : void
    1121            3 : Vehicle::setLine(const std::string& vehID, const std::string& line) {
    1122            3 :     Dom::setString(libsumo::VAR_LINE, vehID, line);
    1123            3 : }
    1124              : 
    1125              : 
    1126              : void
    1127            4 : Vehicle::setVia(const std::string& vehID, const std::vector<std::string>& edgeList) {
    1128            4 :     Dom::setStringVector(libsumo::VAR_VIA, vehID, edgeList);
    1129            4 : }
    1130              : 
    1131              : 
    1132              : void
    1133           23 : Vehicle::setLength(const std::string& vehID, double length) {
    1134           23 :     Dom::setDouble(libsumo::VAR_LENGTH, vehID, length);
    1135           23 : }
    1136              : 
    1137              : 
    1138              : void
    1139            9 : Vehicle::setMaxSpeed(const std::string& vehID, double speed) {
    1140            9 :     Dom::setDouble(libsumo::VAR_MAXSPEED, vehID, speed);
    1141            9 : }
    1142              : 
    1143              : 
    1144              : void
    1145            2 : Vehicle::setVehicleClass(const std::string& vehID, const std::string& clazz) {
    1146            2 :     Dom::setString(libsumo::VAR_VEHICLECLASS, vehID, clazz);
    1147            2 : }
    1148              : 
    1149              : 
    1150              : void
    1151            2 : Vehicle::setShapeClass(const std::string& vehID, const std::string& clazz) {
    1152            2 :     Dom::setString(libsumo::VAR_SHAPECLASS, vehID, clazz);
    1153            2 : }
    1154              : 
    1155              : 
    1156              : void
    1157            5 : Vehicle::setEmissionClass(const std::string& vehID, const std::string& clazz) {
    1158            5 :     Dom::setString(libsumo::VAR_EMISSIONCLASS, vehID, clazz);
    1159            5 : }
    1160              : 
    1161              : 
    1162              : void
    1163            3 : Vehicle::setWidth(const std::string& vehID, double width) {
    1164            3 :     Dom::setDouble(libsumo::VAR_WIDTH, vehID, width);
    1165            3 : }
    1166              : 
    1167              : 
    1168              : void
    1169            2 : Vehicle::setHeight(const std::string& vehID, double height) {
    1170            2 :     Dom::setDouble(libsumo::VAR_HEIGHT, vehID, height);
    1171            2 : }
    1172              : 
    1173              : 
    1174              : void
    1175            2 : Vehicle::setMass(const std::string& vehID, double mass) {
    1176            2 :     Dom::setDouble(libsumo::VAR_MASS, vehID, mass);
    1177            2 : }
    1178              : 
    1179              : 
    1180              : void
    1181            3 : Vehicle::setMinGap(const std::string& vehID, double minGap) {
    1182            3 :     Dom::setDouble(libsumo::VAR_MINGAP, vehID, minGap);
    1183            3 : }
    1184              : 
    1185              : 
    1186              : void
    1187            5 : Vehicle::setAccel(const std::string& vehID, double accel) {
    1188            5 :     Dom::setDouble(libsumo::VAR_ACCEL, vehID, accel);
    1189            5 : }
    1190              : 
    1191              : 
    1192              : void
    1193            3 : Vehicle::setDecel(const std::string& vehID, double decel) {
    1194            3 :     Dom::setDouble(libsumo::VAR_DECEL, vehID, decel);
    1195            3 : }
    1196              : 
    1197              : 
    1198              : void
    1199            5 : Vehicle::setEmergencyDecel(const std::string& vehID, double decel) {
    1200            5 :     Dom::setDouble(libsumo::VAR_EMERGENCY_DECEL, vehID, decel);
    1201            5 : }
    1202              : 
    1203              : 
    1204              : void
    1205            3 : Vehicle::setApparentDecel(const std::string& vehID, double decel) {
    1206            3 :     Dom::setDouble(libsumo::VAR_APPARENT_DECEL, vehID, decel);
    1207            3 : }
    1208              : 
    1209              : 
    1210              : void
    1211            5 : Vehicle::setImperfection(const std::string& vehID, double imperfection) {
    1212            5 :     Dom::setDouble(libsumo::VAR_IMPERFECTION, vehID, imperfection);
    1213            5 : }
    1214              : 
    1215              : 
    1216              : void
    1217            3 : Vehicle::setTau(const std::string& vehID, double tau) {
    1218            3 :     Dom::setDouble(libsumo::VAR_TAU, vehID, tau);
    1219            3 : }
    1220              : 
    1221              : 
    1222              : void
    1223            2 : Vehicle::setMinGapLat(const std::string& vehID, double minGapLat) {
    1224            2 :     Dom::setDouble(libsumo::VAR_MINGAP_LAT, vehID, minGapLat);
    1225            2 : }
    1226              : 
    1227              : 
    1228              : void
    1229            2 : Vehicle::setMaxSpeedLat(const std::string& vehID, double speed) {
    1230            2 :     Dom::setDouble(libsumo::VAR_MAXSPEED_LAT, vehID, speed);
    1231            2 : }
    1232              : 
    1233              : 
    1234              : void
    1235            2 : Vehicle::setLateralAlignment(const std::string& vehID, const std::string& latAlignment) {
    1236            2 :     Dom::setString(libsumo::VAR_LATALIGNMENT, vehID, latAlignment);
    1237            2 : }
    1238              : 
    1239              : 
    1240              : void
    1241            6 : Vehicle::setImpatience(const std::string& vehID, double impatience) {
    1242            6 :     Dom::setDouble(libsumo::VAR_IMPATIENCE, vehID, impatience);
    1243            6 : }
    1244              : 
    1245              : void
    1246            2 : Vehicle::setBoardingDuration(const std::string& vehID, double boardingDuration) {
    1247            2 :     Dom::setDouble(libsumo::VAR_BOARDING_DURATION, vehID, boardingDuration);
    1248            2 : }
    1249              : 
    1250              : 
    1251              : void
    1252           10 : Vehicle::highlight(const std::string& vehID, const libsumo::TraCIColor& col, double size, const int alphaMax, const double duration, const int type) {
    1253           10 :     tcpip::Storage content;
    1254           10 :     StoHelp::writeCompound(content, alphaMax > 0 ? 5 : 2);
    1255           10 :     content.writeUnsignedByte(libsumo::TYPE_COLOR);
    1256           10 :     content.writeUnsignedByte(col.r);
    1257           10 :     content.writeUnsignedByte(col.g);
    1258           10 :     content.writeUnsignedByte(col.b);
    1259           10 :     content.writeUnsignedByte(col.a);
    1260              :     StoHelp::writeTypedDouble(content, size);
    1261           10 :     if (alphaMax > 0) {
    1262            6 :         content.writeUnsignedByte(libsumo::TYPE_UBYTE);
    1263            6 :         content.writeUnsignedByte(alphaMax);
    1264              :         StoHelp::writeTypedDouble(content, duration);
    1265            6 :         content.writeUnsignedByte(libsumo::TYPE_UBYTE);
    1266            6 :         content.writeUnsignedByte(type);
    1267              :     }
    1268           10 :     Dom::set(libsumo::VAR_HIGHLIGHT, vehID, &content);
    1269           10 : }
    1270              : 
    1271              : void
    1272           36 : Vehicle::dispatchTaxi(const std::string& vehID,  const std::vector<std::string>& reservations) {
    1273           36 :     Dom::setStringVector(libsumo::CMD_TAXI_DISPATCH, vehID, reservations);
    1274           31 : }
    1275              : 
    1276              : 
    1277              : void
    1278           17 : Vehicle::subscribeLeader(const std::string& vehID, double dist, double begin, double end) {
    1279           17 :     subscribe(vehID, std::vector<int>({ libsumo::VAR_LEADER }), begin, end,
    1280           51 :     libsumo::TraCIResults({ {libsumo::VAR_LEADER, std::make_shared<libsumo::TraCIDouble>(dist)} }));
    1281           17 : }
    1282              : 
    1283              : 
    1284              : void
    1285           43 : Vehicle::addSubscriptionFilterLanes(const std::vector<int>& lanes, bool noOpposite, double downstreamDist, double upstreamDist) {
    1286           43 :     tcpip::Storage content;
    1287           43 :     content.writeUnsignedByte((int)lanes.size());
    1288          115 :     for (int lane : lanes) {
    1289           72 :         content.writeUnsignedByte(lane < 0 ? lane + 256 : lane);
    1290              :     }
    1291           43 :     libtraci::Connection::getActive().addFilter(libsumo::FILTER_TYPE_LANES, &content);
    1292           43 :     if (noOpposite) {
    1293            1 :         addSubscriptionFilterNoOpposite();
    1294              :     }
    1295           43 :     if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
    1296            2 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    1297              :     }
    1298           43 :     if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
    1299            2 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    1300              :     }
    1301           43 : }
    1302              : 
    1303              : 
    1304              : void
    1305           14 : Vehicle::addSubscriptionFilterNoOpposite() {
    1306           14 :     libtraci::Connection::getActive().addFilter(libsumo::FILTER_TYPE_NOOPPOSITE);
    1307           14 : }
    1308              : 
    1309              : 
    1310              : void
    1311           51 : Vehicle::addSubscriptionFilterDownstreamDistance(double dist) {
    1312           51 :     tcpip::Storage content;
    1313              :     StoHelp::writeTypedDouble(content, dist);
    1314           51 :     libtraci::Connection::getActive().addFilter(libsumo::FILTER_TYPE_DOWNSTREAM_DIST, &content);
    1315           51 : }
    1316              : 
    1317              : 
    1318              : void
    1319           43 : Vehicle::addSubscriptionFilterUpstreamDistance(double dist) {
    1320           43 :     tcpip::Storage content;
    1321              :     StoHelp::writeTypedDouble(content, dist);
    1322           43 :     libtraci::Connection::getActive().addFilter(libsumo::FILTER_TYPE_UPSTREAM_DIST, &content);
    1323           43 : }
    1324              : 
    1325              : 
    1326              : void
    1327            1 : Vehicle::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) {
    1328            1 :     addSubscriptionFilterLeadFollow(std::vector<int>(1));
    1329            1 :     if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
    1330            0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    1331              :     }
    1332            1 :     if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
    1333            0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    1334              :     }
    1335            1 : }
    1336              : 
    1337              : 
    1338              : void
    1339            4 : Vehicle::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) {
    1340            4 :     if (direction == libsumo::INVALID_INT_VALUE) {
    1341            1 :         addSubscriptionFilterLeadFollow({ -1, 0, 1 });
    1342            3 :     } else if (direction != -1 && direction != 1) {
    1343              :         // warnings.warn("Ignoring lane change subscription filter with non-neighboring lane offset direction=%s." % direction)
    1344              :         return;
    1345              :     } else {
    1346            3 :         addSubscriptionFilterLeadFollow({ 0, direction });
    1347              :     }
    1348            4 :     if (noOpposite) {
    1349            0 :         addSubscriptionFilterNoOpposite();
    1350              :     }
    1351            4 :     if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
    1352            0 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    1353              :     }
    1354            4 :     if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
    1355            0 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    1356              :     }
    1357              : }
    1358              : 
    1359              : 
    1360              : void
    1361            5 : Vehicle::addSubscriptionFilterLeadFollow(const std::vector<int>& lanes) {
    1362            5 :     libtraci::Connection::getActive().addFilter(libsumo::FILTER_TYPE_LEAD_FOLLOW);
    1363            5 :     addSubscriptionFilterLanes(lanes);
    1364            5 : }
    1365              : 
    1366              : 
    1367              : void
    1368            8 : Vehicle::addSubscriptionFilterTurn(double downstreamDist, double foeDistToJunction) {
    1369            8 :     tcpip::Storage content;
    1370              :     StoHelp::writeTypedDouble(content, foeDistToJunction);
    1371            8 :     libtraci::Connection::getActive().addFilter(libsumo::FILTER_TYPE_TURN, &content);
    1372            8 :     if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
    1373            8 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    1374              :     }
    1375            8 : }
    1376              : 
    1377              : 
    1378              : void
    1379            3 : Vehicle::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) {
    1380            3 :     tcpip::Storage content;
    1381              :     StoHelp::writeTypedStringList(content, vClasses);
    1382            3 :     libtraci::Connection::getActive().addFilter(libsumo::FILTER_TYPE_VCLASS, &content);
    1383            3 : }
    1384              : 
    1385              : 
    1386              : void
    1387            3 : Vehicle::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) {
    1388            3 :     tcpip::Storage content;
    1389              :     StoHelp::writeTypedStringList(content, vTypes);
    1390            3 :     libtraci::Connection::getActive().addFilter(libsumo::FILTER_TYPE_VTYPE, &content);
    1391            3 : }
    1392              : 
    1393              : 
    1394              : void
    1395            8 : Vehicle::addSubscriptionFilterFieldOfVision(double openingAngle) {
    1396            8 :     tcpip::Storage content;
    1397              :     StoHelp::writeTypedDouble(content, openingAngle);
    1398            8 :     libtraci::Connection::getActive().addFilter(libsumo::FILTER_TYPE_FIELD_OF_VISION, &content);
    1399            8 : }
    1400              : 
    1401              : 
    1402              : void
    1403            8 : Vehicle::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) {
    1404            8 :     tcpip::Storage content;
    1405              :     StoHelp::writeTypedDouble(content, lateralDist);
    1406            8 :     libtraci::Connection::getActive().addFilter(libsumo::FILTER_TYPE_LATERAL_DIST, &content);
    1407            7 :     if (downstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
    1408            7 :         addSubscriptionFilterDownstreamDistance(downstreamDist);
    1409              :     }
    1410            7 :     if (upstreamDist != libsumo::INVALID_DOUBLE_VALUE) {
    1411            7 :         addSubscriptionFilterUpstreamDistance(upstreamDist);
    1412              :     }
    1413            8 : }
    1414              : 
    1415              : 
    1416              : }
    1417              : 
    1418              : 
    1419              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1