2020-10-22 14:02:15 -03:00
|
|
|
#pragma once
|
|
|
|
|
2023-03-08 06:33:59 -04:00
|
|
|
#include "AP_Generator_config.h"
|
2020-10-22 14:02:15 -03:00
|
|
|
|
2021-09-24 00:10:47 -03:00
|
|
|
#if HAL_GENERATOR_ENABLED
|
2020-10-22 14:02:15 -03:00
|
|
|
|
|
|
|
#include <AP_Param/AP_Param.h>
|
|
|
|
#include <AP_BattMonitor/AP_BattMonitor.h>
|
|
|
|
|
|
|
|
class AP_Generator_Backend;
|
|
|
|
class AP_Generator_IE_650_800;
|
|
|
|
class AP_Generator_IE_2400;
|
|
|
|
class AP_Generator_RichenPower;
|
|
|
|
|
|
|
|
class AP_Generator
|
|
|
|
{
|
|
|
|
friend class AP_Generator_Backend;
|
|
|
|
friend class AP_Generator_IE_650_800;
|
|
|
|
friend class AP_Generator_IE_2400;
|
|
|
|
friend class AP_Generator_RichenPower;
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Constructor
|
|
|
|
AP_Generator();
|
|
|
|
|
|
|
|
// Do not allow copies
|
2022-09-30 06:50:43 -03:00
|
|
|
CLASS_NO_COPY(AP_Generator);
|
2020-10-22 14:02:15 -03:00
|
|
|
|
|
|
|
static AP_Generator* get_singleton();
|
|
|
|
|
|
|
|
void init(void);
|
|
|
|
void update(void);
|
|
|
|
|
|
|
|
bool pre_arm_check(char *failmsg, uint8_t failmsg_len) const;
|
|
|
|
|
2020-11-24 06:58:38 -04:00
|
|
|
AP_BattMonitor::Failsafe update_failsafes(void);
|
2020-10-22 14:02:15 -03:00
|
|
|
|
|
|
|
// Helpers to retrieve measurements
|
|
|
|
float get_voltage(void) const { return _voltage; }
|
|
|
|
float get_current(void) const { return _current; }
|
2023-03-10 03:04:05 -04:00
|
|
|
// get_fuel_remaining returns fuel remaining as a scale 0-1
|
|
|
|
float get_fuel_remaining(void) const { return _fuel_remaining; }
|
2020-10-22 14:02:15 -03:00
|
|
|
float get_batt_consumed(void) const { return _consumed_mah; }
|
|
|
|
uint16_t get_rpm(void) const { return _rpm; }
|
|
|
|
|
|
|
|
// Helpers to see if backend has a measurement
|
|
|
|
bool has_current() const { return _has_current; }
|
|
|
|
bool has_consumed_energy() const { return _has_consumed_energy; }
|
2023-03-10 03:04:05 -04:00
|
|
|
bool has_fuel_remaining() const { return _has_fuel_remaining; }
|
2020-10-22 14:02:15 -03:00
|
|
|
|
|
|
|
// healthy() returns true if the generator is not present, or it is
|
|
|
|
// present, providing telemetry and not indicating any errors.
|
|
|
|
bool healthy(void) const { return _healthy; }
|
|
|
|
|
|
|
|
// Generator controls must return true if present in generator type
|
|
|
|
bool stop(void);
|
|
|
|
bool idle(void);
|
|
|
|
bool run(void);
|
|
|
|
|
2022-02-25 01:06:28 -04:00
|
|
|
void send_generator_status(const class GCS_MAVLINK &channel);
|
2020-10-22 14:02:15 -03:00
|
|
|
|
|
|
|
// Parameter block
|
|
|
|
static const struct AP_Param::GroupInfo var_info[];
|
|
|
|
|
2022-05-24 08:05:52 -03:00
|
|
|
// bits which can be set in _options to modify generator behaviour:
|
|
|
|
enum class Option {
|
|
|
|
INHIBIT_MAINTENANCE_WARNINGS = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool option_set(Option opt) const {
|
|
|
|
return (_options & 1U<<uint32_t(opt)) != 0;
|
|
|
|
}
|
|
|
|
|
2020-10-22 14:02:15 -03:00
|
|
|
private:
|
|
|
|
|
|
|
|
// Pointer to chosen driver
|
|
|
|
AP_Generator_Backend* _driver_ptr;
|
|
|
|
|
|
|
|
// Parameters
|
|
|
|
AP_Int8 _type; // Select which generator to use
|
2022-05-24 08:05:52 -03:00
|
|
|
AP_Int32 _options; // Select which generator to use
|
2020-10-22 14:02:15 -03:00
|
|
|
|
|
|
|
enum class Type {
|
|
|
|
GEN_DISABLED = 0,
|
2023-08-14 01:13:11 -03:00
|
|
|
#if AP_GENERATOR_IE_650_800_ENABLED
|
2020-10-22 14:02:15 -03:00
|
|
|
IE_650_800 = 1,
|
2023-02-27 01:06:56 -04:00
|
|
|
#endif
|
2023-08-14 01:13:11 -03:00
|
|
|
#if AP_GENERATOR_IE_2400_ENABLED
|
2020-10-22 14:02:15 -03:00
|
|
|
IE_2400 = 2,
|
2023-02-27 01:06:56 -04:00
|
|
|
#endif
|
|
|
|
#if AP_GENERATOR_RICHENPOWER_ENABLED
|
2020-10-22 14:02:15 -03:00
|
|
|
RICHENPOWER = 3,
|
2023-02-27 01:06:56 -04:00
|
|
|
#endif
|
2022-01-17 01:58:52 -04:00
|
|
|
// LOWEHEISER = 4,
|
2020-10-22 14:02:15 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
// Helper to get param and cast to GenType
|
|
|
|
Type type(void) const;
|
|
|
|
|
|
|
|
// Front end variables
|
|
|
|
float _voltage;
|
|
|
|
float _current;
|
2023-03-10 03:04:05 -04:00
|
|
|
float _fuel_remaining; // 0-1
|
|
|
|
bool _has_fuel_remaining;
|
2020-10-22 14:02:15 -03:00
|
|
|
float _consumed_mah;
|
|
|
|
uint16_t _rpm;
|
|
|
|
bool _healthy;
|
|
|
|
bool _has_current;
|
|
|
|
bool _has_consumed_energy;
|
|
|
|
|
|
|
|
static AP_Generator *_singleton;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace AP {
|
|
|
|
AP_Generator *generator();
|
|
|
|
};
|
|
|
|
#endif
|