spam protection
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
Marius Eggert 2023-09-29 15:56:07 +02:00
parent 59bc783045
commit 0e48721655
2 changed files with 11 additions and 2 deletions

View File

@ -281,6 +281,7 @@ ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() {
ReturnValue_t PowerController::calculateCoulombCounterCharge() {
double timeDiff = timevalOperations::toDouble(now - oldTime);
if (timeDiff > maxAllowedTimeDiff) {
// should not be a permanent state so no spam protection required
triggerEvent(power::TIMEDELTA_OUT_OF_BOUNDS, static_cast<uint32_t>(timeDiff * 10));
sif::error << "Power Controller::Time delta too large for Coulomb Counter: " << timeDiff
<< std::endl;
@ -329,14 +330,21 @@ 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, static_cast<uint32_t>(voltage * 10));
if (not voltageOutOfBoundsFlag) {
triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0, static_cast<uint32_t>(voltage * 10));
voltageOutOfBoundsFlag = true;
}
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, static_cast<uint32_t>(voltage * 10));
if (not voltageOutOfBoundsFlag) {
triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1, static_cast<uint32_t>(voltage * 10));
voltageOutOfBoundsFlag = true;
}
sif::error << "Power Controller::Voltage is too low: " << voltage << std::endl;
return returnvalue::FAILED;
}
voltageOutOfBoundsFlag = false;
while (lookUpTableOcv[1][idx] > voltage) {
idx--;
}

View File

@ -116,6 +116,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM
bool pwrLvlLowFlag = false;
bool pwrLvlCriticalFlag = false;
bool voltageOutOfBoundsFlag = false;
// HK Datasets for Calculation
BpxBatteryHk bpxBatteryHk = BpxBatteryHk(objects::BPX_BATT_HANDLER);