From 7e230b64ea98602376ea7a2d655abcbdbcfdd2c8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 28 Apr 2022 15:29:57 +0200 Subject: [PATCH] create and add syrlinks fdir --- bsp_q7s/core/ObjectFactory.cpp | 14 +- linux/ObjectFactory.cpp | 4 +- mission/devices/SyrlinksHkHandler.cpp | 4 +- mission/devices/SyrlinksHkHandler.h | 2 +- mission/system/CMakeLists.txt | 4 - mission/system/fdir/CMakeLists.txt | 6 + mission/system/fdir/SyrlinksFdir.cpp | 183 +++++++++++++------------- mission/system/fdir/SyrlinksFdir.h | 4 +- 8 files changed, 114 insertions(+), 107 deletions(-) create mode 100644 mission/system/fdir/CMakeLists.txt diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index ecc88ede..f0204cb4 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,5 +1,7 @@ #include "ObjectFactory.h" +#include + #include "OBSWConfig.h" #include "bsp_q7s/boardtest/Q7STestTask.h" #include "bsp_q7s/callbacks/gnssCallback.h" @@ -37,11 +39,11 @@ #include "linux/obc/PdecHandler.h" #include "linux/obc/Ptme.h" #include "linux/obc/PtmeConfig.h" -#include "mission/system/AcsBoardFdir.h" -#include "mission/system/RtdFdir.h" #include "mission/system/SusAssembly.h" -#include "mission/system/SusFdir.h" #include "mission/system/TcsBoardAssembly.h" +#include "mission/system/fdir/AcsBoardFdir.h" +#include "mission/system/fdir/RtdFdir.h" +#include "mission/system/fdir/SusFdir.h" #include "tmtc/apid.h" #include "tmtc/pusIds.h" @@ -629,8 +631,10 @@ void ObjectFactory::createSyrlinksComponents(PowerSwitchIF* pwrSwitcher) { syrlinks::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); syrlinksUartCookie->setParityEven(); - auto syrlinksHandler = new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, - syrlinksUartCookie, pcdu::PDU1_CH1_SYRLINKS_12V); + auto syrlinksFdir = new SyrlinksFdir(objects::SYRLINKS_HK_HANDLER); + auto syrlinksHandler = + new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie, + pcdu::PDU1_CH1_SYRLINKS_12V, syrlinksFdir); syrlinksHandler->setPowerSwitcher(pwrSwitcher); } diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 7811fdbe..816fa71d 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -9,10 +9,10 @@ #include #include #include -#include #include -#include #include +#include +#include #include "OBSWConfig.h" #include "devConf.h" diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 43888724..81a832e4 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -5,8 +5,8 @@ #include "OBSWConfig.h" SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - power::Switch_t powerSwitch) - : DeviceHandlerBase(objectId, comIF, comCookie), + power::Switch_t powerSwitch, FailureIsolationBase* customFdir) + : DeviceHandlerBase(objectId, comIF, comCookie, customFdir), rxDataset(this), txDataset(this), temperatureSet(this), diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 78ae6d99..7143327f 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -20,7 +20,7 @@ class SyrlinksHkHandler : public DeviceHandlerBase { public: SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - power::Switch_t powerSwitch); + power::Switch_t powerSwitch, FailureIsolationBase* customFdir); virtual ~SyrlinksHkHandler(); /** diff --git a/mission/system/CMakeLists.txt b/mission/system/CMakeLists.txt index 24ecaafb..b6f4baab 100644 --- a/mission/system/CMakeLists.txt +++ b/mission/system/CMakeLists.txt @@ -10,10 +10,6 @@ target_sources(${LIB_EIVE_MISSION} PRIVATE PowerStateMachineBase.cpp DualLaneAssemblyBase.cpp TcsBoardAssembly.cpp - - AcsBoardFdir.cpp - SusFdir.cpp - RtdFdir.cpp ) add_subdirectory(fdir) diff --git a/mission/system/fdir/CMakeLists.txt b/mission/system/fdir/CMakeLists.txt new file mode 100644 index 00000000..cf99cfdf --- /dev/null +++ b/mission/system/fdir/CMakeLists.txt @@ -0,0 +1,6 @@ +target_sources(${LIB_EIVE_MISSION} PRIVATE + AcsBoardFdir.cpp + RtdFdir.cpp + SusFdir.cpp + SyrlinksFdir.cpp +) diff --git a/mission/system/fdir/SyrlinksFdir.cpp b/mission/system/fdir/SyrlinksFdir.cpp index 2c14d904..27e17293 100644 --- a/mission/system/fdir/SyrlinksFdir.cpp +++ b/mission/system/fdir/SyrlinksFdir.cpp @@ -9,99 +9,100 @@ #include "fsfw/thermal/ThermalComponentIF.h" #include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" -SyrlinksFdir::SyrlinksFdir(object_id_t syrlinksId) {} +SyrlinksFdir::SyrlinksFdir(object_id_t syrlinksId) + : DeviceHandlerFailureIsolation(syrlinksId, objects::NO_OBJECT) {} ReturnValue_t SyrlinksFdir::eventReceived(EventMessage* event) { if (isFdirInActionOrAreWeFaulty(event)) { - return RETURN_OK; - } - ReturnValue_t result = RETURN_FAILED; - switch (event->getEvent()) { - case HasModesIF::MODE_TRANSITION_FAILED: - case HasModesIF::OBJECT_IN_INVALID_MODE: - case DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT: - // We'll try a recovery as long as defined in MAX_REBOOT. - // Might cause some AssemblyBase cycles, so keep number low. - // handleRecovery(event->getEvent()); - triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); - break; - case DeviceHandlerIF::DEVICE_INTERPRETING_REPLY_FAILED: - case DeviceHandlerIF::DEVICE_READING_REPLY_FAILED: - case DeviceHandlerIF::DEVICE_UNREQUESTED_REPLY: - case DeviceHandlerIF::DEVICE_UNKNOWN_REPLY: // Some DH's generate generic reply-ids. - case DeviceHandlerIF::DEVICE_BUILDING_COMMAND_FAILED: - // These faults all mean that there were stupid replies from a device. - if (strangeReplyCount.incrementAndCheck()) { - // handleRecovery(event->getEvent()); - triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); - } - break; - case DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED: - case DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED: - // The two above should never be confirmed. - case DeviceHandlerIF::DEVICE_MISSED_REPLY: - result = sendConfirmationRequest(event); - if (result == HasReturnvaluesIF::RETURN_OK) { - break; - } - // else - if (missedReplyCount.incrementAndCheck()) { - // handleRecovery(event->getEvent()); - triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); - } - break; - case StorageManagerIF::GET_DATA_FAILED: - case StorageManagerIF::STORE_DATA_FAILED: - // Rather strange bugs, occur in RAW mode only. Ignore. - break; - case DeviceHandlerIF::INVALID_DEVICE_COMMAND: - // Ignore, is bad configuration. We can't do anything in flight. - break; - case HasHealthIF::HEALTH_INFO: - case HasModesIF::MODE_INFO: - case HasModesIF::CHANGING_MODE: - // Do nothing, but mark as handled. - break; - //****Power***** - case PowerSwitchIF::SWITCH_WENT_OFF: - if (powerConfirmation != MessageQueueIF::NO_QUEUE) { - result = sendConfirmationRequest(event, powerConfirmation); - if (result == RETURN_OK) { - setFdirState(DEVICE_MIGHT_BE_OFF); - } - } - break; - case Fuse::FUSE_WENT_OFF: - // Not so good, because PCDU reacted. - case Fuse::POWER_ABOVE_HIGH_LIMIT: - // Better, because software detected over-current. - setFaulty(event->getEvent()); - break; - case Fuse::POWER_BELOW_LOW_LIMIT: - // Device might got stuck during boot, retry. - // handleRecovery(event->getEvent()); - triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); - break; - //****Thermal***** - case ThermalComponentIF::COMPONENT_TEMP_LOW: - case ThermalComponentIF::COMPONENT_TEMP_HIGH: - case ThermalComponentIF::COMPONENT_TEMP_OOL_LOW: - case ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH: - // Well, the device is not really faulty, but it is required to stay off as long as possible. - setFaulty(event->getEvent()); - break; - case ThermalComponentIF::TEMP_NOT_IN_OP_RANGE: - // Ignore, is information only. - break; - //*******Default monitoring variables. Are currently not used.***** - // case DeviceHandlerIF::MONITORING_LIMIT_EXCEEDED: - // setFaulty(event->getEvent()); - // break; - // case DeviceHandlerIF::MONITORING_AMBIGUOUS: - // break; - default: - // We don't know the event, someone else should handle it. - return RETURN_FAILED; - } return RETURN_OK; + } + ReturnValue_t result = RETURN_FAILED; + switch (event->getEvent()) { + case HasModesIF::MODE_TRANSITION_FAILED: + case HasModesIF::OBJECT_IN_INVALID_MODE: + case DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT: + // We'll try a recovery as long as defined in MAX_REBOOT. + // Might cause some AssemblyBase cycles, so keep number low. + // handleRecovery(event->getEvent()); + triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); + break; + case DeviceHandlerIF::DEVICE_INTERPRETING_REPLY_FAILED: + case DeviceHandlerIF::DEVICE_READING_REPLY_FAILED: + case DeviceHandlerIF::DEVICE_UNREQUESTED_REPLY: + case DeviceHandlerIF::DEVICE_UNKNOWN_REPLY: // Some DH's generate generic reply-ids. + case DeviceHandlerIF::DEVICE_BUILDING_COMMAND_FAILED: + // These faults all mean that there were stupid replies from a device. + if (strangeReplyCount.incrementAndCheck()) { + // handleRecovery(event->getEvent()); + triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); + } + break; + case DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED: + case DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED: + // The two above should never be confirmed. + case DeviceHandlerIF::DEVICE_MISSED_REPLY: + result = sendConfirmationRequest(event); + if (result == HasReturnvaluesIF::RETURN_OK) { + break; + } + // else + if (missedReplyCount.incrementAndCheck()) { + // handleRecovery(event->getEvent()); + triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); + } + break; + case StorageManagerIF::GET_DATA_FAILED: + case StorageManagerIF::STORE_DATA_FAILED: + // Rather strange bugs, occur in RAW mode only. Ignore. + break; + case DeviceHandlerIF::INVALID_DEVICE_COMMAND: + // Ignore, is bad configuration. We can't do anything in flight. + break; + case HasHealthIF::HEALTH_INFO: + case HasModesIF::MODE_INFO: + case HasModesIF::CHANGING_MODE: + // Do nothing, but mark as handled. + break; + //****Power***** + case PowerSwitchIF::SWITCH_WENT_OFF: + if (powerConfirmation != MessageQueueIF::NO_QUEUE) { + result = sendConfirmationRequest(event, powerConfirmation); + if (result == RETURN_OK) { + setFdirState(DEVICE_MIGHT_BE_OFF); + } + } + break; + case Fuse::FUSE_WENT_OFF: + // Not so good, because PCDU reacted. + case Fuse::POWER_ABOVE_HIGH_LIMIT: + // Better, because software detected over-current. + setFaulty(event->getEvent()); + break; + case Fuse::POWER_BELOW_LOW_LIMIT: + // Device might got stuck during boot, retry. + // handleRecovery(event->getEvent()); + triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); + break; + //****Thermal***** + case ThermalComponentIF::COMPONENT_TEMP_LOW: + case ThermalComponentIF::COMPONENT_TEMP_HIGH: + case ThermalComponentIF::COMPONENT_TEMP_OOL_LOW: + case ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH: + // Well, the device is not really faulty, but it is required to stay off as long as possible. + setFaulty(event->getEvent()); + break; + case ThermalComponentIF::TEMP_NOT_IN_OP_RANGE: + // Ignore, is information only. + break; + //*******Default monitoring variables. Are currently not used.***** + // case DeviceHandlerIF::MONITORING_LIMIT_EXCEEDED: + // setFaulty(event->getEvent()); + // break; + // case DeviceHandlerIF::MONITORING_AMBIGUOUS: + // break; + default: + // We don't know the event, someone else should handle it. + return RETURN_FAILED; + } + return RETURN_OK; } diff --git a/mission/system/fdir/SyrlinksFdir.h b/mission/system/fdir/SyrlinksFdir.h index bafd8a48..79480924 100644 --- a/mission/system/fdir/SyrlinksFdir.h +++ b/mission/system/fdir/SyrlinksFdir.h @@ -3,12 +3,12 @@ #include -class SyrlinksFdir: public DeviceHandlerFailureIsolation { +class SyrlinksFdir : public DeviceHandlerFailureIsolation { public: SyrlinksFdir(object_id_t syrlinksId); + private: ReturnValue_t eventReceived(EventMessage* event); }; - #endif /* MISSION_DEVICES_SYRLINKSFDIR_H_ */