LCOV - code coverage report
Current view: top level - src/libtraci - VehicleType.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 99.3 % 138 137
Test Date: 2024-10-24 15:46:30 Functions: 95.5 % 66 63

            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    VehicleType.cpp
      15              : /// @author  Jakob Erdmann
      16              : /// @author  Michael Behrisch
      17              : /// @date    30.05.2012
      18              : ///
      19              : // C++ TraCI client API implementation
      20              : /****************************************************************************/
      21              : #include <config.h>
      22              : #include <sstream>
      23              : 
      24              : #define LIBTRACI 1
      25              : #include <libsumo/VehicleType.h>
      26              : #include "Connection.h"
      27              : #include "Domain.h"
      28              : 
      29              : 
      30              : namespace libtraci {
      31              : 
      32              : typedef Domain<libsumo::CMD_GET_VEHICLETYPE_VARIABLE, libsumo::CMD_SET_VEHICLETYPE_VARIABLE> Dom;
      33              : 
      34              : 
      35              : // ===========================================================================
      36              : // static member definitions
      37              : // ===========================================================================
      38              : std::vector<std::string>
      39           42 : VehicleType::getIDList() {
      40           83 :     return Dom::getStringVector(libsumo::TRACI_ID_LIST, "");
      41              : }
      42              : 
      43              : 
      44              : int
      45            2 : VehicleType::getIDCount() {
      46            4 :     return Dom::getInt(libsumo::ID_COUNT, "");
      47              : }
      48              : 
      49              : 
      50          118 : LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(VehicleType, VEHICLETYPE)
      51           39 : LIBTRACI_PARAMETER_IMPLEMENTATION(VehicleType, VEHICLETYPE)
      52              : 
      53              : 
      54              : void
      55            1 : VehicleType::copy(const std::string& origTypeID, const std::string& newTypeID)  {
      56            1 :     Dom::setString(libsumo::COPY, origTypeID, newTypeID);
      57            1 : }
      58              : 
      59              : double
      60           33 : VehicleType::getSpeedFactor(const std::string& typeID) {
      61           33 :     return Dom::getDouble(libsumo::VAR_SPEED_FACTOR, typeID);
      62              : }
      63              : 
      64              : double
      65            2 : VehicleType::getSpeedDeviation(const std::string& typeID) {
      66            2 :     return Dom::getDouble(libsumo::VAR_SPEED_DEVIATION, typeID);
      67              : }
      68              : 
      69              : 
      70              : std::string
      71            2 : VehicleType::getEmissionClass(const std::string& typeID) {
      72            2 :     return Dom::getString(libsumo::VAR_EMISSIONCLASS, typeID);
      73              : }
      74              : 
      75              : std::string
      76            2 : VehicleType::getShapeClass(const std::string& typeID) {
      77            2 :     return Dom::getString(libsumo::VAR_SHAPECLASS, typeID);
      78              : }
      79              : 
      80              : 
      81              : double
      82           88 : VehicleType::getLength(const std::string& typeID) {
      83           88 :     return Dom::getDouble(libsumo::VAR_LENGTH, typeID);
      84              : }
      85              : 
      86              : 
      87              : double
      88            6 : VehicleType::getAccel(const std::string& typeID) {
      89            6 :     return Dom::getDouble(libsumo::VAR_ACCEL, typeID);
      90              : }
      91              : 
      92              : 
      93              : double
      94          103 : VehicleType::getDecel(const std::string& typeID) {
      95          103 :     return Dom::getDouble(libsumo::VAR_DECEL, typeID);
      96              : }
      97              : 
      98              : 
      99          187 : double VehicleType::getEmergencyDecel(const std::string& typeID) {
     100          187 :     return Dom::getDouble(libsumo::VAR_EMERGENCY_DECEL, typeID);
     101              : }
     102              : 
     103              : 
     104            4 : double VehicleType::getApparentDecel(const std::string& typeID) {
     105            4 :     return Dom::getDouble(libsumo::VAR_APPARENT_DECEL, typeID);
     106              : }
     107              : 
     108              : 
     109            4 : double VehicleType::getActionStepLength(const std::string& typeID) {
     110            4 :     return Dom::getDouble(libsumo::VAR_ACTIONSTEPLENGTH, typeID);
     111              : }
     112              : 
     113              : 
     114              : double
     115          103 : VehicleType::getTau(const std::string& typeID) {
     116          103 :     return Dom::getDouble(libsumo::VAR_TAU, typeID);
     117              : }
     118              : 
     119              : 
     120              : double
     121            6 : VehicleType::getImperfection(const std::string& typeID) {
     122            6 :     return Dom::getDouble(libsumo::VAR_IMPERFECTION, typeID);
     123              : }
     124              : 
     125              : 
     126              : std::string
     127          164 : VehicleType::getVehicleClass(const std::string& typeID) {
     128          164 :     return Dom::getString(libsumo::VAR_VEHICLECLASS, typeID);
     129              : }
     130              : 
     131              : 
     132              : double
     133          103 : VehicleType::getMinGap(const std::string& typeID) {
     134          103 :     return Dom::getDouble(libsumo::VAR_MINGAP, typeID);
     135              : }
     136              : 
     137              : 
     138              : double
     139            2 : VehicleType::getMinGapLat(const std::string& typeID) {
     140            2 :     return Dom::getDouble(libsumo::VAR_MINGAP_LAT, typeID);
     141              : }
     142              : 
     143              : 
     144              : double
     145            6 : VehicleType::getMaxSpeed(const std::string& typeID) {
     146            6 :     return Dom::getDouble(libsumo::VAR_MAXSPEED, typeID);
     147              : }
     148              : 
     149              : 
     150              : double
     151            2 : VehicleType::getMaxSpeedLat(const std::string& typeID) {
     152            2 :     return Dom::getDouble(libsumo::VAR_MAXSPEED_LAT, typeID);
     153              : }
     154              : 
     155              : 
     156              : std::string
     157            2 : VehicleType::getLateralAlignment(const std::string& typeID) {
     158            2 :     return Dom::getString(libsumo::VAR_LATALIGNMENT, typeID);
     159              : }
     160              : 
     161              : 
     162              : double
     163            4 : VehicleType::getWidth(const std::string& typeID) {
     164            4 :     return Dom::getDouble(libsumo::VAR_WIDTH, typeID);
     165              : }
     166              : 
     167              : 
     168              : double
     169            1 : VehicleType::getHeight(const std::string& typeID) {
     170            1 :     return Dom::getDouble(libsumo::VAR_HEIGHT, typeID);
     171              : }
     172              : 
     173              : 
     174              : double
     175            1 : VehicleType::getMass(const std::string& typeID) {
     176            1 :     return Dom::getDouble(libsumo::VAR_MASS, typeID);
     177              : }
     178              : 
     179              : 
     180              : libsumo::TraCIColor
     181            2 : VehicleType::getColor(const std::string& typeID) {
     182            2 :     return Dom::getCol(libsumo::VAR_COLOR, typeID);
     183              : }
     184              : 
     185              : 
     186              : int
     187            1 : VehicleType::getPersonCapacity(const std::string& typeID) {
     188            1 :     return Dom::getInt(libsumo::VAR_PERSON_CAPACITY, typeID);
     189              : }
     190              : 
     191              : 
     192              : double
     193            1 : VehicleType::getScale(const std::string& typeID) {
     194            1 :     return Dom::getDouble(libsumo::VAR_SCALE, typeID);
     195              : }
     196              : 
     197              : 
     198              : double
     199            2 : VehicleType::getBoardingDuration(const std::string& typeID) {
     200            2 :     return Dom::getDouble(libsumo::VAR_BOARDING_DURATION, typeID);
     201              : }
     202              : 
     203              : 
     204              : double
     205            2 : VehicleType::getImpatience(const std::string& typeID) {
     206            2 :     return Dom::getDouble(libsumo::VAR_IMPATIENCE, typeID);
     207              : }
     208              : 
     209              : 
     210              : void
     211            1 : VehicleType::setImpatience(const std::string& typeID, double impatience) {
     212            1 :     Dom::setDouble(libsumo::VAR_IMPATIENCE, typeID, impatience);
     213            1 : }
     214              : 
     215              : void
     216            1 : VehicleType::setBoardingDuration(const std::string& typeID, double boardingDuration) {
     217            1 :     Dom::setDouble(libsumo::VAR_BOARDING_DURATION, typeID, boardingDuration);
     218            1 : }
     219              : 
     220              : void
     221            3 : VehicleType::setActionStepLength(const std::string& typeID, double actionStepLength, bool resetActionOffset) {
     222              :     //if (actionStepLength < 0) {
     223              :     //    raise TraCIException("Invalid value for actionStepLength. Given value must be non-negative.")
     224              :     //{
     225              :     // Use negative value to indicate resetActionOffset == False
     226            3 :     if (!resetActionOffset) {
     227            0 :         actionStepLength *= -1;
     228              :     }
     229            3 :     Dom::setDouble(libsumo::VAR_ACTIONSTEPLENGTH, typeID, actionStepLength);
     230            3 : }
     231              : 
     232              : 
     233              : void
     234            1 : VehicleType::setColor(const std::string& typeID, const libsumo::TraCIColor& col) {
     235            1 :     Dom::setCol(libsumo::VAR_COLOR, typeID, col);
     236            1 : }
     237              : 
     238              : 
     239              : void
     240            2 : VehicleType::setSpeedFactor(const std::string& typeID, double factor) {
     241            2 :     Dom::setDouble(libsumo::VAR_SPEED_FACTOR, typeID, factor);
     242            2 : }
     243              : 
     244              : 
     245              : void
     246            1 : VehicleType::setSpeedDeviation(const std::string& typeID, double deviation) {
     247            1 :     Dom::setDouble(libsumo::VAR_SPEED_DEVIATION, typeID, deviation);
     248            1 : }
     249              : 
     250              : 
     251              : void
     252            2 : VehicleType::setLength(const std::string& typeID, double length) {
     253            2 :     Dom::setDouble(libsumo::VAR_LENGTH, typeID, length);
     254            2 : }
     255              : 
     256              : 
     257              : void
     258            3 : VehicleType::setMaxSpeed(const std::string& typeID, double speed) {
     259            3 :     Dom::setDouble(libsumo::VAR_MAXSPEED, typeID, speed);
     260            3 : }
     261              : 
     262              : 
     263              : void
     264            1 : VehicleType::setVehicleClass(const std::string& typeID, const std::string& clazz) {
     265            1 :     Dom::setString(libsumo::VAR_VEHICLECLASS, typeID, clazz);
     266            1 : }
     267              : 
     268              : 
     269              : void
     270            1 : VehicleType::setShapeClass(const std::string& typeID, const std::string& clazz) {
     271            1 :     Dom::setString(libsumo::VAR_SHAPECLASS, typeID, clazz);
     272            1 : }
     273              : 
     274              : 
     275              : void
     276            1 : VehicleType::setEmissionClass(const std::string& typeID, const std::string& clazz) {
     277            1 :     Dom::setString(libsumo::VAR_EMISSIONCLASS, typeID, clazz);
     278            1 : }
     279              : 
     280              : 
     281              : void
     282            2 : VehicleType::setWidth(const std::string& typeID, double width) {
     283            2 :     Dom::setDouble(libsumo::VAR_WIDTH, typeID, width);
     284            2 : }
     285              : 
     286              : 
     287              : void
     288            1 : VehicleType::setHeight(const std::string& typeID, double height) {
     289            1 :     Dom::setDouble(libsumo::VAR_HEIGHT, typeID, height);
     290            1 : }
     291              : 
     292              : 
     293              : void
     294            1 : VehicleType::setMass(const std::string& typeID, double mass) {
     295            1 :     Dom::setDouble(libsumo::VAR_MASS, typeID, mass);
     296            1 : }
     297              : 
     298              : 
     299              : void
     300            2 : VehicleType::setMinGap(const std::string& typeID, double minGap) {
     301            2 :     Dom::setDouble(libsumo::VAR_MINGAP, typeID, minGap);
     302            2 : }
     303              : 
     304              : 
     305              : void
     306            3 : VehicleType::setAccel(const std::string& typeID, double accel) {
     307            3 :     Dom::setDouble(libsumo::VAR_ACCEL, typeID, accel);
     308            3 : }
     309              : 
     310              : 
     311              : void
     312            2 : VehicleType::setDecel(const std::string& typeID, double decel) {
     313            2 :     Dom::setDouble(libsumo::VAR_DECEL, typeID, decel);
     314            2 : }
     315              : 
     316              : 
     317              : void
     318            2 : VehicleType::setEmergencyDecel(const std::string& typeID, double decel) {
     319            2 :     Dom::setDouble(libsumo::VAR_EMERGENCY_DECEL, typeID, decel);
     320            2 : }
     321              : 
     322              : 
     323              : void
     324            2 : VehicleType::setApparentDecel(const std::string& typeID, double decel) {
     325            2 :     Dom::setDouble(libsumo::VAR_APPARENT_DECEL, typeID, decel);
     326            2 : }
     327              : 
     328              : 
     329              : void
     330            3 : VehicleType::setImperfection(const std::string& typeID, double imperfection) {
     331            3 :     Dom::setDouble(libsumo::VAR_IMPERFECTION, typeID, imperfection);
     332            3 : }
     333              : 
     334              : 
     335              : void
     336            2 : VehicleType::setTau(const std::string& typeID, double tau) {
     337            2 :     Dom::setDouble(libsumo::VAR_TAU, typeID, tau);
     338            2 : }
     339              : 
     340              : 
     341              : void
     342            1 : VehicleType::setMinGapLat(const std::string& typeID, double minGapLat) {
     343            1 :     Dom::setDouble(libsumo::VAR_MINGAP_LAT, typeID, minGapLat);
     344            1 : }
     345              : 
     346              : 
     347              : void
     348            1 : VehicleType::setMaxSpeedLat(const std::string& typeID, double speed) {
     349            1 :     Dom::setDouble(libsumo::VAR_MAXSPEED_LAT, typeID, speed);
     350            1 : }
     351              : 
     352              : 
     353              : void
     354            1 : VehicleType::setLateralAlignment(const std::string& typeID, const std::string& latAlignment) {
     355            1 :     Dom::setString(libsumo::VAR_LATALIGNMENT, typeID, latAlignment);
     356            1 : }
     357              : 
     358              : void
     359            1 : VehicleType::setScale(const std::string& typeID, double value) {
     360            1 :     Dom::setDouble(libsumo::VAR_SCALE, typeID, value);
     361            1 : }
     362              : 
     363              : }
     364              : 
     365              : 
     366              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1