#pragma once #include "AP_Generator_config.h" #if HAL_GENERATOR_ENABLED #include #include 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 CLASS_NO_COPY(AP_Generator); static AP_Generator* get_singleton(); void init(void); void update(void); bool pre_arm_check(char *failmsg, uint8_t failmsg_len) const; AP_BattMonitor::Failsafe update_failsafes(void); // Helpers to retrieve measurements float get_voltage(void) const { return _voltage; } float get_current(void) const { return _current; } // get_fuel_remaining returns fuel remaining as a scale 0-1 float get_fuel_remaining(void) const { return _fuel_remaining; } 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; } bool has_fuel_remaining() const { return _has_fuel_remaining; } // 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); void send_generator_status(const class GCS_MAVLINK &channel); // Parameter block static const struct AP_Param::GroupInfo var_info[]; // 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<