LCOV - code coverage report
Current view: top level - AP_Generator - AP_Generator_Backend.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 5 11 45.5 %
Date: 2026-09-09 11:02:08 Functions: 3 10 30.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "AP_Generator.h"
       4             : 
       5             : #if HAL_GENERATOR_ENABLED
       6             : 
       7             : class AP_Generator_Backend
       8             : {
       9             : public:
      10             : 
      11             :     // Constructor
      12             :     AP_Generator_Backend(AP_Generator& frontend);
      13             : 
      14             :     // Declare a virtual destructor in case Generator drivers want to override
      15           0 :     virtual ~AP_Generator_Backend() {};
      16             : 
      17             :     virtual void init(void) = 0;
      18             :     virtual void update(void) = 0;
      19             : 
      20             :     // Set default to not fail arming checks
      21           0 :     virtual bool pre_arm_check(char *failmsg, uint8_t failmsg_len) const { return true; }
      22             : 
      23             :     // Set default to not fail failsafes
      24        3620 :     virtual AP_BattMonitor::Failsafe update_failsafes(void) const {
      25        3620 :         return AP_BattMonitor::Failsafe::None;
      26             :     }
      27             : 
      28             :     virtual bool healthy(void) const = 0;
      29             : 
      30             :     // Generator controls must return true if present in generator type
      31           0 :     virtual bool stop(void) { return false; }
      32           0 :     virtual bool idle(void) { return false; }
      33           0 :     virtual bool run(void) { return false; }
      34             : 
      35             :     // Use generator mavlink message
      36        1750 :     virtual void send_generator_status(const GCS_MAVLINK &channel) {}
      37             : 
      38          13 :     virtual const struct AP_Param::GroupInfo *get_var_info() const {
      39          13 :         return nullptr;
      40             :     }
      41             : 
      42             :     // method to reset the amount of energy remaining in a generator.
      43             :     // This typically means someone has refueled the vehicle without
      44             :     // powering it off, and is indicating that the fuel tank is full.
      45           0 :     virtual bool reset_consumed_energy() { return false; }
      46             : 
      47             : protected:
      48             : 
      49             :     // Update frontend
      50             :     void update_frontend(void);
      51             : 
      52             :     // Measurements readings to write to front end
      53             :     float _voltage;
      54             :     float _current;
      55             :     float _fuel_remaining; // Decimal from 0 to 1
      56             :     float _fuel_remaining_l = -1; // -1 means unused
      57             :     float _consumed_mah;
      58             :     uint16_t _rpm;
      59             : 
      60             :     AP_Generator& _frontend;
      61             : 
      62             : };
      63             : #endif

Generated by: LCOV version 1.14