SoC Calculator #754
@ -281,6 +281,7 @@ ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() {
|
|||||||
ReturnValue_t PowerController::calculateCoulombCounterCharge() {
|
ReturnValue_t PowerController::calculateCoulombCounterCharge() {
|
||||||
double timeDiff = timevalOperations::toDouble(now - oldTime);
|
double timeDiff = timevalOperations::toDouble(now - oldTime);
|
||||||
if (timeDiff > maxAllowedTimeDiff) {
|
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));
|
triggerEvent(power::TIMEDELTA_OUT_OF_BOUNDS, static_cast<uint32_t>(timeDiff * 10));
|
||||||
sif::error << "Power Controller::Time delta too large for Coulomb Counter: " << timeDiff
|
sif::error << "Power Controller::Time delta too large for Coulomb Counter: " << timeDiff
|
||||||
<< std::endl;
|
<< 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) {
|
ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &idx) {
|
||||||
if (voltage >= lookUpTableOcv[1][99]) {
|
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;
|
sif::error << "Power Controller::Voltage is too high: " << voltage << std::endl;
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
} else if (voltage <= lookUpTableOcv[1][0]) {
|
} 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;
|
sif::error << "Power Controller::Voltage is too low: " << voltage << std::endl;
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
voltageOutOfBoundsFlag = false;
|
||||||
while (lookUpTableOcv[1][idx] > voltage) {
|
while (lookUpTableOcv[1][idx] > voltage) {
|
||||||
idx--;
|
idx--;
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM
|
|||||||
|
|
||||||
bool pwrLvlLowFlag = false;
|
bool pwrLvlLowFlag = false;
|
||||||
bool pwrLvlCriticalFlag = false;
|
bool pwrLvlCriticalFlag = false;
|
||||||
|
bool voltageOutOfBoundsFlag = false;
|
||||||
|
|
||||||
// HK Datasets for Calculation
|
// HK Datasets for Calculation
|
||||||
BpxBatteryHk bpxBatteryHk = BpxBatteryHk(objects::BPX_BATT_HANDLER);
|
BpxBatteryHk bpxBatteryHk = BpxBatteryHk(objects::BPX_BATT_HANDLER);
|
||||||
|
Loading…
Reference in New Issue
Block a user