Merge branch 'mueller/system-subsystems' into mueller/master

This commit is contained in:
Robin Müller 2022-03-11 14:34:10 +01:00
commit 47beaad58c
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
26 changed files with 247 additions and 269 deletions

View File

@ -37,8 +37,12 @@ endif()
include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake) include(${CMAKE_SCRIPT_PATH}/PreProjectConfig.cmake)
pre_project_config() 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 Name
project(eive-obsw ASM C CXX) project(eive-obsw)
################################################################################ ################################################################################
# Pre-Sources preparation # Pre-Sources preparation
@ -150,9 +154,6 @@ set(FSFW_ADDITIONAL_INC_PATHS
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
) )
# Check whether the user has already installed Catch2 first
find_package(Catch2 3)
################################################################################ ################################################################################
# Executable and Sources # Executable and Sources
################################################################################ ################################################################################
@ -199,8 +200,10 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(COMPILER_FLAGS "/permissive-") set(COMPILER_FLAGS "/permissive-")
endif() endif()
# Not installed, so use FetchContent to download and provide Catch2 # Not installed, so use FetchContent to download and provide Catch2
if(NOT Catch2_FOUND) if(NOT Catch2_FOUND)
message(STATUS "Did not find a valid Catch2 installation. Using FetchContent to install it")
include(FetchContent) include(FetchContent)
FetchContent_Declare( FetchContent_Declare(

View File

@ -625,9 +625,9 @@ ReturnValue_t CoreController::initVersionFile() {
std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." + std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." +
std::to_string(SW_SUBVERSION) + "." + std::to_string(SW_SUBVERSION) + "." +
std::to_string(SW_REVISION); std::to_string(SW_REVISION);
std::string fullFsfwVersionString = "FSFW: v" + std::to_string(FSFW_VERSION.major) + "." + char versionString[16] = {};
std::to_string(FSFW_VERSION.minor) + "." + fsfw::FSFW_VERSION.getVersion(versionString, sizeof(versionString));
std::to_string(FSFW_VERSION.revision); std::string fullFsfwVersionString = "FSFW: v" + std::string(versionString);
std::string systemString = "System: " + unameLine; std::string systemString = "System: " + unameLine;
std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix(); std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix();
std::string versionFilePath = mountPrefix + VERSION_FILE; std::string versionFilePath = mountPrefix + VERSION_FILE;

View File

@ -14,7 +14,6 @@ static int OBSW_ALREADY_RUNNING = -2;
int obsw::obsw() { int obsw::obsw() {
using namespace fsfw; using namespace fsfw;
fsfw::getVersion(version);
std::cout << "-- EIVE OBSW --" << std::endl; std::cout << "-- EIVE OBSW --" << std::endl;
#if BOARD_TE0720 == 0 #if BOARD_TE0720 == 0
std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl; std::cout << "-- Compiled for Linux (Xiphos Q7S) --" << std::endl;
@ -22,8 +21,7 @@ int obsw::obsw() {
std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; std::cout << "-- Compiled for Linux (TE0720) --" << std::endl;
#endif #endif
std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << "." << SW_REVISION << ", FSFW v" std::cout << "-- OBSW v" << SW_VERSION << "." << SW_SUBVERSION << "." << SW_REVISION << ", FSFW v"
<< FSFW_VERSION.major << "." << FSFW_VERSION.minor << "." << FSFW_VERSION.revision << FSFW_VERSION << "--" << std::endl;
<< "--" << std::endl;
std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl;
#if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1 #if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1

View File

@ -406,7 +406,7 @@ SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations& currentOp) {
bool bytesRead = false; bool bytesRead = false;
#if OBSW_ENABLE_TIMERS == 1 #if OBSW_ENABLE_TIMERS == 1
Countdown timer(100); Countdown timer(1000);
#endif #endif
while (true) { while (true) {
ReturnValue_t result = cmdExecutor.check(bytesRead); ReturnValue_t result = cmdExecutor.check(bytesRead);

View File

@ -75,7 +75,7 @@ ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& fil
int result = std::system(oss.str().c_str()); int result = std::system(oss.str().c_str());
if (result != 0) { if (result != 0) {
if (result == 256) { if (WEXITSTATUS(result) == 1) {
sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl;
// Could not find value // Could not find value
std::remove(filename.c_str()); std::remove(filename.c_str());

View File

@ -5,6 +5,6 @@ const char* const SW_NAME = "eive";
#define SW_VERSION 1 #define SW_VERSION 1
#define SW_SUBVERSION 9 #define SW_SUBVERSION 9
#define SW_REVISION 0 #define SW_REVISION 1
#endif /* COMMON_CONFIG_OBSWVERSION_H_ */ #endif /* COMMON_CONFIG_OBSWVERSION_H_ */

View File

@ -21,6 +21,7 @@ enum: uint8_t {
STR_HELPER = 120, STR_HELPER = 120,
PL_PCDU_HANDLER = 121, PL_PCDU_HANDLER = 121,
ACS_BOARD_ASS = 122, ACS_BOARD_ASS = 122,
SUS_BOARD_ASS = 123,
COMMON_SUBSYSTEM_ID_END COMMON_SUBSYSTEM_ID_END
}; };
} }

2
fsfw

@ -1 +1 @@
Subproject commit 9509847b849c18374a5df809c2fb83dd98d66dc3 Subproject commit fec5f83f4f2459facee25939e0292115f89a6d73

View File

@ -12,7 +12,7 @@
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/fsfwgen.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/gen.py" />
<option name="PARAMETERS" value="events" /> <option name="PARAMETERS" value="events" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />

View File

@ -12,7 +12,7 @@
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/fsfwgen.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/gen.py" />
<option name="PARAMETERS" value="objects" /> <option name="PARAMETERS" value="objects" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />

View File

@ -12,7 +12,7 @@
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/fsfwgen.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/gen.py" />
<option name="PARAMETERS" value="returnvalues" /> <option name="PARAMETERS" value="returnvalues" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 162 translations. * @brief Auto-generated event translation file. Contains 162 translations.
* @details * @details
* Generated on: 2022-03-07 17:09:35 * Generated on: 2022-03-11 14:31:47
*/ */
#include "translateEvents.h" #include "translateEvents.h"

@ -1 +1 @@
Subproject commit c5ef1783a3b082c0e88561bd91bc3ee0f459fafc Subproject commit 5dbe33ceb85b15f27e6722bb907df3ed324b701b

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 113 translations. * Contains 113 translations.
* Generated on: 2022-03-07 17:15:28 * Generated on: 2022-03-11 14:31:51
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -1,14 +1,7 @@
#! /usr/bin/python3 #! /usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """Part of the MIB export tools for the EIVE project by.
:file: returnvalues_parser.py Returnvalue exporter.
: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
""" """
from fsfwgen.core import get_console_logger from fsfwgen.core import get_console_logger
from fsfwgen.utility.file_management import copy_file from fsfwgen.utility.file_management import copy_file

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 162 translations. * @brief Auto-generated event translation file. Contains 162 translations.
* @details * @details
* Generated on: 2022-03-07 17:09:35 * Generated on: 2022-03-11 14:31:47
*/ */
#include "translateEvents.h" #include "translateEvents.h"

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 113 translations. * Contains 113 translations.
* Generated on: 2022-03-07 17:15:28 * Generated on: 2022-03-11 14:31:51
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -6,8 +6,8 @@
AcsBoardAssembly::AcsBoardAssembly(object_id_t objectId, object_id_t parentId, AcsBoardAssembly::AcsBoardAssembly(object_id_t objectId, object_id_t parentId,
PowerSwitchIF* switcher, AcsBoardHelper helper, GpioIF* gpioIF) PowerSwitchIF* switcher, AcsBoardHelper helper, GpioIF* gpioIF)
: AssemblyBase(objectId, parentId), : DualLaneAssemblyBase(objectId, parentId, switcher, SWITCH_A, SWITCH_B,
pwrStateMachine(SWITCH_A, SWITCH_B, switcher), POWER_STATE_MACHINE_TIMEOUT),
helper(helper), helper(helper),
gpioIF(gpioIF) { gpioIF(gpioIF) {
if (switcher == nullptr) { 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; sif::error << "AcsBoardAssembly::AcsBoardAssembly: Invalid GPIO IF passed" << std::endl;
} }
ModeListEntry entry; ModeListEntry entry;
initModeTableEntry(helper.mgm0Lis3IdSideA, entry); initModeTableEntry(helper.mgm0Lis3IdSideA, entry, modeTable);
initModeTableEntry(helper.mgm1Rm3100IdSideA, entry); initModeTableEntry(helper.mgm1Rm3100IdSideA, entry, modeTable);
initModeTableEntry(helper.mgm2Lis3IdSideB, entry); initModeTableEntry(helper.mgm2Lis3IdSideB, entry, modeTable);
initModeTableEntry(helper.mgm3Rm3100IdSideB, entry); initModeTableEntry(helper.mgm3Rm3100IdSideB, entry, modeTable);
initModeTableEntry(helper.gyro0AdisIdSideA, entry); initModeTableEntry(helper.gyro0AdisIdSideA, entry, modeTable);
initModeTableEntry(helper.gyro1L3gIdSideA, entry); initModeTableEntry(helper.gyro1L3gIdSideA, entry, modeTable);
initModeTableEntry(helper.gyro2AdisIdSideB, entry); initModeTableEntry(helper.gyro2AdisIdSideB, entry, modeTable);
initModeTableEntry(helper.gyro3L3gIdSideB, entry); initModeTableEntry(helper.gyro3L3gIdSideB, entry, modeTable);
initModeTableEntry(helper.gpsId, entry); initModeTableEntry(helper.gpsId, entry, modeTable);
}
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);
}
} }
ReturnValue_t AcsBoardAssembly::commandChildren(Mode_t mode, Submode_t submode) { 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) { ReturnValue_t AcsBoardAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) {
using namespace duallane; using namespace duallane;
refreshHelperModes(); 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 (wantedSubmode == A_SIDE) {
if ((helper.gyro0SideAMode != wantedMode and helper.gyro1SideAMode != wantedMode) or if ((helper.gyro0SideAMode != wantedMode and helper.gyro1SideAMode != wantedMode) or
(helper.mgm0SideAMode != wantedMode and helper.mgm1SideAMode != 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; 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) { void AcsBoardAssembly::handleChildrenLostMode(ReturnValue_t result) {
using namespace duallane; using namespace duallane;
// Some ACS board components are required for Safe-Mode. It would be good if the software // 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() { void AcsBoardAssembly::finishModeOp() {
using namespace duallane; using namespace duallane;
AssemblyBase::handleModeReached(); AssemblyBase::handleModeReached();
@ -374,30 +294,6 @@ void AcsBoardAssembly::finishModeOp() {
dualModeErrorSwitch = true; 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 AcsBoardAssembly::initialize() {
ReturnValue_t result = registerChild(helper.gyro0AdisIdSideA); ReturnValue_t result = registerChild(helper.gyro0AdisIdSideA);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {

View File

@ -3,9 +3,9 @@
#include <common/config/commonSubsystemIds.h> #include <common/config/commonSubsystemIds.h>
#include <devices/powerSwitcherList.h> #include <devices/powerSwitcherList.h>
#include <fsfw/devicehandlers/AssemblyBase.h>
#include <fsfw/objectmanager/frameworkObjects.h> #include <fsfw/objectmanager/frameworkObjects.h>
#include "DualLaneAssemblyBase.h"
#include "DualLanePowerStateMachine.h" #include "DualLanePowerStateMachine.h"
struct AcsBoardHelper { 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 * 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. * ACS board where multiple sensors share the same power supply.
*/ */
class AcsBoardAssembly : public AssemblyBase { class AcsBoardAssembly : public DualLaneAssemblyBase {
public: 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 uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::ACS_BOARD_ASS;
static constexpr Event TRANSITION_OTHER_SIDE_FAILED = static constexpr Event TRANSITION_OTHER_SIDE_FAILED =
event::makeEvent(SUBSYSTEM_ID, 0, severity::HIGH); event::makeEvent(SUBSYSTEM_ID, 0, severity::HIGH);
@ -101,12 +105,10 @@ class AcsBoardAssembly : public AssemblyBase {
static constexpr pcduSwitches::Switches SWITCH_B = static constexpr pcduSwitches::Switches SWITCH_B =
pcduSwitches::Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3; pcduSwitches::Switches::PDU2_CH7_ACS_BOARD_SIDE_B_3V3;
// This helper object complete encapsulates power switching
DualLanePowerStateMachine pwrStateMachine;
bool tryingOtherSide = false; bool tryingOtherSide = false;
AcsBoardHelper helper; AcsBoardHelper helper;
GpioIF* gpioIF = nullptr; GpioIF* gpioIF = nullptr;
uint8_t powerRetryCounter = 0;
// duallane::PwrStates state = duallane::PwrStates::IDLE; // duallane::PwrStates state = duallane::PwrStates::IDLE;
duallane::Submodes defaultSubmode = duallane::Submodes::A_SIDE; duallane::Submodes defaultSubmode = duallane::Submodes::A_SIDE;
bool dualModeErrorSwitch = true; bool dualModeErrorSwitch = true;
@ -117,31 +119,13 @@ class AcsBoardAssembly : public AssemblyBase {
// AssemblyBase overrides // AssemblyBase overrides
ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) override; ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) override;
ReturnValue_t checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) 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 handleModeTransitionFailed(ReturnValue_t result) override;
void handleChildrenLostMode(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); ReturnValue_t handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode);
void initModeTableEntry(object_id_t id, ModeListEntry& entry);
void refreshHelperModes(); void refreshHelperModes();
void finishModeOp(); 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_ */ #endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */

View File

@ -7,4 +7,5 @@ target_sources(${LIB_EIVE_MISSION} PRIVATE
ComSubsystem.cpp ComSubsystem.cpp
TcsSubsystem.cpp TcsSubsystem.cpp
DualLanePowerStateMachine.cpp DualLanePowerStateMachine.cpp
DualLaneAssemblyBase.cpp
) )

View File

@ -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();
}
}

View File

@ -0,0 +1,73 @@
#ifndef MISSION_SYSTEM_DUALLANEASSEMBLYBASE_H_
#define MISSION_SYSTEM_DUALLANEASSEMBLYBASE_H_
#include <fsfw/devicehandlers/AssemblyBase.h>
#include <mission/system/DualLanePowerStateMachine.h>
/**
* @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 <size_t MAX_SIZE>
void initModeTableEntry(object_id_t id, ModeListEntry& entry,
FixedArrayList<ModeListEntry, MAX_SIZE>& modeTable);
private:
};
template <size_t MAX_SIZE>
inline void DualLaneAssemblyBase::initModeTableEntry(
object_id_t id, ModeListEntry& entry, FixedArrayList<ModeListEntry, MAX_SIZE>& modeTable) {
entry.setObject(id);
entry.setMode(MODE_OFF);
entry.setSubmode(SUBMODE_NONE);
entry.setInheritSubmode(false);
modeTable.insert(entry);
}
#endif /* MISSION_SYSTEM_DUALLANEASSEMBLYBASE_H_ */

View File

@ -6,10 +6,13 @@
SusAssembly::SusAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher, SusAssembly::SusAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
SusAssHelper helper) 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; ModeListEntry entry;
for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS; idx++) { 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) { ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submode) {
using namespace duallane;
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
auto cmdSeq = [&](object_id_t objectId, uint8_t tableIdx) { auto cmdSeq = [&](object_id_t objectId, uint8_t tableIdx) {
if (mode == DeviceHandlerIF::MODE_NORMAL) { if (mode == DeviceHandlerIF::MODE_NORMAL) {
@ -55,7 +59,7 @@ ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submod
} }
}; };
switch (submode) { switch (submode) {
case (NOMINAL): { case (A_SIDE): {
for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS_ONE_SIDE; idx++) { for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS_ONE_SIDE; idx++) {
cmdSeq(helper.susIds[idx], idx); cmdSeq(helper.susIds[idx], idx);
// Switch off devices on redundant side // Switch off devices on redundant side
@ -64,7 +68,7 @@ ReturnValue_t SusAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t submod
} }
return result; return result;
} }
case (REDUNDANT): { case (B_SIDE): {
for (uint8_t idx = NUMBER_SUN_SENSORS_ONE_SIDE; idx < NUMBER_SUN_SENSORS; idx++) { for (uint8_t idx = NUMBER_SUN_SENSORS_ONE_SIDE; idx < NUMBER_SUN_SENSORS; idx++) {
cmdSeq(helper.susIds[idx], idx); cmdSeq(helper.susIds[idx], idx);
// Switch devices on nominal side // 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) { ReturnValue_t SusAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) {
using namespace duallane;
refreshHelperModes(); refreshHelperModes();
if (wantedSubmode == NOMINAL) { if (wantedSubmode == A_SIDE) {
for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS_ONE_SIDE; idx++) { for (uint8_t idx = 0; idx < NUMBER_SUN_SENSORS_ONE_SIDE; idx++) {
if (helper.susModes[idx] != wantedMode) { if (helper.susModes[idx] != wantedMode) {
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE; return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
} }
} }
return RETURN_OK; 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++) { for (uint8_t idx = NUMBER_SUN_SENSORS_ONE_SIDE; idx < NUMBER_SUN_SENSORS; idx++) {
if (helper.susModes[idx] != wantedMode) { if (helper.susModes[idx] != wantedMode) {
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE; return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
@ -108,13 +113,6 @@ ReturnValue_t SusAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wan
return RETURN_OK; 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 SusAssembly::initialize() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
for (const auto& id : helper.susIds) { for (const auto& id : helper.susIds) {
@ -142,92 +140,13 @@ bool SusAssembly::isUseable(object_id_t object, Mode_t mode) {
return false; 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() { void SusAssembly::handleModeReached() {
AssemblyBase::handleModeReached(); AssemblyBase::handleModeReached();
state = States::IDLE; 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() { void SusAssembly::refreshHelperModes() {
for (uint8_t idx = 0; idx < helper.susModes.size(); idx++) { for (uint8_t idx = 0; idx < helper.susModes.size(); idx++) {
helper.susModes[idx] = childrenMap[helper.susIds[idx]].mode; 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);
}

View File

@ -4,6 +4,8 @@
#include <devices/powerSwitcherList.h> #include <devices/powerSwitcherList.h>
#include <fsfw/devicehandlers/AssemblyBase.h> #include <fsfw/devicehandlers/AssemblyBase.h>
#include "DualLaneAssemblyBase.h"
struct SusAssHelper { struct SusAssHelper {
public: public:
SusAssHelper(std::array<object_id_t, 12> susIds) : susIds(susIds) {} SusAssHelper(std::array<object_id_t, 12> susIds) : susIds(susIds) {}
@ -13,14 +15,18 @@ struct SusAssHelper {
class PowerSwitchIF; class PowerSwitchIF;
class SusAssembly : AssemblyBase { class SusAssembly : DualLaneAssemblyBase {
public: public:
static constexpr uint8_t NUMBER_SUN_SENSORS_ONE_SIDE = 6; static constexpr uint8_t NUMBER_SUN_SENSORS_ONE_SIDE = 6;
static constexpr uint8_t NUMBER_SUN_SENSORS = 12; static constexpr uint8_t NUMBER_SUN_SENSORS = 12;
static constexpr Submode_t NOMINAL = 0; static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SUS_BOARD_ASS;
static constexpr Submode_t REDUNDANT = 1; static constexpr Event TRANSITION_OTHER_SIDE_FAILED =
static constexpr Submode_t DUAL_MODE = 2; 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, SusAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher,
SusAssHelper helper); SusAssHelper helper);
@ -54,7 +60,6 @@ class SusAssembly : AssemblyBase {
bool isUseable(object_id_t object, Mode_t mode); bool isUseable(object_id_t object, Mode_t mode);
void powerStateMachine(Mode_t mode, Submode_t submode); void powerStateMachine(Mode_t mode, Submode_t submode);
ReturnValue_t handleNormalOrOnModeCmd(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(); void refreshHelperModes();
}; };

2
tmtc

@ -1 +1 @@
Subproject commit de68ad9341fbe5570b84305f33562702e3486364 Subproject commit eedb45e4f34bd77d328745808e9acfe4668a1e35