From 758add2928ccd43e996840202fa73a9837689309 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 09:50:48 +0200 Subject: [PATCH] improved events, allowed all modes, removed debug output --- mission/controller/PowerController.cpp | 17 ++++++++--------- mission/controller/PowerController.h | 2 +- mission/power/defs.h | 2 ++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 9347f681..054fcfd2 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -11,7 +11,6 @@ ReturnValue_t PowerController::initialize() { if (result != returnvalue::OK) { return result; } - sif::debug << "Rush B, no stop" << std::endl; return ExtendedControllerBase::initialize(); } @@ -92,7 +91,6 @@ void PowerController::performControlOperation() { } case InternalState::READY: { if (mode != MODE_OFF) { - sif::debug << "oh shit, now i gotta do something" << std::endl; calculateStateOfCharge(); if (mode == MODE_NORMAL) { watchStateOfCharge(); @@ -127,7 +125,7 @@ LocalPoolDataSetBase *PowerController::getDataSetHandle(sid_t sid) { ReturnValue_t PowerController::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { - if (mode == MODE_OFF) { + if (mode == MODE_OFF or mode == MODE_ON or mode == MODE_NORMAL) { if (submode == SUBMODE_NONE) { return returnvalue::OK; } else { @@ -251,8 +249,9 @@ ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { ReturnValue_t PowerController::calculateCoulombCounterCharge() { double timeDiff = timevalOperations::toDouble(now - oldTime); if (timeDiff > maxAllowedTimeDiff) { - triggerEvent(power::TIMEDELTA_OUT_OF_BOUNDS); - sif::error << "Power Controller::Time delta too large for Coulomb Counter" << std::endl; + triggerEvent(power::TIMEDELTA_OUT_OF_BOUNDS, static_cast(timeDiff * 10)); + sif::error << "Power Controller::Time delta too large for Coulomb Counter: " << timeDiff + << std::endl; return returnvalue::FAILED; } if (not pwrCtrlCoreHk.coulombCounterCharge.isValid()) { @@ -298,12 +297,12 @@ float PowerController::linearInterpolation(float x, float x0, float x1, float y0 ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &idx) { if (voltage >= lookUpTableOcv[1][99]) { - triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0); - sif::error << "Power Controller::Voltage is too high" << std::endl; + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0, static_cast(voltage * 10)); + sif::error << "Power Controller::Voltage is too high: " << voltage << std::endl; return returnvalue::FAILED; } else if (voltage <= lookUpTableOcv[1][0]) { - triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1); - sif::error << "Power Controller::Voltage is too low" << std::endl; + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1, static_cast(voltage * 10)); + sif::error << "Power Controller::Voltage is too low: " << voltage << std::endl; return returnvalue::FAILED; } while (lookUpTableOcv[1][idx] > voltage) { diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index 81522023..e374391e 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -55,7 +55,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM // Parameters float batteryInternalResistance = 70.0 / 2.0 / 1000.0; // [Ohm] float batteryMaximumCapacity = 2.6 * 2; // [Ah] - float coulombCounterVoltageUpperThreshold = 16.2e3; // [mV] + float coulombCounterVoltageUpperThreshold = 16.2; // [V] double maxAllowedTimeDiff = 0.5; // [s] float payloadLimit = 0.75; // [%] float higherModesLimit = 0.6; // [%] diff --git a/mission/power/defs.h b/mission/power/defs.h index 22a8af53..28e5eca8 100644 --- a/mission/power/defs.h +++ b/mission/power/defs.h @@ -52,8 +52,10 @@ static constexpr Event DATASET_READ_FAILED = event::makeEvent(SUBSYSTEM_ID, 4, s //! [EXPORT] : [COMMENT] The battery voltage read is out of the bounds in which it is supposed to //! be. //! P1: 1 too high, 0 too low +//! P2: voltage in V * 10 static constexpr Event VOLTAGE_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 5, severity::HIGH); //! [EXPORT] : [COMMENT] Time difference for Coulomb Counter was too large. +//! P1: time in s * 10 static constexpr Event TIMEDELTA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 6, severity::LOW); //! [EXPORT] : [COMMENT] The State of Charge is below the limit for payload use. Setting Payload to //! faulty.