v1.10.0 #220

Merged
meierj merged 592 commits from develop into main 2022-04-22 07:42:20 +02:00
12 changed files with 167 additions and 127 deletions
Showing only changes of commit ce8253b940 - Show all commits

View File

@ -324,7 +324,8 @@ void ObjectFactory::createRadSensorComponent(LinuxLibgpioIF* gpioComIF) {
#endif #endif
} }
void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF* pwrSwitcher) { void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF,
PowerSwitchIF* pwrSwitcher) {
using namespace gpio; using namespace gpio;
GpioCookie* gpioCookieSus = new GpioCookie(); GpioCookie* gpioCookieSus = new GpioCookie();
GpioCallback* susgpio = nullptr; GpioCallback* susgpio = nullptr;
@ -379,96 +380,85 @@ void ObjectFactory::createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComI
susHandlers[0]->setParent(objects::SUS_BOARD_ASS); susHandlers[0]->setParent(objects::SUS_BOARD_ASS);
susHandlers[0]->setCustomFdir(fdir); susHandlers[0]->setCustomFdir(fdir);
spiCookie = spiCookie = new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1, q7s::SPI_DEFAULT_DEV,
new SpiCookie(addresses::SUS_1, gpioIds::CS_SUS_1, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[1] = new SusHandler(objects::SUS_1, 1, objects::SPI_COM_IF, spiCookie); susHandlers[1] = new SusHandler(objects::SUS_1, 1, objects::SPI_COM_IF, spiCookie);
fdir = new SusFdir(objects::SUS_1); fdir = new SusFdir(objects::SUS_1);
susHandlers[1]->setParent(objects::SUS_BOARD_ASS); susHandlers[1]->setParent(objects::SUS_BOARD_ASS);
susHandlers[1]->setCustomFdir(fdir); susHandlers[1]->setCustomFdir(fdir);
spiCookie = spiCookie = new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2, q7s::SPI_DEFAULT_DEV,
new SpiCookie(addresses::SUS_2, gpioIds::CS_SUS_2, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[2] = new SusHandler(objects::SUS_2, 2, objects::SPI_COM_IF, spiCookie); susHandlers[2] = new SusHandler(objects::SUS_2, 2, objects::SPI_COM_IF, spiCookie);
fdir = new SusFdir(objects::SUS_2); fdir = new SusFdir(objects::SUS_2);
susHandlers[2]->setParent(objects::SUS_BOARD_ASS); susHandlers[2]->setParent(objects::SUS_BOARD_ASS);
susHandlers[2]->setCustomFdir(fdir); susHandlers[2]->setCustomFdir(fdir);
spiCookie = spiCookie = new SpiCookie(addresses::SUS_3, gpioIds::CS_SUS_3, std::string(q7s::SPI_DEFAULT_DEV),
new SpiCookie(addresses::SUS_3, gpioIds::CS_SUS_3, std::string(q7s::SPI_DEFAULT_DEV),
SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[3] = new SusHandler(objects::SUS_3, 3, objects::SPI_COM_IF, spiCookie); susHandlers[3] = new SusHandler(objects::SUS_3, 3, objects::SPI_COM_IF, spiCookie);
fdir = new SusFdir(objects::SUS_3); fdir = new SusFdir(objects::SUS_3);
susHandlers[3]->setParent(objects::SUS_BOARD_ASS); susHandlers[3]->setParent(objects::SUS_BOARD_ASS);
susHandlers[3]->setCustomFdir(fdir); susHandlers[3]->setCustomFdir(fdir);
spiCookie = spiCookie = new SpiCookie(addresses::SUS_4, gpioIds::CS_SUS_4, std::string(q7s::SPI_DEFAULT_DEV),
new SpiCookie(addresses::SUS_4, gpioIds::CS_SUS_4, std::string(q7s::SPI_DEFAULT_DEV),
SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[4] = new SusHandler(objects::SUS_4, 4, objects::SPI_COM_IF, spiCookie); susHandlers[4] = new SusHandler(objects::SUS_4, 4, objects::SPI_COM_IF, spiCookie);
fdir = new SusFdir(objects::SUS_4); fdir = new SusFdir(objects::SUS_4);
susHandlers[4]->setParent(objects::SUS_BOARD_ASS); susHandlers[4]->setParent(objects::SUS_BOARD_ASS);
susHandlers[4]->setCustomFdir(fdir); susHandlers[4]->setCustomFdir(fdir);
spiCookie = spiCookie = new SpiCookie(addresses::SUS_5, gpioIds::CS_SUS_5, std::string(q7s::SPI_DEFAULT_DEV),
new SpiCookie(addresses::SUS_5, gpioIds::CS_SUS_5, std::string(q7s::SPI_DEFAULT_DEV),
SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ); SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[5] = new SusHandler(objects::SUS_5, 5, objects::SPI_COM_IF, spiCookie); susHandlers[5] = new SusHandler(objects::SUS_5, 5, objects::SPI_COM_IF, spiCookie);
fdir = new SusFdir(objects::SUS_5); fdir = new SusFdir(objects::SUS_5);
susHandlers[5]->setParent(objects::SUS_BOARD_ASS); susHandlers[5]->setParent(objects::SUS_BOARD_ASS);
susHandlers[5]->setCustomFdir(fdir); susHandlers[5]->setCustomFdir(fdir);
spiCookie = spiCookie = new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, q7s::SPI_DEFAULT_DEV,
new SpiCookie(addresses::SUS_6, gpioIds::CS_SUS_6, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[6] = new SusHandler(objects::SUS_6, 6, objects::SPI_COM_IF, spiCookie); susHandlers[6] = new SusHandler(objects::SUS_6, 6, objects::SPI_COM_IF, spiCookie);
fdir = new SusFdir(objects::SUS_6); fdir = new SusFdir(objects::SUS_6);
susHandlers[6]->setParent(objects::SUS_BOARD_ASS); susHandlers[6]->setParent(objects::SUS_BOARD_ASS);
susHandlers[6]->setCustomFdir(fdir); susHandlers[6]->setCustomFdir(fdir);
spiCookie = spiCookie = new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7, q7s::SPI_DEFAULT_DEV,
new SpiCookie(addresses::SUS_7, gpioIds::CS_SUS_7, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[7] = new SusHandler(objects::SUS_7, 7, objects::SPI_COM_IF, spiCookie); susHandlers[7] = new SusHandler(objects::SUS_7, 7, objects::SPI_COM_IF, spiCookie);
fdir = new SusFdir(objects::SUS_7); fdir = new SusFdir(objects::SUS_7);
susHandlers[7]->setParent(objects::SUS_BOARD_ASS); susHandlers[7]->setParent(objects::SUS_BOARD_ASS);
susHandlers[7]->setCustomFdir(fdir); susHandlers[7]->setCustomFdir(fdir);
spiCookie = spiCookie = new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8, q7s::SPI_DEFAULT_DEV,
new SpiCookie(addresses::SUS_8, gpioIds::CS_SUS_8, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[8] = new SusHandler(objects::SUS_8, 8, objects::SPI_COM_IF, spiCookie); susHandlers[8] = new SusHandler(objects::SUS_8, 8, objects::SPI_COM_IF, spiCookie);
fdir = new SusFdir(objects::SUS_8); fdir = new SusFdir(objects::SUS_8);
susHandlers[8]->setParent(objects::SUS_BOARD_ASS); susHandlers[8]->setParent(objects::SUS_BOARD_ASS);
susHandlers[8]->setCustomFdir(fdir); susHandlers[8]->setCustomFdir(fdir);
spiCookie = spiCookie = new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9, q7s::SPI_DEFAULT_DEV,
new SpiCookie(addresses::SUS_9, gpioIds::CS_SUS_9, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[9] = new SusHandler(objects::SUS_9, 9, objects::SPI_COM_IF, spiCookie); susHandlers[9] = new SusHandler(objects::SUS_9, 9, objects::SPI_COM_IF, spiCookie);
fdir = new SusFdir(objects::SUS_9); fdir = new SusFdir(objects::SUS_9);
susHandlers[9]->setParent(objects::SUS_BOARD_ASS); susHandlers[9]->setParent(objects::SUS_BOARD_ASS);
susHandlers[9]->setCustomFdir(fdir); susHandlers[9]->setCustomFdir(fdir);
spiCookie = spiCookie = new SpiCookie(addresses::SUS_10, gpioIds::CS_SUS_10, q7s::SPI_DEFAULT_DEV,
new SpiCookie(addresses::SUS_10, gpioIds::CS_SUS_10, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[10] = new SusHandler(objects::SUS_10, 10, objects::SPI_COM_IF, spiCookie); susHandlers[10] = new SusHandler(objects::SUS_10, 10, objects::SPI_COM_IF, spiCookie);
fdir = new SusFdir(objects::SUS_10); fdir = new SusFdir(objects::SUS_10);
susHandlers[10]->setParent(objects::SUS_BOARD_ASS); susHandlers[10]->setParent(objects::SUS_BOARD_ASS);
susHandlers[10]->setCustomFdir(fdir); susHandlers[10]->setCustomFdir(fdir);
spiCookie = spiCookie = new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11, q7s::SPI_DEFAULT_DEV,
new SpiCookie(addresses::SUS_11, gpioIds::CS_SUS_11, q7s::SPI_DEFAULT_DEV, SUS::MAX_CMD_SIZE, SUS::MAX_CMD_SIZE, spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
spi::SUS_MAX_1227_MODE, spi::SUS_MAX1227_SPI_FREQ);
susHandlers[11] = new SusHandler(objects::SUS_11, 11, objects::SPI_COM_IF, spiCookie); susHandlers[11] = new SusHandler(objects::SUS_11, 11, objects::SPI_COM_IF, spiCookie);
fdir = new SusFdir(objects::SUS_11); fdir = new SusFdir(objects::SUS_11);
susHandlers[11]->setParent(objects::SUS_BOARD_ASS); susHandlers[11]->setParent(objects::SUS_BOARD_ASS);
susHandlers[11]->setCustomFdir(fdir); susHandlers[11]->setCustomFdir(fdir);
for(auto& sus: susHandlers) { for (auto& sus : susHandlers) {
if(sus != nullptr) { if (sus != nullptr) {
#if OBSW_TEST_SUS == 1 #if OBSW_TEST_SUS == 1
sus->setStartUpImmediately(); sus->setStartUpImmediately();
sus->setToGoToNormalMode(true); sus->setToGoToNormalMode(true);

View File

@ -18,7 +18,8 @@ void createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF** pwrSwitcher
void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF); void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF);
void createTmpComponents(); void createTmpComponents();
void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); void createRadSensorComponent(LinuxLibgpioIF* gpioComIF);
void createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitchIF* pwrSwitcher); void createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF,
PowerSwitchIF* pwrSwitcher);
void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF, void createAcsBoardComponents(LinuxLibgpioIF* gpioComIF, UartComIF* uartComIF,
PowerSwitchIF* pwrSwitcher); PowerSwitchIF* pwrSwitcher);
void createHeaterComponents(); void createHeaterComponents();

2
fsfw

@ -1 +1 @@
Subproject commit 16f2fa9327393ba8848817cc5a22497201c41d13 Subproject commit d791fc87b7bba11c1baa68d544cd991028ff3330

View File

@ -7,6 +7,7 @@ target_sources(${LIB_EIVE_MISSION} PRIVATE
ComSubsystem.cpp ComSubsystem.cpp
TcsSubsystem.cpp TcsSubsystem.cpp
DualLanePowerStateMachine.cpp DualLanePowerStateMachine.cpp
PowerStateMachineBase.cpp
DualLaneAssemblyBase.cpp DualLaneAssemblyBase.cpp
AcsBoardFdir.cpp AcsBoardFdir.cpp

View File

@ -63,8 +63,8 @@ bool DualLaneAssemblyBase::isUseable(object_id_t object, Mode_t mode) {
} }
ReturnValue_t DualLaneAssemblyBase::pwrStateMachineWrapper() { ReturnValue_t DualLaneAssemblyBase::pwrStateMachineWrapper() {
using namespace duallane; using namespace power;
OpCodes opCode = pwrStateMachine.powerStateMachine(); OpCodes opCode = pwrStateMachine.fsm();
if (customRecoveryStates == RecoveryCustomStates::IDLE) { if (customRecoveryStates == RecoveryCustomStates::IDLE) {
if (opCode == OpCodes::NONE) { if (opCode == OpCodes::NONE) {
return RETURN_OK; return RETURN_OK;
@ -163,7 +163,7 @@ void DualLaneAssemblyBase::handleModeTransitionFailed(ReturnValue_t result) {
} }
bool DualLaneAssemblyBase::checkAndHandleRecovery() { bool DualLaneAssemblyBase::checkAndHandleRecovery() {
using namespace duallane; using namespace power;
OpCodes opCode = OpCodes::NONE; OpCodes opCode = OpCodes::NONE;
if (recoveryState == RECOVERY_IDLE) { if (recoveryState == RECOVERY_IDLE) {
return AssemblyBase::checkAndHandleRecovery(); return AssemblyBase::checkAndHandleRecovery();
@ -173,14 +173,14 @@ bool DualLaneAssemblyBase::checkAndHandleRecovery() {
customRecoveryStates = RecoveryCustomStates::POWER_SWITCHING_OFF; customRecoveryStates = RecoveryCustomStates::POWER_SWITCHING_OFF;
} }
if (customRecoveryStates == POWER_SWITCHING_OFF) { if (customRecoveryStates == POWER_SWITCHING_OFF) {
opCode = pwrStateMachine.powerStateMachine(); opCode = pwrStateMachine.fsm();
if (opCode == OpCodes::TO_OFF_DONE or opCode == OpCodes::TIMEOUT_OCCURED) { if (opCode == OpCodes::TO_OFF_DONE or opCode == OpCodes::TIMEOUT_OCCURED) {
customRecoveryStates = RecoveryCustomStates::POWER_SWITCHING_ON; customRecoveryStates = RecoveryCustomStates::POWER_SWITCHING_ON;
pwrStateMachine.start(targetMode, targetSubmode); pwrStateMachine.start(targetMode, targetSubmode);
} }
} }
if (customRecoveryStates == POWER_SWITCHING_ON) { if (customRecoveryStates == POWER_SWITCHING_ON) {
opCode = pwrStateMachine.powerStateMachine(); opCode = pwrStateMachine.fsm();
if (opCode == OpCodes::TO_NOT_OFF_DONE or opCode == OpCodes::TIMEOUT_OCCURED) { if (opCode == OpCodes::TO_NOT_OFF_DONE or opCode == OpCodes::TIMEOUT_OCCURED) {
customRecoveryStates = RecoveryCustomStates::DONE; customRecoveryStates = RecoveryCustomStates::DONE;
} }

View File

@ -7,37 +7,16 @@ DualLanePowerStateMachine::DualLanePowerStateMachine(pcduSwitches::Switches swit
pcduSwitches::Switches switchB, pcduSwitches::Switches switchB,
PowerSwitchIF* pwrSwitcher, PowerSwitchIF* pwrSwitcher,
dur_millis_t checkTimeout) dur_millis_t checkTimeout)
: SWITCH_A(switchA), SWITCH_B(switchB), pwrSwitcher(pwrSwitcher), checkTimeout(checkTimeout) {} : PowerStateMachineBase(pwrSwitcher, checkTimeout), SWITCH_A(switchA), SWITCH_B(switchB) {}
void DualLanePowerStateMachine::setCheckTimeout(dur_millis_t timeout) { power::OpCodes DualLanePowerStateMachine::fsm() {
checkTimeout.setTimeout(timeout);
}
void DualLanePowerStateMachine::start(Mode_t mode, Submode_t submode) {
reset();
checkTimeout.resetTimer();
targetMode = mode;
targetSubmode = submode;
state = duallane::PwrStates::SWITCHING_POWER;
}
duallane::PwrStates DualLanePowerStateMachine::getState() const { return state; }
bool DualLanePowerStateMachine::active() {
if (state == duallane::PwrStates::IDLE or state == duallane::PwrStates::MODE_COMMANDING) {
return false;
}
return true;
}
duallane::OpCodes DualLanePowerStateMachine::powerStateMachine() {
using namespace duallane; using namespace duallane;
ReturnValue_t switchStateA = RETURN_OK; ReturnValue_t switchStateA = RETURN_OK;
ReturnValue_t switchStateB = RETURN_OK; ReturnValue_t switchStateB = RETURN_OK;
if (state == PwrStates::IDLE or state == PwrStates::MODE_COMMANDING) { if (state == power::States::IDLE or state == power::States::MODE_COMMANDING) {
return opResult; return opResult;
} }
if (state == PwrStates::SWITCHING_POWER or state == PwrStates::CHECKING_POWER) { if (state == power::States::SWITCHING_POWER or state == power::States::CHECKING_POWER) {
switchStateA = pwrSwitcher->getSwitchState(SWITCH_A); switchStateA = pwrSwitcher->getSwitchState(SWITCH_A);
switchStateB = pwrSwitcher->getSwitchState(SWITCH_B); switchStateB = pwrSwitcher->getSwitchState(SWITCH_B);
} else { } else {
@ -45,8 +24,8 @@ duallane::OpCodes DualLanePowerStateMachine::powerStateMachine() {
} }
if (targetMode == HasModesIF::MODE_OFF) { if (targetMode == HasModesIF::MODE_OFF) {
if (switchStateA == PowerSwitchIF::SWITCH_OFF and switchStateB == PowerSwitchIF::SWITCH_OFF) { if (switchStateA == PowerSwitchIF::SWITCH_OFF and switchStateB == PowerSwitchIF::SWITCH_OFF) {
state = PwrStates::IDLE; state = power::States::IDLE;
opResult = OpCodes::TO_OFF_DONE; opResult = power::OpCodes::TO_OFF_DONE;
return opResult; return opResult;
} }
} else { } else {
@ -54,8 +33,8 @@ duallane::OpCodes DualLanePowerStateMachine::powerStateMachine() {
case (A_SIDE): { case (A_SIDE): {
if (switchStateA == PowerSwitchIF::SWITCH_ON and if (switchStateA == PowerSwitchIF::SWITCH_ON and
switchStateB == PowerSwitchIF::SWITCH_OFF) { switchStateB == PowerSwitchIF::SWITCH_OFF) {
state = PwrStates::MODE_COMMANDING; state = power::States::MODE_COMMANDING;
opResult = OpCodes::TO_NOT_OFF_DONE; opResult = power::OpCodes::TO_NOT_OFF_DONE;
return opResult; return opResult;
} }
break; break;
@ -63,22 +42,22 @@ duallane::OpCodes DualLanePowerStateMachine::powerStateMachine() {
case (B_SIDE): { case (B_SIDE): {
if (switchStateA == PowerSwitchIF::SWITCH_OFF and if (switchStateA == PowerSwitchIF::SWITCH_OFF and
switchStateB == PowerSwitchIF::SWITCH_ON) { switchStateB == PowerSwitchIF::SWITCH_ON) {
state = PwrStates::MODE_COMMANDING; state = power::States::MODE_COMMANDING;
opResult = OpCodes::TO_NOT_OFF_DONE; opResult = power::OpCodes::TO_NOT_OFF_DONE;
return opResult; return opResult;
} }
break; break;
} }
case (DUAL_MODE): { case (DUAL_MODE): {
if (switchStateA == PowerSwitchIF::SWITCH_ON and switchStateB == PowerSwitchIF::SWITCH_ON) { if (switchStateA == PowerSwitchIF::SWITCH_ON and switchStateB == PowerSwitchIF::SWITCH_ON) {
state = PwrStates::MODE_COMMANDING; state = power::States::MODE_COMMANDING;
opResult = OpCodes::TO_NOT_OFF_DONE; opResult = power::OpCodes::TO_NOT_OFF_DONE;
return opResult; return opResult;
} }
} }
} }
} }
if (state == PwrStates::SWITCHING_POWER) { if (state == power::States::SWITCHING_POWER) {
if (targetMode == HasModesIF::MODE_OFF) { if (targetMode == HasModesIF::MODE_OFF) {
if (switchStateA != PowerSwitchIF::SWITCH_OFF) { if (switchStateA != PowerSwitchIF::SWITCH_OFF) {
pwrSwitcher->sendSwitchCommand(SWITCH_A, PowerSwitchIF::SWITCH_OFF); pwrSwitcher->sendSwitchCommand(SWITCH_A, PowerSwitchIF::SWITCH_OFF);
@ -121,20 +100,12 @@ duallane::OpCodes DualLanePowerStateMachine::powerStateMachine() {
} }
} }
} }
state = PwrStates::CHECKING_POWER; state = power::States::CHECKING_POWER;
} }
if (state == PwrStates::CHECKING_POWER) { if (state == power::States::CHECKING_POWER) {
if (checkTimeout.hasTimedOut()) { if (checkTimeout.hasTimedOut()) {
return OpCodes::TIMEOUT_OCCURED; return power::OpCodes::TIMEOUT_OCCURED;
} }
} }
return opResult; return opResult;
} }
void DualLanePowerStateMachine::reset() {
state = duallane::PwrStates::IDLE;
opResult = duallane::OpCodes::NONE;
targetMode = HasModesIF::MODE_OFF;
targetSubmode = 0;
checkTimeout.resetTimer();
}

View File

@ -3,32 +3,23 @@
#include <devices/powerSwitcherList.h> #include <devices/powerSwitcherList.h>
#include <fsfw/modes/HasModesIF.h> #include <fsfw/modes/HasModesIF.h>
#include <mission/system/PowerStateMachineBase.h>
#include "definitions.h" #include "definitions.h"
class AssemblyBase; class AssemblyBase;
class PowerSwitchIF; class PowerSwitchIF;
class DualLanePowerStateMachine : public HasReturnvaluesIF { class DualLanePowerStateMachine : public PowerStateMachineBase {
public: public:
DualLanePowerStateMachine(pcduSwitches::Switches switchA, pcduSwitches::Switches switchB, DualLanePowerStateMachine(pcduSwitches::Switches switchA, pcduSwitches::Switches switchB,
PowerSwitchIF* pwrSwitcher, dur_millis_t checkTimeout = 5000); PowerSwitchIF* pwrSwitcher, dur_millis_t checkTimeout = 5000);
void setCheckTimeout(dur_millis_t timeout); power::OpCodes fsm() override;
void reset();
void start(Mode_t mode, Submode_t submode);
bool active();
duallane::PwrStates getState() const;
duallane::OpCodes powerStateMachine();
const pcduSwitches::Switches SWITCH_A; const pcduSwitches::Switches SWITCH_A;
const pcduSwitches::Switches SWITCH_B; const pcduSwitches::Switches SWITCH_B;
private: private:
duallane::OpCodes opResult = duallane::OpCodes::NONE;
duallane::PwrStates state = duallane::PwrStates::IDLE;
PowerSwitchIF* pwrSwitcher = nullptr;
Mode_t targetMode = HasModesIF::MODE_OFF;
Submode_t targetSubmode = 0;
Countdown checkTimeout;
}; };
#endif /* MISSION_SYSTEM_DUALLANEPOWERSTATEMACHINE_H_ */ #endif /* MISSION_SYSTEM_DUALLANEPOWERSTATEMACHINE_H_ */

View File

@ -0,0 +1,33 @@
#include "PowerStateMachineBase.h"
PowerStateMachineBase::PowerStateMachineBase(PowerSwitchIF *pwrSwitcher, dur_millis_t checkTimeout)
: pwrSwitcher(pwrSwitcher), checkTimeout(checkTimeout) {}
void PowerStateMachineBase::reset() {
state = power::States::IDLE;
opResult = power::OpCodes::NONE;
targetMode = HasModesIF::MODE_OFF;
targetSubmode = 0;
checkTimeout.resetTimer();
}
void PowerStateMachineBase::setCheckTimeout(dur_millis_t timeout) {
checkTimeout.setTimeout(timeout);
}
void PowerStateMachineBase::start(Mode_t mode, Submode_t submode) {
reset();
checkTimeout.resetTimer();
targetMode = mode;
targetSubmode = submode;
state = power::States::SWITCHING_POWER;
}
power::States PowerStateMachineBase::getState() const { return state; }
bool PowerStateMachineBase::active() {
if (state == power::States::IDLE or state == power::States::MODE_COMMANDING) {
return false;
}
return true;
}

View File

@ -0,0 +1,31 @@
#ifndef MISSION_SYSTEM_POWERSTATEMACHINE_H_
#define MISSION_SYSTEM_POWERSTATEMACHINE_H_
#include <fsfw/modes/HasModesIF.h>
#include <fsfw/power/PowerSwitchIF.h>
#include <fsfw/timemanager/Countdown.h>
#include "definitions.h"
class PowerStateMachineBase : public HasReturnvaluesIF {
public:
PowerStateMachineBase(PowerSwitchIF* pwrSwitcher, dur_millis_t checkTimeout);
virtual power::OpCodes fsm() = 0;
void setCheckTimeout(dur_millis_t timeout);
void reset();
void start(Mode_t mode, Submode_t submode);
bool active();
power::States getState() const;
protected:
power::OpCodes opResult = power::OpCodes::NONE;
power::States state = power::States::IDLE;
PowerSwitchIF* pwrSwitcher = nullptr;
Mode_t targetMode = HasModesIF::MODE_OFF;
Submode_t targetSubmode = 0;
Countdown checkTimeout;
};
#endif /* MISSION_SYSTEM_POWERSTATEMACHINE_H_ */

View File

@ -1,23 +1,34 @@
#include "TcsSubsystem.h" #include "TcsSubsystem.h"
TcsSubsystem::TcsSubsystem(object_id_t objectId, object_id_t parentId, TcsBoardHelper helper) #include <fsfw/devicehandlers/DeviceHandlerIF.h>
: SubsystemBase(objectId, parentId, MODE_OFF, 24), helper(helper) {
}
ReturnValue_t TcsSubsystem::handleCommandMessage(CommandMessage *message) { TcsSubsystem::TcsSubsystem(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
return RETURN_OK; power::Switch_t theSwitch, TcsBoardHelper helper)
} : SubsystemBase(objectId, parentId, MODE_OFF, 24),
switcher(pwrSwitcher, theSwitch),
helper(helper) {}
void TcsSubsystem::performChildOperation() { ReturnValue_t TcsSubsystem::handleCommandMessage(CommandMessage* message) { return RETURN_OK; }
}
void TcsSubsystem::performChildOperation() {}
ReturnValue_t TcsSubsystem::checkModeCommand(Mode_t mode, Submode_t submode, ReturnValue_t TcsSubsystem::checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) { uint32_t* msToReachTheMode) {
if (mode == MODE_ON or mode == MODE_OFF or mode == DeviceHandlerIF::MODE_NORMAL) {
return RETURN_OK; return RETURN_OK;
}
return HasModesIF::INVALID_MODE;
} }
ReturnValue_t TcsSubsystem::initialize() { ReturnValue_t TcsSubsystem::initialize() {
ReturnValue_t result = RETURN_OK;
for (const auto& obj : helper.rtdIds) {
result = registerChild(obj);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
}
return SubsystemBase::initialize();
} }
void TcsSubsystem::startTransition(Mode_t mode, Submode_t submode) { void TcsSubsystem::startTransition(Mode_t mode, Submode_t submode) {}
}

View File

@ -1,21 +1,29 @@
#ifndef MISSION_SYSTEM_TCSSUBSYSTEM_H_ #ifndef MISSION_SYSTEM_TCSSUBSYSTEM_H_
#define MISSION_SYSTEM_TCSSUBSYSTEM_H_ #define MISSION_SYSTEM_TCSSUBSYSTEM_H_
#include <fsfw/container/FixedArrayList.h>
#include <fsfw/power/PowerSwitcher.h>
#include <fsfw/subsystem/SubsystemBase.h> #include <fsfw/subsystem/SubsystemBase.h>
struct TcsBoardHelper { struct TcsBoardHelper {
TcsBoardHelper(std::array<object_id_t, 16> rtdIds): rtdIds(rtdIds) {} TcsBoardHelper(std::array<object_id_t, 16> rtdIds) : rtdIds(rtdIds) {}
std::array<object_id_t, 16> rtdIds = {}; std::array<object_id_t, 16> rtdIds = {};
}; };
class TcsSubsystem: public SubsystemBase { class TcsSubsystem : public SubsystemBase {
public: public:
TcsSubsystem(object_id_t objectId, object_id_t parentId, TcsBoardHelper helper); TcsSubsystem(object_id_t objectId, object_id_t parentId, PowerSwitchIF *pwrSwitcher,
power::Switch_t switcher, TcsBoardHelper helper);
ReturnValue_t initialize() override; ReturnValue_t initialize() override;
private: private:
static constexpr uint8_t NUMBER_RTDS = 16;
PowerSwitcher switcher;
TcsBoardHelper helper;
FixedArrayList<ModeListEntry, NUMBER_RTDS> modeTable;
ReturnValue_t handleCommandMessage(CommandMessage *message) override; ReturnValue_t handleCommandMessage(CommandMessage *message) override;
void performChildOperation() override; void performChildOperation() override;
@ -24,8 +32,6 @@ private:
uint32_t *msToReachTheMode) override; uint32_t *msToReachTheMode) override;
void startTransition(Mode_t mode, Submode_t submode) override; void startTransition(Mode_t mode, Submode_t submode) override;
TcsBoardHelper helper;
}; };
#endif /* MISSION_SYSTEM_TCSSUBSYSTEM_H_ */ #endif /* MISSION_SYSTEM_TCSSUBSYSTEM_H_ */

View File

@ -3,10 +3,15 @@
#include <fsfw/modes/ModeMessage.h> #include <fsfw/modes/ModeMessage.h>
namespace power {
enum class States { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING };
enum class OpCodes { NONE, TO_OFF_DONE, TO_NOT_OFF_DONE, TIMEOUT_OCCURED };
} // namespace power
namespace duallane { namespace duallane {
enum class PwrStates { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING };
enum class OpCodes { NONE, TO_OFF_DONE, TO_NOT_OFF_DONE, TIMEOUT_OCCURED };
enum Submodes : Submode_t { A_SIDE = 0, B_SIDE = 1, DUAL_MODE = 2 }; enum Submodes : Submode_t { A_SIDE = 0, B_SIDE = 1, DUAL_MODE = 2 };
} // namespace duallane } // namespace duallane