From b21fdb77434736a2a0f860b777f94ec819fc03a6 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 24 Nov 2020 21:58:38 +1100 Subject: [PATCH] AP_Generator: use enum class For Battery Failsafe --- libraries/AP_Generator/AP_Generator.cpp | 4 ++-- libraries/AP_Generator/AP_Generator.h | 2 +- libraries/AP_Generator/AP_Generator_Backend.h | 4 ++-- libraries/AP_Generator/AP_Generator_IE_2400.cpp | 8 ++++---- libraries/AP_Generator/AP_Generator_IE_2400.h | 2 +- libraries/AP_Generator/AP_Generator_IE_650_800.cpp | 8 ++++---- libraries/AP_Generator/AP_Generator_IE_650_800.h | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libraries/AP_Generator/AP_Generator.cpp b/libraries/AP_Generator/AP_Generator.cpp index 0dff0ef098..c8ffc8a274 100644 --- a/libraries/AP_Generator/AP_Generator.cpp +++ b/libraries/AP_Generator/AP_Generator.cpp @@ -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(); } diff --git a/libraries/AP_Generator/AP_Generator.h b/libraries/AP_Generator/AP_Generator.h index e662ffa251..1c37aee4dc 100644 --- a/libraries/AP_Generator/AP_Generator.h +++ b/libraries/AP_Generator/AP_Generator.h @@ -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; } diff --git a/libraries/AP_Generator/AP_Generator_Backend.h b/libraries/AP_Generator/AP_Generator_Backend.h index dac3e27592..28ea54ee43 100644 --- a/libraries/AP_Generator/AP_Generator_Backend.h +++ b/libraries/AP_Generator/AP_Generator_Backend.h @@ -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; diff --git a/libraries/AP_Generator/AP_Generator_IE_2400.cpp b/libraries/AP_Generator/AP_Generator_IE_2400.cpp index 77b5a92417..f654ce9783 100644 --- a/libraries/AP_Generator/AP_Generator_IE_2400.cpp +++ b/libraries/AP_Generator/AP_Generator_IE_2400.cpp @@ -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 diff --git a/libraries/AP_Generator/AP_Generator_IE_2400.h b/libraries/AP_Generator/AP_Generator_IE_2400.h index 8f15a5d093..8ae995e31a 100644 --- a/libraries/AP_Generator/AP_Generator_IE_2400.h +++ b/libraries/AP_Generator/AP_Generator_IE_2400.h @@ -13,7 +13,7 @@ public: void init(void) override; - AP_BattMonitor::BatteryFailsafe update_failsafes() const override; + AP_BattMonitor::Failsafe update_failsafes() const override; private: diff --git a/libraries/AP_Generator/AP_Generator_IE_650_800.cpp b/libraries/AP_Generator/AP_Generator_IE_650_800.cpp index a5b30f8a2c..86b1bbd38b 100644 --- a/libraries/AP_Generator/AP_Generator_IE_650_800.cpp +++ b/libraries/AP_Generator/AP_Generator_IE_650_800.cpp @@ -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 diff --git a/libraries/AP_Generator/AP_Generator_IE_650_800.h b/libraries/AP_Generator/AP_Generator_IE_650_800.h index aed690cc49..c90421e9f8 100644 --- a/libraries/AP_Generator/AP_Generator_IE_650_800.h +++ b/libraries/AP_Generator/AP_Generator_IE_650_800.h @@ -13,7 +13,7 @@ public: void init(void) override; - AP_BattMonitor::BatteryFailsafe update_failsafes() const override; + AP_BattMonitor::Failsafe update_failsafes() const override; private: