continue autonomous depl handling
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
SolarArrayDeploymentHandler::SolarArrayDeploymentHandler(object_id_t setObjectId_,
|
||||
GpioIF& gpioInterface,
|
||||
@@ -49,6 +51,73 @@ ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCod
|
||||
}
|
||||
|
||||
ReturnValue_t SolarArrayDeploymentHandler::performAutonomousDepl(sd::SdCard sdCard) {
|
||||
using namespace std::filesystem;
|
||||
using namespace std;
|
||||
auto initFile = [](const char* filename) {
|
||||
ofstream of(filename);
|
||||
of << "phase: init\n";
|
||||
of << "secs_since_start: 0\n";
|
||||
};
|
||||
auto handler = [](const char* filename) {
|
||||
|
||||
ifstream file(filename);
|
||||
string line;
|
||||
string word;
|
||||
unsigned int lineNum = 0;
|
||||
AutonomousDeplState deplState;
|
||||
while(std::getline(file, line)) {
|
||||
if(lineNum == 0) {
|
||||
std::istringstream iss(line);
|
||||
if (lineNum == 0) {
|
||||
iss >> word;
|
||||
if(word.find("phase:") == string::npos) {
|
||||
return false;
|
||||
}
|
||||
iss >> word;
|
||||
if(word.find(PHASE_INIT_STR) != string::npos) {
|
||||
deplState = AutonomousDeplState::INIT;
|
||||
} else if(word.find(PHASE_FIRST_BURN_STR) != string::npos) {
|
||||
deplState = AutonomousDeplState::FIRST_BURN;
|
||||
} else if(word.find(PHASE_WAIT_STR) != string::npos) {
|
||||
deplState = AutonomousDeplState::WAIT;
|
||||
} else if(word.find(PHASE_SECOND_BURN_STR) != string::npos) {
|
||||
deplState = AutonomousDeplState::SECOND_BURN;
|
||||
} else if(word.find(PHASE_DONE) != string::npos) {
|
||||
deplState = AutonomousDeplState::DONE;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if(lineNum == 1) {
|
||||
iss >> word;
|
||||
if(word.find("phase:") == string::npos) {
|
||||
return false;
|
||||
}
|
||||
uint32_t secsSinceBoot = 0;
|
||||
iss >> secsSinceBoot;
|
||||
if (iss.bad()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
lineNum++;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
if (sdCard == sd::SdCard::SLOT_0) {
|
||||
if (not exists(SD_0_DEPLY_INFO)) {
|
||||
initFile(SD_0_DEPLY_INFO);
|
||||
}
|
||||
if (not handler(SD_0_DEPLY_INFO)) {
|
||||
initFile(SD_0_DEPLY_INFO);
|
||||
}
|
||||
} else if(sdCard == sd::SdCard::SLOT_1) {
|
||||
if (not exists(SD_1_DEPLY_INFO)) {
|
||||
initFile(SD_1_DEPLY_INFO);
|
||||
}
|
||||
if (not handler(SD_1_DEPLY_INFO)) {
|
||||
initFile(SD_1_DEPLY_INFO);
|
||||
}
|
||||
}
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
@@ -176,7 +245,7 @@ void SolarArrayDeploymentHandler::readCommandQueue() {
|
||||
ReturnValue_t SolarArrayDeploymentHandler::executeAction(ActionId_t actionId,
|
||||
MessageQueueId_t commandedBy,
|
||||
const uint8_t* data, size_t size) {
|
||||
ReturnValue_t result;
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
// if (stateMachine != WAIT_ON_DELOYMENT_COMMAND) {
|
||||
// sif::error << "SolarArrayDeploymentHandler::executeAction: Received command while not in"
|
||||
// << "waiting-on-command-state" << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user