From a1a1c3aef9959001f679f8e29e4127c3f93e6e64 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 13 Sep 2023 16:29:54 +0200 Subject: [PATCH] biggest changes possible --- mission/controller/PowerController.cpp | 12 +++++++++--- mission/controller/PowerController.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 58177313..d10f233c 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -1,4 +1,3 @@ - #include PowerController::PowerController(object_id_t objectId, bool enableHkSets) @@ -89,6 +88,9 @@ void PowerController::performControlOperation() { // if (mode != MODE_OFF) { sif::debug << "oh shit, now i gotta do something" << std::endl; calculateStateOfCharge(); + if (mode == MODE_NORMAL) { + watchStateOfCharge(); + } // do something //} break; @@ -204,9 +206,13 @@ void PowerController::calculateStateOfCharge() { } } +void PowerController::watchStateOfCharge() { + // ToDo: FDIR +} + ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { float vBatCorrected = p60CoreHk.batteryVoltage.value - iBat * batteryInternalResistance; - uint8_t lookUpTableIdx = 99; + uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx); if (result != returnvalue::OK) { return result; @@ -289,7 +295,7 @@ ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &i } ReturnValue_t PowerController::calculateCoulombCounterChargeUpperThreshold() { - uint8_t lookUpTableIdx = 99; + uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; ReturnValue_t result = lookUpTableOcvIdxFinder(coulombCounterVoltageUpperThreshold, lookUpTableIdx); if (result != returnvalue::OK) { diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index e7f9383c..700860bc 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -43,6 +43,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM void performControlOperation() override; void calculateStateOfCharge(); + void watchStateOfCharge(); ReturnValue_t calculateOpenCircuitVoltageCharge(); ReturnValue_t calculateCoulombCounterCharge(); ReturnValue_t updateEpsData(); @@ -58,6 +59,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM double maxAllowedTimeDiff = 0.5; // [s] // OCV Look-up-Table + static constexpr uint8_t LOOK_UP_TABLE_MAX_IDX = 99; float lookUpTableOcv[2][100] = { {0.00000000e+00, 3.16227766e-04, 4.52809661e-04, 6.48382625e-04, 9.28425483e-04, 1.32942162e-03, 1.90361194e-03, 2.72580074e-03, 3.90310099e-03, 5.58888885e-03,