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 46 additions and 41 deletions
Showing only changes of commit 99f703a2eb - Show all commits

View File

@ -36,6 +36,7 @@ SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() = default;
ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) { ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) {
using namespace std::filesystem; using namespace std::filesystem;
if (opDivider.checkAndIncrement()) {
auto activeSdc = sdcMan.getActiveSdCard(); auto activeSdc = sdcMan.getActiveSdCard();
if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and
sdcMan.isSdCardUsable(activeSdc.value())) { sdcMan.isSdCardUsable(activeSdc.value())) {
@ -50,8 +51,12 @@ ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCod
performAutonomousDepl(sd::SdCard::SLOT_1, dryRunStringInFile(SD_1_DEPL_FILE)); performAutonomousDepl(sd::SdCard::SLOT_1, dryRunStringInFile(SD_1_DEPL_FILE));
} }
} }
}
readCommandQueue(); readCommandQueue();
handleStateMachine(); handleStateMachine();
if (firstCycle) {
firstCycle = false;
}
return returnvalue::OK; return returnvalue::OK;
} }
@ -113,17 +118,21 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(const char* filename, bo
} }
} else if (lineNum == 1) { } else if (lineNum == 1) {
iss >> word; iss >> word;
if (iss.bad()) {
return false;
}
if (word.find("secs_since_start:") == string::npos) { if (word.find("secs_since_start:") == string::npos) {
return false; return false;
} }
iss >> secsSinceBoot; iss >> secsSinceBoot;
if (not initUptime) {
initUptime = secsSinceBoot;
}
if (iss.bad()) { if (iss.bad()) {
return false; return false;
} }
if (not initUptime) {
initUptime = secsSinceBoot;
}
auto switchCheck = [&](AutonomousDeplState expected) { auto switchCheck = [&](AutonomousDeplState expected) {
if (deplState != expected) { if (deplState != expected) {
deplState = expected; deplState = expected;
@ -143,24 +152,20 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(const char* filename, bo
} }
lineNum++; lineNum++;
} }
bool updateUptime = false;
if (opDivider.checkAndIncrement()) {
if (initUptime) { if (initUptime) {
secsSinceBoot = initUptime.value(); secsSinceBoot = initUptime.value();
} }
// Uptime has increased by X seconds so we need to update the uptime count inside the file // Uptime has increased by X seconds so we need to update the uptime count inside the file
secsSinceBoot += Clock::getUptime().tv_sec; secsSinceBoot += Clock::getUptime().tv_sec;
updateUptime = true; if (stateSwitch or firstCycle) {
}
if (stateSwitch) {
if (deplState == AutonomousDeplState::FIRST_BURN or if (deplState == AutonomousDeplState::FIRST_BURN or
deplState == AutonomousDeplState::SECOND_BURN) { deplState == AutonomousDeplState::SECOND_BURN) {
startFsmOn(config::SA_DEPL_BURN_TIME_SECS, dryRun); startFsmOn(config::SA_DEPL_BURN_TIME_SECS, dryRun);
} else if (deplState == AutonomousDeplState::WAIT or deplState == AutonomousDeplState::DONE) { } else if (deplState == AutonomousDeplState::WAIT or deplState == AutonomousDeplState::DONE or
deplState == AutonomousDeplState::INIT) {
startFsmOff(); startFsmOff();
} }
} }
if (stateSwitch or updateUptime) {
std::ofstream of(filename); std::ofstream of(filename);
of << "phase: "; of << "phase: ";
if (deplState == AutonomousDeplState::INIT) { if (deplState == AutonomousDeplState::INIT) {
@ -175,7 +180,6 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(const char* filename, bo
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;
} }
@ -287,7 +291,7 @@ void SolarArrayDeploymentHandler::startFsmOff() {
} }
fsmInfo.onOff = false; fsmInfo.onOff = false;
retryCounter = 0; retryCounter = 0;
stateMachine = StateMachine::MAIN_POWER_ON; stateMachine = StateMachine::MAIN_POWER_OFF;
} }
void SolarArrayDeploymentHandler::finishFsm(ReturnValue_t resultForActionHelper) { void SolarArrayDeploymentHandler::finishFsm(ReturnValue_t resultForActionHelper) {

View File

@ -151,6 +151,7 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
FsmInfo fsmInfo; FsmInfo fsmInfo;
StateMachine stateMachine = IDLE; StateMachine stateMachine = IDLE;
bool actionActive = false; bool actionActive = false;
bool firstCycle = true;
ActionId_t activeCmd = HasActionsIF::INVALID_ACTION_ID; ActionId_t activeCmd = HasActionsIF::INVALID_ACTION_ID;
std::optional<uint64_t> initUptime; std::optional<uint64_t> initUptime;
PeriodicOperationDivider opDivider = PeriodicOperationDivider(5); PeriodicOperationDivider opDivider = PeriodicOperationDivider(5);