From 5d721706f3e4a3392e1dd08fe52d56eb6d98c7f0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 14 Oct 2022 14:17:20 +0200 Subject: [PATCH] bugfix for autonomous handling --- common/config/eive/definitions.h | 2 +- .../devices/SolarArrayDeploymentHandler.cpp | 92 +++++++++---------- 2 files changed, 46 insertions(+), 48 deletions(-) diff --git a/common/config/eive/definitions.h b/common/config/eive/definitions.h index 81792c20..33d37812 100644 --- a/common/config/eive/definitions.h +++ b/common/config/eive/definitions.h @@ -41,7 +41,7 @@ static constexpr uint32_t SA_DEPL_WAIT_TIME_SECS = 45 * 60; // HW constraints (current limit) mean that the GPIO channels need to be switched on in alternation static constexpr uint32_t SA_DEPL_CHANNEL_ALTERNATION_INTERVAL_SECS = 5; // Maximum allowed burn time allowed by the software. -static constexpr uint32_t SA_DEPL_MAX_BURN_TIME = 120; +static constexpr uint32_t SA_DEPL_MAX_BURN_TIME = 180; } // namespace config diff --git a/mission/devices/SolarArrayDeploymentHandler.cpp b/mission/devices/SolarArrayDeploymentHandler.cpp index cd64fd7b..baa35861 100644 --- a/mission/devices/SolarArrayDeploymentHandler.cpp +++ b/mission/devices/SolarArrayDeploymentHandler.cpp @@ -89,56 +89,54 @@ bool SolarArrayDeploymentHandler::autonomousDeplForFile(const char* filename, bo bool stateSwitch = false; uint32_t secsSinceBoot = 0; while (std::getline(file, line)) { + std::istringstream iss(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("secs_since_start:") == string::npos) { - return false; - } + 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("secs_since_start:") == string::npos) { + return false; + } - iss >> secsSinceBoot; - if (not initUptime) { - initUptime = secsSinceBoot; - } - if (iss.bad()) { - return false; - } - auto switchCheck = [&](AutonomousDeplState expected) { - if (deplState != expected) { - deplState = expected; - stateSwitch = true; - } - }; - if ((secsSinceBoot > FIRST_BURN_START_TIME) and (secsSinceBoot < FIRST_BURN_END_TIME)) { - switchCheck(AutonomousDeplState::FIRST_BURN); - } else if ((secsSinceBoot > WAIT_START_TIME) and (secsSinceBoot < WAIT_END_TIME)) { - switchCheck(AutonomousDeplState::WAIT); - } else if ((secsSinceBoot > SECOND_BURN_START_TIME) and - (secsSinceBoot < SECOND_BURN_END_TIME)) { - switchCheck(AutonomousDeplState::SECOND_BURN); - } else if (secsSinceBoot > SECOND_BURN_END_TIME) { - switchCheck(AutonomousDeplState::DONE); + iss >> secsSinceBoot; + if (not initUptime) { + initUptime = secsSinceBoot; + } + if (iss.bad()) { + return false; + } + auto switchCheck = [&](AutonomousDeplState expected) { + if (deplState != expected) { + deplState = expected; + stateSwitch = true; } + }; + if ((secsSinceBoot > FIRST_BURN_START_TIME) and (secsSinceBoot < FIRST_BURN_END_TIME)) { + switchCheck(AutonomousDeplState::FIRST_BURN); + } else if ((secsSinceBoot > WAIT_START_TIME) and (secsSinceBoot < WAIT_END_TIME)) { + switchCheck(AutonomousDeplState::WAIT); + } else if ((secsSinceBoot > SECOND_BURN_START_TIME) and + (secsSinceBoot < SECOND_BURN_END_TIME)) { + switchCheck(AutonomousDeplState::SECOND_BURN); + } else if (secsSinceBoot > SECOND_BURN_END_TIME) { + switchCheck(AutonomousDeplState::DONE); } } lineNum++;