LCOV - code coverage report
Current view: top level - src/microsim/engine - GenericEngineModel.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 0.0 % 2 0
Test Date: 2024-10-17 15:44:51 Functions: - 0 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-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    GenericEngineModel.h
      15              : /// @author  Michele Segata
      16              : /// @date    4 Feb 2015
      17              : ///
      18              : // Generic interface for an engine model
      19              : /****************************************************************************/
      20              : 
      21              : #pragma once
      22              : #include <config.h>
      23              : 
      24              : #include <map>
      25              : #include <string>
      26              : #include <utils/common/SUMOTime.h>
      27              : #include <utils/common/Parameterised.h>
      28              : 
      29              : /**
      30              :  * This is an interface for plexe engine models. It provides two virtual methods
      31              :  * that should be overridden by implementing classes: getRealAcceleration and
      32              :  * loadParameters
      33              :  */
      34              : class GenericEngineModel {
      35              : 
      36              : public:
      37              :     /// @brief constructor
      38            0 :     GenericEngineModel() : maxAcceleration_mpsps(1.5), maxDeceleration_mpsps(7) {};
      39              : 
      40              :     /// @brief destructor
      41            0 :     virtual ~GenericEngineModel() {};
      42              : 
      43              :     /**
      44              :      * Computes real vehicle acceleration given current speed, current acceleration,
      45              :      * and requested acceleration. Acceleration can be negative as well. The
      46              :      * model should handle decelerations as well
      47              :      *
      48              :      * @param[in] speed_mps current speed in meters per second
      49              :      * @param[in] accel_mps2 current acceleration in meters per squared second
      50              :      * @param[in] reqAccel_mps2 requested acceleration in meters per squared second
      51              :      * @param[in] timeStep current simulation timestep
      52              :      * @return the real acceleration that the vehicle applies in meters per
      53              :      * squared second
      54              :      */
      55              :     virtual double getRealAcceleration(double speed_mps, double accel_mps2, double reqAccel_mps2, SUMOTime timeStep = 0) = 0;
      56              : 
      57              :     /**
      58              :      * Sets a single parameter value
      59              :      *
      60              :      * @param[in] parameter the name of the parameter
      61              :      * @param[in] value the value for the parameter
      62              :      */
      63              :     virtual void setParameter(const std::string parameter, const std::string& value) = 0;
      64              :     virtual void setParameter(const std::string parameter, double value) = 0;
      65              :     virtual void setParameter(const std::string parameter, int value) = 0;
      66              : 
      67              :     /**
      68              :      * Sets maximum acceleration value
      69              :      *
      70              :      * @param[in] maximum acceleration in meters per second squared
      71              :      */
      72              :     void setMaximumAcceleration(double maxAcc);
      73              :     /**
      74              :      * Sets maximum deceleration value
      75              :      *
      76              :      * @param[in] maximum deceleration (positive value) in meters per second
      77              :      * squared
      78              :      */
      79              :     void setMaximumDeceleration(double maxDec);
      80              : 
      81              : protected:
      82              :     //class name, used to log information
      83              :     std::string className;
      84              : 
      85              :     //minimum and maximum acceleration of the model, if any
      86              :     double maxAcceleration_mpsps, maxDeceleration_mpsps;
      87              : 
      88              :     /**
      89              :      * Prints a parameter error
      90              :      */
      91              :     void printParameterError(std::string parameter, std::string value);
      92              : 
      93              :     /**
      94              :      * Parses a value from the parameter map
      95              :      */
      96              :     void parseParameter(const Parameterised::Map& parameters, std::string parameter, double& value);
      97              :     void parseParameter(const Parameterised::Map& parameters, std::string parameter, int& value);
      98              :     void parseParameter(const Parameterised::Map& parameters, std::string parameter, std::string& value);
      99              : };
        

Generated by: LCOV version 2.0-1