SoC Calculator #754

Merged
muellerr merged 74 commits from soc-calculator into main 2023-10-11 10:50:48 +02:00
8 changed files with 22 additions and 33 deletions
Showing only changes of commit 2c30efa821 - Show all commits

View File

@ -49,12 +49,10 @@ ReturnValue_t PlPcduDummy::checkModeCommand(Mode_t commandedMode, Submode_t comm
if (commandedMode != MODE_OFF) { if (commandedMode != MODE_OFF) {
PoolReadGuard pg(&enablePl); PoolReadGuard pg(&enablePl);
if (pg.getReadResult() == returnvalue::OK) { if (pg.getReadResult() == returnvalue::OK) {
if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) {
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, return NON_OP_STATE_OF_CHARGE;
msToReachTheMode);
} }
} }
return NON_OP_STATE_OF_CHARGE;
} }
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode);
} }

View File

@ -28,12 +28,10 @@ ReturnValue_t PlocMpsocDummy::checkModeCommand(Mode_t commandedMode, Submode_t c
if (commandedMode != MODE_OFF) { if (commandedMode != MODE_OFF) {
PoolReadGuard pg(&enablePl); PoolReadGuard pg(&enablePl);
if (pg.getReadResult() == returnvalue::OK) { if (pg.getReadResult() == returnvalue::OK) {
if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) {
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, return NON_OP_STATE_OF_CHARGE;
msToReachTheMode);
} }
} }
return NON_OP_STATE_OF_CHARGE;
} }
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode);
} }

View File

@ -58,12 +58,10 @@ ReturnValue_t PlocSupervisorDummy::checkModeCommand(Mode_t commandedMode,
if (commandedMode != MODE_OFF) { if (commandedMode != MODE_OFF) {
PoolReadGuard pg(&enablePl); PoolReadGuard pg(&enablePl);
if (pg.getReadResult() == returnvalue::OK) { if (pg.getReadResult() == returnvalue::OK) {
if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) {
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, return NON_OP_STATE_OF_CHARGE;
msToReachTheMode);
} }
} }
return NON_OP_STATE_OF_CHARGE;
} }
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode);
} }

View File

@ -1511,12 +1511,10 @@ ReturnValue_t PlocMpsocHandler::checkModeCommand(Mode_t commandedMode, Submode_t
if (commandedMode != MODE_OFF) { if (commandedMode != MODE_OFF) {
PoolReadGuard pg(&enablePl); PoolReadGuard pg(&enablePl);
if (pg.getReadResult() == returnvalue::OK) { if (pg.getReadResult() == returnvalue::OK) {
if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) {
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, return NON_OP_STATE_OF_CHARGE;
msToReachTheMode);
} }
} }
return NON_OP_STATE_OF_CHARGE;
} }
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode);
} }

View File

@ -1999,12 +1999,10 @@ ReturnValue_t PlocSupervisorHandler::checkModeCommand(Mode_t commandedMode,
if (commandedMode != MODE_OFF) { if (commandedMode != MODE_OFF) {
PoolReadGuard pg(&enablePl); PoolReadGuard pg(&enablePl);
if (pg.getReadResult() == returnvalue::OK) { if (pg.getReadResult() == returnvalue::OK) {
if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) {
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, return NON_OP_STATE_OF_CHARGE;
msToReachTheMode);
} }
} }
return NON_OP_STATE_OF_CHARGE;
} }
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode);
} }

View File

@ -24,6 +24,8 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM
uint16_t startAtIndex) override; uint16_t startAtIndex) override;
private: private:
int test = 0;
bool enableHkSets = false; bool enableHkSets = false;
ParameterHelper parameterHelper; ParameterHelper parameterHelper;
@ -48,7 +50,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM
ReturnValue_t calculateCoulombCounterCharge(); ReturnValue_t calculateCoulombCounterCharge();
ReturnValue_t updateEpsData(); ReturnValue_t updateEpsData();
float charge2stateOfCharge(float capacity, bool coulombCounter); float charge2stateOfCharge(float capacity, bool coulombCounter);
ReturnValue_t lookUpTableOcvIdxFinder(float voltage, uint8_t& idx); ReturnValue_t lookUpTableOcvIdxFinder(float voltage, uint8_t& idx, bool paramCmd);
float linearInterpolation(float x, float x0, float x1, float y0, float y1); float linearInterpolation(float x, float x0, float x1, float y0, float y1);
ReturnValue_t calculateCoulombCounterChargeUpperThreshold(); ReturnValue_t calculateCoulombCounterChargeUpperThreshold();
@ -103,10 +105,11 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM
// Variables // Variables
timeval now; timeval now;
timeval oldTime; timeval oldTime;
int16_t iBat = 0; // [mA] int16_t iBat = 0; // [mA]
float openCircuitVoltageCharge = 0.0; // [Ah] float openCircuitVoltageCharge = 0.0; // [Ah]
float coulombCounterCharge = 0.0; // [Ah] float coulombCounterCharge = 0.0; // [Ah]
float coulombCounterChargeUpperThreshold = 0.0; // [Ah] float coulombCounterChargeUpperThreshold = 0.0; // [Ah]
float oldCoulombCounterVoltageUpperThreshold = 0.0; // [V]
static constexpr float CONVERT_FROM_MILLI = 1e-3; static constexpr float CONVERT_FROM_MILLI = 1e-3;
static constexpr float SECONDS_TO_HOURS = 1. / (60. * 60.); static constexpr float SECONDS_TO_HOURS = 1. / (60. * 60.);

View File

@ -569,12 +569,10 @@ ReturnValue_t PayloadPcduHandler::checkModeCommand(Mode_t commandedMode, Submode
if (commandedMode != MODE_OFF) { if (commandedMode != MODE_OFF) {
PoolReadGuard pg(&enablePl); PoolReadGuard pg(&enablePl);
if (pg.getReadResult() == returnvalue::OK) { if (pg.getReadResult() == returnvalue::OK) {
if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) {
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, return NON_OP_STATE_OF_CHARGE;
msToReachTheMode);
} }
} }
return NON_OP_STATE_OF_CHARGE;
} }
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode);
} }

View File

@ -14,12 +14,10 @@ ReturnValue_t CamSwitcher::checkModeCommand(Mode_t commandedMode, Submode_t comm
if (commandedMode != MODE_OFF) { if (commandedMode != MODE_OFF) {
PoolReadGuard pg(&enablePl); PoolReadGuard pg(&enablePl);
if (pg.getReadResult() == returnvalue::OK) { if (pg.getReadResult() == returnvalue::OK) {
if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) {
return PowerSwitcherComponent::checkModeCommand(commandedMode, commandedSubmode, return TRANS_NOT_ALLOWED;
msToReachTheMode);
} }
} }
return TRANS_NOT_ALLOWED;
} }
return PowerSwitcherComponent::checkModeCommand(commandedMode, commandedSubmode, return PowerSwitcherComponent::checkModeCommand(commandedMode, commandedSubmode,
msToReachTheMode); msToReachTheMode);