From 3dbf66383ab854d080c908769ab2dcd0591c7af0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 11:57:27 +0100 Subject: [PATCH 01/19] minor fixes --- bsp_q7s/memory/SdCardManager.cpp | 2 +- bsp_q7s/memory/scratchApi.h | 2 +- fsfw | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index b336b84c..4ca11787 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -406,7 +406,7 @@ SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations& currentOp) { bool bytesRead = false; #if OBSW_ENABLE_TIMERS == 1 - Countdown timer(100); + Countdown timer(1000); #endif while (true) { ReturnValue_t result = cmdExecutor.check(bytesRead); diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h index babd26dc..96264995 100644 --- a/bsp_q7s/memory/scratchApi.h +++ b/bsp_q7s/memory/scratchApi.h @@ -75,7 +75,7 @@ ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& fil int result = std::system(oss.str().c_str()); if (result != 0) { - if (result == 256) { + if (WEXITSTATUS(result) == 1) { sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; // Could not find value std::remove(filename.c_str()); diff --git a/fsfw b/fsfw index 3b497dbb..d63c01b9 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 3b497dbb8dae77f1cf28f50f7ba770c4256acd2d +Subproject commit d63c01b96f2eb031eb4d568879dfee2e2151537a From b992058e00cf2a86c19b781650b5692453acb127 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 11:57:27 +0100 Subject: [PATCH 02/19] hotfix for countdown in SDC manager --- bsp_q7s/memory/SdCardManager.cpp | 2 +- bsp_q7s/memory/scratchApi.h | 2 +- fsfw | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/memory/SdCardManager.cpp b/bsp_q7s/memory/SdCardManager.cpp index b76cee12..06072253 100644 --- a/bsp_q7s/memory/SdCardManager.cpp +++ b/bsp_q7s/memory/SdCardManager.cpp @@ -406,7 +406,7 @@ SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations& currentOp) { bool bytesRead = false; #if OBSW_ENABLE_TIMERS == 1 - Countdown timer(100); + Countdown timer(1000); #endif while (true) { ReturnValue_t result = cmdExecutor.check(bytesRead); diff --git a/bsp_q7s/memory/scratchApi.h b/bsp_q7s/memory/scratchApi.h index babd26dc..96264995 100644 --- a/bsp_q7s/memory/scratchApi.h +++ b/bsp_q7s/memory/scratchApi.h @@ -75,7 +75,7 @@ ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& fil int result = std::system(oss.str().c_str()); if (result != 0) { - if (result == 256) { + if (WEXITSTATUS(result) == 1) { sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; // Could not find value std::remove(filename.c_str()); diff --git a/fsfw b/fsfw index 73f0b9c0..47d15815 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 73f0b9c0dc3995e2b1f11694ae1018953e7e62b1 +Subproject commit 47d158156b9efa0edbca9b3a1694f4132b0b30e5 From 15151e0400ed8c56c82ee5d7651365a307fdc1d5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 11:59:06 +0100 Subject: [PATCH 03/19] bump revision --- common/config/OBSWVersion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/config/OBSWVersion.h b/common/config/OBSWVersion.h index f719a274..71fd3355 100644 --- a/common/config/OBSWVersion.h +++ b/common/config/OBSWVersion.h @@ -5,6 +5,6 @@ const char* const SW_NAME = "eive"; #define SW_VERSION 1 #define SW_SUBVERSION 9 -#define SW_REVISION 0 +#define SW_REVISION 1 #endif /* COMMON_CONFIG_OBSWVERSION_H_ */ From 95e694d01a7bdf2a36bcdb10629472c8b0d09c06 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Mar 2022 13:08:50 +0100 Subject: [PATCH 04/19] add quiet flag --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03d51ac2..e6c07ee5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,7 +151,7 @@ set(FSFW_ADDITIONAL_INC_PATHS ) # Check whether the user has already installed Catch2 first -find_package(Catch2 3) +find_package(Catch2 3 QUIET) ################################################################################ # Executable and Sources From 39b4393b13ef27c5e48ed664ca59eed33a4fc459 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Mar 2022 09:27:16 +0100 Subject: [PATCH 05/19] suppress Catch2 warning --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03d51ac2..e6c07ee5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -151,7 +151,7 @@ set(FSFW_ADDITIONAL_INC_PATHS ) # Check whether the user has already installed Catch2 first -find_package(Catch2 3) +find_package(Catch2 3 QUIET) ################################################################################ # Executable and Sources From 8cf3220cd0b1a9ae481330699a1b5e597f067cfc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Mar 2022 09:36:52 +0100 Subject: [PATCH 06/19] added status message --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6c07ee5..dadf7234 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,9 +150,6 @@ set(FSFW_ADDITIONAL_INC_PATHS ${CMAKE_CURRENT_BINARY_DIR} ) -# Check whether the user has already installed Catch2 first -find_package(Catch2 3 QUIET) - ################################################################################ # Executable and Sources ################################################################################ @@ -199,8 +196,12 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(COMPILER_FLAGS "/permissive-") endif() +# Check whether the user has already installed Catch2 first +find_package(Catch2 3 QUIET) + # Not installed, so use FetchContent to download and provide Catch2 if(NOT Catch2_FOUND) + message(STATUS "Did not find a valid Catch2 installation. Using FetchContent to install it") include(FetchContent) FetchContent_Declare( From bfc8d8a7c4e03ee64dccd0c9b0eed104454c98ab Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Mar 2022 10:14:59 +0100 Subject: [PATCH 07/19] fixes some issues --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dadf7234..b959b5a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,8 +37,12 @@ endif() include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake) pre_project_config() +# Check whether the user has already installed Catch2 first. This has to come before +# the project call. We could also exlcude doing this when the Q7S primary OBSW is built.. +find_package(Catch2 3 CONFIG QUIET) + # Project Name -project(eive-obsw ASM C CXX) +project(eive-obsw) ################################################################################ # Pre-Sources preparation @@ -196,8 +200,6 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(COMPILER_FLAGS "/permissive-") endif() -# Check whether the user has already installed Catch2 first -find_package(Catch2 3 QUIET) # Not installed, so use FetchContent to download and provide Catch2 if(NOT Catch2_FOUND) From d836f6ea10fa2f13e03165ac6f904434f13a0389 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Mar 2022 18:21:05 +0100 Subject: [PATCH 08/19] small tweaks --- generators/returnvalues/returnvalues_parser.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/generators/returnvalues/returnvalues_parser.py b/generators/returnvalues/returnvalues_parser.py index 53c84564..5bcf3bc2 100644 --- a/generators/returnvalues/returnvalues_parser.py +++ b/generators/returnvalues/returnvalues_parser.py @@ -1,14 +1,7 @@ -#! /usr/bin/python3 +#! /usr/bin/env python3 # -*- coding: utf-8 -*- -""" -:file: returnvalues_parser.py -:brief: Part of the MOD export tools for the SOURCE project by KSat. -TODO: Integrate into Parser Structure instead of calling this file (no cpp file generated yet) -:details: -Return Value exporter. -To use MySQLdb, run pip install mysqlclient or install in IDE. On Windows, Build Tools -installation might be necessary. -:data: 21.11.2019 +"""Part of the MIB export tools for the EIVE project by. +Returnvalue exporter. """ from fsfwgen.core import get_console_logger from fsfwgen.utility.file_management import copy_file From 85372a10c8a7e60f7f5adfdfcf68f1d97f290b29 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Mar 2022 19:12:08 +0100 Subject: [PATCH 09/19] fsfw and tmtc update --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index d63c01b9..06577ed7 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d63c01b96f2eb031eb4d568879dfee2e2151537a +Subproject commit 06577ed78ae404bdb457be7c78bd29bffbc04f6a diff --git a/tmtc b/tmtc index abe9c8bc..de68ad93 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit abe9c8bc000e834b99a2c367ed10f927eeb666b0 +Subproject commit de68ad9341fbe5570b84305f33562702e3486364 From 406f44ae2665fca2ccf681a2c98d2a2d3b111e95 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 9 Mar 2022 19:26:49 +0100 Subject: [PATCH 10/19] update for version handling --- bsp_q7s/core/obsw.cpp | 6 +++--- tmtc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index 4b0639f7..ca7271ce 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -13,7 +13,7 @@ static int OBSW_ALREADY_RUNNING = -2; int obsw::obsw() { - fsfw::Version version; + using namespace fsfw; fsfw::getVersion(version); std::cout << "-- EIVE OBSW --" << std::endl; #if BOARD_TE0720 == 0 @@ -22,8 +22,8 @@ int obsw::obsw() { std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; #endif std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << "." << SW_REVISION << ", FSFW v" - << version.major << "." << version.minor << "." << version.revision << "--" - << std::endl; + << FSFW_VERSION.major << "." << FSFW_VERSION.minor << "." << FSFW_VERSION.revision + << "--" << std::endl; std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; #if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1 diff --git a/tmtc b/tmtc index de68ad93..eedb45e4 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit de68ad9341fbe5570b84305f33562702e3486364 +Subproject commit eedb45e4f34bd77d328745808e9acfe4668a1e35 From 3f54a3a5a5dc768147bcd5ea41e1d5f414391df7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 09:48:01 +0100 Subject: [PATCH 11/19] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 06577ed7..60639f56 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 06577ed78ae404bdb457be7c78bd29bffbc04f6a +Subproject commit 60639f56dc924576e9d98c0a271cb6515e3c87b6 From 662e8cae17e5bfca71c5260a4f30439cb8fe5a25 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 09:56:31 +0100 Subject: [PATCH 12/19] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 60639f56..b5d6b974 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 60639f56dc924576e9d98c0a271cb6515e3c87b6 +Subproject commit b5d6b9745f3e5fdd10463677ca2acb688cad4e84 From 1dcf34f3baaf9cb55a34e6b0d85180ad23a2223f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 09:59:25 +0100 Subject: [PATCH 13/19] small fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index b5d6b974..17262a1d 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit b5d6b9745f3e5fdd10463677ca2acb688cad4e84 +Subproject commit 17262a1da91a92c3b5995ccfbd67d439d01bb456 From 03aba8b08083cdc386f5682a49e495db3d988f79 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 10:04:26 +0100 Subject: [PATCH 14/19] fixes where FSFW version is used --- bsp_q7s/core/CoreController.cpp | 8 ++++---- bsp_q7s/core/obsw.cpp | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index b1783054..6c176eb1 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -4,7 +4,7 @@ #include "OBSWConfig.h" #include "OBSWVersion.h" -#include "fsfw/FSFWVersion.h" +#include "fsfw/version.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/Stopwatch.h" #include "watchdogConf.h" @@ -624,9 +624,9 @@ ReturnValue_t CoreController::initVersionFile() { std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." + std::to_string(SW_SUBVERSION) + "." + std::to_string(SW_REVISION); - std::string fullFsfwVersionString = "FSFW: v" + std::to_string(FSFW_VERSION) + "." + - std::to_string(FSFW_SUBVERSION) + "." + - std::to_string(FSFW_REVISION); + char versionString[16] = {}; + fsfw::FSFW_VERSION.getVersion(versionString, sizeof(versionString)); + std::string fullFsfwVersionString = "FSFW: v" + std::string(versionString); std::string systemString = "System: " + unameLine; std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix(); std::string versionFilePath = mountPrefix + VERSION_FILE; diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index ca7271ce..197ca66b 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -14,7 +14,6 @@ static int OBSW_ALREADY_RUNNING = -2; int obsw::obsw() { using namespace fsfw; - fsfw::getVersion(version); std::cout << "-- EIVE OBSW --" << std::endl; #if BOARD_TE0720 == 0 std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; @@ -22,8 +21,7 @@ int obsw::obsw() { std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; #endif std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << "." << SW_REVISION << ", FSFW v" - << FSFW_VERSION.major << "." << FSFW_VERSION.minor << "." << FSFW_VERSION.revision - << "--" << std::endl; + << FSFW_VERSION << "--" << std::endl; std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; #if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1 From 1742371c1429dd664963fb31e16416e7ef4a629d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 10:54:27 +0100 Subject: [PATCH 15/19] created new dual lane assembly base --- bsp_q7s/core/CoreController.cpp | 2 +- mission/system/AcsBoardAssembly.cpp | 118 +++--------------------- mission/system/AcsBoardAssembly.h | 33 ++----- mission/system/CMakeLists.txt | 1 + mission/system/DualLaneAssemblyBase.cpp | 92 ++++++++++++++++++ mission/system/DualLaneAssemblyBase.h | 66 +++++++++++++ 6 files changed, 178 insertions(+), 134 deletions(-) create mode 100644 mission/system/DualLaneAssemblyBase.cpp create mode 100644 mission/system/DualLaneAssemblyBase.h diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 6c176eb1..89d9ce14 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -4,9 +4,9 @@ #include "OBSWConfig.h" #include "OBSWVersion.h" -#include "fsfw/version.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/Stopwatch.h" +#include "fsfw/version.h" #include "watchdogConf.h" #if OBSW_USE_TMTC_TCP_BRIDGE == 0 #include "fsfw/osal/common/UdpTmTcBridge.h" diff --git a/mission/system/AcsBoardAssembly.cpp b/mission/system/AcsBoardAssembly.cpp index 286bb106..76e2d916 100644 --- a/mission/system/AcsBoardAssembly.cpp +++ b/mission/system/AcsBoardAssembly.cpp @@ -6,8 +6,8 @@ AcsBoardAssembly::AcsBoardAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* switcher, AcsBoardHelper helper, GpioIF* gpioIF) - : AssemblyBase(objectId, parentId), - pwrStateMachine(SWITCH_A, SWITCH_B, switcher), + : DualLaneAssemblyBase(objectId, parentId, switcher, SWITCH_A, SWITCH_B, + POWER_STATE_MACHINE_TIMEOUT), helper(helper), gpioIF(gpioIF) { if (switcher == nullptr) { @@ -19,46 +19,15 @@ AcsBoardAssembly::AcsBoardAssembly(object_id_t objectId, object_id_t parentId, sif::error << "AcsBoardAssembly::AcsBoardAssembly: Invalid GPIO IF passed" << std::endl; } ModeListEntry entry; - initModeTableEntry(helper.mgm0Lis3IdSideA, entry); - initModeTableEntry(helper.mgm1Rm3100IdSideA, entry); - initModeTableEntry(helper.mgm2Lis3IdSideB, entry); - initModeTableEntry(helper.mgm3Rm3100IdSideB, entry); - initModeTableEntry(helper.gyro0AdisIdSideA, entry); - initModeTableEntry(helper.gyro1L3gIdSideA, entry); - initModeTableEntry(helper.gyro2AdisIdSideB, entry); - initModeTableEntry(helper.gyro3L3gIdSideB, entry); - initModeTableEntry(helper.gpsId, entry); -} - -void AcsBoardAssembly::performChildOperation() { - using namespace duallane; - if (pwrStateMachine.active()) { - pwrStateMachineWrapper(); - // This state is the indicator that the power state machine is done - } - if (not pwrStateMachine.active()) { - AssemblyBase::performChildOperation(); - } -} - -void AcsBoardAssembly::startTransition(Mode_t mode, Submode_t submode) { - using namespace duallane; - pwrStateMachine.reset(); - // If anything other than MODE_OFF is commanded, perform power state machine first - if (mode != MODE_OFF) { - // Cache the target modes, required by power state machine - pwrStateMachine.start(mode, submode); - // Cache these for later after the power state machine has finished - targetMode = mode; - targetSubmode = submode; - // Perform power state machine first, then start mode transition. The power state machine will - // start the transition after it has finished - pwrStateMachineWrapper(); - } else { - // Command the devices to off first before switching off the power. The handleModeReached - // custom implementation will take care of starting the power state machine. - AssemblyBase::startTransition(mode, submode); - } + initModeTableEntry(helper.mgm0Lis3IdSideA, entry, modeTable); + initModeTableEntry(helper.mgm1Rm3100IdSideA, entry, modeTable); + initModeTableEntry(helper.mgm2Lis3IdSideB, entry, modeTable); + initModeTableEntry(helper.mgm3Rm3100IdSideB, entry, modeTable); + initModeTableEntry(helper.gyro0AdisIdSideA, entry, modeTable); + initModeTableEntry(helper.gyro1L3gIdSideA, entry, modeTable); + initModeTableEntry(helper.gyro2AdisIdSideB, entry, modeTable); + initModeTableEntry(helper.gyro3L3gIdSideB, entry, modeTable); + initModeTableEntry(helper.gpsId, entry, modeTable); } ReturnValue_t AcsBoardAssembly::commandChildren(Mode_t mode, Submode_t submode) { @@ -95,11 +64,6 @@ ReturnValue_t AcsBoardAssembly::commandChildren(Mode_t mode, Submode_t submode) ReturnValue_t AcsBoardAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) { using namespace duallane; refreshHelperModes(); - // if (state == PwrStates::SWITCHING_POWER) { - // // Wrong mode - // sif::error << "Wrong mode, currently switching power" << std::endl; - // return RETURN_OK; - // } if (wantedSubmode == A_SIDE) { if ((helper.gyro0SideAMode != wantedMode and helper.gyro1SideAMode != wantedMode) or (helper.mgm0SideAMode != wantedMode and helper.mgm1SideAMode != wantedMode) or @@ -245,34 +209,6 @@ ReturnValue_t AcsBoardAssembly::isModeCombinationValid(Mode_t mode, Submode_t su return HasReturnvaluesIF::RETURN_OK; } -bool AcsBoardAssembly::isUseable(object_id_t object, Mode_t mode) { - if (healthHelper.healthTable->isFaulty(object)) { - return false; - } - - // Check if device is already in target mode - if (childrenMap[object].mode == mode) { - return true; - } - - if (healthHelper.healthTable->isCommandable(object)) { - return true; - } - return false; -} - -void AcsBoardAssembly::handleModeReached() { - using namespace duallane; - if (targetMode == MODE_OFF) { - pwrStateMachine.start(targetMode, targetSubmode); - // Now we can switch off the power. After that, the AssemblyBase::handleModeReached function - // will be called - pwrStateMachineWrapper(); - } else { - finishModeOp(); - } -} - void AcsBoardAssembly::handleChildrenLostMode(ReturnValue_t result) { using namespace duallane; // Some ACS board components are required for Safe-Mode. It would be good if the software @@ -357,14 +293,6 @@ void AcsBoardAssembly::refreshHelperModes() { } } -void AcsBoardAssembly::initModeTableEntry(object_id_t id, ModeListEntry& entry) { - entry.setObject(id); - entry.setMode(MODE_OFF); - entry.setSubmode(SUBMODE_NONE); - entry.setInheritSubmode(false); - modeTable.insert(entry); -} - void AcsBoardAssembly::finishModeOp() { using namespace duallane; AssemblyBase::handleModeReached(); @@ -374,30 +302,6 @@ void AcsBoardAssembly::finishModeOp() { dualModeErrorSwitch = true; } -ReturnValue_t AcsBoardAssembly::pwrStateMachineWrapper() { - using namespace duallane; - OpCodes opCode = pwrStateMachine.powerStateMachine(); - if (opCode == OpCodes::NONE) { - return RETURN_OK; - } else if (opCode == OpCodes::FINISH_OP) { - finishModeOp(); - } else if (opCode == OpCodes::START_TRANSITION) { - AssemblyBase::startTransition(targetMode, targetSubmode); - } else if (opCode == OpCodes::TIMEOUT_OCCURED) { - if (powerRetryCounter == 0) { - powerRetryCounter++; - pwrStateMachine.reset(); - } else { -#if OBSW_VERBOSE_LEVEL >= 1 - sif::warning << "Timeout occured in power state machine" << std::endl; -#endif - triggerEvent(POWER_STATE_MACHINE_TIMEOUT, 0, 0); - return RETURN_FAILED; - } - } - return RETURN_OK; -} - ReturnValue_t AcsBoardAssembly::initialize() { ReturnValue_t result = registerChild(helper.gyro0AdisIdSideA); if (result != HasReturnvaluesIF::RETURN_OK) { diff --git a/mission/system/AcsBoardAssembly.h b/mission/system/AcsBoardAssembly.h index 7f2a85fa..20b8d748 100644 --- a/mission/system/AcsBoardAssembly.h +++ b/mission/system/AcsBoardAssembly.h @@ -3,9 +3,9 @@ #include #include -#include #include +#include "DualLaneAssemblyBase.h" #include "DualLanePowerStateMachine.h" struct AcsBoardHelper { @@ -71,15 +71,15 @@ class GpioIF; * doing this task would be performed by the device handlers, but this is not possible for the * ACS board where multiple sensors share the same power supply. */ -class AcsBoardAssembly : public AssemblyBase { +class AcsBoardAssembly : public DualLaneAssemblyBase { public: static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::ACS_BOARD_ASS; static constexpr Event TRANSITION_OTHER_SIDE_FAILED = - event::makeEvent(SUBSYSTEM_ID, 0, severity::HIGH); + event::makeEvent(SUBSYSTEM_ID, TRANSITION_OTHER_SIDE_FAILED_ID, severity::HIGH); static constexpr Event NOT_ENOUGH_DEVICES_DUAL_MODE = - event::makeEvent(SUBSYSTEM_ID, 1, severity::HIGH); + event::makeEvent(SUBSYSTEM_ID, NOT_ENOUGH_DEVICES_DUAL_MODE_ID, severity::HIGH); static constexpr Event POWER_STATE_MACHINE_TIMEOUT = - event::makeEvent(SUBSYSTEM_ID, 2, severity::MEDIUM); + event::makeEvent(SUBSYSTEM_ID, POWER_STATE_MACHINE_TIMEOUT_ID, severity::MEDIUM); static constexpr uint8_t NUMBER_DEVICES_MODE_TABLE = 9; @@ -101,12 +101,10 @@ class AcsBoardAssembly : public AssemblyBase { static constexpr pcduSwitches::Switches SWITCH_B = pcduSwitches::Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3; - // This helper object complete encapsulates power switching - DualLanePowerStateMachine pwrStateMachine; bool tryingOtherSide = false; AcsBoardHelper helper; GpioIF* gpioIF = nullptr; - uint8_t powerRetryCounter = 0; + // duallane::PwrStates state = duallane::PwrStates::IDLE; duallane::Submodes defaultSubmode = duallane::Submodes::A_SIDE; bool dualModeErrorSwitch = true; @@ -118,30 +116,13 @@ class AcsBoardAssembly : public AssemblyBase { ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) override; ReturnValue_t checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) override; ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override; - void performChildOperation() override; - void startTransition(Mode_t mode, Submode_t submode) override; - void handleModeReached() override; + void handleModeTransitionFailed(ReturnValue_t result) override; void handleChildrenLostMode(ReturnValue_t result) override; - /** - * Check whether it makes sense to send mode commands to the device - * @param object - * @param mode - * @return - */ - bool isUseable(object_id_t object, Mode_t mode); ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode); - void initModeTableEntry(object_id_t id, ModeListEntry& entry); void refreshHelperModes(); void finishModeOp(); - /** - * Thin wrapper function which is required because the helper class - * can not access protected member functions. - * @param mode - * @param submode - */ - ReturnValue_t pwrStateMachineWrapper(); }; #endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */ diff --git a/mission/system/CMakeLists.txt b/mission/system/CMakeLists.txt index fb8d7096..333de2f9 100644 --- a/mission/system/CMakeLists.txt +++ b/mission/system/CMakeLists.txt @@ -7,4 +7,5 @@ target_sources(${LIB_EIVE_MISSION} PRIVATE ComSubsystem.cpp TcsSubsystem.cpp DualLanePowerStateMachine.cpp + DualLaneAssemblyBase.cpp ) \ No newline at end of file diff --git a/mission/system/DualLaneAssemblyBase.cpp b/mission/system/DualLaneAssemblyBase.cpp new file mode 100644 index 00000000..8ed549b1 --- /dev/null +++ b/mission/system/DualLaneAssemblyBase.cpp @@ -0,0 +1,92 @@ +#include "DualLaneAssemblyBase.h" + +DualLaneAssemblyBase::DualLaneAssemblyBase(object_id_t objectId, object_id_t parentId, + PowerSwitchIF* pwrSwitcher, + pcduSwitches::Switches switch1, + pcduSwitches::Switches switch2, Event pwrTimeoutEvent) + : AssemblyBase(objectId, parentId), + pwrStateMachine(switch1, switch2, pwrSwitcher), + pwrTimeoutEvent(pwrTimeoutEvent) {} + +void DualLaneAssemblyBase::performChildOperation() { + using namespace duallane; + if (pwrStateMachine.active()) { + pwrStateMachineWrapper(); + // This state is the indicator that the power state machine is done + } + if (not pwrStateMachine.active()) { + AssemblyBase::performChildOperation(); + } +} + +void DualLaneAssemblyBase::startTransition(Mode_t mode, Submode_t submode) { + using namespace duallane; + pwrStateMachine.reset(); + // If anything other than MODE_OFF is commanded, perform power state machine first + if (mode != MODE_OFF) { + // Cache the target modes, required by power state machine + pwrStateMachine.start(mode, submode); + // Cache these for later after the power state machine has finished + targetMode = mode; + targetSubmode = submode; + // Perform power state machine first, then start mode transition. The power state machine will + // start the transition after it has finished + pwrStateMachineWrapper(); + } else { + // Command the devices to off first before switching off the power. The handleModeReached + // custom implementation will take care of starting the power state machine. + AssemblyBase::startTransition(mode, submode); + } +} + +bool DualLaneAssemblyBase::isUseable(object_id_t object, Mode_t mode) { + if (healthHelper.healthTable->isFaulty(object)) { + return false; + } + + // Check if device is already in target mode + if (childrenMap[object].mode == mode) { + return true; + } + + if (healthHelper.healthTable->isCommandable(object)) { + return true; + } + return false; +} + +ReturnValue_t DualLaneAssemblyBase::pwrStateMachineWrapper() { + using namespace duallane; + OpCodes opCode = pwrStateMachine.powerStateMachine(); + if (opCode == OpCodes::NONE) { + return RETURN_OK; + } else if (opCode == OpCodes::FINISH_OP) { + finishModeOp(); + } else if (opCode == OpCodes::START_TRANSITION) { + AssemblyBase::startTransition(targetMode, targetSubmode); + } else if (opCode == OpCodes::TIMEOUT_OCCURED) { + if (powerRetryCounter == 0) { + powerRetryCounter++; + pwrStateMachine.reset(); + } else { +#if OBSW_VERBOSE_LEVEL >= 1 + sif::warning << "Timeout occured in power state machine" << std::endl; +#endif + triggerEvent(pwrTimeoutEvent, 0, 0); + return RETURN_FAILED; + } + } + return RETURN_OK; +} + +void DualLaneAssemblyBase::handleModeReached() { + using namespace duallane; + if (targetMode == MODE_OFF) { + pwrStateMachine.start(targetMode, targetSubmode); + // Now we can switch off the power. After that, the AssemblyBase::handleModeReached function + // will be called + pwrStateMachineWrapper(); + } else { + finishModeOp(); + } +} diff --git a/mission/system/DualLaneAssemblyBase.h b/mission/system/DualLaneAssemblyBase.h new file mode 100644 index 00000000..79037efa --- /dev/null +++ b/mission/system/DualLaneAssemblyBase.h @@ -0,0 +1,66 @@ +#ifndef MISSION_SYSTEM_DUALLANEASSEMBLYBASE_H_ +#define MISSION_SYSTEM_DUALLANEASSEMBLYBASE_H_ + +#include +#include + +class DualLaneAssemblyBase : public AssemblyBase { + public: + static constexpr uint8_t TRANSITION_OTHER_SIDE_FAILED_ID = 0; + static constexpr uint8_t NOT_ENOUGH_DEVICES_DUAL_MODE_ID = 1; + static constexpr uint8_t POWER_STATE_MACHINE_TIMEOUT_ID = 2; + + DualLaneAssemblyBase(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher, + pcduSwitches::Switches switch1, pcduSwitches::Switches switch2, + Event pwrSwitchTimeoutEvent); + + virtual void performChildOperation() override; + virtual void startTransition(Mode_t mode, Submode_t submode) override; + + protected: + // This helper object complete encapsulates power switching + DualLanePowerStateMachine pwrStateMachine; + Event pwrTimeoutEvent; + uint8_t powerRetryCounter = 0; + + /** + * Check whether it makes sense to send mode commands to the device + * @param object + * @param mode + * @return + */ + bool isUseable(object_id_t object, Mode_t mode); + /** + * Thin wrapper function which is required because the helper class + * can not access protected member functions. + * @param mode + * @param submode + */ + virtual ReturnValue_t pwrStateMachineWrapper(); + virtual void handleModeReached(); + + /** + * Implemented by user. Will be called if a full mode operation has finished. + * This includes both the regular mode state machine operations and the power state machine + * operations + */ + virtual void finishModeOp() = 0; + + template + void initModeTableEntry(object_id_t id, ModeListEntry& entry, + FixedArrayList& modeTable); + + private: +}; + +template +inline void DualLaneAssemblyBase::initModeTableEntry( + object_id_t id, ModeListEntry& entry, FixedArrayList& modeTable) { + entry.setObject(id); + entry.setMode(MODE_OFF); + entry.setSubmode(SUBMODE_NONE); + entry.setInheritSubmode(false); + modeTable.insert(entry); +} + +#endif /* MISSION_SYSTEM_DUALLANEASSEMBLYBASE_H_ */ From 3cfb58d68138c6c309d1888d9b10357aa03186e6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 11:02:07 +0100 Subject: [PATCH 16/19] started integrating new base obj into sus assembly --- common/config/commonSubsystemIds.h | 1 + mission/system/AcsBoardAssembly.cpp | 8 -- mission/system/AcsBoardAssembly.h | 1 - mission/system/DualLaneAssemblyBase.cpp | 8 ++ mission/system/DualLaneAssemblyBase.h | 6 +- mission/system/SusAssembly.cpp | 103 +++--------------------- mission/system/SusAssembly.h | 15 ++-- 7 files changed, 33 insertions(+), 109 deletions(-) diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index 554f4812..0e64e634 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -21,6 +21,7 @@ enum: uint8_t { STR_HELPER = 120, PL_PCDU_HANDLER = 121, ACS_BOARD_ASS = 122, + SUS_BOARD_ASS = 123, COMMON_SUBSYSTEM_ID_END }; } diff --git a/mission/system/AcsBoardAssembly.cpp b/mission/system/AcsBoardAssembly.cpp index 76e2d916..903202b3 100644 --- a/mission/system/AcsBoardAssembly.cpp +++ b/mission/system/AcsBoardAssembly.cpp @@ -201,14 +201,6 @@ ReturnValue_t AcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s return result; } -ReturnValue_t AcsBoardAssembly::isModeCombinationValid(Mode_t mode, Submode_t submode) { - using namespace duallane; - if (submode != A_SIDE and submode != B_SIDE and submode != DUAL_MODE) { - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; -} - void AcsBoardAssembly::handleChildrenLostMode(ReturnValue_t result) { using namespace duallane; // Some ACS board components are required for Safe-Mode. It would be good if the software diff --git a/mission/system/AcsBoardAssembly.h b/mission/system/AcsBoardAssembly.h index 20b8d748..788a7227 100644 --- a/mission/system/AcsBoardAssembly.h +++ b/mission/system/AcsBoardAssembly.h @@ -115,7 +115,6 @@ class AcsBoardAssembly : public DualLaneAssemblyBase { // AssemblyBase overrides ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) override; ReturnValue_t checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) override; - ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override; void handleModeTransitionFailed(ReturnValue_t result) override; void handleChildrenLostMode(ReturnValue_t result) override; diff --git a/mission/system/DualLaneAssemblyBase.cpp b/mission/system/DualLaneAssemblyBase.cpp index 8ed549b1..24759f58 100644 --- a/mission/system/DualLaneAssemblyBase.cpp +++ b/mission/system/DualLaneAssemblyBase.cpp @@ -79,6 +79,14 @@ ReturnValue_t DualLaneAssemblyBase::pwrStateMachineWrapper() { return RETURN_OK; } +ReturnValue_t DualLaneAssemblyBase::isModeCombinationValid(Mode_t mode, Submode_t submode) { + using namespace duallane; + if (submode != A_SIDE and submode != B_SIDE and submode != DUAL_MODE) { + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + void DualLaneAssemblyBase::handleModeReached() { using namespace duallane; if (targetMode == MODE_OFF) { diff --git a/mission/system/DualLaneAssemblyBase.h b/mission/system/DualLaneAssemblyBase.h index 79037efa..78d47437 100644 --- a/mission/system/DualLaneAssemblyBase.h +++ b/mission/system/DualLaneAssemblyBase.h @@ -14,9 +14,6 @@ class DualLaneAssemblyBase : public AssemblyBase { pcduSwitches::Switches switch1, pcduSwitches::Switches switch2, Event pwrSwitchTimeoutEvent); - virtual void performChildOperation() override; - virtual void startTransition(Mode_t mode, Submode_t submode) override; - protected: // This helper object complete encapsulates power switching DualLanePowerStateMachine pwrStateMachine; @@ -37,6 +34,9 @@ class DualLaneAssemblyBase : public AssemblyBase { * @param submode */ virtual ReturnValue_t pwrStateMachineWrapper(); + virtual ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override; + virtual void performChildOperation() override; + virtual void startTransition(Mode_t mode, Submode_t submode) override; virtual void handleModeReached(); /** diff --git a/mission/system/SusAssembly.cpp b/mission/system/SusAssembly.cpp index 5da464fb..7f41f159 100644 --- a/mission/system/SusAssembly.cpp +++ b/mission/system/SusAssembly.cpp @@ -6,10 +6,13 @@ SusAssembly::SusAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher, SusAssHelper helper) - : AssemblyBase(objectId, parentId), helper(helper), pwrSwitcher(pwrSwitcher) { + : DualLaneAssemblyBase(objectId, parentId, pwrSwitcher, SWITCH_NOM, SWITCH_RED, + POWER_STATE_MACHINE_TIMEOUT), + helper(helper), + pwrSwitcher(pwrSwitcher) { ModeListEntry entry; for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS; idx++) { - initModeTableEntry(helper.susIds[idx], entry); + initModeTableEntry(helper.susIds[idx], entry, modeTable); } } @@ -34,6 +37,7 @@ ReturnValue_t SusAssembly::commandChildren(Mode_t mode, Submode_t submode) { } ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode) { + using namespace duallane; ReturnValue_t result = RETURN_OK; auto cmdSeq = [&](object_id_t objectId, uint8_t tableIdx) { if (mode == DeviceHandlerIF::MODE_NORMAL) { @@ -55,7 +59,7 @@ ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submod } }; switch (submode) { - case (NOMINAL): { + case (A_SIDE): { for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS_ONE_SIDE; idx++) { cmdSeq(helper.susIds[idx], idx); // Switch off devices on redundant side @@ -64,7 +68,7 @@ ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submod } return result; } - case (REDUNDANT): { + case (B_SIDE): { for (uint8_t idx = NUMBER_SUN_SENSORS_ONE_SIDE; idx < NUMBER_SUN_SENSORS; idx++) { cmdSeq(helper.susIds[idx], idx); // Switch devices on nominal side @@ -84,15 +88,16 @@ ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submod } ReturnValue_t SusAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) { + using namespace duallane; refreshHelperModes(); - if (wantedSubmode == NOMINAL) { + if (wantedSubmode == A_SIDE) { for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS_ONE_SIDE; idx++) { if (helper.susModes[idx] != wantedMode) { return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE; } } return RETURN_OK; - } else if (wantedSubmode == REDUNDANT) { + } else if (wantedSubmode == B_SIDE) { for (uint8_t idx = NUMBER_SUN_SENSORS_ONE_SIDE; idx < NUMBER_SUN_SENSORS; idx++) { if (helper.susModes[idx] != wantedMode) { return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE; @@ -108,13 +113,6 @@ ReturnValue_t SusAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wan return RETURN_OK; } -ReturnValue_t SusAssembly::isModeCombinationValid(Mode_t mode, Submode_t submode) { - if (submode != NOMINAL and submode != REDUNDANT and submode != DUAL_MODE) { - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; -} - ReturnValue_t SusAssembly::initialize() { ReturnValue_t result = RETURN_OK; for (const auto& id : helper.susIds) { @@ -142,92 +140,13 @@ bool SusAssembly::isUseable(object_id_t object, Mode_t mode) { return false; } -void SusAssembly::powerStateMachine(Mode_t mode, Submode_t submode) { - ReturnValue_t switchStateNom = RETURN_OK; - ReturnValue_t switchStateRed = RETURN_OK; - if (state == States::IDLE or state == States::SWITCHING_POWER) { - switchStateNom = pwrSwitcher->getSwitchState(SWITCH_NOM); - switchStateRed = pwrSwitcher->getSwitchState(SWITCH_RED); - } else { - return; - } - if (mode == MODE_OFF) { - if (switchStateNom == PowerSwitchIF::SWITCH_OFF and - switchStateRed == PowerSwitchIF::SWITCH_OFF) { - state = States::MODE_COMMANDING; - return; - } - } else { - if (state == States::IDLE) { - if (mode == MODE_OFF) { - if (switchStateNom != PowerSwitchIF::SWITCH_OFF) { - pwrSwitcher->sendSwitchCommand(SWITCH_NOM, false); - } - if (switchStateRed != PowerSwitchIF::SWITCH_OFF) { - pwrSwitcher->sendSwitchCommand(SWITCH_RED, false); - } - } else { - switch (submode) { - case (NOMINAL): { - if (switchStateNom != PowerSwitchIF::SWITCH_ON) { - pwrSwitcher->sendSwitchCommand(SWITCH_NOM, true); - } - if (switchStateRed != PowerSwitchIF::SWITCH_OFF) { - pwrSwitcher->sendSwitchCommand(SWITCH_RED, false); - } - break; - } - case (REDUNDANT): { - if (switchStateRed != PowerSwitchIF::SWITCH_OFF) { - pwrSwitcher->sendSwitchCommand(SWITCH_RED, false); - } - if (switchStateNom != PowerSwitchIF::SWITCH_ON) { - pwrSwitcher->sendSwitchCommand(SWITCH_NOM, true); - } - break; - } - case (DUAL_MODE): { - if (switchStateNom != PowerSwitchIF::SWITCH_ON) { - pwrSwitcher->sendSwitchCommand(SWITCH_NOM, true); - } - if (switchStateRed != PowerSwitchIF::SWITCH_ON) { - pwrSwitcher->sendSwitchCommand(SWITCH_RED, true); - } - break; - } - } - } - state = States::SWITCHING_POWER; - } - if (state == States::SWITCHING_POWER) { - // TODO: Could check for a timeout (temporal or cycles) here and resend command - } - } -} - void SusAssembly::handleModeReached() { AssemblyBase::handleModeReached(); state = States::IDLE; } -void SusAssembly::handleModeTransitionFailed(ReturnValue_t result) { - // The sun-sensors are required for the Safe-Mode. It would be good if the software - // transitions from nominal side to redundant side and from redundant side to dual mode - // autonomously to ensure that that enough sensors are available witout an operators intervention. - // Therefore, the failure handler is overriden to perform these steps. - // TODO: Implement transitions mentioned above -} - void SusAssembly::refreshHelperModes() { for (uint8_t idx = 0; idx < helper.susModes.size(); idx++) { helper.susModes[idx] = childrenMap[helper.susIds[idx]].mode; } } - -void SusAssembly::initModeTableEntry(object_id_t id, ModeListEntry& entry) { - entry.setObject(id); - entry.setMode(MODE_OFF); - entry.setSubmode(SUBMODE_NONE); - entry.setInheritSubmode(false); - modeTable.insert(entry); -} diff --git a/mission/system/SusAssembly.h b/mission/system/SusAssembly.h index b4941724..37f3d3a5 100644 --- a/mission/system/SusAssembly.h +++ b/mission/system/SusAssembly.h @@ -4,6 +4,8 @@ #include #include +#include "DualLaneAssemblyBase.h" + struct SusAssHelper { public: SusAssHelper(std::array susIds) : susIds(susIds) {} @@ -13,14 +15,18 @@ struct SusAssHelper { class PowerSwitchIF; -class SusAssembly : AssemblyBase { +class SusAssembly : DualLaneAssemblyBase { public: static constexpr uint8_t NUMBER_SUN_SENSORS_ONE_SIDE = 6; static constexpr uint8_t NUMBER_SUN_SENSORS = 12; - static constexpr Submode_t NOMINAL = 0; - static constexpr Submode_t REDUNDANT = 1; - static constexpr Submode_t DUAL_MODE = 2; + static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SUS_BOARD_ASS; + static constexpr Event TRANSITION_OTHER_SIDE_FAILED = + event::makeEvent(SUBSYSTEM_ID, TRANSITION_OTHER_SIDE_FAILED_ID, severity::HIGH); + static constexpr Event NOT_ENOUGH_DEVICES_DUAL_MODE = + event::makeEvent(SUBSYSTEM_ID, NOT_ENOUGH_DEVICES_DUAL_MODE_ID, severity::HIGH); + static constexpr Event POWER_STATE_MACHINE_TIMEOUT = + event::makeEvent(SUBSYSTEM_ID, POWER_STATE_MACHINE_TIMEOUT_ID, severity::MEDIUM); SusAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher, SusAssHelper helper); @@ -54,7 +60,6 @@ class SusAssembly : AssemblyBase { bool isUseable(object_id_t object, Mode_t mode); void powerStateMachine(Mode_t mode, Submode_t submode); ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode); - void initModeTableEntry(object_id_t id, ModeListEntry& entry); void refreshHelperModes(); }; From 8c41669d1f2673abda6279c2f9d75cb861e623a4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 11:05:43 +0100 Subject: [PATCH 17/19] docs --- mission/system/DualLaneAssemblyBase.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mission/system/DualLaneAssemblyBase.h b/mission/system/DualLaneAssemblyBase.h index 78d47437..c806561a 100644 --- a/mission/system/DualLaneAssemblyBase.h +++ b/mission/system/DualLaneAssemblyBase.h @@ -4,6 +4,13 @@ #include #include +/** + * @brief Encapsulates assemblies which are also responsible for dual lane power switching + * @details + * This is the base class for both the ACS board and the SUS board. Both boards have redundant + * power lanes and are required for the majority of satellite modes. Therefore, there is a lot + * of common code, for example the power switching. + */ class DualLaneAssemblyBase : public AssemblyBase { public: static constexpr uint8_t TRANSITION_OTHER_SIDE_FAILED_ID = 0; From fec6cc3ea98011ea34eddd08781e873066c6035c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Mar 2022 11:10:42 +0100 Subject: [PATCH 18/19] more docs --- mission/system/DualLaneAssemblyBase.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mission/system/DualLaneAssemblyBase.cpp b/mission/system/DualLaneAssemblyBase.cpp index 24759f58..9c163721 100644 --- a/mission/system/DualLaneAssemblyBase.cpp +++ b/mission/system/DualLaneAssemblyBase.cpp @@ -12,8 +12,10 @@ void DualLaneAssemblyBase::performChildOperation() { using namespace duallane; if (pwrStateMachine.active()) { pwrStateMachineWrapper(); - // This state is the indicator that the power state machine is done } + // Only perform the regular child operation if the power state machine is not active. + // It does not make any sense to command device modes while the power switcher is busy + // switching off or on devices. if (not pwrStateMachine.active()) { AssemblyBase::performChildOperation(); } @@ -61,8 +63,11 @@ ReturnValue_t DualLaneAssemblyBase::pwrStateMachineWrapper() { if (opCode == OpCodes::NONE) { return RETURN_OK; } else if (opCode == OpCodes::FINISH_OP) { + // Will be called for transitions to MODE_OFF, where everything is done after power switching finishModeOp(); } else if (opCode == OpCodes::START_TRANSITION) { + // Will be called for transitions from MODE_OFF to anything else, where the mode still has + // to be commanded after power switching AssemblyBase::startTransition(targetMode, targetSubmode); } else if (opCode == OpCodes::TIMEOUT_OCCURED) { if (powerRetryCounter == 0) { From dd37f90b4730259b92865ed40e7c87b67b84a222 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Mar 2022 14:33:09 +0100 Subject: [PATCH 19/19] update for gen scripts, small fixes --- fsfw | 2 +- generators/.run/events.run.xml | 2 +- generators/.run/objects.run.xml | 2 +- generators/.run/returnvalues.run.xml | 2 +- generators/bsp_q7s_returnvalues.csv | 6 +----- generators/events/translateEvents.cpp | 2 +- generators/fsfwgen | 2 +- generators/{fsfwgen.py => gen.py} | 0 generators/objects/translateObjects.cpp | 2 +- linux/fsfwconfig/events/translateEvents.cpp | 2 +- linux/fsfwconfig/objects/translateObjects.cpp | 2 +- mission/system/AcsBoardAssembly.h | 10 +++++++--- 12 files changed, 17 insertions(+), 17 deletions(-) rename generators/{fsfwgen.py => gen.py} (100%) diff --git a/fsfw b/fsfw index 17262a1d..fec5f83f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 17262a1da91a92c3b5995ccfbd67d439d01bb456 +Subproject commit fec5f83f4f2459facee25939e0292115f89a6d73 diff --git a/generators/.run/events.run.xml b/generators/.run/events.run.xml index 18f71033..6bc73c96 100644 --- a/generators/.run/events.run.xml +++ b/generators/.run/events.run.xml @@ -12,7 +12,7 @@