v1.15.0 #311

Merged
muellerr merged 107 commits from develop into main 2022-10-27 11:28:49 +02:00
2 changed files with 94 additions and 62 deletions
Showing only changes of commit db7f7bdae2 - Show all commits

View File

@ -142,7 +142,7 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(const char* filename) {
lineNum++; lineNum++;
} }
bool updateUptime = false; bool updateUptime = false;
if(opDivider.checkAndIncrement()) { if (opDivider.checkAndIncrement()) {
if (initUptime) { if (initUptime) {
secsSinceBoot = initUptime.value(); secsSinceBoot = initUptime.value();
} }
@ -158,21 +158,21 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(const char* filename) {
startFsm(false, false); startFsm(false, false);
} }
} }
if(stateSwitch or updateUptime) { if (stateSwitch or updateUptime) {
std::ofstream of(filename); std::ofstream of(filename);
of << "phase: " ; of << "phase: ";
if(deplState == AutonomousDeplState::INIT) { if (deplState == AutonomousDeplState::INIT) {
of << PHASE_INIT_STR << "\n"; of << PHASE_INIT_STR << "\n";
} else if(deplState == AutonomousDeplState::FIRST_BURN) { } else if (deplState == AutonomousDeplState::FIRST_BURN) {
of << PHASE_FIRST_BURN_STR << "\n"; of << PHASE_FIRST_BURN_STR << "\n";
} else if(deplState == AutonomousDeplState::WAIT) { } else if (deplState == AutonomousDeplState::WAIT) {
of << PHASE_WAIT_STR << "\n"; of << PHASE_WAIT_STR << "\n";
} else if(deplState == AutonomousDeplState::SECOND_BURN) { } else if (deplState == AutonomousDeplState::SECOND_BURN) {
of << PHASE_SECOND_BURN_STR << "\n"; of << PHASE_SECOND_BURN_STR << "\n";
} else if(deplState == AutonomousDeplState::DONE) { } else if (deplState == AutonomousDeplState::DONE) {
of << PHASE_DONE<< "\n"; of << PHASE_DONE << "\n";
} }
of << "secs_since_start: " << std::to_string(secsSinceBoot) << "\n"; of << "secs_since_start: " << std::to_string(secsSinceBoot) << "\n";
} }
return true; return true;
} }
@ -192,8 +192,9 @@ void SolarArrayDeploymentHandler::handleStateMachine() {
stateMachine = WAIT_MAIN_POWER_ON; stateMachine = WAIT_MAIN_POWER_ON;
} }
if (stateMachine == MAIN_POWER_OFF) { if (stateMachine == MAIN_POWER_OFF) {
// This should never fail // These should never fail
deploymentTransistorsOff(); deploymentTransistorsOff(DeploymentChannels::SA_1);
deploymentTransistorsOff(DeploymentChannels::SA_2);
mainLineSwitcher.sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON); mainLineSwitcher.sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_ON);
mainSwitchCountdown.setTimeout(mainLineSwitcher.getSwitchDelayMs()); mainSwitchCountdown.setTimeout(mainLineSwitcher.getSwitchDelayMs());
stateMachine = WAIT_MAIN_POWER_OFF; stateMachine = WAIT_MAIN_POWER_OFF;
@ -210,7 +211,7 @@ void SolarArrayDeploymentHandler::handleStateMachine() {
} }
if (stateMachine == SWITCH_DEPL_GPIOS) { if (stateMachine == SWITCH_DEPL_GPIOS) {
// This should never fail // This should never fail
deploymentTransistorsOn(); // deploymentTransistorsOn();
finishFsm(returnvalue::OK); finishFsm(returnvalue::OK);
} }
} }
@ -262,42 +263,50 @@ void SolarArrayDeploymentHandler::finishFsm(ReturnValue_t resultForActionHelper)
} }
} }
ReturnValue_t SolarArrayDeploymentHandler::deploymentTransistorsOn() { ReturnValue_t SolarArrayDeploymentHandler::deploymentTransistorsOn(DeploymentChannels channel) {
ReturnValue_t result = gpioInterface.pullHigh(deplSA1); ReturnValue_t result = returnvalue::FAILED;
if (result != returnvalue::OK) { if (channel == DeploymentChannels::SA_1) {
sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" result = gpioInterface.pullHigh(deplSA1);
" array deployment switch 1 high " if (result != returnvalue::OK) {
<< std::endl; sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
// If gpio switch high failed, state machine is reset to wait for a command re-initiating " array deployment switch 1 high "
// the deployment sequence. << std::endl;
triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED); // If gpio switch high failed, state machine is reset to wait for a command re-initiating
} // the deployment sequence.
result = gpioInterface.pullHigh(deplSA2); triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED);
if (result != returnvalue::OK) { }
sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" } else if (channel == DeploymentChannels::SA_2) {
" array deployment switch 2 high " result = gpioInterface.pullHigh(deplSA2);
<< std::endl; if (result != returnvalue::OK) {
triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED); sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
" array deployment switch 2 high "
<< std::endl;
triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED);
}
} }
return result; return result;
} }
ReturnValue_t SolarArrayDeploymentHandler::deploymentTransistorsOff() { ReturnValue_t SolarArrayDeploymentHandler::deploymentTransistorsOff(DeploymentChannels channel) {
ReturnValue_t result = gpioInterface.pullLow(deplSA1); ReturnValue_t result = returnvalue::FAILED;
if (result != returnvalue::OK) { if (channel == DeploymentChannels::SA_1) {
sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" result = gpioInterface.pullLow(deplSA1);
" array deployment switch 1 low" if (result != returnvalue::OK) {
<< std::endl; sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
// If gpio switch high failed, state machine is reset to wait for a command re-initiating " array deployment switch 1 high "
// the deployment sequence. << std::endl;
triggerEvent(DEPL_SA1_GPIO_SWTICH_ON_FAILED); // If gpio switch high failed, state machine is reset to wait for a command re-initiating
} // the deployment sequence.
result = gpioInterface.pullLow(deplSA2); triggerEvent(DEPL_SA1_GPIO_SWTICH_OFF_FAILED);
if (result != returnvalue::OK) { }
sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar" } else if (channel == DeploymentChannels::SA_2) {
" array deployment switch 2 low" result = gpioInterface.pullLow(deplSA2);
<< std::endl; if (result != returnvalue::OK) {
triggerEvent(DEPL_SA2_GPIO_SWTICH_ON_FAILED); sif::debug << "SolarArrayDeploymentHandler::handleStateMachine: Failed to pull solar"
" array deployment switch 2 high "
<< std::endl;
triggerEvent(DEPL_SA2_GPIO_SWTICH_OFF_FAILED);
}
} }
return result; return result;
} }
@ -318,13 +327,18 @@ void SolarArrayDeploymentHandler::readCommandQueue() {
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) {
// TODO: Finish command handling
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
if (actionId == FORCE_DEPLY_ON) {
}
if (actionId == FORCE_DEPLY_OFF) {
}
if (actionId == DEPLOY_SOLAR_ARRAYS_MANUALLY) { if (actionId == DEPLOY_SOLAR_ARRAYS_MANUALLY) {
ManualDeploymentCommand cmd;
if (size < cmd.getSerializedSize()) {
return HasActionsIF::INVALID_PARAMETERS;
}
result = cmd.deSerialize(&data, &size, SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
} else {
return HasActionsIF::INVALID_ACTION_ID;
} }
return result; return result;
} }

