Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_BattMonitor/AP_BattMonitor_Generator.h
9642 views
1
#pragma once
2
3
#include <AP_Generator/AP_Generator.h>
4
5
#if HAL_GENERATOR_ENABLED
6
7
#include "AP_BattMonitor.h"
8
#include "AP_BattMonitor_Backend.h"
9
10
// Sub class for generator electrical
11
class AP_BattMonitor_Generator_Elec : public AP_BattMonitor_Backend
12
{
13
public:
14
15
// Inherit constructor
16
using AP_BattMonitor_Backend::AP_BattMonitor_Backend;
17
18
void init(void) override {};
19
20
// Read the battery voltage and current
21
void read(void) override;
22
23
bool has_current(void) const override;
24
25
bool has_consumed_energy(void) const override;
26
27
// Override backend update_failsafes
28
AP_BattMonitor::Failsafe update_failsafes() override;
29
};
30
31
// Sub class for generator fuel
32
class AP_BattMonitor_Generator_FuelLevel : public AP_BattMonitor_Backend
33
{
34
public:
35
36
// Inherit constructor
37
using AP_BattMonitor_Backend::AP_BattMonitor_Backend;
38
39
void init(void) override;
40
41
// Read the fuel level
42
void read(void) override;
43
44
// This is where we tell the battery monitor 'we have current' if we want to report a fuel level remaining
45
bool has_current(void) const override;
46
47
// This is where we tell the battery monitor 'we have consumed energy' if we want to report a fuel level remaining
48
bool has_consumed_energy(void) const override;
49
50
// reset remaining percentage to given value
51
bool reset_remaining(float percentage) override;
52
53
// capacity_remaining_ml - returns true if the capacity remaining in (mL) is valid and writes to capacity_ml
54
bool capacity_remaining_ml(float &capacity_ml) const;
55
56
// capacity_remaining_pct - returns true if the percentage is valid and writes to percentage argument
57
bool capacity_remaining_pct(uint8_t &percentage) const override;
58
59
// Override backend update_failsafes
60
AP_BattMonitor::Failsafe update_failsafes() override;
61
62
// by default we asume 100% full tank, we can use MAV_CMD_BATTERY_RESET mavlink command to specify otherwise
63
// this is only used in case the generator doesn't provide a fuel percentage on its own. This variable
64
// is needed to support tank refills or different than 100% initial fuel level
65
uint8_t _initial_fuel_pct = 100.0f;
66
};
67
#endif
68
69