simplified PL PCDU
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
parent
66029cb47a
commit
6fa975cc74
2
fsfw
2
fsfw
@ -1 +1 @@
|
||||
Subproject commit 6ea1eabb2dd3688f2c7db484cd141f15c9f4fe49
|
||||
Subproject commit 283a37dccc064b71a0e4ca5c483c9a5a5241d355
|
@ -35,6 +35,7 @@ void PayloadPcduHandler::doStartUp() {
|
||||
if (opCode == power::OpCodes::TO_NOT_OFF_DONE or opCode == power::OpCodes::TIMEOUT_OCCURED) {
|
||||
pwrStateMachine.reset();
|
||||
quickTransitionAlreadyCalled = false;
|
||||
state = States::POWER_CHANNELS_ON;
|
||||
setMode(_MODE_TO_ON);
|
||||
}
|
||||
}
|
||||
@ -55,13 +56,22 @@ void PayloadPcduHandler::doShutDown() {
|
||||
}
|
||||
}
|
||||
|
||||
void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||
void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||
if (mode == _MODE_TO_NORMAL) {
|
||||
stateMachineToNormal(modeFrom, subModeFrom);
|
||||
return;
|
||||
}
|
||||
DeviceHandlerBase::doTransition(modeFrom, subModeFrom);
|
||||
}
|
||||
|
||||
ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||
using namespace plpcdu;
|
||||
if (submode == plpcdu::NORMAL_ALL_ON or submode == plpcdu::NORMAL_ADC_ONLY) {
|
||||
if (submode == NormalSubmodes::SOLID_STATE_RELAYS_ADC_ON) {
|
||||
if (state == States::PL_PCDU_OFF) {
|
||||
sif::error << "PayloadPcduHandler::stateMachineToNormal: Unexpected state PL_PCDU_OFF"
|
||||
<< "detected" << std::endl;
|
||||
setMode(MODE_OFF);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if (state == States::POWER_CHANNELS_ON) {
|
||||
// Switch on relays here
|
||||
@ -93,42 +103,19 @@ void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subMode
|
||||
if (adcState == AdcStates::SEND_SETUP) {
|
||||
if (adcCmdExecuted) {
|
||||
adcState = AdcStates::NORMAL;
|
||||
if (submode == plpcdu::NORMAL_ADC_ONLY) {
|
||||
setMode(MODE_NORMAL, NORMAL_ADC_ONLY);
|
||||
}
|
||||
adcCountdown.setTimeout(100);
|
||||
adcCountdown.resetTimer();
|
||||
adcCmdExecuted = false;
|
||||
if (submode == plpcdu::NORMAL_ADC_ONLY) {
|
||||
setMode(MODE_NORMAL, submode);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (submode == plpcdu::NORMAL_ALL_ON) {
|
||||
if (state == States::ON_TRANS_ADC_CLOSE_ZERO) {
|
||||
if (not commandExecuted and adcState == AdcStates::NORMAL) {
|
||||
float waitTime = DFT_SSR_TO_DRO_WAIT_TIME;
|
||||
params.getValue(PARAM_KEY_MAP[SSR_TO_DRO_WAIT_TIME], waitTime);
|
||||
countdown.setTimeout(std::round(waitTime * 1000));
|
||||
countdown.resetTimer();
|
||||
commandExecuted = true;
|
||||
// TODO: For now, skip ADC check
|
||||
transitionOk = true;
|
||||
}
|
||||
// ADC values are ok, 5 seconds have elapsed
|
||||
if (transitionOk and countdown.hasTimedOut()) {
|
||||
state = States::ON_TRANS_DRO;
|
||||
// Now start monitoring for negative voltages instead
|
||||
monMode = MonitoringMode::NEGATIVE;
|
||||
commandExecuted = false;
|
||||
transitionOk = false;
|
||||
}
|
||||
}
|
||||
if (state == States::ON_TRANS_DRO) {
|
||||
if (not commandExecuted) {
|
||||
float waitTime = DFT_DRO_TO_X8_WAIT_TIME;
|
||||
params.getValue(PARAM_KEY_MAP[DRO_TO_X8_WAIT_TIME], waitTime);
|
||||
countdown.setTimeout(std::round(waitTime * 1000));
|
||||
countdown.resetTimer();
|
||||
|
||||
if (submode == NormalSubmodes::DRO_ON) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::info << "Enabling PL PCDU DRO module" << std::endl;
|
||||
#endif
|
||||
@ -136,110 +123,53 @@ void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subMode
|
||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO);
|
||||
adcCountdown.setTimeout(100);
|
||||
adcCountdown.resetTimer();
|
||||
commandExecuted = true;
|
||||
setMode(MODE_NORMAL, submode);
|
||||
}
|
||||
// ADC values are ok, 5 seconds have elapsed
|
||||
if (transitionOk and countdown.hasTimedOut()) {
|
||||
state = States::ON_TRANS_X8;
|
||||
commandExecuted = false;
|
||||
transitionOk = false;
|
||||
}
|
||||
}
|
||||
if (state == States::ON_TRANS_X8) {
|
||||
if (not commandExecuted) {
|
||||
float waitTime = DFT_X8_TO_TX_WAIT_TIME;
|
||||
params.getValue(PARAM_KEY_MAP[X8_TO_TX_WAIT_TIME], waitTime);
|
||||
countdown.setTimeout(std::round(waitTime * 1000));
|
||||
countdown.resetTimer();
|
||||
|
||||
if (submode == NormalSubmodes::X8_ON) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::info << "Enabling PL PCDU X8 module" << std::endl;
|
||||
#endif
|
||||
// Switch on X8
|
||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_X8);
|
||||
// Switch on DRO and start monitoring for negative voltages
|
||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO);
|
||||
adcCountdown.setTimeout(100);
|
||||
adcCountdown.resetTimer();
|
||||
commandExecuted = true;
|
||||
setMode(MODE_NORMAL, submode);
|
||||
}
|
||||
// ADC values are ok, 5 seconds have elapsed
|
||||
if (transitionOk and countdown.hasTimedOut()) {
|
||||
state = States::ON_TRANS_TX;
|
||||
commandExecuted = false;
|
||||
transitionOk = false;
|
||||
}
|
||||
}
|
||||
if (state == States::ON_TRANS_TX) {
|
||||
if (not commandExecuted) {
|
||||
float waitTime = DFT_TX_TO_MPA_WAIT_TIME;
|
||||
params.getValue(PARAM_KEY_MAP[TX_TO_MPA_WAIT_TIME], waitTime);
|
||||
countdown.setTimeout(std::round(waitTime * 1000));
|
||||
countdown.resetTimer();
|
||||
|
||||
if (submode == NormalSubmodes::TX_ON) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::info << "Enabling PL PCDU TX module" << std::endl;
|
||||
#endif
|
||||
// Switch on TX
|
||||
// Switch on DRO and start monitoring for negative voltages
|
||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_TX);
|
||||
// Wait for 100 ms before checking ADC values
|
||||
adcCountdown.setTimeout(100);
|
||||
adcCountdown.resetTimer();
|
||||
commandExecuted = true;
|
||||
setMode(MODE_NORMAL, submode);
|
||||
}
|
||||
// ADC values are ok, 5 seconds have elapsed
|
||||
if (transitionOk and countdown.hasTimedOut()) {
|
||||
state = States::ON_TRANS_MPA;
|
||||
commandExecuted = false;
|
||||
transitionOk = false;
|
||||
}
|
||||
}
|
||||
if (state == States::ON_TRANS_MPA) {
|
||||
if (not commandExecuted) {
|
||||
float waitTime = DFT_MPA_TO_HPA_WAIT_TIME;
|
||||
params.getValue(PARAM_KEY_MAP[MPA_TO_HPA_WAIT_TIME], waitTime);
|
||||
countdown.setTimeout(std::round(waitTime * 1000));
|
||||
countdown.resetTimer();
|
||||
|
||||
if (submode == NormalSubmodes::MPA_ON) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::info << "Enabling PL PCDU MPA module" << std::endl;
|
||||
#endif
|
||||
// Switch on MPA
|
||||
// Switch on DRO and start monitoring for negative voltages
|
||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_MPA);
|
||||
// Wait for 100 ms before checking ADC values
|
||||
adcCountdown.setTimeout(100);
|
||||
adcCountdown.resetTimer();
|
||||
commandExecuted = true;
|
||||
setMode(MODE_NORMAL, submode);
|
||||
}
|
||||
// ADC values are ok, 5 seconds have elapsed
|
||||
if (transitionOk and countdown.hasTimedOut()) {
|
||||
state = States::ON_TRANS_HPA;
|
||||
commandExecuted = false;
|
||||
transitionOk = false;
|
||||
}
|
||||
}
|
||||
if (state == States::ON_TRANS_HPA) {
|
||||
if (not commandExecuted) {
|
||||
// Switch on HPA
|
||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA);
|
||||
|
||||
if (submode == NormalSubmodes::HPA_ON) {
|
||||
#if OBSW_VERBOSE_LEVEL >= 1
|
||||
sif::info << "Enabling PL PCDU HPA module" << std::endl;
|
||||
#endif
|
||||
commandExecuted = true;
|
||||
// Switch on DRO and start monitoring for negative voltages
|
||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA);
|
||||
adcCountdown.setTimeout(100);
|
||||
adcCountdown.resetTimer();
|
||||
setMode(MODE_NORMAL, submode);
|
||||
}
|
||||
// ADC values are ok, 5 seconds have elapsed
|
||||
if (transitionOk and countdown.hasTimedOut()) {
|
||||
state = States::PL_PCDU_ON;
|
||||
setMode(MODE_NORMAL, plpcdu::NORMAL_ALL_ON);
|
||||
countdown.resetTimer();
|
||||
commandExecuted = false;
|
||||
transitionOk = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||
if (mode == _MODE_TO_NORMAL) {
|
||||
stateMachineToNormal(modeFrom, subModeFrom);
|
||||
return;
|
||||
}
|
||||
DeviceHandlerBase::doTransition(modeFrom, subModeFrom);
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
@ -613,7 +543,28 @@ bool PayloadPcduHandler::checkCurrent(float val, float upperBound, Event event)
|
||||
}
|
||||
|
||||
ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) {
|
||||
if (mode == MODE_NORMAL and submode <= 1) {
|
||||
using namespace plpcdu;
|
||||
if (mode == MODE_NORMAL) {
|
||||
if (submode == NormalSubmodes::SOLID_STATE_RELAYS_ADC_ON and
|
||||
this->submode != NormalSubmodes::ALL_OFF) {
|
||||
return TRANS_NOT_ALLOWED;
|
||||
}
|
||||
if ((submode == NormalSubmodes::DRO_ON and
|
||||
this->submode != NormalSubmodes::SOLID_STATE_RELAYS_ADC_ON)) {
|
||||
return TRANS_NOT_ALLOWED;
|
||||
}
|
||||
if ((submode == NormalSubmodes::X8_ON and this->submode != NormalSubmodes::DRO_ON)) {
|
||||
return TRANS_NOT_ALLOWED;
|
||||
}
|
||||
if ((submode == NormalSubmodes::TX_ON and this->submode != NormalSubmodes::X8_ON)) {
|
||||
return TRANS_NOT_ALLOWED;
|
||||
}
|
||||
if ((submode == NormalSubmodes::MPA_ON and this->submode != NormalSubmodes::MPA_ON)) {
|
||||
return TRANS_NOT_ALLOWED;
|
||||
}
|
||||
if ((submode == NormalSubmodes::HPA_ON and this->submode != NormalSubmodes::MPA_ON)) {
|
||||
return TRANS_NOT_ALLOWED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
return DeviceHandlerBase::isModeCombinationValid(mode, submode);
|
||||
|
@ -166,7 +166,7 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
||||
void checkAdcValues();
|
||||
void handleOutOfBoundsPrintout();
|
||||
void checkJsonFileInit();
|
||||
void stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom);
|
||||
ReturnValue_t stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom);
|
||||
bool checkVoltage(float val, float lowerBound, float upperBound, Event event);
|
||||
bool checkCurrent(float val, float upperBound, Event event);
|
||||
void handleFailureInjection(std::string output, Event event);
|
||||
|
@ -94,6 +94,16 @@ static constexpr DeviceCommandId_t READ_WITH_TEMP_EXT = 3;
|
||||
static constexpr Submode_t NORMAL_ADC_ONLY = 0;
|
||||
static constexpr Submode_t NORMAL_ALL_ON = 1;
|
||||
|
||||
enum NormalSubmodes {
|
||||
ALL_OFF = 0,
|
||||
SOLID_STATE_RELAYS_ADC_ON = 1,
|
||||
DRO_ON = 2,
|
||||
X8_ON = 3,
|
||||
TX_ON = 4,
|
||||
MPA_ON = 5,
|
||||
HPA_ON = 6
|
||||
};
|
||||
|
||||
// 12 ADC values * 2 + trailing zero
|
||||
static constexpr size_t ADC_REPLY_SIZE = 25;
|
||||
// Conversion byte + 24 * zero
|
||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
||||
Subproject commit bca8d5d05d25812b4e112ac0544b24915ec01971
|
||||
Subproject commit e37430423e814b9e05f25d63970f2c2b5048cfb1
|
Loading…
Reference in New Issue
Block a user