Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move trigger function to E_TRIG & dont use external events
Browse files Browse the repository at this point in the history
MandKastner committed Jan 27, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 3599fc9 commit 5059f69
Showing 4 changed files with 36 additions and 29 deletions.
12 changes: 0 additions & 12 deletions src/core/funcbloc.cpp
Original file line number Diff line number Diff line change
@@ -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){
19 changes: 7 additions & 12 deletions src/core/funcbloc.h
Original file line number Diff line number Diff line change
@@ -426,18 +426,20 @@ 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
*/
void setupInputConnectionTrackingData(TEventID paNumEIs) {
mInputEventConnectionCount = std::make_unique<size_t[]>(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<size_t[]> mInputEventConnectionCount;


#ifdef FORTE_SUPPORT_MONITORING
friend class forte::core::CMonitoringHandler;
#endif //FORTE_SUPPORT_MONITORING
20 changes: 16 additions & 4 deletions src/stdfblib/events/E_TRIG_fbt.cpp
Original file line number Diff line number Diff line change
@@ -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<CFunctionBlock*>(paContainer)->triggerEventsOfType(paEventType);
triggerEventsOfType(paEventType, static_cast<CFunctionBlock*>(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));
}
}
}
14 changes: 13 additions & 1 deletion src/stdfblib/events/E_TRIG_fbt.h
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 5059f69

Please sign in to comment.