diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index e3357a53..fac22115 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -1,9 +1,11 @@ #include "SolarArrayDeploymentHandler.h" -#include -#include -#include -#include +#include "devices/gpioIds.h" +#include "fsfw/ipc/QueueFactory.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw_hal/common/gpio/GpioCookie.h" + +#include SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId_, GpioIF& gpioInterface, @@ -17,16 +19,36 @@ SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId deplSA2(deplSA2), mainLineSwitcher(mainLineSwitcher_), mainLineSwitch(mainLineSwitch_), + sdcMan(sdcMountedIF), actionHelper(this, nullptr) { auto mqArgs = MqArgs(setObjectId_, static_cast(this)); commandQueue = QueueFactory::instance()->createMessageQueue( cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } -SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() {} +SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() = default; ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) { + using namespace std::filesystem; handleStateMachine(); + auto activeSdc = sdcMan.getActiveSdCard(); + if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and + sdcMan.isSdCardUsable(activeSdc.value())) { + if (exists(SD_0_DEPL_FILE)) { + // perform autonomous deployment handling + performAutonomousDepl(sd::SdCard::SLOT_0); + } + } else if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_1 and + sdcMan.isSdCardUsable(activeSdc.value())) { + if (exists(SD_1_DEPL_FILE)) { + // perform autonomous deployment handling + performAutonomousDepl(sd::SdCard::SLOT_1); + } + } + return returnvalue::OK; +} + +ReturnValue_t SolarArrayDeploymentHandler::performAutonomousDepl(sd::SdCard sdCard) { return returnvalue::OK; } diff --git a/mission/devices/SolarArrayDeploymentHandler.h b/mission/devices/SolarArrayDeploymentHandler.h index 74d207a9..9e0bdfa1 100644 --- a/mission/devices/SolarArrayDeploymentHandler.h +++ b/mission/devices/SolarArrayDeploymentHandler.h @@ -1,7 +1,10 @@ #ifndef MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ #define MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ +#include + #include "devices/powerSwitcherList.h" +#include "events/subsystemIdRanges.h" #include "fsfw/action/HasActionsIF.h" #include "fsfw/devicehandlers/CookieIF.h" #include "fsfw/devicehandlers/DeviceHandlerIF.h" @@ -12,10 +15,6 @@ #include "fsfw/timemanager/Countdown.h" #include "fsfw_hal/common/gpio/GpioIF.h" #include "mission/memory/SdCardMountedIF.h" - -#include - -#include "events/subsystemIdRanges.h" #include "returnvalues/classIds.h" /** @@ -28,7 +27,10 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, public HasActionsIF { public: static constexpr DeviceCommandId_t DEPLOY_SOLAR_ARRAYS_MANUALLY = 0x5; - + static const char SD_0_DEPL_FILE[] = "/mnt/sd0/conf/deployment"; + static const char SD_1_DEPL_FILE[] = "/mnt/sd1/conf/deployment"; + static const char SD_0_DEPLY_INFO[] = "/mnt/sd0/conf/deployment_info.txt"; + static const char SD_1_DEPLY_INFO[] = "/mnt/sd1/conf/deployment_info.txt"; /** * @brief constructor * @@ -46,8 +48,7 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, */ SolarArrayDeploymentHandler(object_id_t setObjectId, GpioIF& gpio, PowerSwitchIF& mainLineSwitcher, pcdu::Switches mainLineSwitch, - gpioId_t deplSA1, gpioId_t deplSA2, - SdCardMountedIF& sdcMountedIF); + gpioId_t deplSA1, gpioId_t deplSA2, SdCardMountedIF& sdcMountedIF); virtual ~SolarArrayDeploymentHandler(); @@ -84,6 +85,8 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, // // StateMachine stateMachine = WAIT_ON_DELOYMENT_COMMAND; + ReturnValue_t performAutonomousDepl(sd::SdCard sdCard); + /** * This countdown is used to check if the PCDU sets the 8V line on in the intended time. */ @@ -106,9 +109,6 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, gpioId_t deplSA1; gpioId_t deplSA2; - /** Queue to receive messages from other objects. */ - MessageQueueIF* commandQueue = nullptr; - /** * After initialization this pointer will hold the reference to the main line switcher object. */ @@ -117,8 +117,13 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF, /** Switch number of the 8V power switch */ uint8_t mainLineSwitch; + SdCardMountedIF& sdcMan; + ActionHelper actionHelper; + /** Queue to receive messages from other objects. */ + MessageQueueIF* commandQueue = nullptr; + void readCommandQueue(); /**