some more important bugfixes
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
parent
7aca487888
commit
99f703a2eb
@ -36,22 +36,27 @@ SolarArrayDeploymentHandler::~SolarArrayDeploymentHandler() = default;
|
||||
|
||||
ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCode) {
|
||||
using namespace std::filesystem;
|
||||
auto activeSdc = sdcMan.getActiveSdCard();
|
||||
if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and
|
||||
sdcMan.isSdCardUsable(activeSdc.value())) {
|
||||
if (exists(SD_0_DEPL_FILE)) {
|
||||
// perform autonomous deployment handling
|
||||
performAutonomousDepl(sd::SdCard::SLOT_0, dryRunStringInFile(SD_0_DEPL_FILE));
|
||||
}
|
||||
} else if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_1 and
|
||||
sdcMan.isSdCardUsable(activeSdc.value())) {
|
||||
if (exists(SD_1_DEPL_FILE)) {
|
||||
// perform autonomous deployment handling
|
||||
performAutonomousDepl(sd::SdCard::SLOT_1, dryRunStringInFile(SD_1_DEPL_FILE));
|
||||
if (opDivider.checkAndIncrement()) {
|
||||
auto activeSdc = sdcMan.getActiveSdCard();
|
||||
if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and
|
||||
sdcMan.isSdCardUsable(activeSdc.value())) {
|
||||
if (exists(SD_0_DEPL_FILE)) {
|
||||
// perform autonomous deployment handling
|
||||
performAutonomousDepl(sd::SdCard::SLOT_0, dryRunStringInFile(SD_0_DEPL_FILE));
|
||||
}
|
||||
} else if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_1 and
|
||||
sdcMan.isSdCardUsable(activeSdc.value())) {
|
||||
if (exists(SD_1_DEPL_FILE)) {
|
||||
// perform autonomous deployment handling
|
||||
performAutonomousDepl(sd::SdCard::SLOT_1, dryRunStringInFile(SD_1_DEPL_FILE));
|
||||
}
|
||||
}
|
||||
}
|
||||
readCommandQueue();
|
||||
handleStateMachine();
|
||||
if (firstCycle) {
|
||||
firstCycle = false;
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
@ -113,17 +118,21 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(const char* filename, bo
|
||||
}
|
||||
} else if (lineNum == 1) {
|
||||
iss >> word;
|
||||
if (iss.bad()) {
|
||||
return false;
|
||||
}
|
||||
if (word.find("secs_since_start:") == string::npos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
iss >> secsSinceBoot;
|
||||
if (not initUptime) {
|
||||
initUptime = secsSinceBoot;
|
||||
}
|
||||
if (iss.bad()) {
|
||||
return false;
|
||||
}
|
||||
if (not initUptime) {
|
||||
initUptime = secsSinceBoot;
|
||||
}
|
||||
|
||||
auto switchCheck = [&](AutonomousDeplState expected) {
|
||||
if (deplState != expected) {
|
||||
deplState = expected;
|
||||
@ -143,39 +152,34 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(const char* filename, bo
|
||||
}
|
||||
lineNum++;
|
||||
}
|
||||
bool updateUptime = false;
|
||||
if (opDivider.checkAndIncrement()) {
|
||||
if (initUptime) {
|
||||
secsSinceBoot = initUptime.value();
|
||||
}
|
||||
// Uptime has increased by X seconds so we need to update the uptime count inside the file
|
||||
secsSinceBoot += Clock::getUptime().tv_sec;
|
||||
updateUptime = true;
|
||||
if (initUptime) {
|
||||
secsSinceBoot = initUptime.value();
|
||||
}
|
||||
if (stateSwitch) {
|
||||
// Uptime has increased by X seconds so we need to update the uptime count inside the file
|
||||
secsSinceBoot += Clock::getUptime().tv_sec;
|
||||
if (stateSwitch or firstCycle) {
|
||||
if (deplState == AutonomousDeplState::FIRST_BURN or
|
||||
deplState == AutonomousDeplState::SECOND_BURN) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
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";
|
||||
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;
|
||||
}
|
||||
|
||||
@ -287,7 +291,7 @@ void SolarArrayDeploymentHandler::startFsmOff() {
|
||||
}
|
||||
fsmInfo.onOff = false;
|
||||
retryCounter = 0;
|
||||
stateMachine = StateMachine::MAIN_POWER_ON;
|
||||
stateMachine = StateMachine::MAIN_POWER_OFF;
|
||||
}
|
||||
|
||||
void SolarArrayDeploymentHandler::finishFsm(ReturnValue_t resultForActionHelper) {
|
||||
|
@ -151,6 +151,7 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
|
||||
FsmInfo fsmInfo;
|
||||
StateMachine stateMachine = IDLE;
|
||||
bool actionActive = false;
|
||||
bool firstCycle = true;
|
||||
ActionId_t activeCmd = HasActionsIF::INVALID_ACTION_ID;
|
||||
std::optional<uint64_t> initUptime;
|
||||
PeriodicOperationDivider opDivider = PeriodicOperationDivider(5);
|
||||
|
Loading…
Reference in New Issue
Block a user