diff --git a/CHANGELOG.md b/CHANGELOG.md index fe42fb59..6c3e4e50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,9 @@ will consitute of a breaking change warranting a new major release: - UDP TMTC Bridge: 50 -> 120 - TCP TMTC Bridge: 50 -> 120 - Service 5: 120 -> 160, number of events handled in one cycle increased to 80 +- EM: PCDU dummy is not a device handler anymore, but a custom power switcher object. This avoids + some issues where the event manager could not send an event message to the PCDU dummy because + the FDIR event queue was too small. ## Added diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 2d06e697..05a3fee0 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -63,8 +63,7 @@ void ObjectFactory::produce(void* args) { PowerSwitchIF* pwrSwitcher = nullptr; #if OBSW_ADD_GOMSPACE_PCDU == 0 - auto* comCookieDummy = new ComCookieDummy(); - pwrSwitcher = new PcduHandlerDummy(objects::PCDU_HANDLER, objects::DUMMY_COM_IF, comCookieDummy); + pwrSwitcher = new PcduHandlerDummy(objects::PCDU_HANDLER); #else createPcduComponents(gpioComIF, &pwrSwitcher, enableHkSets); #endif diff --git a/dummies/PcduHandlerDummy.cpp b/dummies/PcduHandlerDummy.cpp index 0b1dec69..c91de74c 100644 --- a/dummies/PcduHandlerDummy.cpp +++ b/dummies/PcduHandlerDummy.cpp @@ -1,49 +1,20 @@ #include "PcduHandlerDummy.h" +#include #include #include "mission/power/defs.h" -PcduHandlerDummy::PcduHandlerDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie) - : DeviceHandlerBase(objectId, comif, comCookie), dummySwitcher(objectId, 18, 18, false) { +PcduHandlerDummy::PcduHandlerDummy(object_id_t objectId) + : SystemObject(objectId), manager(this, nullptr), dummySwitcher(objectId, 18, 18, false) { switcherLock = MutexFactory::instance()->createMutex(); + queue = QueueFactory::instance()->createMessageQueue(20); } PcduHandlerDummy::~PcduHandlerDummy() {} -void PcduHandlerDummy::doStartUp() { setMode(MODE_NORMAL); } - -void PcduHandlerDummy::doShutDown() { setMode(MODE_OFF); } - -ReturnValue_t PcduHandlerDummy::buildNormalDeviceCommand(DeviceCommandId_t *id) { - return NOTHING_TO_SEND; -} - -ReturnValue_t PcduHandlerDummy::buildTransitionDeviceCommand(DeviceCommandId_t *id) { - return NOTHING_TO_SEND; -} - -ReturnValue_t PcduHandlerDummy::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, - size_t commandDataLen) { - return returnvalue::OK; -} - -ReturnValue_t PcduHandlerDummy::scanForReply(const uint8_t *start, size_t len, - DeviceCommandId_t *foundId, size_t *foundLen) { - return returnvalue::OK; -} - -ReturnValue_t PcduHandlerDummy::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { - return returnvalue::OK; -} - -void PcduHandlerDummy::fillCommandAndReplyMap() {} - -uint32_t PcduHandlerDummy::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 500; } - -ReturnValue_t PcduHandlerDummy::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { +ReturnValue_t PcduHandlerDummy::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) { return returnvalue::OK; } @@ -76,7 +47,8 @@ ReturnValue_t PcduHandlerDummy::getFuseState(uint8_t fuseNr) const { uint32_t PcduHandlerDummy::getSwitchDelayMs(void) const { return dummySwitcher.getSwitchDelayMs(); } -void PcduHandlerDummy::performOperationHook() { +ReturnValue_t PcduHandlerDummy::performOperation(uint8_t opCode) { + // TODO: Handle HK messages in queue. SwitcherBoolArray switcherChangeCopy{}; { MutexGuard mg(switcherLock); @@ -93,4 +65,18 @@ void PcduHandlerDummy::performOperationHook() { switchChangeArray[idx] = false; } } + return returnvalue::OK; } + +object_id_t PcduHandlerDummy::getObjectId() const { return SystemObject::getObjectId(); } + +MessageQueueId_t PcduHandlerDummy::getCommandQueue() const { return queue->getId(); } + +dur_millis_t PcduHandlerDummy::getPeriodicOperationFrequency() const { + // TODO: dummy value. Retrieve from intiitalize after task creation.. + return 400; +} + +LocalDataPoolManager* PcduHandlerDummy::getHkManagerHandle() { return &manager; } + +LocalPoolDataSetBase* PcduHandlerDummy::getDataSetHandle(sid_t sid) { return nullptr; } diff --git a/dummies/PcduHandlerDummy.h b/dummies/PcduHandlerDummy.h index 7980629b..c41846f3 100644 --- a/dummies/PcduHandlerDummy.h +++ b/dummies/PcduHandlerDummy.h @@ -3,7 +3,10 @@ #include #include -class PcduHandlerDummy : public DeviceHandlerBase, public PowerSwitchIF { +class PcduHandlerDummy : public PowerSwitchIF, + public HasLocalDataPoolIF, + public SystemObject, + public ExecutableObjectIF { public: static const DeviceCommandId_t SIMPLE_COMMAND = 1; static const DeviceCommandId_t PERIODIC_REPLY = 2; @@ -11,33 +14,49 @@ class PcduHandlerDummy : public DeviceHandlerBase, public PowerSwitchIF { static const uint8_t SIMPLE_COMMAND_DATA = 1; static const uint8_t PERIODIC_REPLY_DATA = 2; - PcduHandlerDummy(object_id_t objectId, object_id_t comif, CookieIF *comCookie); + PcduHandlerDummy(object_id_t objectId); virtual ~PcduHandlerDummy(); protected: - MutexIF *switcherLock; + MessageQueueIF* queue; + LocalDataPoolManager manager; + MutexIF* switcherLock; DummyPowerSwitcher dummySwitcher; using SwitcherBoolArray = std::array; + ReturnValue_t performOperation(uint8_t opCode) override; SwitcherBoolArray switchChangeArray{}; - void performOperationHook() override; - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; - ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; - ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, - size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; - void fillCommandAndReplyMap() override; - uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override; + + ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, + LocalDataPoolManager& poolManager) override; ReturnValue_t sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) override; ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override; ReturnValue_t getSwitchState(power::Switch_t switchNr) const override; ReturnValue_t getFuseState(uint8_t fuseNr) const override; uint32_t getSwitchDelayMs(void) const override; + + object_id_t getObjectId() const override; + + /** Command queue for housekeeping messages. */ + MessageQueueId_t getCommandQueue() const override; + + dur_millis_t getPeriodicOperationFrequency() const override; + + /** + * Every class implementing this interface should have a local data pool manager. This + * function will return a reference to the manager. + * @return + */ + LocalDataPoolManager* getHkManagerHandle() override; + + /** + * This function is used by the pool manager to get a valid dataset + * from a SID. This function is protected to prevent users from + * using raw data set pointers which could not be thread-safe. Users + * should use the #ProvidesDataPoolSubscriptionIF. + * @param sid Corresponding structure ID + * @return + */ + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; };