diff --git a/src/core/funcbloc.cpp b/src/core/funcbloc.cpp index 6535a3715..cfb449a3a 100644 --- a/src/core/funcbloc.cpp +++ b/src/core/funcbloc.cpp @@ -674,18 +674,6 @@ size_t CFunctionBlock::getToStringBufferSize() const { } -void CFunctionBlock::triggerEventsOfType(TEventTypeID paEventTypeId) { - //most of the FBs will only have the basic event type -> mEITypes == nullptr - if (getFBInterfaceSpec().mEITypeNames != nullptr) { - for (TEventID eventId = 0; eventId < getFBInterfaceSpec().mNumEIs; eventId++) { - if (getEIType(eventId) == paEventTypeId && !isInputEventConnected(eventId)) { - getResource()->getResourceEventExecution()->startEventChain(CConnectionPoint(this, eventId)); - } - } - } -} - - //********************************** below here are CTF Tracing specific functions ********************************************************** #ifdef FORTE_TRACE_CTF void CFunctionBlock::traceInputEvent(TEventID paEIID){ diff --git a/src/core/funcbloc.h b/src/core/funcbloc.h index 19166a170..282b21c26 100644 --- a/src/core/funcbloc.h +++ b/src/core/funcbloc.h @@ -426,11 +426,6 @@ class CFunctionBlock : public forte::core::CFBContainer { } } - /*!\brief This function will trigger unconnected event ports of a certain EventType - * \param paEventTypeId ID of event type to be triggered - */ - void triggerEventsOfType(TEventTypeID paEventTypeId); - /*!\brief initialize the data structure which holds conneciton counts per pin * \param paNumEIs number of eventInputs */ @@ -438,6 +433,13 @@ class CFunctionBlock : public forte::core::CFBContainer { mInputEventConnectionCount = std::make_unique(paNumEIs); } + /* !\brief checks if an input event pin is connected + * + */ + [[nodiscard]] bool isInputEventConnected(TEventID paEIID) const { + return mInputEventConnectionCount != nullptr && mInputEventConnectionCount[paEIID] > 0; + } + protected: /*!\brief The main constructor for a function block. @@ -530,12 +532,6 @@ class CFunctionBlock : public forte::core::CFBContainer { } } #endif //FORTE_TRACE_CTF - /* !\brief checks if an input event pin is connected - * - */ - [[nodiscard]] bool isInputEventConnected(TEventID paEIID) const { - return mInputEventConnectionCount != nullptr && mInputEventConnectionCount[paEIID] > 0; - } /*!\brief Set the initial values of data inputs, outputs, and internal vars. * @@ -706,7 +702,6 @@ class CFunctionBlock : public forte::core::CFBContainer { */ std::unique_ptr mInputEventConnectionCount; - #ifdef FORTE_SUPPORT_MONITORING friend class forte::core::CMonitoringHandler; #endif //FORTE_SUPPORT_MONITORING diff --git a/src/stdfblib/events/E_TRIG_fbt.cpp b/src/stdfblib/events/E_TRIG_fbt.cpp index 36fb651ae..2f0562eb4 100644 --- a/src/stdfblib/events/E_TRIG_fbt.cpp +++ b/src/stdfblib/events/E_TRIG_fbt.cpp @@ -56,7 +56,7 @@ void FORTE_E_TRIG::executeEvent(const TEventID paEIID, CEventChainExecutionThrea case scmEventREQID: const TEventTypeID eventTypeId = CStringDictionary::getInstance().getId(var_EVENTTYPE.c_str()); if (eventTypeId != CStringDictionary::scmInvalidStringId) { - triggerEvents(getResource(), eventTypeId); + triggerEventsInResource(getResource(), eventTypeId, paECET); sendOutputEvent(scmEventCNFID, paECET); } break; @@ -107,15 +107,27 @@ CDataConnection *FORTE_E_TRIG::getDOConUnchecked(TPortId) { return nullptr; } -void FORTE_E_TRIG::triggerEvents(forte::core::CFBContainer* paContainer, TEventTypeID paEventType) { +void FORTE_E_TRIG::triggerEventsInResource(forte::core::CFBContainer* paContainer, const TEventTypeID paEventType, CEventChainExecutionThread *const paECET) { if (paContainer != nullptr) { if (paContainer->isFB()) { - static_cast(paContainer)->triggerEventsOfType(paEventType); + triggerEventsOfType(paEventType, static_cast(paContainer), paECET); } if (paContainer->isDynamicContainer()) { for (auto child: paContainer->getChildren()) { - triggerEvents(child, paEventType); + triggerEventsInResource(child, paEventType, paECET); } } } } + +void FORTE_E_TRIG::triggerEventsOfType(TEventTypeID paEventTypeId, CFunctionBlock* paFb, CEventChainExecutionThread *const paECET) { + //most of the FBs will only have the basic event type -> mEITypes == nullptr + if (paFb->getFBInterfaceSpec().mEITypeNames == nullptr) { + return; + } + for (TEventID eventId = 0; eventId < paFb->getFBInterfaceSpec().mNumEIs; eventId++) { + if (paFb->getEIType(eventId) == paEventTypeId && !paFb->isInputEventConnected(eventId)) { + paECET->addEventEntry(CConnectionPoint(paFb,eventId)); + } + } +} diff --git a/src/stdfblib/events/E_TRIG_fbt.h b/src/stdfblib/events/E_TRIG_fbt.h index 06ceb64c2..b58bbe0c4 100644 --- a/src/stdfblib/events/E_TRIG_fbt.h +++ b/src/stdfblib/events/E_TRIG_fbt.h @@ -35,13 +35,25 @@ class FORTE_E_TRIG final : public CFunctionBlock { static const SFBInterfaceSpec scmFBInterfaceSpec; + CEventChainExecutionThread* mEcet; + void executeEvent(TEventID paEIID, CEventChainExecutionThread *const paECET) override; void readInputData(TEventID paEIID) override; void writeOutputData(TEventID paEIID) override; void setInitialValues() override; - void triggerEvents(forte::core::CFBContainer* paContainer, TEventTypeID paEventType); + /*!\brief This function will trigger unconnected event ports of a certain EventType within a resource + * \param paEventTypeId ID of event type to be triggered + */ + void triggerEventsInResource(forte::core::CFBContainer* paContainer, const TEventTypeID paEventType, CEventChainExecutionThread *const paECET); + + /*!\brief This function will trigger unconnected event ports of a certain EventType + * \param paEventTypeId ID of event type to be triggered + * \param paFb function block search for events to be triggerd + * \param paECET event chain execution thread to add the event + */ + void triggerEventsOfType(TEventTypeID paEventTypeId, CFunctionBlock* paFb, CEventChainExecutionThread *const paECET); public: FORTE_E_TRIG(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer);