that should do the job
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
This commit is contained in:
parent
b23ae2e152
commit
d2c0c1709e
@ -66,7 +66,11 @@ void PayloadPcduHandler::doShutDown() {
|
||||
}
|
||||
state = States::PL_PCDU_OFF;
|
||||
quickTransitionAlreadyCalled = false;
|
||||
{
|
||||
PoolReadGuard pg(&adcSet);
|
||||
adcSet.setReportingEnabled(false);
|
||||
adcSet.setValidity(false, true);
|
||||
}
|
||||
// No need to set mode _MODE_POWER_DOWN, power switching was already handled
|
||||
setMode(MODE_OFF);
|
||||
}
|
||||
@ -86,6 +90,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_
|
||||
using namespace plpcdu;
|
||||
bool doFinish = true;
|
||||
if (toNormalOneShot) {
|
||||
PoolReadGuard pg(&adcSet);
|
||||
adcSet.setReportingEnabled(true);
|
||||
toNormalOneShot = false;
|
||||
}
|
||||
@ -114,23 +119,23 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_
|
||||
state = States::ON_TRANS_ADC_CLOSE_ZERO;
|
||||
adcCountdown.setTimeout(50);
|
||||
adcCountdown.resetTimer();
|
||||
adcState = AdcStates::BOOT_DELAY;
|
||||
adcState = AdcState::BOOT_DELAY;
|
||||
doFinish = false;
|
||||
// If the values are not close to zero, we should not allow transition
|
||||
monMode = MonitoringMode::CLOSE_TO_ZERO;
|
||||
}
|
||||
}
|
||||
if (state == States::ON_TRANS_ADC_CLOSE_ZERO) {
|
||||
if (adcState == AdcStates::BOOT_DELAY) {
|
||||
if (adcState == AdcState::BOOT_DELAY) {
|
||||
doFinish = false;
|
||||
if (adcCountdown.hasTimedOut()) {
|
||||
adcState = AdcStates::SEND_SETUP;
|
||||
adcState = AdcState::SEND_SETUP;
|
||||
adcCmdExecuted = false;
|
||||
}
|
||||
}
|
||||
if (adcState == AdcStates::SEND_SETUP) {
|
||||
if (adcState == AdcState::SEND_SETUP) {
|
||||
if (adcCmdExecuted) {
|
||||
adcState = AdcStates::NORMAL;
|
||||
adcState = AdcState::NORMAL;
|
||||
doFinish = true;
|
||||
adcCountdown.setTimeout(100);
|
||||
adcCountdown.resetTimer();
|
||||
@ -175,11 +180,11 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_
|
||||
|
||||
ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
switch (adcState) {
|
||||
case (AdcStates::SEND_SETUP): {
|
||||
case (AdcState::SEND_SETUP): {
|
||||
*id = plpcdu::SETUP_CMD;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
case (AdcStates::NORMAL): {
|
||||
case (AdcState::NORMAL): {
|
||||
*id = plpcdu::READ_WITH_TEMP_EXT;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
@ -191,7 +196,7 @@ ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id
|
||||
}
|
||||
|
||||
ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||
if (adcState == AdcStates::SEND_SETUP) {
|
||||
if (adcState == AdcState::SEND_SETUP) {
|
||||
*id = plpcdu::SETUP_CMD;
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
@ -212,9 +217,9 @@ void PayloadPcduHandler::updateSwitchGpio(gpioId_t id, gpio::Levels level) {
|
||||
}
|
||||
|
||||
void PayloadPcduHandler::fillCommandAndReplyMap() {
|
||||
insertInCommandAndReplyMap(plpcdu::READ_CMD, 2, &adcSet);
|
||||
insertInCommandAndReplyMap(plpcdu::READ_TEMP_EXT, 1, &adcSet);
|
||||
insertInCommandAndReplyMap(plpcdu::READ_WITH_TEMP_EXT, 1, &adcSet);
|
||||
insertInCommandAndReplyMap(plpcdu::READ_CMD, 2);
|
||||
insertInCommandAndReplyMap(plpcdu::READ_TEMP_EXT, 1);
|
||||
insertInCommandAndReplyMap(plpcdu::READ_WITH_TEMP_EXT, 1);
|
||||
insertInCommandAndReplyMap(plpcdu::SETUP_CMD, 1);
|
||||
}
|
||||
|
||||
@ -278,6 +283,7 @@ ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
break;
|
||||
}
|
||||
case (READ_CMD): {
|
||||
{
|
||||
PoolReadGuard pg(&adcSet);
|
||||
if (pg.getReadResult() != returnvalue::OK) {
|
||||
return pg.getReadResult();
|
||||
@ -285,10 +291,12 @@ ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
handleExtConvRead(packet);
|
||||
checkAdcValues();
|
||||
adcSet.setValidity(true, true);
|
||||
}
|
||||
handlePrintout();
|
||||
break;
|
||||
}
|
||||
case (READ_WITH_TEMP_EXT): {
|
||||
{
|
||||
PoolReadGuard pg(&adcSet);
|
||||
if (pg.getReadResult() != returnvalue::OK) {
|
||||
return pg.getReadResult();
|
||||
@ -299,6 +307,7 @@ ReturnValue_t PayloadPcduHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
max1227::getTemperature(packet[tempStartIdx] << 8 | packet[tempStartIdx + 1]);
|
||||
checkAdcValues();
|
||||
adcSet.setValidity(true, true);
|
||||
}
|
||||
handlePrintout();
|
||||
break;
|
||||
}
|
||||
@ -370,9 +379,11 @@ void PayloadPcduHandler::quickTransitionBackToOff(bool startTransitionToOff, boo
|
||||
States currentState = state;
|
||||
pullAllGpiosLow(200);
|
||||
state = States::STACK_5V_SWITCHING;
|
||||
adcState = AdcStates::OFF;
|
||||
adcState = AdcState::OFF;
|
||||
if (startTransitionToOff) {
|
||||
sif::debug << "transition back to off" << std::endl;
|
||||
startTransition(MODE_OFF, 0);
|
||||
sif::debug << "blubwapfwa" << std::endl;
|
||||
}
|
||||
if (notifyFdir) {
|
||||
triggerEvent(TRANSITION_BACK_TO_OFF, static_cast<uint32_t>(currentState));
|
||||
@ -400,18 +411,39 @@ void PayloadPcduHandler::checkAdcValues() {
|
||||
float lowerBound = 0.0;
|
||||
float upperBound = 0.0;
|
||||
bool adcTransition = false;
|
||||
adcTransition = state == States::ON_TRANS_DRO and adcCountdown.isBusy();
|
||||
// Now check against voltage and current limits, depending on state
|
||||
if (state >= States::ON_TRANS_DRO and not adcTransition) {
|
||||
adcTransition = adcState == AdcState::NORMAL and adcCountdown.isBusy();
|
||||
if (NO_ADC_CHECKS) {
|
||||
return;
|
||||
}
|
||||
// Now check against voltage and current limits.
|
||||
if (ssrToDroInjectionRequested) {
|
||||
handleFailureInjection("SSR to DRO", NEG_V_OUT_OF_BOUNDS);
|
||||
ssrToDroInjectionRequested = false;
|
||||
return;
|
||||
}
|
||||
if (droToX8InjectionRequested) {
|
||||
handleFailureInjection("X8 to TX", U_X8_OUT_OF_BOUNDS);
|
||||
droToX8InjectionRequested = false;
|
||||
return;
|
||||
}
|
||||
if (txToMpaInjectionRequested) {
|
||||
handleFailureInjection("TX to MPA", U_TX_OUT_OF_BOUNDS);
|
||||
txToMpaInjectionRequested = false;
|
||||
return;
|
||||
}
|
||||
if (mpaToHpaInjectionRequested) {
|
||||
handleFailureInjection("MPA to HPA", U_HPA_OUT_OF_BOUNDS);
|
||||
mpaToHpaInjectionRequested = false;
|
||||
return;
|
||||
}
|
||||
if (allOnInjectRequested) {
|
||||
handleFailureInjection("All On", U_HPA_OUT_OF_BOUNDS);
|
||||
allOnInjectRequested = false;
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[NEG_V_LOWER_BOUND], lowerBound);
|
||||
params.getValue(PARAM_KEY_MAP[NEG_V_UPPER_BOUND], upperBound);
|
||||
if (not checkVoltage(adcSet.processed[U_NEG_V_FB], lowerBound, upperBound,
|
||||
NEG_V_OUT_OF_BOUNDS)) {
|
||||
if (not checkVoltage(adcSet.processed[U_NEG_V_FB], lowerBound, upperBound, NEG_V_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[DRO_U_LOWER_BOUND], lowerBound);
|
||||
@ -428,50 +460,24 @@ void PayloadPcduHandler::checkAdcValues() {
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
adcTransition = state == States::ON_TRANS_X8 and adcCountdown.isBusy();
|
||||
if (state >= States::ON_TRANS_X8 and not adcTransition) {
|
||||
if (droToX8InjectionRequested) {
|
||||
handleFailureInjection("X8 to TX", U_X8_OUT_OF_BOUNDS);
|
||||
droToX8InjectionRequested = false;
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[X8_U_LOWER_BOUND], lowerBound);
|
||||
params.getValue(PARAM_KEY_MAP[X8_U_UPPER_BOUND], upperBound);
|
||||
if (not checkVoltage(adcSet.processed[U_X8_DIV_6], lowerBound, upperBound,
|
||||
U_X8_OUT_OF_BOUNDS)) {
|
||||
if (not checkVoltage(adcSet.processed[U_X8_DIV_6], lowerBound, upperBound, U_X8_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[X8_I_UPPER_BOUND], upperBound);
|
||||
if (not checkCurrent(adcSet.processed[I_X8], upperBound, I_X8_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
adcTransition = state == States::ON_TRANS_TX and adcCountdown.isBusy();
|
||||
if (state >= States::ON_TRANS_TX and not adcTransition) {
|
||||
if (txToMpaInjectionRequested) {
|
||||
handleFailureInjection("TX to MPA", U_TX_OUT_OF_BOUNDS);
|
||||
txToMpaInjectionRequested = false;
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[TX_U_LOWER_BOUND], lowerBound);
|
||||
params.getValue(PARAM_KEY_MAP[TX_U_UPPER_BOUND], upperBound);
|
||||
if (not checkVoltage(adcSet.processed[U_TX_DIV_6], lowerBound, upperBound,
|
||||
U_TX_OUT_OF_BOUNDS)) {
|
||||
if (not checkVoltage(adcSet.processed[U_TX_DIV_6], lowerBound, upperBound, U_TX_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[TX_I_UPPER_BOUND], upperBound);
|
||||
if (not checkCurrent(adcSet.processed[I_TX], upperBound, I_TX_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
adcTransition = state == States::ON_TRANS_MPA and adcCountdown.isBusy();
|
||||
if (state >= States::ON_TRANS_MPA and not adcTransition) {
|
||||
if (mpaToHpaInjectionRequested) {
|
||||
handleFailureInjection("MPA to HPA", U_HPA_OUT_OF_BOUNDS);
|
||||
mpaToHpaInjectionRequested = false;
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[MPA_U_LOWER_BOUND], lowerBound);
|
||||
params.getValue(PARAM_KEY_MAP[MPA_U_UPPER_BOUND], upperBound);
|
||||
if (not checkVoltage(adcSet.processed[U_MPA_DIV_6], lowerBound, upperBound,
|
||||
@ -482,14 +488,6 @@ void PayloadPcduHandler::checkAdcValues() {
|
||||
if (not checkCurrent(adcSet.processed[I_MPA], upperBound, I_MPA_OUT_OF_BOUNDS)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
adcTransition = state == States::ON_TRANS_HPA and adcCountdown.isBusy();
|
||||
if (state >= States::ON_TRANS_HPA and not adcTransition) {
|
||||
if (allOnInjectRequested) {
|
||||
handleFailureInjection("All On", U_HPA_OUT_OF_BOUNDS);
|
||||
allOnInjectRequested = false;
|
||||
return;
|
||||
}
|
||||
params.getValue(PARAM_KEY_MAP[HPA_U_LOWER_BOUND], lowerBound);
|
||||
params.getValue(PARAM_KEY_MAP[HPA_U_UPPER_BOUND], upperBound);
|
||||
if (not checkVoltage(adcSet.processed[U_HPA_DIV_6], lowerBound, upperBound,
|
||||
@ -502,7 +500,6 @@ void PayloadPcduHandler::checkAdcValues() {
|
||||
<< adcSet.processed[I_HPA] << " mA" << std::endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
transitionOk = true;
|
||||
}
|
||||
|
||||
@ -521,6 +518,8 @@ void PayloadPcduHandler::checkJsonFileInit() {
|
||||
|
||||
bool PayloadPcduHandler::checkVoltage(float val, float lowerBound, float upperBound, Event event) {
|
||||
bool tooLarge = false;
|
||||
sif::debug << "CHecking voltage. Value: " << val << ", lower bound: " << lowerBound
|
||||
<< ", upper bound: " << upperBound << std::endl;
|
||||
if (val < lowerBound or val > upperBound) {
|
||||
if (val > upperBound) {
|
||||
tooLarge = true;
|
||||
@ -698,6 +697,8 @@ ReturnValue_t PayloadPcduHandler::handleDoubleParamUpdate(std::string key,
|
||||
return params.writeJsonFile();
|
||||
}
|
||||
|
||||
LocalPoolDataSetBase* PayloadPcduHandler::getDataSetHandle(sid_t sid) { return &adcSet; }
|
||||
|
||||
#ifdef XIPHOS_Q7S
|
||||
ReturnValue_t PayloadPcduHandler::extConvAsTwoCallback(SpiComIF* comIf, SpiCookie* cookie,
|
||||
const uint8_t* sendData, size_t sendLen,
|
||||
|
@ -76,6 +76,8 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
||||
#endif
|
||||
|
||||
private:
|
||||
static constexpr bool NO_ADC_CHECKS = false;
|
||||
|
||||
enum class States : uint8_t {
|
||||
PL_PCDU_OFF,
|
||||
STACK_5V_SWITCHING,
|
||||
@ -84,20 +86,7 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
||||
// Solid State Relay, enable battery voltages VBAT0 and VBAT1. This will also switch on
|
||||
// the ADC
|
||||
ON_TRANS_SSR,
|
||||
ON_TRANS_ADC_CLOSE_ZERO,
|
||||
// Enable Dielectric Resonant Oscillator and start monitoring voltages as
|
||||
// soon as DRO voltage reaches 6V
|
||||
ON_TRANS_DRO,
|
||||
// Switch on X8 compoennt and monitor voltages for 5 seconds
|
||||
ON_TRANS_X8,
|
||||
// Switch on TX component and monitor voltages for 5 seconds
|
||||
ON_TRANS_TX,
|
||||
// Switch on MPA component and monitor voltages for 5 seconds
|
||||
ON_TRANS_MPA,
|
||||
// Switch on HPA component and monitor voltages for 5 seconds
|
||||
ON_TRANS_HPA,
|
||||
// All components of the experiment are on
|
||||
PL_PCDU_ON,
|
||||
ON_TRANS_ADC_CLOSE_ZERO
|
||||
} state = States::PL_PCDU_OFF;
|
||||
|
||||
duallane::Submodes pwrSubmode = duallane::Submodes::A_SIDE;
|
||||
@ -106,7 +95,7 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
||||
|
||||
enum class MonitoringMode { NONE, CLOSE_TO_ZERO, NEGATIVE } monMode = MonitoringMode::NONE;
|
||||
|
||||
enum class AdcStates { OFF, BOOT_DELAY, SEND_SETUP, NORMAL } adcState = AdcStates::OFF;
|
||||
enum class AdcState { OFF, BOOT_DELAY, SEND_SETUP, NORMAL } adcState = AdcState::OFF;
|
||||
|
||||
bool goToNormalMode = false;
|
||||
plpcdu::PlPcduAdcSet adcSet;
|
||||
@ -180,6 +169,7 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
||||
ReturnValue_t serializeFloat(uint32_t& param, float val);
|
||||
ReturnValue_t handleDoubleParamUpdate(std::string key, ParameterWrapper* parameterWrapper,
|
||||
const ParameterWrapper* newValues);
|
||||
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||
};
|
||||
|
||||
#endif /* LINUX_DEVICES_PLPCDUHANDLER_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user