v1.15.0 #311

Merged
muellerr merged 107 commits from develop into main 2022-10-27 11:28:49 +02:00
Showing only changes of commit 0e8a085f97 - Show all commits

View File

@ -9,6 +9,8 @@
#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw_hal/common/gpio/GpioCookie.h" #include "fsfw_hal/common/gpio/GpioCookie.h"
static constexpr bool DEBUG_MODE = true;
SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId_, SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId_,
GpioIF& gpioInterface, GpioIF& gpioInterface,
PowerSwitchIF& mainLineSwitcher_, PowerSwitchIF& mainLineSwitcher_,
@ -177,51 +179,59 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(const char* filename, bo
return true; return true;
} }
ReturnValue_t SolarArrayDeploymentHandler::initialize() {
ReturnValue_t result = actionHelper.initialize(commandQueue);
if (result != returnvalue::OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
return SystemObject::initialize();
}
void SolarArrayDeploymentHandler::handleStateMachine() { void SolarArrayDeploymentHandler::handleStateMachine() {
if (stateMachine == MAIN_POWER_ON) { if (stateMachine == MAIN_POWER_ON) {
mainLineSwitcher.sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); mainLineSwitcher.sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON);
mainSwitchCountdown.setTimeout(mainLineSwitcher.getSwitchDelayMs()); mainSwitchCountdown.setTimeout(mainLineSwitcher.getSwitchDelayMs());
stateMachine = WAIT_MAIN_POWER_ON; stateMachine = WAIT_MAIN_POWER_ON;
if (DEBUG_MODE) {
sif::debug << "SA DEPL FSM: MAIN_POWER_ON done -> WAIT_MAIN_POWER_ON" << std::endl;
}
} }
if (stateMachine == MAIN_POWER_OFF) { if (stateMachine == MAIN_POWER_OFF) {
// These should never fail // These should never fail
allOff(); allOff();
stateMachine = WAIT_MAIN_POWER_OFF; stateMachine = WAIT_MAIN_POWER_OFF;
if (DEBUG_MODE) {
sif::debug << "SA DEPL FSM: MAIN_POWER_OFF done -> WAIT_MAIN_POWER_OFF" << std::endl;
}
} }
if (stateMachine == WAIT_MAIN_POWER_ON) { if (stateMachine == WAIT_MAIN_POWER_ON) {
if (checkMainPowerOn()) { if (checkMainPowerOn()) {
if (DEBUG_MODE) {
sif::debug << "SA DEPL FSM: WAIT_MAIN_POWER_ON done -> SWITCH_DEPL_GPIOS" << std::endl;
}
stateMachine = SWITCH_DEPL_GPIOS; stateMachine = SWITCH_DEPL_GPIOS;
} }
} }
if (stateMachine == WAIT_MAIN_POWER_OFF) { if (stateMachine == WAIT_MAIN_POWER_OFF) {
if (checkMainPowerOff()) { if (checkMainPowerOff()) {
if (DEBUG_MODE) {
sif::debug << "SA DEPL FSM: WAIT_MAIN_POWER_OFF done -> FSM DONE" << std::endl;
}
finishFsm(returnvalue::OK); finishFsm(returnvalue::OK);
} }
} }
if (stateMachine == SWITCH_DEPL_GPIOS) { if (stateMachine == SWITCH_DEPL_GPIOS) {
burnCountdown.setTimeout(fsmInfo.burnCountdown); burnCountdown.setTimeout(fsmInfo.burnCountdown);
// This should never fail // This should never fail
if (not fsmInfo.dryRun) {
channelAlternationCd.resetTimer(); channelAlternationCd.resetTimer();
if (not fsmInfo.dryRun) {
sa2Off(); sa2Off();
sa1On(); sa1On();
fsmInfo.alternationDummy = true; fsmInfo.alternationDummy = true;
} }
if (DEBUG_MODE) {
sif::debug << "SA DEPL FSM: SWITCH_DEPL_GPIOS done -> BURNING" << std::endl;
}
stateMachine = BURNING; stateMachine = BURNING;
} }
if (stateMachine == BURNING) { if (stateMachine == BURNING) {
if (not fsmInfo.dryRun) {
saGpioAlternation(); saGpioAlternation();
}
if (burnCountdown.hasTimedOut()) { if (burnCountdown.hasTimedOut()) {
if (DEBUG_MODE) {
sif::debug << "SA DEPL FSM: BURNING done -> WAIT_MAIN_POWER_OFF" << std::endl;
}
allOff(); allOff();
stateMachine = WAIT_MAIN_POWER_OFF; stateMachine = WAIT_MAIN_POWER_OFF;
} }
@ -285,6 +295,9 @@ void SolarArrayDeploymentHandler::startFsmOff() {
void SolarArrayDeploymentHandler::finishFsm(ReturnValue_t resultForActionHelper) { void SolarArrayDeploymentHandler::finishFsm(ReturnValue_t resultForActionHelper) {
retryCounter = 0; retryCounter = 0;
stateMachine = StateMachine::IDLE; stateMachine = StateMachine::IDLE;
fsmInfo.dryRun = false;
fsmInfo.onOff = false;
fsmInfo.alternationDummy = false;
if (actionActive) { if (actionActive) {
bool success = false; bool success = false;
if (resultForActionHelper == returnvalue::OK or if (resultForActionHelper == returnvalue::OK or
@ -315,19 +328,6 @@ bool SolarArrayDeploymentHandler::dryRunStringInFile(const char* filename) {
return false; return false;
} }
void SolarArrayDeploymentHandler::readCommandQueue() {
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result != returnvalue::OK) {
return;
}
result = actionHelper.handleActionMessage(&command);
if (result == returnvalue::OK) {
return;
}
}
ReturnValue_t SolarArrayDeploymentHandler::executeAction(ActionId_t actionId, ReturnValue_t SolarArrayDeploymentHandler::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) { const uint8_t* data, size_t size) {
@ -363,7 +363,7 @@ ReturnValue_t SolarArrayDeploymentHandler::executeAction(ActionId_t actionId,
ReturnValue_t SolarArrayDeploymentHandler::saGpioAlternation() { ReturnValue_t SolarArrayDeploymentHandler::saGpioAlternation() {
ReturnValue_t status = returnvalue::OK; ReturnValue_t status = returnvalue::OK;
ReturnValue_t result; ReturnValue_t result;
if (channelAlternationCd.hasTimedOut()) { if (channelAlternationCd.hasTimedOut() and not fsmInfo.dryRun) {
if (fsmInfo.alternationDummy) { if (fsmInfo.alternationDummy) {
result = sa1Off(); result = sa1Off();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
@ -454,6 +454,27 @@ ReturnValue_t SolarArrayDeploymentHandler::sa2Off() {
return result; return result;
} }
void SolarArrayDeploymentHandler::readCommandQueue() {
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result != returnvalue::OK) {
return;
}
result = actionHelper.handleActionMessage(&command);
if (result == returnvalue::OK) {
return;
}
}
MessageQueueId_t SolarArrayDeploymentHandler::getCommandQueue() const { MessageQueueId_t SolarArrayDeploymentHandler::getCommandQueue() const {
return commandQueue->getId(); return commandQueue->getId();
} }
ReturnValue_t SolarArrayDeploymentHandler::initialize() {
ReturnValue_t result = actionHelper.initialize(commandQueue);
if (result != returnvalue::OK) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
return SystemObject::initialize();
}