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

View File

@ -2,6 +2,7 @@
#define MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
#include <unordered_map>
#include "devices/powerSwitcherList.h"
@ -13,12 +14,30 @@
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/power/PowerSwitchIF.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/serialize/SerialLinkedListAdapter.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"
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.
*
@ -28,11 +47,8 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
public SystemObject,
public HasActionsIF {
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;
// 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 =
@ -95,6 +111,8 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
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);
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 StateMachine {
@ -178,8 +196,8 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
/**
* @brief This functions handles the switching of the solar array deployment transistors.
*/
ReturnValue_t deploymentTransistorsOn();
ReturnValue_t deploymentTransistorsOff();
ReturnValue_t deploymentTransistorsOn(DeploymentChannels channel);
ReturnValue_t deploymentTransistorsOff(DeploymentChannels channel);
};
#endif /* MISSION_DEVICES_SOLARARRAYDEPLOYMENT_H_ */