Merge remote-tracking branch 'origin/develop' into feature_custom_obsw_update_path
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:
@ -54,7 +54,6 @@ CoreController::CoreController(object_id_t objectId, bool enableHkSet)
|
||||
// Set up state of SD card manager and own initial state.
|
||||
// Stopwatch watch;
|
||||
sdcMan->updateSdCardStateFile();
|
||||
sdcMan->updateSdStatePair();
|
||||
SdCardManager::SdStatePair sdStates;
|
||||
sdcMan->getSdCardsStatus(sdStates);
|
||||
auto sdCard = sdcMan->getPreferredSdCard();
|
||||
@ -368,7 +367,7 @@ ReturnValue_t CoreController::initSdCardBlocking() {
|
||||
}
|
||||
|
||||
if (sdInfo.cfgMode == SdCfgMode::COLD_REDUNDANT) {
|
||||
updateSdInfoOther();
|
||||
updateInternalSdInfo();
|
||||
sif::info << "Cold redundant SD card configuration, preferred SD card: "
|
||||
<< static_cast<int>(sdInfo.active) << std::endl;
|
||||
result = sdColdRedundantBlockingInit();
|
||||
@ -404,23 +403,23 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
} else {
|
||||
// Still update SD state file
|
||||
if (sdInfo.cfgMode == SdCfgMode::PASSIVE) {
|
||||
sdFsmState = SdStates::UPDATE_INFO;
|
||||
sdFsmState = SdStates::UPDATE_SD_INFO_END;
|
||||
} else {
|
||||
sdInfo.cycleCount = 0;
|
||||
sdInfo.commandExecuted = false;
|
||||
sdFsmState = SdStates::GET_INFO;
|
||||
sdInfo.commandPending = false;
|
||||
sdFsmState = SdStates::UPDATE_SD_INFO_START;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This lambda checks the non-blocking operation and assigns the new state on success.
|
||||
// It returns true for an operation success and false otherwise
|
||||
auto nonBlockingOpChecking = [&](SdStates newStateOnSuccess, uint16_t maxCycleCount,
|
||||
std::string opPrintout) {
|
||||
// This lambda checks the non-blocking operation of the SD card manager and assigns the new
|
||||
// state on success. It returns true for an operation success and false otherwise
|
||||
auto nonBlockingSdcOpChecking = [&](SdStates newStateOnSuccess, uint16_t maxCycleCount,
|
||||
std::string opPrintout) {
|
||||
SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation);
|
||||
if (status == SdCardManager::OpStatus::SUCCESS) {
|
||||
sdFsmState = newStateOnSuccess;
|
||||
sdInfo.commandExecuted = false;
|
||||
sdInfo.commandPending = false;
|
||||
sdInfo.cycleCount = 0;
|
||||
return true;
|
||||
} else if (sdInfo.cycleCount > 4) {
|
||||
@ -431,26 +430,16 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
return false;
|
||||
};
|
||||
|
||||
if (sdFsmState == SdStates::GET_INFO) {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
if (sdFsmState == SdStates::UPDATE_SD_INFO_START) {
|
||||
if (not sdInfo.commandPending) {
|
||||
// Create updated status file
|
||||
result = sdcMan->updateSdCardStateFile();
|
||||
if (result != returnvalue::OK) {
|
||||
sif::warning << "CoreController::sdStateMachine: Updating SD card state file failed"
|
||||
<< std::endl;
|
||||
}
|
||||
sdFsmState = SdStates::SET_STATE_SELF;
|
||||
sdInfo.commandExecuted = false;
|
||||
sdInfo.cycleCount = 0;
|
||||
} else {
|
||||
nonBlockingOpChecking(SdStates::SET_STATE_SELF, 4, "Updating SDC file");
|
||||
}
|
||||
}
|
||||
|
||||
if (sdFsmState == SdStates::SET_STATE_SELF) {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
result = sdcMan->getSdCardsStatus(sdInfo.currentState);
|
||||
updateSdInfoOther();
|
||||
updateInternalSdInfo();
|
||||
if (sdInfo.active != sd::SdCard::SLOT_0 and sdInfo.active != sd::SdCard::SLOT_1) {
|
||||
sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl;
|
||||
sdInfo.active = sd::SdCard::SLOT_0;
|
||||
@ -478,12 +467,12 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
sdFsmState = SdStates::DETERMINE_OTHER;
|
||||
} else if (sdInfo.activeState == sd::SdState::OFF) {
|
||||
sdCardSetup(sdInfo.active, sd::SdState::ON, sdInfo.activeChar, false);
|
||||
sdInfo.commandExecuted = true;
|
||||
sdInfo.commandPending = true;
|
||||
} else if (sdInfo.activeState == sd::SdState::ON) {
|
||||
sdFsmState = SdStates::MOUNT_SELF;
|
||||
}
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) {
|
||||
if (nonBlockingSdcOpChecking(SdStates::MOUNT_SELF, 10, "Setting SDC state")) {
|
||||
sdInfo.activeState = sd::SdState::ON;
|
||||
currentStateSetter(sdInfo.active, sd::SdState::ON);
|
||||
}
|
||||
@ -491,11 +480,11 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
}
|
||||
|
||||
if (sdFsmState == SdStates::MOUNT_SELF) {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
if (not sdInfo.commandPending) {
|
||||
result = sdCardSetup(sdInfo.active, sd::SdState::MOUNTED, sdInfo.activeChar);
|
||||
sdInfo.commandExecuted = true;
|
||||
sdInfo.commandPending = true;
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) {
|
||||
if (nonBlockingSdcOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) {
|
||||
sdcMan->setActiveSdCard(sdInfo.active);
|
||||
currMntPrefix = sdcMan->getCurrentMountPrefix();
|
||||
sdInfo.activeState = sd::SdState::MOUNTED;
|
||||
@ -532,23 +521,23 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
if (sdFsmState == SdStates::SET_STATE_OTHER) {
|
||||
// Set state of other SD card to ON or OFF, depending on redundancy mode
|
||||
if (sdInfo.cfgMode == SdCfgMode::COLD_REDUNDANT) {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
if (not sdInfo.commandPending) {
|
||||
result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar, false);
|
||||
sdInfo.commandExecuted = true;
|
||||
sdInfo.commandPending = true;
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10,
|
||||
"Switching off other SD card")) {
|
||||
if (nonBlockingSdcOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10,
|
||||
"Switching off other SD card")) {
|
||||
sdInfo.otherState = sd::SdState::OFF;
|
||||
currentStateSetter(sdInfo.other, sd::SdState::OFF);
|
||||
}
|
||||
}
|
||||
} else if (sdInfo.cfgMode == SdCfgMode::HOT_REDUNDANT) {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
if (not sdInfo.commandPending) {
|
||||
result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar, false);
|
||||
sdInfo.commandExecuted = true;
|
||||
sdInfo.commandPending = true;
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10,
|
||||
"Switching on other SD card")) {
|
||||
if (nonBlockingSdcOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10,
|
||||
"Switching on other SD card")) {
|
||||
sdInfo.otherState = sd::SdState::ON;
|
||||
currentStateSetter(sdInfo.other, sd::SdState::ON);
|
||||
}
|
||||
@ -559,21 +548,25 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
if (sdFsmState == SdStates::MOUNT_UNMOUNT_OTHER) {
|
||||
// Mount or unmount other SD card, depending on redundancy mode
|
||||
if (sdInfo.cfgMode == SdCfgMode::COLD_REDUNDANT) {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
if (not sdInfo.commandPending) {
|
||||
result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar);
|
||||
sdInfo.commandExecuted = true;
|
||||
sdInfo.commandPending = true;
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) {
|
||||
if (nonBlockingSdcOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card")) {
|
||||
sdInfo.otherState = sd::SdState::ON;
|
||||
currentStateSetter(sdInfo.other, sd::SdState::ON);
|
||||
} else {
|
||||
sdInfo.otherState = sd::SdState::ON;
|
||||
currentStateSetter(sdInfo.other, sd::SdState::ON);
|
||||
sdFsmState = SdStates::SET_STATE_OTHER;
|
||||
}
|
||||
}
|
||||
} else if (sdInfo.cfgMode == SdCfgMode::HOT_REDUNDANT) {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
if (not sdInfo.commandPending) {
|
||||
result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar);
|
||||
sdInfo.commandExecuted = true;
|
||||
sdInfo.commandPending = true;
|
||||
} else {
|
||||
if (nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card")) {
|
||||
if (nonBlockingSdcOpChecking(SdStates::UPDATE_SD_INFO_END, 4, "Mounting other SD card")) {
|
||||
sdInfo.otherState = sd::SdState::MOUNTED;
|
||||
currentStateSetter(sdInfo.other, sd::SdState::MOUNTED);
|
||||
}
|
||||
@ -582,14 +575,15 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
}
|
||||
|
||||
if (sdFsmState == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) {
|
||||
sdFsmState = SdStates::UPDATE_INFO;
|
||||
} else if (sdFsmState == SdStates::UPDATE_INFO) {
|
||||
sdFsmState = SdStates::UPDATE_SD_INFO_END;
|
||||
} else if (sdFsmState == SdStates::UPDATE_SD_INFO_END) {
|
||||
// Update status file
|
||||
result = sdcMan->updateSdCardStateFile();
|
||||
if (result != returnvalue::OK) {
|
||||
sif::warning << "CoreController::initialize: Updating SD card state file failed" << std::endl;
|
||||
sif::warning << "CoreController: Updating SD card state file failed" << std::endl;
|
||||
}
|
||||
sdInfo.commandExecuted = false;
|
||||
updateInternalSdInfo();
|
||||
sdInfo.commandPending = false;
|
||||
sdFsmState = SdStates::IDLE;
|
||||
sdInfo.cycleCount = 0;
|
||||
sdcMan->setBlocking(false);
|
||||
@ -599,8 +593,16 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
actionHelper.finish(true, sdCommandingInfo.commander, sdCommandingInfo.actionId,
|
||||
returnvalue::OK);
|
||||
}
|
||||
const char *modeStr = "UNKNOWN";
|
||||
if (sdInfo.cfgMode == SdCfgMode::COLD_REDUNDANT) {
|
||||
modeStr = "COLD REDUNDANT";
|
||||
} else if (sdInfo.cfgMode == SdCfgMode::HOT_REDUNDANT) {
|
||||
modeStr = "HOT REDUNDANT";
|
||||
}
|
||||
sif::info << "SD card update into " << modeStr
|
||||
<< " mode finished. Active SD: " << sdInfo.activeChar << std::endl;
|
||||
if (not sdInfo.initFinished) {
|
||||
updateSdInfoOther();
|
||||
updateInternalSdInfo();
|
||||
sdInfo.initFinished = true;
|
||||
sif::info << "SD card initialization finished" << std::endl;
|
||||
}
|
||||
@ -977,7 +979,7 @@ ReturnValue_t CoreController::gracefulShutdownTasks(xsc::Chip chip, xsc::Copy co
|
||||
return result;
|
||||
}
|
||||
|
||||
void CoreController::updateSdInfoOther() {
|
||||
void CoreController::updateInternalSdInfo() {
|
||||
if (sdInfo.active == sd::SdCard::SLOT_0) {
|
||||
sdInfo.activeChar = "0";
|
||||
sdInfo.otherChar = "1";
|
||||
|
Reference in New Issue
Block a user