LCOV - code coverage report
Current view: top level - SITL - SIM_ICEngine.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 8 8 100.0 %
Date: 2026-09-09 11:02:08 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :    This program is free software: you can redistribute it and/or modify
       3             :    it under the terms of the GNU General Public License as published by
       4             :    the Free Software Foundation, either version 3 of the License, or
       5             :    (at your option) any later version.
       6             : 
       7             :    This program is distributed in the hope that it will be useful,
       8             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
       9             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      10             :    GNU General Public License for more details.
      11             : 
      12             :    You should have received a copy of the GNU General Public License
      13             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      14             :  */
      15             : /*
      16             :   simple internal combustion motor simulation class
      17             : */
      18             : 
      19             : #pragma once
      20             : 
      21             : #include "SIM_Aircraft.h"
      22             : 
      23             : namespace SITL {
      24             : 
      25             : class ICEngine {
      26             : public:
      27             :     const uint8_t throttle_servo;
      28             :     const int8_t choke_servo;
      29             :     const int8_t ignition_servo;
      30             :     const int8_t starter_servo;
      31             :     const float slew_rate; // percent-per-second
      32             : 
      33         691 :     ICEngine(uint8_t _throttle, int8_t _choke, int8_t _ignition, int8_t _starter, float _slew_rate, bool _throttle_reversed) :
      34         691 :         throttle_servo(_throttle),
      35         691 :         choke_servo(_choke),
      36         691 :         ignition_servo(_ignition),
      37         691 :         starter_servo(_starter),
      38         691 :         slew_rate(_slew_rate),
      39         691 :         throttle_reversed(_throttle_reversed)
      40         691 :     {}
      41             : 
      42             :     // update motor state
      43             :     float update(const struct sitl_input &input);
      44             : 
      45             : private:
      46             :     float last_output;
      47             :     uint64_t start_time_us;
      48             :     uint64_t last_update_us;
      49             :     union state {
      50             :         struct {
      51             :             bool choke:1;
      52             :             bool ignition:1;
      53             :             bool starter:1;
      54             :         };
      55             :         uint8_t value;
      56             :     } state, last_state;
      57             :     bool overheat;
      58             :     bool throttle_reversed;
      59             : };
      60             : }

Generated by: LCOV version 1.14