From 4791e6f367cbd6bf9e009a6b55c5c4158d22a89a Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Thu, 21 Sep 2023 12:11:24 +1000 Subject: [PATCH] AP_Generator: use HAL_LOGGING_ENABLED --- libraries/AP_Generator/AP_Generator_IE_2400.cpp | 3 +++ libraries/AP_Generator/AP_Generator_IE_2400.h | 2 ++ libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp | 2 ++ libraries/AP_Generator/AP_Generator_IE_FuelCell.h | 4 ++++ libraries/AP_Generator/AP_Generator_RichenPower.cpp | 4 ++++ libraries/AP_Generator/AP_Generator_RichenPower.h | 3 +++ 6 files changed, 18 insertions(+) diff --git a/libraries/AP_Generator/AP_Generator_IE_2400.cpp b/libraries/AP_Generator/AP_Generator_IE_2400.cpp index 70dc5563f0..d297261d5f 100644 --- a/libraries/AP_Generator/AP_Generator_IE_2400.cpp +++ b/libraries/AP_Generator/AP_Generator_IE_2400.cpp @@ -182,6 +182,7 @@ bool AP_Generator_IE_2400::check_for_err_code(char* msg_txt, uint8_t msg_len) co return true; } +#if HAL_LOGGING_ENABLED // log generator status to the onboard log void AP_Generator_IE_2400::log_write() { @@ -203,4 +204,6 @@ void AP_Generator_IE_2400::log_write() _err_code ); } +#endif // HAL_LOGGING_ENABLED + #endif // AP_GENERATOR_IE_2400_ENABLED diff --git a/libraries/AP_Generator/AP_Generator_IE_2400.h b/libraries/AP_Generator/AP_Generator_IE_2400.h index b660bc105e..65acfa8ef9 100644 --- a/libraries/AP_Generator/AP_Generator_IE_2400.h +++ b/libraries/AP_Generator/AP_Generator_IE_2400.h @@ -32,7 +32,9 @@ private: // Check for error codes that are deemed severe and would be cause to trigger a battery monitor low failsafe action bool is_low_error(const uint32_t err_in) const; +#if HAL_LOGGING_ENABLED void log_write(void) override; +#endif // IE 2.4kW failsafes enum class ErrorCode { diff --git a/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp b/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp index ce2a9049e6..b66d59b8dd 100644 --- a/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp +++ b/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp @@ -67,7 +67,9 @@ void AP_Generator_IE_FuelCell::update() update_frontend(); +#if HAL_LOGGING_ENABLED log_write(); +#endif } // Add a single character to the buffer and attempt to decode diff --git a/libraries/AP_Generator/AP_Generator_IE_FuelCell.h b/libraries/AP_Generator/AP_Generator_IE_FuelCell.h index 682d71f350..13a852d9a3 100644 --- a/libraries/AP_Generator/AP_Generator_IE_FuelCell.h +++ b/libraries/AP_Generator/AP_Generator_IE_FuelCell.h @@ -4,6 +4,8 @@ #if AP_GENERATOR_IE_ENABLED +#include + class AP_Generator_IE_FuelCell : public AP_Generator_Backend { @@ -81,7 +83,9 @@ protected: // Assigns the unit specific measurements once a valid sentence is obtained virtual void assign_measurements(const uint32_t now) = 0; +#if HAL_LOGGING_ENABLED virtual void log_write(void) {} +#endif // Add a single character to the buffer and attempt to decode. // Returns true if a complete sentence was successfully decoded or if the buffer is full. diff --git a/libraries/AP_Generator/AP_Generator_RichenPower.cpp b/libraries/AP_Generator/AP_Generator_RichenPower.cpp index 129cbc2e5b..c021cbd43e 100644 --- a/libraries/AP_Generator/AP_Generator_RichenPower.cpp +++ b/libraries/AP_Generator/AP_Generator_RichenPower.cpp @@ -235,7 +235,9 @@ void AP_Generator_RichenPower::update(void) update_frontend_readings(); +#if HAL_LOGGING_ENABLED Log_Write(); +#endif } // update_runstate updates the servo output we use to control the @@ -308,6 +310,7 @@ void AP_Generator_RichenPower::update_runstate() } } +#if HAL_LOGGING_ENABLED // log generator status to the onboard log void AP_Generator_RichenPower::Log_Write() { @@ -336,6 +339,7 @@ void AP_Generator_RichenPower::Log_Write() last_reading.mode ); } +#endif // generator prearm checks; notably, if we never see a generator we do // not run the checks. Generators are attached/detached at will, and diff --git a/libraries/AP_Generator/AP_Generator_RichenPower.h b/libraries/AP_Generator/AP_Generator_RichenPower.h index 790f2f7ff3..c5999c0ed6 100644 --- a/libraries/AP_Generator/AP_Generator_RichenPower.h +++ b/libraries/AP_Generator/AP_Generator_RichenPower.h @@ -5,6 +5,7 @@ #if AP_GENERATOR_RICHENPOWER_ENABLED +#include #include #include #include @@ -93,9 +94,11 @@ private: Mode mode; }; +#if HAL_LOGGING_ENABLED // method and state to write and entry to the onboard log: void Log_Write(); uint32_t last_logged_reading_ms; +#endif struct Reading last_reading; uint32_t last_reading_ms;