LCOV - code coverage report
Current view: top level - AP_BattMonitor - AP_BattMonitor_EFI.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 15 0.0 %
Date: 2026-09-09 11:02:08 Functions: 0 1 0.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             : #include "AP_BattMonitor_config.h"
      17             : 
      18             : #if AP_BATTERY_EFI_ENABLED
      19             : 
      20             : #include <AP_Common/AP_Common.h>
      21             : #include <AP_Math/AP_Math.h>
      22             : #include <AP_EFI/AP_EFI.h>
      23             : 
      24             : #include "AP_BattMonitor_EFI.h"
      25             : 
      26             : // update state
      27           0 : void AP_BattMonitor_EFI::read()
      28             : {
      29           0 :     AP_EFI *efi = AP::EFI();
      30           0 :     if (efi == nullptr) {
      31           0 :         return;
      32             :     }
      33             : 
      34           0 :     if (!efi->is_healthy()) {
      35           0 :         _state.healthy = false;
      36           0 :         return;
      37             :     }
      38             : 
      39           0 :     struct EFI_State efi_state;
      40             :     /*
      41             :       a simple mapping of 1 Amp == 1 litre/hour and 1Ah = 1Litre
      42             :      */
      43           0 :     efi->get_state(efi_state);
      44             : 
      45           0 :     _state.current_amps = efi_state.fuel_consumption_rate_cm3pm*0.001*60; // litres/hour
      46             :     // use arbitrary 1.0 Volts
      47           0 :     _state.voltage = 1.0;
      48           0 :     _state.consumed_mah = efi_state.estimated_consumed_fuel_volume_cm3; // millilitres
      49           0 :     _state.consumed_wh = 0.001 * _state.consumed_mah;
      50           0 :     _state.healthy = true;
      51           0 :     _state.last_time_micros = AP_HAL::micros();
      52             : }
      53             : 
      54             : #endif // AP_BATTERY_EFI_ENABLED

Generated by: LCOV version 1.14