continued acs board assembly
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

This commit is contained in:
Robin Müller 2022-03-02 17:56:54 +01:00
parent 0b200cd296
commit 5873371d36
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
12 changed files with 341 additions and 27 deletions

View File

@ -6,8 +6,8 @@
#include "OBSWConfig.h"
#include "fsfw/timemanager/Countdown.h"
#include "linux/devices/devicedefinitions/StarTrackerDefinitions.h"
#include "mission/utility/Timestamp.h"
#include "mission/utility/ProgressPrinter.h"
#include "mission/utility/Timestamp.h"
StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId) {}

View File

@ -1 +1,249 @@
#include "AcsBoardAssembly.h"
#include <devices/powerSwitcherList.h>
#include <fsfw/power/PowerSwitchIF.h>
#include <fsfw/serviceinterface.h>
AcsBoardAssembly::AcsBoardAssembly(object_id_t objectId, object_id_t parentId,
PowerSwitchIF* switcher, AcsBoardHelper helper)
: AssemblyBase(objectId, parentId), switcher(switcher), helper(helper) {
if (switcher == nullptr) {
sif::error << "AcsBoardAssembly::AcsBoardAssembly: Invalid Power Switcher "
"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);
}
ReturnValue_t AcsBoardAssembly::commandChildren(Mode_t mode, Submode_t submode) {
ReturnValue_t result = RETURN_OK;
if (currentMode == mode and submode == currentSubmode) {
return result;
}
helper.gyro0SideAMode = childrenMap[helper.gyro0AdisIdSideA].mode;
helper.gyro1SideAMode = childrenMap[helper.gyro1L3gIdSideA].mode;
helper.gyro2SideBMode = childrenMap[helper.gyro2AdisIdSideB].mode;
helper.gyro3SideBMode = childrenMap[helper.gyro2AdisIdSideB].mode;
helper.mgm0SideAMode = childrenMap[helper.mgm0Lis3IdSideA].mode;
helper.mgm1SideAMode = childrenMap[helper.mgm1Rm3100IdSideA].mode;
helper.mgm2SideBMode = childrenMap[helper.mgm2Lis3IdSideB].mode;
helper.mgm3SideBMode = childrenMap[helper.mgm3Rm3100IdSideB].mode;
helper.gpsMode = childrenMap[helper.gpsId].mode;
if (mode == DeviceHandlerIF::MODE_NORMAL) {
handleNormalModeCmd(submode);
} else if (mode == MODE_ON) {
} else {
}
HybridIterator<ModeListEntry> tableIter(modeTable.begin(), modeTable.end());
executeTable(tableIter);
return result;
}
ReturnValue_t AcsBoardAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t AcsBoardAssembly::initialize() {
ReturnValue_t result = registerChild(helper.gyro0AdisIdSideA);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = registerChild(helper.gyro1L3gIdSideA);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = registerChild(helper.gyro2AdisIdSideB);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = registerChild(helper.gyro3L3gIdSideB);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = registerChild(helper.mgm0Lis3IdSideA);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = registerChild(helper.mgm1Rm3100IdSideA);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = registerChild(helper.mgm2Lis3IdSideB);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = registerChild(helper.mgm3Rm3100IdSideB);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
void AcsBoardAssembly::initModeTableEntry(object_id_t id, ModeListEntry& entry) {
modeTable.insert(entry);
entry.setObject(id);
entry.setMode(MODE_OFF);
entry.setSubmode(SUBMODE_NONE);
entry.setInheritSubmode(false);
}
ReturnValue_t AcsBoardAssembly::isModeCombinationValid(Mode_t mode, Submode_t submode) {
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;
}
ReturnValue_t AcsBoardAssembly::handleNormalModeCmd(Submode_t submode) {
ReturnValue_t result = RETURN_OK;
Mode_t tgtMode = DeviceHandlerIF::MODE_NORMAL;
powerStateMachine(submode);
if (state == States::MODE_COMMANDING) {
auto cmdSeq = [&](object_id_t objectId, ModeTableIdx tableIdx) {
if (isUseable(objectId, mode)) {
if (helper.gyro0SideAMode != MODE_OFF) {
modeTable[tableIdx].setMode(tgtMode);
modeTable[tableIdx].setSubmode(SUBMODE_NONE);
} else {
result = NEED_SECOND_STEP;
modeTable[tableIdx].setMode(MODE_ON);
modeTable[tableIdx].setSubmode(SUBMODE_NONE);
}
}
};
switch (submode) {
case (A_SIDE): {
cmdSeq(helper.gyro0AdisIdSideA, ModeTableIdx::GYRO_0_A);
cmdSeq(helper.gyro1L3gIdSideA, ModeTableIdx::GYRO_1_A);
cmdSeq(helper.mgm0Lis3IdSideA, ModeTableIdx::MGM_0_A);
cmdSeq(helper.mgm1Rm3100IdSideA, ModeTableIdx::MGM_1_A);
modeTable[ModeTableIdx::GYRO_2_B].setMode(MODE_OFF);
modeTable[ModeTableIdx::GYRO_2_B].setSubmode(SUBMODE_NONE);
modeTable[ModeTableIdx::GYRO_3_B].setMode(MODE_OFF);
modeTable[ModeTableIdx::GYRO_3_B].setSubmode(SUBMODE_NONE);
modeTable[ModeTableIdx::MGM_2_B].setMode(MODE_OFF);
modeTable[ModeTableIdx::MGM_2_B].setSubmode(SUBMODE_NONE);
modeTable[ModeTableIdx::MGM_3_B].setMode(MODE_OFF);
modeTable[ModeTableIdx::MGM_3_B].setSubmode(SUBMODE_NONE);
return result;
}
case (B_SIDE): {
cmdSeq(helper.gyro2AdisIdSideB, ModeTableIdx::GYRO_2_B);
cmdSeq(helper.gyro3L3gIdSideB, ModeTableIdx::GYRO_3_B);
cmdSeq(helper.mgm2Lis3IdSideB, ModeTableIdx::MGM_2_B);
cmdSeq(helper.mgm3Rm3100IdSideB, ModeTableIdx::MGM_3_B);
modeTable[ModeTableIdx::GYRO_0_A].setMode(MODE_OFF);
modeTable[ModeTableIdx::GYRO_0_A].setSubmode(SUBMODE_NONE);
modeTable[ModeTableIdx::GYRO_1_A].setMode(MODE_OFF);
modeTable[ModeTableIdx::GYRO_1_A].setSubmode(SUBMODE_NONE);
modeTable[ModeTableIdx::MGM_0_A].setMode(MODE_OFF);
modeTable[ModeTableIdx::MGM_0_A].setSubmode(SUBMODE_NONE);
modeTable[ModeTableIdx::MGM_1_A].setMode(MODE_OFF);
modeTable[ModeTableIdx::MGM_1_A].setSubmode(SUBMODE_NONE);
return result;
}
case (DUAL_MODE): {
cmdSeq(helper.gyro0AdisIdSideA, ModeTableIdx::GYRO_0_A);
cmdSeq(helper.gyro1L3gIdSideA, ModeTableIdx::GYRO_1_A);
cmdSeq(helper.gyro2AdisIdSideB, ModeTableIdx::GYRO_2_B);
cmdSeq(helper.gyro3L3gIdSideB, ModeTableIdx::GYRO_3_B);
cmdSeq(helper.mgm0Lis3IdSideA, ModeTableIdx::MGM_0_A);
cmdSeq(helper.mgm1Rm3100IdSideA, ModeTableIdx::MGM_1_A);
cmdSeq(helper.mgm2Lis3IdSideB, ModeTableIdx::MGM_2_B);
cmdSeq(helper.mgm3Rm3100IdSideB, ModeTableIdx::MGM_3_B);
return result;
}
default: {
sif::error << "AcsBoardAssembly::handleNormalModeCmd: Unknown submode" << std::endl;
}
}
}
return result;
}
void AcsBoardAssembly::powerStateMachine(Submode_t submode) {
ReturnValue_t switchStateA = switcher->getSwitchState(pcduSwitches::ACS_BOARD_SIDE_A);
ReturnValue_t switchStateB = switcher->getSwitchState(pcduSwitches::ACS_BOARD_SIDE_B);
switch (submode) {
case (A_SIDE): {
if (switchStateA == PowerSwitchIF::SWITCH_ON and switchStateB == PowerSwitchIF::SWITCH_OFF) {
state = States::MODE_COMMANDING;
return;
}
break;
}
case (B_SIDE): {
if (switchStateA == PowerSwitchIF::SWITCH_OFF and switchStateB == PowerSwitchIF::SWITCH_ON) {
state = States::MODE_COMMANDING;
return;
}
break;
}
case (DUAL_MODE): {
if (switchStateA == PowerSwitchIF::SWITCH_ON and switchStateB == PowerSwitchIF::SWITCH_ON) {
state = States::MODE_COMMANDING;
return;
}
}
}
if (state == States::IDLE) {
switch (submode) {
case (A_SIDE): {
if (switchStateA != PowerSwitchIF::SWITCH_ON) {
// Set A side on first in power switcher IF
switcher->sendSwitchCommand(pcduSwitches::ACS_BOARD_SIDE_A, true);
}
if (switchStateB != PowerSwitchIF::SWITCH_OFF) {
switcher->sendSwitchCommand(pcduSwitches::ACS_BOARD_SIDE_B, false);
}
break;
}
case (B_SIDE): {
if (switchStateA != PowerSwitchIF::SWITCH_OFF) {
// Set A side on first in power switcher IF
switcher->sendSwitchCommand(pcduSwitches::ACS_BOARD_SIDE_A, false);
}
if (switchStateB != PowerSwitchIF::SWITCH_ON) {
switcher->sendSwitchCommand(pcduSwitches::ACS_BOARD_SIDE_B, true);
}
break;
}
case (DUAL_MODE): {
if (switchStateA != PowerSwitchIF::SWITCH_ON) {
// Set A side on first in power switcher IF
switcher->sendSwitchCommand(pcduSwitches::ACS_BOARD_SIDE_A, true);
}
if (switchStateB != PowerSwitchIF::SWITCH_ON) {
switcher->sendSwitchCommand(pcduSwitches::ACS_BOARD_SIDE_B, true);
}
break;
}
}
state = States::SWITCHING_POWER;
}
if (state == States::SWITCHING_POWER) {
// TODO: Could check for a timeout (temporal or cycles) here and resent command
}
}

View File

@ -1,8 +1,98 @@
#ifndef MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
#define MISSION_SYSTEM_ACSBOARDASSEMBLY_H_
#include <fsfw/devicehandlers/AssemblyBase.h>
#include <fsfw/objectmanager/frameworkObjects.h>
struct AcsBoardHelper {
AcsBoardHelper(object_id_t mgm0Id, object_id_t mgm1Id, object_id_t mgm2Id, object_id_t mgm3Id,
object_id_t gyro0Id, object_id_t gyro1Id, object_id_t gyro2Id, object_id_t gyro3Id,
object_id_t gpsId)
: mgm0Lis3IdSideA(mgm0Id),
mgm1Rm3100IdSideA(mgm1Id),
mgm2Lis3IdSideB(mgm2Id),
mgm3Rm3100IdSideB(mgm3Id),
gyro0AdisIdSideA(gyro0Id),
gyro1L3gIdSideA(gyro1Id),
gyro2AdisIdSideB(gyro2Id),
gyro3L3gIdSideB(gyro3Id) {}
object_id_t mgm0Lis3IdSideA = objects::NO_OBJECT;
object_id_t mgm1Rm3100IdSideA = objects::NO_OBJECT;
object_id_t mgm2Lis3IdSideB = objects::NO_OBJECT;
object_id_t mgm3Rm3100IdSideB = objects::NO_OBJECT;
object_id_t gyro0AdisIdSideA = objects::NO_OBJECT;
object_id_t gyro1L3gIdSideA = objects::NO_OBJECT;
object_id_t gyro2AdisIdSideB = objects::NO_OBJECT;
object_id_t gyro3L3gIdSideB = objects::NO_OBJECT;
object_id_t gpsId = objects::NO_OBJECT;
Mode_t gyro0SideAMode = HasModesIF::MODE_OFF;
Mode_t gyro1SideAMode = HasModesIF::MODE_OFF;
Mode_t gyro2SideBMode = HasModesIF::MODE_OFF;
Mode_t gyro3SideBMode = HasModesIF::MODE_OFF;
Mode_t mgm0SideAMode = HasModesIF::MODE_OFF;
Mode_t mgm1SideAMode = HasModesIF::MODE_OFF;
Mode_t mgm2SideBMode = HasModesIF::MODE_OFF;
Mode_t mgm3SideBMode = HasModesIF::MODE_OFF;
Mode_t gpsMode = HasModesIF::MODE_OFF;
};
enum ModeTableIdx : uint8_t {
MGM_0_A = 0,
MGM_1_A = 1,
MGM_2_B = 2,
MGM_3_B = 3,
GYRO_0_A = 4,
GYRO_1_A = 5,
GYRO_2_B = 6,
GYRO_3_B = 7,
GPS = 8
};
static constexpr uint8_t NUMBER_DEVICES_MODE_TABLE = 9;
class PowerSwitchIF;
class AcsBoardAssembly : public AssemblyBase {
public:
AcsBoardAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* switcher,
AcsBoardHelper helper);
private:
enum class States { IDLE, SWITCHING_POWER, MODE_COMMANDING };
States state = States::IDLE;
Mode_t currentMode = MODE_OFF;
Submode_t currentSubmode = A_SIDE;
PowerSwitchIF* switcher = nullptr;
AcsBoardHelper helper;
void initModeTableEntry(object_id_t id, ModeListEntry& entry);
ReturnValue_t initialize() override;
FixedArrayList<ModeListEntry, NUMBER_DEVICES_MODE_TABLE> modeTable;
static constexpr Submode_t A_SIDE = 0;
static constexpr Submode_t B_SIDE = 1;
static constexpr Submode_t DUAL_MODE = 2;
// 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;
/**
* 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 handleNormalModeCmd(Submode_t submode);
void powerStateMachine(Submode_t submode);
};
#endif /* MISSION_SYSTEM_ACSBOARDASSEMBLY_H_ */

View File

@ -1,8 +1,4 @@
#ifndef MISSION_SYSTEM_ACSSUBSYSTEM_H_
#define MISSION_SYSTEM_ACSSUBSYSTEM_H_
#endif /* MISSION_SYSTEM_ACSSUBSYSTEM_H_ */

View File

@ -1,3 +1 @@
#include "ComSubsystem.h"

View File

@ -1,8 +1,4 @@
#ifndef MISSION_SYSTEM_COMSUBSYSTEM_H_
#define MISSION_SYSTEM_COMSUBSYSTEM_H_
#endif /* MISSION_SYSTEM_COMSUBSYSTEM_H_ */

View File

@ -1,2 +1 @@
#include "EiveSystem.h"

View File

@ -1,8 +1,4 @@
#ifndef MISSION_SYSTEM_EIVESYSTEM_H_
#define MISSION_SYSTEM_EIVESYSTEM_H_
#endif /* MISSION_SYSTEM_EIVESYSTEM_H_ */

View File

@ -1,2 +1 @@
#include "PayloadSubsystem.h"

View File

@ -1,8 +1,4 @@
#ifndef MISSION_SYSTEM_PAYLOADSUBSYSTEM_H_
#define MISSION_SYSTEM_PAYLOADSUBSYSTEM_H_
#endif /* MISSION_SYSTEM_PAYLOADSUBSYSTEM_H_ */

View File

@ -1,8 +1,4 @@
#ifndef MISSION_SYSTEM_TCSSUBSYSTEM_H_
#define MISSION_SYSTEM_TCSSUBSYSTEM_H_
#endif /* MISSION_SYSTEM_TCSSUBSYSTEM_H_ */

View File

@ -1,11 +1,11 @@
#include "ProgressPrinter.h"
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
ProgressPrinter::ProgressPrinter(std::string name, uint32_t numSteps)
: name(name), numSteps(numSteps) {}
ProgressPrinter::~ProgressPrinter() {
}
ProgressPrinter::~ProgressPrinter() {}
void ProgressPrinter::print(uint32_t currentStep) {
float progressInPercent = static_cast<float>(currentStep) / static_cast<float>(numSteps) * 100;