PL PCDU Update Mode Handling #200
@ -67,6 +67,7 @@ void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
|||||||
|
|
||||||
ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) {
|
ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||||
using namespace plpcdu;
|
using namespace plpcdu;
|
||||||
|
bool doFinish = true;
|
||||||
if (((submode >> SOLID_STATE_RELAYS_ADC_ON) & 0b1) == 1) {
|
if (((submode >> SOLID_STATE_RELAYS_ADC_ON) & 0b1) == 1) {
|
||||||
if (state == States::PL_PCDU_OFF) {
|
if (state == States::PL_PCDU_OFF) {
|
||||||
sif::error << "PayloadPcduHandler::stateMachineToNormal: Unexpected state PL_PCDU_OFF"
|
sif::error << "PayloadPcduHandler::stateMachineToNormal: Unexpected state PL_PCDU_OFF"
|
||||||
@ -83,22 +84,24 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_
|
|||||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT1);
|
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT1);
|
||||||
state = States::ON_TRANS_SSR;
|
state = States::ON_TRANS_SSR;
|
||||||
transitionOk = true;
|
transitionOk = true;
|
||||||
|
doFinish = false;
|
||||||
}
|
}
|
||||||
if (state == States::ON_TRANS_SSR) {
|
if (state == States::ON_TRANS_SSR) {
|
||||||
// If necessary, check whether a certain amount of time has elapsed
|
// If necessary, check whether a certain amount of time has elapsed
|
||||||
if (transitionOk) {
|
if (transitionOk) {
|
||||||
transitionOk = false;
|
transitionOk = false;
|
||||||
state = States::ON_TRANS_ADC_CLOSE_ZERO;
|
state = States::ON_TRANS_ADC_CLOSE_ZERO;
|
||||||
|
|
||||||
adcCountdown.setTimeout(50);
|
adcCountdown.setTimeout(50);
|
||||||
adcCountdown.resetTimer();
|
adcCountdown.resetTimer();
|
||||||
adcState = AdcStates::BOOT_DELAY;
|
adcState = AdcStates::BOOT_DELAY;
|
||||||
|
doFinish = false;
|
||||||
// If the values are not close to zero, we should not allow transition
|
// If the values are not close to zero, we should not allow transition
|
||||||
monMode = MonitoringMode::CLOSE_TO_ZERO;
|
monMode = MonitoringMode::CLOSE_TO_ZERO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state == States::ON_TRANS_ADC_CLOSE_ZERO) {
|
if (state == States::ON_TRANS_ADC_CLOSE_ZERO) {
|
||||||
if (adcState == AdcStates::BOOT_DELAY) {
|
if (adcState == AdcStates::BOOT_DELAY) {
|
||||||
|
doFinish = false;
|
||||||
if (adcCountdown.hasTimedOut()) {
|
if (adcCountdown.hasTimedOut()) {
|
||||||
adcState = AdcStates::SEND_SETUP;
|
adcState = AdcStates::SEND_SETUP;
|
||||||
adcCmdExecuted = false;
|
adcCmdExecuted = false;
|
||||||
@ -107,68 +110,38 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_
|
|||||||
if (adcState == AdcStates::SEND_SETUP) {
|
if (adcState == AdcStates::SEND_SETUP) {
|
||||||
if (adcCmdExecuted) {
|
if (adcCmdExecuted) {
|
||||||
adcState = AdcStates::NORMAL;
|
adcState = AdcStates::NORMAL;
|
||||||
|
doFinish = true;
|
||||||
adcCountdown.setTimeout(100);
|
adcCountdown.setTimeout(100);
|
||||||
adcCountdown.resetTimer();
|
adcCountdown.resetTimer();
|
||||||
adcCmdExecuted = false;
|
adcCmdExecuted = false;
|
||||||
setMode(MODE_NORMAL, submode);
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((submode >> DRO_ON) & 1) == 1) {
|
auto switchHandler = [&](NormalSubmodeBits bit, gpioId_t id, std::string info) {
|
||||||
|
if (((diffMask >> bit) & 1) == 1) {
|
||||||
|
if (((submode >> bit) & 1) == 1) {
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::info << "Enabling PL PCDU DRO module" << std::endl;
|
sif::info << "Enabling PL PCDU " << info << " module" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
// Switch on DRO and start monitoring for negative voltages
|
// Switch on DRO and start monitoring for negative voltages
|
||||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO);
|
updateSwitchGpio(id, gpio::Levels::HIGH);
|
||||||
adcCountdown.setTimeout(100);
|
} else {
|
||||||
adcCountdown.resetTimer();
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
setMode(MODE_NORMAL, submode);
|
sif::info << "Disabling PL PCDU " << info << " module" << std::endl;
|
||||||
}
|
#endif
|
||||||
|
updateSwitchGpio(id, gpio::Levels::LOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (((submode >> X8_ON) & 1) == 1) {
|
switchHandler(DRO_ON, gpioIds::PLPCDU_ENB_DRO, "DRO");
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
switchHandler(X8_ON, gpioIds::PLPCDU_ENB_X8, "X8");
|
||||||
sif::info << "Enabling PL PCDU X8 module" << std::endl;
|
switchHandler(TX_ON, gpioIds::PLPCDU_ENB_TX, "TX");
|
||||||
#endif
|
switchHandler(MPA_ON, gpioIds::PLPCDU_ENB_MPA, "MPA");
|
||||||
// Switch on DRO and start monitoring for negative voltages
|
switchHandler(HPA_ON, gpioIds::PLPCDU_ENB_HPA, "HPA");
|
||||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_X8);
|
if (doFinish) {
|
||||||
adcCountdown.setTimeout(100);
|
|
||||||
adcCountdown.resetTimer();
|
|
||||||
setMode(MODE_NORMAL, submode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((submode >> TX_ON) & 1) == 1) {
|
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
|
||||||
sif::info << "Enabling PL PCDU TX module" << std::endl;
|
|
||||||
#endif
|
|
||||||
// Switch on DRO and start monitoring for negative voltages
|
|
||||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_TX);
|
|
||||||
adcCountdown.setTimeout(100);
|
|
||||||
adcCountdown.resetTimer();
|
|
||||||
setMode(MODE_NORMAL, submode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((submode >> MPA_ON) & 1) == 1) {
|
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
|
||||||
sif::info << "Enabling PL PCDU MPA module" << std::endl;
|
|
||||||
#endif
|
|
||||||
// Switch on DRO and start monitoring for negative voltages
|
|
||||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_MPA);
|
|
||||||
adcCountdown.setTimeout(100);
|
|
||||||
adcCountdown.resetTimer();
|
|
||||||
setMode(MODE_NORMAL, submode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((submode >> HPA_ON) & 1) == 1) {
|
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
|
||||||
sif::info << "Enabling PL PCDU HPA module" << std::endl;
|
|
||||||
#endif
|
|
||||||
// Switch on DRO and start monitoring for negative voltages
|
|
||||||
gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA);
|
|
||||||
adcCountdown.setTimeout(100);
|
|
||||||
adcCountdown.resetTimer();
|
|
||||||
setMode(MODE_NORMAL, submode);
|
setMode(MODE_NORMAL, submode);
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
@ -202,6 +175,16 @@ ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t
|
|||||||
return NOTHING_TO_SEND;
|
return NOTHING_TO_SEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PayloadPcduHandler::updateSwitchGpio(gpioId_t id, gpio::Levels level) {
|
||||||
|
if (level == gpio::Levels::HIGH) {
|
||||||
|
gpioIF->pullHigh(id);
|
||||||
|
} else {
|
||||||
|
gpioIF->pullLow(id);
|
||||||
|
}
|
||||||
|
adcCountdown.setTimeout(100);
|
||||||
|
adcCountdown.resetTimer();
|
||||||
|
}
|
||||||
|
|
||||||
void PayloadPcduHandler::fillCommandAndReplyMap() {
|
void PayloadPcduHandler::fillCommandAndReplyMap() {
|
||||||
insertInCommandAndReplyMap(plpcdu::READ_CMD, 2, &adcSet);
|
insertInCommandAndReplyMap(plpcdu::READ_CMD, 2, &adcSet);
|
||||||
insertInCommandAndReplyMap(plpcdu::READ_TEMP_EXT, 1, &adcSet);
|
insertInCommandAndReplyMap(plpcdu::READ_TEMP_EXT, 1, &adcSet);
|
||||||
@ -549,31 +532,33 @@ bool PayloadPcduHandler::checkCurrent(float val, float upperBound, Event event)
|
|||||||
ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) {
|
ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) {
|
||||||
using namespace plpcdu;
|
using namespace plpcdu;
|
||||||
if (mode == MODE_NORMAL) {
|
if (mode == MODE_NORMAL) {
|
||||||
|
diffMask = submode ^ this->submode;
|
||||||
// Also deals with the case where the mode is MODE_ON, submode should be 0 here
|
// Also deals with the case where the mode is MODE_ON, submode should be 0 here
|
||||||
if ((((submode >> SOLID_STATE_RELAYS_ADC_ON) & 0b1) == SOLID_STATE_RELAYS_ADC_ON) and
|
if ((((submode >> SOLID_STATE_RELAYS_ADC_ON) & 0b1) == SOLID_STATE_RELAYS_ADC_ON) and
|
||||||
(this->mode == MODE_NORMAL and this->submode != ALL_OFF_SUBMODE)) {
|
(this->mode == MODE_NORMAL and this->submode != ALL_OFF_SUBMODE)) {
|
||||||
return TRANS_NOT_ALLOWED;
|
return TRANS_NOT_ALLOWED;
|
||||||
}
|
}
|
||||||
if (((((submode >> DRO_ON) & 1) == 1) and
|
if (((((submode >> DRO_ON) & 1) == 1) and
|
||||||
(this->submode != (1 << SOLID_STATE_RELAYS_ADC_ON)))) {
|
((this->submode & 0b1) != (1 << SOLID_STATE_RELAYS_ADC_ON)))) {
|
||||||
return TRANS_NOT_ALLOWED;
|
return TRANS_NOT_ALLOWED;
|
||||||
}
|
}
|
||||||
if ((((submode >> X8_ON) & 1) == 1) and
|
if ((((submode >> X8_ON) & 1) == 1) and
|
||||||
(this->submode != ((1 << SOLID_STATE_RELAYS_ADC_ON) | (1 << DRO_ON)))) {
|
((this->submode & 0b11) != ((1 << SOLID_STATE_RELAYS_ADC_ON) | (1 << DRO_ON)))) {
|
||||||
return TRANS_NOT_ALLOWED;
|
return TRANS_NOT_ALLOWED;
|
||||||
}
|
}
|
||||||
if (((((submode >> TX_ON) & 1) == 1) and
|
if (((((submode >> TX_ON) & 1) == 1) and
|
||||||
(this->submode != ((1 << X8_ON) | (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) {
|
((this->submode & 0b111) !=
|
||||||
|
((1 << X8_ON) | (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) {
|
||||||
return TRANS_NOT_ALLOWED;
|
return TRANS_NOT_ALLOWED;
|
||||||
}
|
}
|
||||||
if ((((submode >> MPA_ON) & 1) == 1 and
|
if ((((submode >> MPA_ON) & 1) == 1 and
|
||||||
(this->submode !=
|
((this->submode & 0b1111) !=
|
||||||
((1 << TX_ON) | (1 << X8_ON) | (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) {
|
((1 << TX_ON) | (1 << X8_ON) | (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) {
|
||||||
return TRANS_NOT_ALLOWED;
|
return TRANS_NOT_ALLOWED;
|
||||||
}
|
}
|
||||||
if ((((submode >> HPA_ON) & 1) == 1 and
|
if ((((submode >> HPA_ON) & 1) == 1 and
|
||||||
(this->submode != ((1 << MPA_ON) | (1 << TX_ON) | (1 << X8_ON) | (1 << DRO_ON) |
|
((this->submode & 0b11111) != ((1 << MPA_ON) | (1 << TX_ON) | (1 << X8_ON) |
|
||||||
(1 << SOLID_STATE_RELAYS_ADC_ON))))) {
|
(1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) {
|
||||||
return TRANS_NOT_ALLOWED;
|
return TRANS_NOT_ALLOWED;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
@ -134,6 +134,7 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
|||||||
SdCardMountedIF* sdcMan;
|
SdCardMountedIF* sdcMan;
|
||||||
plpcdu::PlPcduParameter params;
|
plpcdu::PlPcduParameter params;
|
||||||
bool quickTransitionAlreadyCalled = true;
|
bool quickTransitionAlreadyCalled = true;
|
||||||
|
uint8_t diffMask = 0;
|
||||||
|
|
||||||
PoolEntry<uint16_t> channelValues = PoolEntry<uint16_t>({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
PoolEntry<uint16_t> channelValues = PoolEntry<uint16_t>({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||||
PoolEntry<float> processedValues =
|
PoolEntry<float> processedValues =
|
||||||
@ -141,6 +142,8 @@ class PayloadPcduHandler : public DeviceHandlerBase {
|
|||||||
PoolEntry<float> tempC = PoolEntry<float>({0.0});
|
PoolEntry<float> tempC = PoolEntry<float>({0.0});
|
||||||
DualLanePowerStateMachine pwrStateMachine;
|
DualLanePowerStateMachine pwrStateMachine;
|
||||||
|
|
||||||
|
void updateSwitchGpio(gpioId_t id, gpio::Levels level);
|
||||||
|
|
||||||
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
|
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
|
||||||
void doStartUp() override;
|
void doStartUp() override;
|
||||||
void doShutDown() override;
|
void doShutDown() override;
|
||||||
|
Loading…
Reference in New Issue
Block a user