v1.15.0 #311
@ -36,22 +36,27 @@ 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;
|
||||||
auto activeSdc = sdcMan.getActiveSdCard();
|
if (opDivider.checkAndIncrement()) {
|
||||||
if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and
|
auto activeSdc = sdcMan.getActiveSdCard();
|
||||||
sdcMan.isSdCardUsable(activeSdc.value())) {
|
if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and
|
||||||
if (exists(SD_0_DEPL_FILE)) {
|
sdcMan.isSdCardUsable(activeSdc.value())) {
|
||||||
// perform autonomous deployment handling
|
if (exists(SD_0_DEPL_FILE)) {
|
||||||
performAutonomousDepl(sd::SdCard::SLOT_0, dryRunStringInFile(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())) {
|
} else if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_1 and
|
||||||
if (exists(SD_1_DEPL_FILE)) {
|
sdcMan.isSdCardUsable(activeSdc.value())) {
|
||||||
// perform autonomous deployment handling
|
if (exists(SD_1_DEPL_FILE)) {
|
||||||
performAutonomousDepl(sd::SdCard::SLOT_1, dryRunStringInFile(SD_1_DEPL_FILE));
|
// perform autonomous deployment handling
|
||||||
|
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,39 +152,34 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(const char* filename, bo
|
|||||||
}
|
}
|
||||||
lineNum++;
|
lineNum++;
|
||||||
}
|
}
|
||||||
bool updateUptime = false;
|
if (initUptime) {
|
||||||
if (opDivider.checkAndIncrement()) {
|
secsSinceBoot = initUptime.value();
|
||||||
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 (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
|
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) {
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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) {
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user