tcs assembly working for now
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2022-03-22 20:35:37 +01:00
parent 5fb4e468ba
commit 3e9910b1d2
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
6 changed files with 86 additions and 42 deletions

2
fsfw

@ -1 +1 @@
Subproject commit bbe21e7e8957a39e6697c6dd4fb2fe044b560044
Subproject commit 4b5e3e70f7eb65780b697a81ba95ecc2a74a8b84

View File

@ -87,6 +87,7 @@ void Max31865PT1000Handler::doStartUp() {
void Max31865PT1000Handler::doShutDown() {
commandExecuted = false;
warningSwitch = true;
setMode(_MODE_POWER_DOWN);
}
@ -319,15 +320,15 @@ ReturnValue_t Max31865PT1000Handler::interpretDeviceReply(DeviceCommandId_t id,
switch (id) {
case (Max31865Definitions::REQUEST_CONFIG): {
if (packet[1] != DEFAULT_CONFIG) {
if(warningSwitch) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
if (warningSwitch) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
// it propably would be better if we at least try one restart..
sif::warning << "Max31865PT1000Handler: 0x" << std::hex << this->getObjectId()
<< ": Invalid configuration reply" << std::endl;
#else
<< ": Invalid configuration reply" << std::endl;
#else
sif::printWarning("Max31865PT1000Handler: %04x: Invalid configuration reply!\n",
this->getObjectId());
#endif
this->getObjectId());
#endif
warningSwitch = false;
}
return HasReturnvaluesIF::RETURN_OK;
@ -508,10 +509,6 @@ ReturnValue_t Max31865PT1000Handler::getSwitches(const uint8_t **switches,
return DeviceHandlerBase::NO_SWITCH;
}
void Max31865PT1000Handler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
DeviceHandlerBase::doTransition(modeFrom, subModeFrom);
}
ReturnValue_t Max31865PT1000Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(Max31865Definitions::PoolIds::RTD_VALUE, new PoolEntry<float>({0}));

View File

@ -74,8 +74,6 @@ class Max31865PT1000Handler : public DeviceHandlerBase {
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override;
void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
void debugInterface(uint8_t positionTracker = 0, object_id_t objectId = 0,
uint32_t parameter = 0) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
@ -84,7 +82,7 @@ class Max31865PT1000Handler : public DeviceHandlerBase {
private:
uint8_t switchId = 0;
bool instantNormal = true;
bool instantNormal = false;
bool warningSwitch = true;
enum class InternalState {

View File

@ -8,6 +8,14 @@ TcsBoardAssembly::TcsBoardAssembly(object_id_t objectId, object_id_t parentId,
TcsBoardHelper helper)
: AssemblyBase(objectId, parentId, 24), switcher(pwrSwitcher, theSwitch), helper(helper) {
eventQueue = QueueFactory::instance()->createMessageQueue(24);
ModeListEntry entry;
for (uint8_t idx = 0; idx < NUMBER_RTDS; idx++) {
entry.setObject(helper.rtdIds[idx]);
entry.setMode(MODE_OFF);
entry.setSubmode(SUBMODE_NONE);
entry.setInheritSubmode(false);
modeTable.insert(entry);
}
}
void TcsBoardAssembly::performChildOperation() {
@ -24,7 +32,7 @@ void TcsBoardAssembly::performChildOperation() {
switcher.getState() == PowerSwitcher::SWITCH_IS_ON) {
// Indicator that mode commanding can be performed now
AssemblyBase::startTransition(targetMode, targetSubmode);
AssemblyBase::performChildOperation();
// AssemblyBase::performChildOperation();
}
}
@ -46,14 +54,33 @@ ReturnValue_t TcsBoardAssembly::commandChildren(Mode_t mode, Submode_t submode)
}
ReturnValue_t TcsBoardAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) {
uint8_t devsInWrongMode = 0;
for (uint8_t idx = 0; idx < NUMBER_RTDS; idx++) {
if (childrenMap[idx].mode != wantedMode) {
devsInWrongMode++;
int devsInWrongMode = 0;
try {
for (uint8_t idx = 0; idx < NUMBER_RTDS; idx++) {
if (childrenMap.at(helper.rtdIds[idx]).mode != wantedMode) {
devsInWrongMode++;
}
}
} catch (const std::out_of_range& e) {
sif::error << "TcsBoardAssembly: Invalid children map: " << e.what() << std::endl;
}
if (devsInWrongMode == 16) {
if (warningSwitch) {
sif::warning << "TcsBoardAssembly::checkChildrenStateOn: All devices in"
<< " wrong mode" << std::endl;
warningSwitch = false;
}
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
}
// TODO: Can't really do something other than power cycling if devices in wrong mode.
// Might attempt one power-cycle. In any case, trigger an event
if (devsInWrongMode > 0) {
if (warningSwitch) {
sif::warning << "TcsBoardAssembly::checkChildrenStateOn: " << devsInWrongMode << " devices in"
<< " wrong mode" << std::endl;
warningSwitch = false;
}
}
return RETURN_OK;
}
@ -77,7 +104,7 @@ ReturnValue_t TcsBoardAssembly::initialize() {
void TcsBoardAssembly::startTransition(Mode_t mode, Submode_t submode) {
if (mode != MODE_OFF) {
switcher.turnOn();
switcher.turnOn(true);
switcher.doStateMachine();
if (switcher.getState() == PowerSwitcher::SWITCH_IS_ON) {
AssemblyBase::startTransition(mode, submode);
@ -87,6 +114,7 @@ void TcsBoardAssembly::startTransition(Mode_t mode, Submode_t submode) {
targetSubmode = submode;
}
} else {
// Perform regular mode commanding first
AssemblyBase::startTransition(mode, submode);
}
}
@ -96,30 +124,34 @@ ReturnValue_t TcsBoardAssembly::handleNormalOrOnModeCmd(Mode_t mode, Submode_t s
bool needsSecondStep = false;
Mode_t devMode = 0;
object_id_t objId = 0;
for (uint8_t idx = 0; idx < NUMBER_RTDS; idx++) {
devMode = childrenMap[idx].mode;
objId = helper.rtdIds[idx];
if (mode == devMode) {
modeTable[idx].setMode(mode);
} else if (mode == DeviceHandlerIF::MODE_NORMAL) {
if (isUseable(objId, devMode)) {
if (devMode == MODE_ON) {
modeTable[idx].setMode(mode);
modeTable[idx].setSubmode(SUBMODE_NONE);
} else {
modeTable[idx].setMode(MODE_ON);
modeTable[idx].setSubmode(SUBMODE_NONE);
if (internalState != STATE_SECOND_STEP) {
needsSecondStep = true;
try {
for (uint8_t idx = 0; idx < NUMBER_RTDS; idx++) {
devMode = childrenMap.at(helper.rtdIds[idx]).mode;
objId = helper.rtdIds[idx];
if (mode == devMode) {
modeTable[idx].setMode(mode);
} else if (mode == DeviceHandlerIF::MODE_NORMAL) {
if (isUseable(objId, devMode)) {
if (devMode == MODE_ON) {
modeTable[idx].setMode(mode);
modeTable[idx].setSubmode(SUBMODE_NONE);
} else {
modeTable[idx].setMode(MODE_ON);
modeTable[idx].setSubmode(SUBMODE_NONE);
if (internalState != STATE_SECOND_STEP) {
needsSecondStep = true;
}
}
}
}
} else if (mode == MODE_ON) {
if (isUseable(objId, devMode)) {
modeTable[idx].setMode(MODE_ON);
modeTable[idx].setSubmode(SUBMODE_NONE);
} else if (mode == MODE_ON) {
if (isUseable(objId, devMode)) {
modeTable[idx].setMode(MODE_ON);
modeTable[idx].setSubmode(SUBMODE_NONE);
}
}
}
} catch (const std::out_of_range& e) {
sif::error << "TcsBoardAssembly: Invalid children map: " << e.what() << std::endl;
}
if (needsSecondStep) {
result = NEED_SECOND_STEP;
@ -147,7 +179,7 @@ MessageQueueId_t TcsBoardAssembly::getEventReceptionQueue() { return eventQueue-
void TcsBoardAssembly::handleModeReached() {
if (targetMode == MODE_OFF) {
switcher.turnOff();
switcher.turnOff(true);
switcher.doStateMachine();
// Need to wait with call to AssemblyBase::handleModeReached until power switcher is done
if (switcher.getState() == PowerSwitcher::SWITCH_IS_OFF) {
@ -157,3 +189,17 @@ void TcsBoardAssembly::handleModeReached() {
AssemblyBase::handleModeReached();
}
}
void TcsBoardAssembly::handleChildrenLostMode(ReturnValue_t result) {
// TODO: Maybe trigger event
return;
}
void TcsBoardAssembly::handleModeTransitionFailed(ReturnValue_t result) {
if (targetMode == MODE_OFF) {
AssemblyBase::handleModeTransitionFailed(result);
} else {
// To avoid transitioning back to off
triggerEvent(MODE_TRANSITION_FAILED, result);
}
}

View File

@ -23,6 +23,7 @@ class TcsBoardAssembly : public AssemblyBase, public ConfirmsFailuresIF {
private:
static constexpr uint8_t NUMBER_RTDS = 16;
PowerSwitcher switcher;
bool warningSwitch = true;
TcsBoardHelper helper;
FixedArrayList<ModeListEntry, NUMBER_RTDS> modeTable;
MessageQueueIF* eventQueue = nullptr;
@ -45,6 +46,8 @@ class TcsBoardAssembly : public AssemblyBase, public ConfirmsFailuresIF {
ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
void startTransition(Mode_t mode, Submode_t submode) override;
void handleModeReached() override;
void handleChildrenLostMode(ReturnValue_t result) override;
void handleModeTransitionFailed(ReturnValue_t result) override;
};
#endif /* MISSION_SYSTEM_TCSSUBSYSTEM_H_ */

2
tmtc

@ -1 +1 @@
Subproject commit a55940339850e862b05a06a94fa8381bf7da0743
Subproject commit 0abdea987a677a629173b6ec9cd2fa8dc265cb24