continue autonomous depl handling
EIVE/eive-obsw/pipeline/head This commit looks good Details

This commit is contained in:
Robin Müller 2022-10-12 15:19:21 +02:00
parent 6a900693f3
commit 2bc7c7b3ae
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 104 additions and 5 deletions

View File

@ -34,6 +34,10 @@ static constexpr uint8_t LIVE_TM = 0;
static constexpr uint32_t MAX_PATH_SIZE = 100;
static constexpr uint32_t MAX_FILENAME_SIZE = 50;
static constexpr uint32_t SA_DEPL_INIT_BUFFER_SECS = 120;
static constexpr uint32_t SA_DEPL_BURN_TIME_SECS = 90;
static constexpr uint32_t SA_DEPL_WAIT_TIME_SECS = 45 * 60;
} // namespace config
#endif /* COMMON_CONFIG_DEFINITIONS_H_ */

View File

@ -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;

View File

@ -3,6 +3,7 @@
#include <unordered_map>
#include "eive/definitions.h"
#include "devices/powerSwitcherList.h"
#include "events/subsystemIdRanges.h"
#include "fsfw/action/HasActionsIF.h"
@ -26,11 +27,29 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
public SystemObject,
public HasActionsIF {
public:
// Burn them for a custom amount limited by 120 secs
static constexpr DeviceCommandId_t DEPLOY_SOLAR_ARRAYS_MANUALLY = 0x5;
static const char SD_0_DEPL_FILE[] = "/mnt/sd0/conf/deployment";
static const char SD_1_DEPL_FILE[] = "/mnt/sd1/conf/deployment";
static const char SD_0_DEPLY_INFO[] = "/mnt/sd0/conf/deployment_info.txt";
static const char SD_1_DEPLY_INFO[] = "/mnt/sd1/conf/deployment_info.txt";
// Careful with these command, not automatic off handling!
static constexpr DeviceCommandId_t FORCE_DEPLY_ON = 0x06;
static constexpr DeviceCommandId_t FORCE_DEPLY_OFF = 0x07;
static constexpr uint32_t FIRST_BURN_START_TIME = config::SA_DEPL_BURN_TIME_SECS;
static constexpr uint32_t FIRST_BURN_END_TIME = FIRST_BURN_START_TIME + config::SA_DEPL_BURN_TIME_SECS;
static constexpr uint32_t FIRST_WAIT_START_TIME = FIRST_BURN_END_TIME;
static constexpr uint32_t FIRST_WAIT_END_TIME = FIRST_BURN_END_TIME + config::SA_DEPL_WAIT_TIME_SECS;
static constexpr uint32_t SECOND_BURN_START_TIME = FIRST_WAIT_END_TIME;
static constexpr uint32_t SECOND_BURN_END_TIME = SECOND_BURN_START_TIME + config::SA_DEPL_WAIT_TIME_SECS;
static constexpr char SD_0_DEPL_FILE[] = "/mnt/sd0/conf/deployment";
static constexpr char SD_1_DEPL_FILE[] = "/mnt/sd1/conf/deployment";
static constexpr char SD_0_DEPLY_INFO[] = "/mnt/sd0/conf/deployment_info.txt";
static constexpr char SD_1_DEPLY_INFO[] = "/mnt/sd1/conf/deployment_info.txt";
static constexpr char PHASE_INIT_STR[] = "init";
static constexpr char PHASE_FIRST_BURN_STR[] = "first_burn";
static constexpr char PHASE_WAIT_STR[] = "wait";
static constexpr char PHASE_SECOND_BURN_STR[] = "second_burn";
static constexpr char PHASE_DONE[] = "done";
/**
* @brief constructor
*
@ -74,6 +93,13 @@ class SolarArrayDeploymentHandler : public ExecutableObjectIF,
static const Event DEPL_SA1_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(3, severity::HIGH);
static const Event DEPL_SA2_GPIO_SWTICH_ON_FAILED = MAKE_EVENT(4, severity::HIGH);
enum AutonomousDeplState {
INIT,
FIRST_BURN,
WAIT,
SECOND_BURN,
DONE
};
// enum StateMachine {
// WAIT_ON_DELOYMENT_COMMAND,
// SWITCH_8V_ON,