From a91393b4b4a54b9af6aee9c58d01b57ff8b2bc96 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Wed, 17 Aug 2022 17:55:21 +0200 Subject: [PATCH] Small fixes --- mission/devices/HeaterHandler.cpp | 32 +++++++++++-------- mission/devices/HeaterHandler.h | 2 ++ .../devices/SolarArrayDeploymentHandler.cpp | 25 +++++++++++---- mission/devices/SolarArrayDeploymentHandler.h | 1 + 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index dc6b5668..365e671d 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -104,13 +104,11 @@ void HeaterHandler::readCommandQueue() { } while (result == RETURN_OK); } -ReturnValue_t HeaterHandler::executeAction(Action* action) { - return action->handle(); -} +ReturnValue_t HeaterHandler::executeAction(Action* action) { return action->handle(); } - ReturnValue_t HeaterHandler::handleAction(SetHeaterAction *heaterAction){ - auto& heater = heaterVec.at(heaterAction->switchNr); - auto action = heaterAction->switchAction; +ReturnValue_t HeaterHandler::handleAction(SetHeaterAction* heaterAction) { + auto& heater = heaterVec.at(heaterAction->switchNr); + auto action = heaterAction->switchAction; // Always accepts OFF commands if (action == SetHeaterAction::SwitchAction::SET_SWITCH_ON) { HasHealthIF::HealthState health = heater.healthDevice->getHealth(); @@ -119,7 +117,8 @@ ReturnValue_t HeaterHandler::executeAction(Action* action) { return HasHealthIF::OBJECT_NOT_HEALTHY; } auto cmdSource = heaterAction->cmdSource; - if (health == HasHealthIF::EXTERNAL_CONTROL and cmdSource == SetHeaterAction::CmdSourceParam::INTERNAL) { + if (health == HasHealthIF::EXTERNAL_CONTROL and + cmdSource == SetHeaterAction::CmdSourceParam::INTERNAL) { return HasHealthIF::IS_EXTERNALLY_CONTROLLED; } } @@ -131,7 +130,7 @@ ReturnValue_t HeaterHandler::executeAction(Action* action) { heater.cmdActive = true; heater.replyQueue = heaterAction->commandedBy; return RETURN_OK; - } +} ReturnValue_t HeaterHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) { ReturnValue_t result; @@ -157,7 +156,8 @@ ReturnValue_t HeaterHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t o result = ipcStore->addData(&storeAddress, commandData, sizeof(commandData)); if (result == RETURN_OK) { CommandMessage message; - ActionMessage::setCommand(&message, static_cast(HeaterCommands::SWITCH_HEATER), storeAddress); + ActionMessage::setCommand(&message, static_cast(HeaterCommands::SWITCH_HEATER), + storeAddress); /* Send heater command to own command queue */ result = commandQueue->sendMessage(commandQueue->getId(), &message, 0); if (result != RETURN_OK) { @@ -211,7 +211,8 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) { heater.cmdActive = false; heater.waitMainSwitchOn = false; if (heater.replyQueue != commandQueue->getId()) { - actionHelper.finish(false, heater.replyQueue, static_cast(heater.action), MAIN_SWITCH_SET_TIMEOUT); + actionHelper.finish(false, heater.replyQueue, static_cast(heater.action), + MAIN_SWITCH_SET_TIMEOUT); } return; } @@ -237,9 +238,11 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) { // HeaterHandler itself if (heater.replyQueue != commandQueue->getId()) { if (result == RETURN_OK) { - actionHelper.finish(true, heater.replyQueue, static_cast(heater.action), result); + actionHelper.finish(true, heater.replyQueue, static_cast(heater.action), + result); } else { - actionHelper.finish(false, heater.replyQueue, static_cast(heater.action), result); + actionHelper.finish(false, heater.replyQueue, static_cast(heater.action), + result); } } heater.cmdActive = false; @@ -255,7 +258,8 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) { sif::debug << "HeaterHandler::handleSwitchHandling: Failed to get state of" << " main line switch" << std::endl; if (heater.replyQueue != commandQueue->getId()) { - actionHelper.finish(false, heater.replyQueue, static_cast(heater.action), mainSwitchState); + actionHelper.finish(false, heater.replyQueue, static_cast(heater.action), + mainSwitchState); } heater.cmdActive = false; } @@ -316,6 +320,8 @@ bool HeaterHandler::allSwitchesOff() { MessageQueueId_t HeaterHandler::getCommandQueue() const { return commandQueue->getId(); } +ActionHelper* HeaterHandler::getActionHelper() { return &actionHelper; } + ReturnValue_t HeaterHandler::sendFuseOnCommand(uint8_t fuseNr) { return RETURN_OK; } ReturnValue_t HeaterHandler::getSwitchState(uint8_t switchNr) const { diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index 69e8f391..f4c334ce 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -66,8 +66,10 @@ class HeaterHandler : public ExecutableObjectIF, uint32_t getSwitchDelayMs(void) const override; MessageQueueId_t getCommandQueue() const override; + ActionHelper* getActionHelper() override; ReturnValue_t executeAction(Action* action) override; ReturnValue_t handleAction(SetHeaterAction *heaterAction); + ReturnValue_t initialize() override; private: diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index 9fe6539d..6035dd12 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -111,8 +111,10 @@ void SolarArrayDeploymentHandler::performWaitOn8VActions() { } else { if (mainSwitchCountdown.hasTimedOut()) { triggerEvent(MAIN_SWITCH_ON_TIMEOUT); - actionHelper.finish(false, rememberCommanderId, static_cast(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS), - MAIN_SWITCH_TIMEOUT_FAILURE); + actionHelper.finish( + false, rememberCommanderId, + static_cast(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS), + MAIN_SWITCH_TIMEOUT_FAILURE); stateMachine = WAIT_ON_DELOYMENT_COMMAND; } } @@ -129,7 +131,10 @@ void SolarArrayDeploymentHandler::switchDeploymentTransistors() { * the deployment sequence. */ stateMachine = WAIT_ON_DELOYMENT_COMMAND; triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED); - actionHelper.finish(false, rememberCommanderId, static_cast(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS), SWITCHING_DEPL_SA1_FAILED); + actionHelper.finish( + false, rememberCommanderId, + static_cast(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS), + SWITCHING_DEPL_SA1_FAILED); mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); } result = gpioInterface->pullHigh(deplSA2); @@ -139,7 +144,10 @@ void SolarArrayDeploymentHandler::switchDeploymentTransistors() { << std::endl; stateMachine = WAIT_ON_DELOYMENT_COMMAND; triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED); - actionHelper.finish(false, rememberCommanderId, static_cast(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS), SWITCHING_DEPL_SA2_FAILED); + actionHelper.finish( + false, rememberCommanderId, + static_cast(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS), + SWITCHING_DEPL_SA2_FAILED); mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); } deploymentCountdown.setTimeout(burnTimeMs); @@ -149,7 +157,10 @@ void SolarArrayDeploymentHandler::switchDeploymentTransistors() { void SolarArrayDeploymentHandler::handleDeploymentFinish() { ReturnValue_t result = RETURN_OK; if (deploymentCountdown.hasTimedOut()) { - actionHelper.finish(true, rememberCommanderId, static_cast(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS), RETURN_OK); + actionHelper.finish( + true, rememberCommanderId, + static_cast(SolarArrayDeploymentCommands::DEPLOY_SOLAR_ARRAYS), + RETURN_OK); result = gpioInterface->pullLow(deplSA1); if (result != RETURN_OK) { sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" @@ -187,7 +198,7 @@ ReturnValue_t SolarArrayDeploymentHandler::executeAction(Action* action) { << "waiting-on-command-state" << std::endl; return DEPLOYMENT_ALREADY_EXECUTING; } - //delegates to SolarArrayDeploymentHandler::handleAction() + // delegates to SolarArrayDeploymentHandler::handleAction() return action->handle(); } @@ -200,3 +211,5 @@ ReturnValue_t SolarArrayDeploymentHandler::handleAction(SolarArrayDeploymentActi MessageQueueId_t SolarArrayDeploymentHandler::getCommandQueue() const { return commandQueue->getId(); } + +ActionHelper* SolarArrayDeploymentHandler::getActionHelper() { return &actionHelper; } diff --git a/mission/devices/SolarArrayDeploymentHandler.h b/mission/devices/SolarArrayDeploymentHandler.h index 0b2bf236..e6021e1a 100644 --- a/mission/devices/SolarArrayDeploymentHandler.h +++ b/mission/devices/SolarArrayDeploymentHandler.h @@ -50,6 +50,7 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; virtual MessageQueueId_t getCommandQueue() const override; + virtual ActionHelper *getActionHelper() override; virtual ReturnValue_t executeAction(Action* action) override; ReturnValue_t handleAction(SolarArrayDeploymentAction* action); virtual ReturnValue_t initialize() override;