View File

@ -2,6 +2,7 @@
#define MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ #define MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_
#include <fsfw/globalfunctions/PeriodicOperationDivider.h> #include <fsfw/globalfunctions/PeriodicOperationDivider.h>
#include <unordered_map> #include <unordered_map>
#include "devices/powerSwitcherList.h" #include "devices/powerSwitcherList.h"
@ -13,12 +14,30 @@
#include "fsfw/objectmanager/SystemObject.h" #include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/power/PowerSwitchIF.h" #include "fsfw/power/PowerSwitchIF.h"
#include "fsfw/returnvalues/returnvalue.h" #include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/serialize/SerialLinkedListAdapter.h"
#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/timemanager/Countdown.h" #include "fsfw/timemanager/Countdown.h"
#include "fsfw_hal/common/gpio/GpioIF.h" #include "fsfw_hal/common/gpio/GpioIF.h"
#include "mission/memory/SdCardMountedIF.h" #include "mission/memory/SdCardMountedIF.h"
#include "returnvalues/classIds.h" #include "returnvalues/classIds.h"
enum DeploymentChannels : uint8_t { SA_1 = 1, SA_2 = 2 };
class ManualDeploymentCommand : SerialLinkedListAdapter<SerializeIF> {
public:
ManualDeploymentCommand() = default;
void setLinks() {
setStart(&burnTime);
burnTime.setNext(&channel);
}
private:
SerializeElement<uint32_t> burnTime;
// Deployment channel SA1 or SA2
SerializeElement<uint8_t> channel;
};
/** /**
* @brief This class is used to control the solar array deployment. * @brief This class is used to control the solar array deployment.
* *
@ -28,11 +47,8 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
public SystemObject, public SystemObject,
public HasActionsIF { public HasActionsIF {
public: public:
// Burn them for a custom amount limited by 120 secs //! Manual deployment of the solar arrays. Burn time and channels are supplied with TC parameters
static constexpr DeviceCommandId_t DEPLOY_SOLAR_ARRAYS_MANUALLY = 0x05; static constexpr DeviceCommandId_t DEPLOY_SOLAR_ARRAYS_MANUALLY = 0x05;
// 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_START_TIME = config::SA_DEPL_BURN_TIME_SECS;
static constexpr uint32_t FIRST_BURN_END_TIME = static constexpr uint32_t FIRST_BURN_END_TIME =
@ -95,6 +111,8 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
static const Event DEPLOYMENT_FAILED = MAKE_EVENT(2, severity::HIGH); 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_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH);
static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH); static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH);
static const Event DEPL_SA1_GPIO_SWTICH_OFF_FAILED = MAKE_EVENT(5, severity::HIGH);
static const Event DEPL_SA2_GPIO_SWTICH_OFF_FAILED = MAKE_EVENT(6, severity::HIGH);
enum AutonomousDeplState { INIT, FIRST_BURN, WAIT, SECOND_BURN, DONE }; enum AutonomousDeplState { INIT, FIRST_BURN, WAIT, SECOND_BURN, DONE };
enum StateMachine { enum StateMachine {
@ -178,8 +196,8 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
/** /**
* @brief This functions handles the switching of the solar array deployment transistors. * @brief This functions handles the switching of the solar array deployment transistors.
*/ */
ReturnValue_t deploymentTransistorsOn(); ReturnValue_t deploymentTransistorsOn(DeploymentChannels channel);
ReturnValue_t deploymentTransistorsOff(); ReturnValue_t deploymentTransistorsOff(DeploymentChannels channel);
}; };
#endif /* MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ */ #endif /* MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ */