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 34 additions and 33 deletions
Showing only changes of commit d97e0a1a6a - Show all commits

View File

@ -155,10 +155,10 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(const char* filename) {
deplState == AutonomousDeplState::SECOND_BURN) {
// TODO: Update to be channel specific
// startFsmOn(channel, config::SA_DEPL_BURN_TIME_SECS);
//startFsm(true, true);
// startFsm(true, true);
} else if (deplState == AutonomousDeplState::WAIT or deplState == AutonomousDeplState::DONE) {
startFsmOff();
//startFsm(false, false);
// startFsm(false, false);
}
}
if (stateSwitch or updateUptime) {
@ -215,8 +215,8 @@ void SolarArrayDeploymentHandler::handleStateMachine() {
burnCountdown.setTimeout(fsmInfo.burnCountdown);
stateMachine = CHANNEL_ON;
}
if(stateMachine == CHANNEL_ON) {
if(burnCountdown.hasTimedOut()) {
if (stateMachine == CHANNEL_ON) {
if (burnCountdown.hasTimedOut()) {
allOff();
stateMachine = WAIT_MAIN_POWER_OFF;
}
@ -257,7 +257,7 @@ bool SolarArrayDeploymentHandler::startFsmOn(DeploymentChannels channel, uint32_
if (stateMachine != StateMachine::IDLE) {
return false;
}
if(burnCountdown_ > config::SA_DEPL_MAX_BURN_TIME) {
if (burnCountdown_ > config::SA_DEPL_MAX_BURN_TIME) {
burnCountdown_ = config::SA_DEPL_MAX_BURN_TIME;
}
fsmInfo.onOff = true;
@ -268,7 +268,7 @@ bool SolarArrayDeploymentHandler::startFsmOn(DeploymentChannels channel, uint32_
}
void SolarArrayDeploymentHandler::startFsmOff() {
if(stateMachine != StateMachine::IDLE) {
if (stateMachine != StateMachine::IDLE) {
// off commands override the state machine. Cancel any active action commands.
finishFsm(returnvalue::FAILED);
}
@ -282,7 +282,8 @@ void SolarArrayDeploymentHandler::finishFsm(ReturnValue_t resultForActionHelper)
stateMachine = StateMachine::IDLE;
if (actionActive) {
bool success = false;
if(resultForActionHelper == returnvalue::OK or resultForActionHelper == HasActionsIF::EXECUTION_FINISHED) {
if (resultForActionHelper == returnvalue::OK or
resultForActionHelper == HasActionsIF::EXECUTION_FINISHED) {
success = true;
}
actionHelper.finish(success, rememberCommanderId, activeCmd, resultForActionHelper);
@ -373,16 +374,16 @@ ReturnValue_t SolarArrayDeploymentHandler::executeAction(ActionId_t actionId,
uint32_t burnCountdown = cmd.getBurnTime();
DeploymentChannels channel;
result = cmd.getChannel(channel);
if(result != returnvalue::OK) {
if (result != returnvalue::OK) {
return result;
}
if (not startFsmOn(channel, burnCountdown)) {
return HasActionsIF::IS_BUSY;
}
return result;
} else if(actionId == SWITCH_OFF_DEPLOYMENT) {
startFsmOff();
return result;
} else if (actionId == SWITCH_OFF_DEPLOYMENT) {
startFsmOff();
return result;
} else {
return HasActionsIF::INVALID_ACTION_ID;
}

View File

@ -32,9 +32,7 @@ class ManualDeploymentCommand : public SerialLinkedListAdapter<SerializeIF> {
burnTime.setNext(&channel);
}
uint32_t getBurnTime() const {
return burnTime.entry;
}
uint32_t getBurnTime() const { return burnTime.entry; }
ReturnValue_t getChannel(DeploymentChannels& channel_) const {
if (channel.entry == 1 or channel.entry == 2) {
@ -111,6 +109,26 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
virtual ReturnValue_t initialize() override;
private:
enum AutonomousDeplState { INIT, FIRST_BURN, WAIT, SECOND_BURN, DONE };
enum StateMachine {
IDLE,
MAIN_POWER_ON,
MAIN_POWER_OFF,
WAIT_MAIN_POWER_ON,
WAIT_MAIN_POWER_OFF,
SWITCH_DEPL_GPIOS,
CHANNEL_ON
};
struct FsmInfo {
DeploymentChannels channel;
// false if OFF, true is ON
bool onOff;
bool dryRun;
uint32_t burnCountdown = config::SA_DEPL_MAX_BURN_TIME;
};
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);
@ -127,17 +145,7 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
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 {
IDLE,
MAIN_POWER_ON,
MAIN_POWER_OFF,
WAIT_MAIN_POWER_ON,
WAIT_MAIN_POWER_OFF,
SWITCH_DEPL_GPIOS,
CHANNEL_ON
};
FsmInfo fsmInfo;
StateMachine stateMachine = IDLE;
bool actionActive = false;
ActionId_t activeCmd = HasActionsIF::INVALID_ACTION_ID;
@ -148,14 +156,6 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
bool startFsmOn(DeploymentChannels channel, uint32_t burnCountdown);
void startFsmOff();
struct FsmInfo {
DeploymentChannels channel;
// false if OFF, true is ON
bool onOff;
uint32_t burnCountdown = config::SA_DEPL_MAX_BURN_TIME;
} fsmInfo;
void finishFsm(ReturnValue_t resultForActionHelper);
ReturnValue_t performAutonomousDepl(sd::SdCard sdCard);