diff --git a/CMakeLists.txt b/CMakeLists.txt
index 03d51ac2..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
@@ -150,9 +154,6 @@ set(FSFW_ADDITIONAL_INC_PATHS
${CMAKE_CURRENT_BINARY_DIR}
)
-# Check whether the user has already installed Catch2 first
-find_package(Catch2 3)
-
################################################################################
# Executable and Sources
################################################################################
@@ -199,8 +200,10 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(COMPILER_FLAGS "/permissive-")
endif()
+
# 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(
diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp
index 587d22f0..7204db14 100644
--- a/bsp_q7s/core/CoreController.cpp
+++ b/bsp_q7s/core/CoreController.cpp
@@ -625,9 +625,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.major) + "." +
- std::to_string(FSFW_VERSION.minor) + "." +
- std::to_string(FSFW_VERSION.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
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/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_ */
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/fsfw b/fsfw
index 9509847b..fec5f83f 160000
--- a/fsfw
+++ b/fsfw
@@ -1 +1 @@
-Subproject commit 9509847b849c18374a5df809c2fb83dd98d66dc3
+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 @@
-
+
diff --git a/generators/.run/objects.run.xml b/generators/.run/objects.run.xml
index 961b8ed9..df684cc8 100644
--- a/generators/.run/objects.run.xml
+++ b/generators/.run/objects.run.xml
@@ -12,7 +12,7 @@
-
+
diff --git a/generators/.run/returnvalues.run.xml b/generators/.run/returnvalues.run.xml
index 51b16449..dcb00efb 100644
--- a/generators/.run/returnvalues.run.xml
+++ b/generators/.run/returnvalues.run.xml
@@ -12,7 +12,7 @@
-
+
diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp
index 9cbd0bef..92250a50 100644
--- a/generators/events/translateEvents.cpp
+++ b/generators/events/translateEvents.cpp
@@ -1,7 +1,7 @@
/**
* @brief Auto-generated event translation file. Contains 162 translations.
* @details
- * Generated on: 2022-03-07 17:09:35
+ * Generated on: 2022-03-11 14:31:47
*/
#include "translateEvents.h"
diff --git a/generators/fsfwgen b/generators/fsfwgen
index c5ef1783..5dbe33ce 160000
--- a/generators/fsfwgen
+++ b/generators/fsfwgen
@@ -1 +1 @@
-Subproject commit c5ef1783a3b082c0e88561bd91bc3ee0f459fafc
+Subproject commit 5dbe33ceb85b15f27e6722bb907df3ed324b701b
diff --git a/generators/fsfwgen.py b/generators/gen.py
similarity index 100%
rename from generators/fsfwgen.py
rename to generators/gen.py
diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp
index b29ed5db..c0e79d7a 100644
--- a/generators/objects/translateObjects.cpp
+++ b/generators/objects/translateObjects.cpp
@@ -2,7 +2,7 @@
* @brief Auto-generated object translation file.
* @details
* Contains 113 translations.
- * Generated on: 2022-03-07 17:15:28
+ * Generated on: 2022-03-11 14:31:51
*/
#include "translateObjects.h"
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
diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp
index 9cbd0bef..92250a50 100644
--- a/linux/fsfwconfig/events/translateEvents.cpp
+++ b/linux/fsfwconfig/events/translateEvents.cpp
@@ -1,7 +1,7 @@
/**
* @brief Auto-generated event translation file. Contains 162 translations.
* @details
- * Generated on: 2022-03-07 17:09:35
+ * Generated on: 2022-03-11 14:31:47
*/
#include "translateEvents.h"
diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp
index b29ed5db..c0e79d7a 100644
--- a/linux/fsfwconfig/objects/translateObjects.cpp
+++ b/linux/fsfwconfig/objects/translateObjects.cpp
@@ -2,7 +2,7 @@
* @brief Auto-generated object translation file.
* @details
* Contains 113 translations.
- * Generated on: 2022-03-07 17:15:28
+ * Generated on: 2022-03-11 14:31:51
*/
#include "translateObjects.h"
diff --git a/mission/system/AcsBoardAssembly.cpp b/mission/system/AcsBoardAssembly.cpp
index 286bb106..903202b3 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
@@ -237,42 +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;
-}
-
-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 +285,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 +294,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..2b29a357 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,8 +71,12 @@ 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:
+ // Use these variables instead of magic numbers when generator was updated
+ // TRANSITION_OTHER_SIDE_FAILED_ID
+ // NOT_ENOUGH_DEVICES_DUAL_MODE_ID
+ // POWER_STATE_MACHINE_TIMEOUT_ID
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);
@@ -101,12 +105,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;
@@ -117,31 +119,13 @@ class AcsBoardAssembly : public AssemblyBase {
// 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 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..9c163721
--- /dev/null
+++ b/mission/system/DualLaneAssemblyBase.cpp
@@ -0,0 +1,105 @@
+#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();
+ }
+ // 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();
+ }
+}
+
+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) {
+ // 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) {
+ 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;
+}
+
+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) {
+ 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..c806561a
--- /dev/null
+++ b/mission/system/DualLaneAssemblyBase.h
@@ -0,0 +1,73 @@
+#ifndef MISSION_SYSTEM_DUALLANEASSEMBLYBASE_H_
+#define MISSION_SYSTEM_DUALLANEASSEMBLYBASE_H_
+
+#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;
+ 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);
+
+ 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 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();
+
+ /**
+ * 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_ */
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();
};
diff --git a/tmtc b/tmtc
index de68ad93..eedb45e4 160000
--- a/tmtc
+++ b/tmtc
@@ -1 +1 @@
-Subproject commit de68ad9341fbe5570b84305f33562702e3486364
+Subproject commit eedb45e4f34bd77d328745808e9acfe4668a1e35