LCOV - code coverage report
Current view: top level - src/libtraci - Calibrator.cpp (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 54 54
Test Date: 2024-10-24 15:46:30 Functions: 75.0 % 28 21

            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    Calibrator.cpp
      15              : /// @author  Jakob Erdmann
      16              : /// @date    16.03.2020
      17              : ///
      18              : // C++ TraCI client API implementation
      19              : /****************************************************************************/
      20              : #include <config.h>
      21              : 
      22              : #define LIBTRACI 1
      23              : #include <libsumo/TraCIConstants.h>
      24              : #include <libsumo/Calibrator.h>
      25              : #include "Connection.h"
      26              : #include "Domain.h"
      27              : 
      28              : 
      29              : namespace libtraci {
      30              : 
      31              : typedef Domain<libsumo::CMD_GET_CALIBRATOR_VARIABLE, libsumo::CMD_SET_CALIBRATOR_VARIABLE> Dom;
      32              : 
      33              : // ===========================================================================
      34              : // static member definitions
      35              : // ===========================================================================
      36              : std::vector<std::string>
      37           28 : Calibrator::getIDList() {
      38           55 :     return Dom::getStringVector(libsumo::TRACI_ID_LIST, "");
      39              : }
      40              : 
      41              : int
      42            1 : Calibrator::getIDCount() {
      43            2 :     return Dom::getInt(libsumo::ID_COUNT, "");
      44              : }
      45              : 
      46              : std::string
      47            2 : Calibrator::getEdgeID(const std::string& calibratorID) {
      48            2 :     return Dom::getString(libsumo::VAR_ROAD_ID, calibratorID);
      49              : }
      50              : 
      51              : std::string
      52            2 : Calibrator::getLaneID(const std::string& calibratorID) {
      53            2 :     return Dom::getString(libsumo::VAR_LANE_ID, calibratorID);
      54              : }
      55              : 
      56              : double
      57            3 : Calibrator::getVehsPerHour(const std::string& calibratorID) {
      58            3 :     return Dom::getDouble(libsumo::VAR_VEHSPERHOUR, calibratorID);
      59              : }
      60              : 
      61              : double
      62            2 : Calibrator::getSpeed(const std::string& calibratorID) {
      63            2 :     return Dom::getDouble(libsumo::VAR_SPEED, calibratorID);
      64              : }
      65              : 
      66              : std::string
      67            2 : Calibrator::getTypeID(const std::string& calibratorID) {
      68            2 :     return Dom::getString(libsumo::VAR_TYPE, calibratorID);
      69              : }
      70              : 
      71              : double
      72            3 : Calibrator::getBegin(const std::string& calibratorID) {
      73            3 :     return Dom::getDouble(libsumo::VAR_BEGIN, calibratorID);
      74              : }
      75              : 
      76              : double
      77            3 : Calibrator::getEnd(const std::string& calibratorID) {
      78            3 :     return Dom::getDouble(libsumo::VAR_END, calibratorID);
      79              : }
      80              : 
      81              : std::string
      82            2 : Calibrator::getRouteID(const std::string& calibratorID) {
      83            2 :     return Dom::getString(libsumo::VAR_ROUTE_ID, calibratorID);
      84              : }
      85              : 
      86              : std::string
      87            2 : Calibrator::getRouteProbeID(const std::string& calibratorID) {
      88            2 :     return Dom::getString(libsumo::VAR_ROUTE_PROBE, calibratorID);
      89              : }
      90              : 
      91              : std::vector<std::string>
      92            2 : Calibrator::getVTypes(const std::string& calibratorID) {
      93            2 :     return Dom::getStringVector(libsumo::VAR_VTYPES, calibratorID);
      94              : }
      95              : 
      96              : 
      97              : int
      98            2 : Calibrator::getPassed(const std::string& calibratorID) {
      99            2 :     return Dom::getInt(libsumo::VAR_PASSED, calibratorID);
     100              : }
     101              : 
     102              : int
     103            2 : Calibrator::getInserted(const std::string& calibratorID) {
     104            2 :     return Dom::getInt(libsumo::VAR_INSERTED, calibratorID);
     105              : }
     106              : 
     107              : int
     108            2 : Calibrator::getRemoved(const std::string& calibratorID) {
     109            2 :     return Dom::getInt(libsumo::VAR_REMOVED, calibratorID);
     110              : }
     111              : 
     112            4 : LIBTRACI_PARAMETER_IMPLEMENTATION(Calibrator, CALIBRATOR)
     113              : 
     114              : void
     115            2 : Calibrator::setFlow(const std::string& calibratorID, double begin, double end, double vehsPerHour, double speed,
     116              :                     const std::string& typeID, const std::string& routeID, const std::string& departLane, const std::string& departSpeed) {
     117            2 :     tcpip::Storage content;
     118            2 :     content.writeUnsignedByte(libsumo::TYPE_COMPOUND);
     119            2 :     content.writeInt(8);
     120            2 :     content.writeByte(libsumo::TYPE_DOUBLE);
     121            2 :     content.writeDouble(begin);
     122            2 :     content.writeByte(libsumo::TYPE_DOUBLE);
     123            2 :     content.writeDouble(end);
     124            2 :     content.writeByte(libsumo::TYPE_DOUBLE);
     125            2 :     content.writeDouble(vehsPerHour);
     126            2 :     content.writeByte(libsumo::TYPE_DOUBLE);
     127            2 :     content.writeDouble(speed);
     128            2 :     content.writeByte(libsumo::TYPE_STRING);
     129            2 :     content.writeString(typeID);
     130            2 :     content.writeByte(libsumo::TYPE_STRING);
     131            2 :     content.writeString(routeID);
     132            2 :     content.writeByte(libsumo::TYPE_STRING);
     133            2 :     content.writeString(departLane);
     134            2 :     content.writeByte(libsumo::TYPE_STRING);
     135            2 :     content.writeString(departSpeed);
     136            2 :     Dom::set(libsumo::CMD_SET_FLOW, calibratorID, &content);
     137            2 : }
     138              : 
     139          102 : LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(Calibrator, CALIBRATOR)
     140              : 
     141              : 
     142              : }
     143              : 
     144              : 
     145              : /****************************************************************************/
        

Generated by: LCOV version 2.0-1