less trashy mode checker
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2023-11-21 12:51:39 +01:00
parent ed8f2c75bf
commit 949401e247
3 changed files with 57 additions and 32 deletions

2
fsfw

@ -1 +1 @@
Subproject commit cc3e64e70d90f6a2b5c59215b2569c1771e890f0 Subproject commit 41d67bff639192afa2e18a23db6801c75b4fea88

View File

@ -4,6 +4,7 @@
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "fsfw/thermal/tcsDefinitions.h" #include "fsfw/thermal/tcsDefinitions.h"
#include "mission/payload/payloadPcduDefinitions.h"
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
#include <fsfw_hal/linux/UnixFileGuard.h> #include <fsfw_hal/linux/UnixFileGuard.h>
@ -576,6 +577,7 @@ void PayloadPcduHandler::performOperationHook() { checkJsonFileInit(); }
ReturnValue_t PayloadPcduHandler::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, ReturnValue_t PayloadPcduHandler::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode,
uint32_t* msToReachTheMode) { uint32_t* msToReachTheMode) {
using namespace plpcdu;
if (commandedMode != MODE_OFF) { if (commandedMode != MODE_OFF) {
PoolReadGuard pg(&enablePl); PoolReadGuard pg(&enablePl);
if (pg.getReadResult() == returnvalue::OK) { if (pg.getReadResult() == returnvalue::OK) {
@ -584,48 +586,62 @@ ReturnValue_t PayloadPcduHandler::checkModeCommand(Mode_t commandedMode, Submode
} }
} }
} }
return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); if (commandedMode == MODE_NORMAL) {
uint8_t dhbSubmode = getSubmode();
diffMask = commandedSubmode ^ dhbSubmode;
// For all higher level modes, SSR needs to be on. This is to ensure we have valid ADC
// measurements
if ((droOnForSubmode(commandedSubmode) or x8OnForSubmode(commandedSubmode) or
txOnForSubmode(commandedSubmode) or mpaOnForSubmode(commandedSubmode) or
hpaOnForSubmode(commandedSubmode)) and
not ssrOnForSubmode(dhbSubmode)) {
} }
ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) {
using namespace plpcdu;
if (mode == MODE_NORMAL) {
if (disableChannelOrderCheck) { if (disableChannelOrderCheck) {
return returnvalue::OK; return returnvalue::OK;
} }
uint8_t dhbSubmode = getSubmode(); if (x8OnForSubmode(commandedSubmode) and not droOnForSubmode(dhbSubmode)) {
diffMask = submode ^ dhbSubmode;
// 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
(getMode() == MODE_NORMAL and dhbSubmode != ALL_OFF_SUBMODE)) {
return TRANS_NOT_ALLOWED; return TRANS_NOT_ALLOWED;
} }
if (((((submode >> DRO_ON) & 1) == 1) and if (txOnForSubmode(commandedSubmode) and
((dhbSubmode & 0b1) != (1 << SOLID_STATE_RELAYS_ADC_ON)))) { (not droOnForSubmode(dhbSubmode) or not x8OnForSubmode(dhbSubmode))) {
return TRANS_NOT_ALLOWED; return TRANS_NOT_ALLOWED;
} }
if ((((submode >> X8_ON) & 1) == 1) and if (txOnForSubmode(commandedSubmode) and
((dhbSubmode & 0b11) != ((1 << SOLID_STATE_RELAYS_ADC_ON) | (1 << DRO_ON)))) { (not droOnForSubmode(dhbSubmode) or not x8OnForSubmode(dhbSubmode) or
not txOnForSubmode(dhbSubmode))) {
return TRANS_NOT_ALLOWED; return TRANS_NOT_ALLOWED;
} }
if (((((submode >> TX_ON) & 1) == 1) and if (hpaOnForSubmode(commandedSubmode) and
((dhbSubmode & 0b111) != (not droOnForSubmode(dhbSubmode) or not x8OnForSubmode(dhbSubmode) or
((1 << X8_ON) | (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) { not txOnForSubmode(dhbSubmode) or not mpaOnForSubmode(dhbSubmode))) {
return TRANS_NOT_ALLOWED;
}
if ((((submode >> MPA_ON) & 1) == 1 and
((dhbSubmode & 0b1111) !=
((1 << TX_ON) | (1 << X8_ON) | (1 << DRO_ON) | (1 << SOLID_STATE_RELAYS_ADC_ON))))) {
return TRANS_NOT_ALLOWED;
}
if ((((submode >> HPA_ON) & 1) == 1 and
((dhbSubmode & 0b11111) != ((1 << MPA_ON) | (1 << TX_ON) | (1 << X8_ON) | (1 << DRO_ON) |
(1 << SOLID_STATE_RELAYS_ADC_ON))))) {
return TRANS_NOT_ALLOWED; return TRANS_NOT_ALLOWED;
} }
return returnvalue::OK; return returnvalue::OK;
} }
return DeviceHandlerBase::isModeCombinationValid(mode, submode); return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode);
}
bool PayloadPcduHandler::ssrOnForSubmode(uint8_t submode) {
return (submode & plpcdu::SOLID_STATE_RELAYS_ADC_ON) == plpcdu::SOLID_STATE_RELAYS_ADC_ON;
}
bool PayloadPcduHandler::droOnForSubmode(uint8_t submode) {
return (submode & plpcdu::DRO_ON) == plpcdu::DRO_ON;
}
bool PayloadPcduHandler::x8OnForSubmode(uint8_t submode) {
return (submode & plpcdu::X8_ON) == plpcdu::X8_ON;
}
bool PayloadPcduHandler::txOnForSubmode(uint8_t submode) {
return (submode & plpcdu::TX_ON) == plpcdu::TX_ON;
}
bool PayloadPcduHandler::mpaOnForSubmode(uint8_t submode) {
return (submode & plpcdu::MPA_ON) == plpcdu::MPA_ON;
}
bool PayloadPcduHandler::hpaOnForSubmode(uint8_t submode) {
return (submode & plpcdu::HPA_ON) == plpcdu::HPA_ON;
} }
ReturnValue_t PayloadPcduHandler::serializeFloat(uint32_t& param, float val) { ReturnValue_t PayloadPcduHandler::serializeFloat(uint32_t& param, float val) {

View File

@ -137,6 +137,10 @@ class PayloadPcduHandler : public DeviceHandlerBase {
PoolEntry<float>({0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}); PoolEntry<float>({0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0});
PoolEntry<float> tempC = PoolEntry<float>({0.0}); PoolEntry<float> tempC = PoolEntry<float>({0.0});
/**
* This parameter disables all checks for the channels except the SSR on check. The SSR on check
* is kept to ensure that there is a common start point where the ADC is enabled.
*/
uint8_t disableChannelOrderCheck = false; uint8_t disableChannelOrderCheck = false;
void updateSwitchGpio(gpioId_t id, gpio::Levels level); void updateSwitchGpio(gpioId_t id, gpio::Levels level);
@ -157,7 +161,6 @@ class PayloadPcduHandler : public DeviceHandlerBase {
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override; LocalDataPoolManager& poolManager) override;
ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper* parameterWrapper, ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper* parameterWrapper,
const ParameterWrapper* newValues, uint16_t startAtIndex) override; const ParameterWrapper* newValues, uint16_t startAtIndex) override;
@ -179,6 +182,12 @@ class PayloadPcduHandler : public DeviceHandlerBase {
pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER);
ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode,
uint32_t* msToReachTheMode) override; uint32_t* msToReachTheMode) override;
static bool ssrOnForSubmode(uint8_t submode);
static bool droOnForSubmode(uint8_t submode);
static bool x8OnForSubmode(uint8_t submode);
static bool txOnForSubmode(uint8_t submode);
static bool mpaOnForSubmode(uint8_t submode);
static bool hpaOnForSubmode(uint8_t submode);
}; };
#endif /* LINUX_DEVICES_PLPCDUHANDLER_H_ */ #endif /* LINUX_DEVICES_PLPCDUHANDLER_H_ */