Robin Mueller
2bc7c7b3ae
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
179 lines
6.9 KiB
C++
179 lines
6.9 KiB
C++
#ifndef MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_
|
|
#define MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_
|
|
|
|
#include <unordered_map>
|
|
|
|
#include "eive/definitions.h"
|
|
#include "devices/powerSwitcherList.h"
|
|
#include "events/subsystemIdRanges.h"
|
|
#include "fsfw/action/HasActionsIF.h"
|
|
#include "fsfw/devicehandlers/CookieIF.h"
|
|
#include "fsfw/devicehandlers/DeviceHandlerIF.h"
|
|
#include "fsfw/objectmanager/SystemObject.h"
|
|
#include "fsfw/power/PowerSwitchIF.h"
|
|
#include "fsfw/returnvalues/returnvalue.h"
|
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
|
#include "fsfw/timemanager/Countdown.h"
|
|
#include "fsfw_hal/common/gpio/GpioIF.h"
|
|
#include "mission/memory/SdCardMountedIF.h"
|
|
#include "returnvalues/classIds.h"
|
|
|
|
/**
|
|
* @brief This class is used to control the solar array deployment.
|
|
*
|
|
* @author J. Meier
|
|
*/
|
|
class SolarArrayDeploymentHandler : public ExecutableObjectIF,
|
|
public SystemObject,
|
|
public HasActionsIF {
|
|
public:
|
|
// Burn them for a custom amount limited by 120 secs
|
|
static constexpr DeviceCommandId_t DEPLOY_SOLAR_ARRAYS_MANUALLY = 0x5;
|
|
// Careful with these command, not automatic off handling!
|
|
static constexpr DeviceCommandId_t FORCE_DEPLY_ON = 0x06;
|
|
static constexpr DeviceCommandId_t FORCE_DEPLY_OFF = 0x07;
|
|
|
|
static constexpr uint32_t FIRST_BURN_START_TIME = config::SA_DEPL_BURN_TIME_SECS;
|
|
static constexpr uint32_t FIRST_BURN_END_TIME = FIRST_BURN_START_TIME + config::SA_DEPL_BURN_TIME_SECS;
|
|
static constexpr uint32_t FIRST_WAIT_START_TIME = FIRST_BURN_END_TIME;
|
|
static constexpr uint32_t FIRST_WAIT_END_TIME = FIRST_BURN_END_TIME + config::SA_DEPL_WAIT_TIME_SECS;
|
|
static constexpr uint32_t SECOND_BURN_START_TIME = FIRST_WAIT_END_TIME;
|
|
static constexpr uint32_t SECOND_BURN_END_TIME = SECOND_BURN_START_TIME + config::SA_DEPL_WAIT_TIME_SECS;
|
|
|
|
static constexpr char SD_0_DEPL_FILE[] = "/mnt/sd0/conf/deployment";
|
|
static constexpr char SD_1_DEPL_FILE[] = "/mnt/sd1/conf/deployment";
|
|
static constexpr char SD_0_DEPLY_INFO[] = "/mnt/sd0/conf/deployment_info.txt";
|
|
static constexpr char SD_1_DEPLY_INFO[] = "/mnt/sd1/conf/deployment_info.txt";
|
|
|
|
static constexpr char PHASE_INIT_STR[] = "init";
|
|
static constexpr char PHASE_FIRST_BURN_STR[] = "first_burn";
|
|
static constexpr char PHASE_WAIT_STR[] = "wait";
|
|
static constexpr char PHASE_SECOND_BURN_STR[] = "second_burn";
|
|
static constexpr char PHASE_DONE[] = "done";
|
|
/**
|
|
* @brief constructor
|
|
*
|
|
* @param setObjectId The object id of the SolarArrayDeploymentHandler.
|
|
* @param gpioDriverId The id of the gpio com if.
|
|
* @param gpioCookie GpioCookie holding information about the gpios used to switch the
|
|
* transistors.
|
|
* @param mainLineSwitcherObjectId The object id of the object responsible for switching
|
|
* the 8V power source. This is normally the PCDU.
|
|
* @param mainLineSwitch The id of the main line switch. This is defined in
|
|
* powerSwitcherList.h.
|
|
* @param deplSA1 gpioId of the GPIO controlling the deployment 1 transistor.
|
|
* @param deplSA2 gpioId of the GPIO controlling the deployment 2 transistor.
|
|
* @param burnTimeMs Time duration the power will be applied to the burn wires.
|
|
*/
|
|
SolarArrayDeploymentHandler(object_id_t setObjectId, GpioIF& gpio,
|
|
PowerSwitchIF& mainLineSwitcher, pcdu::Switches mainLineSwitch,
|
|
gpioId_t deplSA1, gpioId_t deplSA2, SdCardMountedIF& sdcMountedIF);
|
|
|
|
virtual ~SolarArrayDeploymentHandler();
|
|
|
|
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
|
|
|
virtual MessageQueueId_t getCommandQueue() const override;
|
|
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
|
const uint8_t* data, size_t size) override;
|
|
virtual ReturnValue_t initialize() override;
|
|
|
|
private:
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::SA_DEPL_HANDLER;
|
|
static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0);
|
|
static const ReturnValue_t DEPLOYMENT_ALREADY_EXECUTING = MAKE_RETURN_CODE(0xA1);
|
|
static const ReturnValue_t MAIN_SWITCH_TIMEOUT_FAILURE = MAKE_RETURN_CODE(0xA2);
|
|
static const ReturnValue_t SWITCHING_DEPL_SA1_FAILED = MAKE_RETURN_CODE(0xA3);
|
|
static const ReturnValue_t SWITCHING_DEPL_SA2_FAILED = MAKE_RETURN_CODE(0xA4);
|
|
|
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SA_DEPL_HANDLER;
|
|
static const Event MAIN_SWITCH_ON_TIMEOUT = MAKE_EVENT(0, severity::LOW);
|
|
static const Event MAIN_SWITCH_OFF_TIMEOUT = MAKE_EVENT(1, severity::LOW);
|
|
static const Event DEPLOYMENT_FAILED = MAKE_EVENT(2, severity::HIGH);
|
|
static const Event DEPL_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH);
|
|
static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH);
|
|
|
|
enum AutonomousDeplState {
|
|
INIT,
|
|
FIRST_BURN,
|
|
WAIT,
|
|
SECOND_BURN,
|
|
DONE
|
|
};
|
|
// enum StateMachine {
|
|
// WAIT_ON_DELOYMENT_COMMAND,
|
|
// SWITCH_8V_ON,
|
|
// WAIT_ON_8V_SWITCH,
|
|
// SWITCH_DEPL_GPIOS,
|
|
// WAIT_ON_DEPLOYMENT_FINISH,
|
|
// WAIT_FOR_MAIN_SWITCH_OFF
|
|
// };
|
|
//
|
|
// 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.
|
|
*/
|
|
Countdown mainSwitchCountdown;
|
|
|
|
/**
|
|
* This countdown is used to wait for the burn wire being successful cut.
|
|
*/
|
|
// Countdown deploymentCountdown;
|
|
|
|
/**
|
|
* The message queue id of the component commanding an action will be stored in this variable.
|
|
* This is necessary to send later the action finish replies.
|
|
*/
|
|
MessageQueueId_t rememberCommanderId = 0;
|
|
|
|
/** Size of command queue */
|
|
size_t cmdQueueSize = 20;
|
|
GpioIF& gpioInterface;
|
|
gpioId_t deplSA1;
|
|
gpioId_t deplSA2;
|
|
|
|
/**
|
|
* After initialization this pointer will hold the reference to the main line switcher object.
|
|
*/
|
|
PowerSwitchIF& mainLineSwitcher;
|
|
|
|
/** 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();
|
|
|
|
/**
|
|
* @brief This function performs actions dependent on the current state.
|
|
*/
|
|
void handleStateMachine();
|
|
|
|
/**
|
|
* @brief This function polls the 8V switch state and changes the state machine when the
|
|
* switch has been enabled.
|
|
*/
|
|
void performWaitOn8VActions();
|
|
|
|
/**
|
|
* @brief This functions handles the switching of the solar array deployment transistors.
|
|
*/
|
|
void deploymentTransistorsOn();
|
|
|
|
/**
|
|
* @brief This function performs actions to finish the deployment. Essentially switches
|
|
* are turned of after the burn time has expired.
|
|
*/
|
|
// void handleDeploymentFinish();
|
|
};
|
|
|
|
#endif /* MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ */
|