AP_Generator: use enum class For Battery Failsafe

This commit is contained in:
Peter Barker 2020-11-24 21:58:38 +11:00 committed by Peter Barker
parent 00a8a8fe8e
commit b21fdb7743
7 changed files with 15 additions and 15 deletions

View File

@ -120,11 +120,11 @@ bool AP_Generator::pre_arm_check(char* failmsg, uint8_t failmsg_len) const
}
// Tell backend check failsafes
AP_BattMonitor::BatteryFailsafe AP_Generator::update_failsafes()
AP_BattMonitor::Failsafe AP_Generator::update_failsafes()
{
// Don't invoke a failsafe if driver not assigned
if (_driver_ptr == nullptr) {
return AP_BattMonitor::BatteryFailsafe_None;
return AP_BattMonitor::Failsafe::None;
}
return _driver_ptr->update_failsafes();
}

View File

@ -39,7 +39,7 @@ public:
bool pre_arm_check(char *failmsg, uint8_t failmsg_len) const;
AP_BattMonitor::BatteryFailsafe update_failsafes(void);
AP_BattMonitor::Failsafe update_failsafes(void);
// Helpers to retrieve measurements
float get_voltage(void) const { return _voltage; }

View File

@ -21,8 +21,8 @@ public:
virtual bool pre_arm_check(char *failmsg, uint8_t failmsg_len) const { return true; }
// Set default to not fail failsafes
virtual AP_BattMonitor::BatteryFailsafe update_failsafes(void) const {
return AP_BattMonitor::BatteryFailsafe::BatteryFailsafe_None;
virtual AP_BattMonitor::Failsafe update_failsafes(void) const {
return AP_BattMonitor::Failsafe::None;
}
virtual bool healthy(void) const = 0;

View File

@ -120,19 +120,19 @@ void AP_Generator_IE_2400::decode_latest_term()
}
// Check for failsafes
AP_BattMonitor::BatteryFailsafe AP_Generator_IE_2400::update_failsafes() const
AP_BattMonitor::Failsafe AP_Generator_IE_2400::update_failsafes() const
{
// Check for error codes that lead to critical action battery monitor failsafe
if (is_critical_error(_err_code)) {
return AP_BattMonitor::BatteryFailsafe::BatteryFailsafe_Critical;
return AP_BattMonitor::Failsafe::Critical;
}
// Check for error codes that lead to low action battery monitor failsafe
if (is_low_error(_err_code)) {
return AP_BattMonitor::BatteryFailsafe::BatteryFailsafe_Low;
return AP_BattMonitor::Failsafe::Low;
}
return AP_BattMonitor::BatteryFailsafe::BatteryFailsafe_None;
return AP_BattMonitor::Failsafe::None;
}
// Check for error codes that are deemed critical

View File

@ -13,7 +13,7 @@ public:
void init(void) override;
AP_BattMonitor::BatteryFailsafe update_failsafes() const override;
AP_BattMonitor::Failsafe update_failsafes() const override;
private:

View File

@ -107,19 +107,19 @@ bool AP_Generator_IE_650_800::check_for_err_code(char* msg_txt, uint8_t msg_len)
}
// Check for failsafes
AP_BattMonitor::BatteryFailsafe AP_Generator_IE_650_800::update_failsafes() const
AP_BattMonitor::Failsafe AP_Generator_IE_650_800::update_failsafes() const
{
// Check if we are in a critical failsafe
if ((_err_code & fs_crit_mask) != 0) {
return AP_BattMonitor::BatteryFailsafe::BatteryFailsafe_Critical;
return AP_BattMonitor::Failsafe::Critical;
}
// Check if we are in a low failsafe
if ((_err_code & fs_low_mask) != 0) {
return AP_BattMonitor::BatteryFailsafe::BatteryFailsafe_Low;
return AP_BattMonitor::Failsafe::Low;
}
return AP_BattMonitor::BatteryFailsafe::BatteryFailsafe_None;
return AP_BattMonitor::Failsafe::None;
}
#endif

View File

@ -13,7 +13,7 @@ public:
void init(void) override;
AP_BattMonitor::BatteryFailsafe update_failsafes() const override;
AP_BattMonitor::Failsafe update_failsafes() const override;
private: