-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement startup behavior for EInit events #298
base: develop
Are you sure you want to change the base?
Changes from all commits
0f3f3e8
4a2d9ea
888134e
d057a4a
001d007
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,4 @@ file_list.txt | |
# IDE files | ||
/.vscode/ | ||
/.vs/ | ||
/.idea/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,9 @@ bool CFunctionBlock::initialize() { | |
#ifdef FORTE_SUPPORT_MONITORING | ||
setupEventMonitoringData(); | ||
#endif //FORTE_SUPPORT_MONITORING | ||
if (getFBInterfaceSpec().mEITypeNames != nullptr) { | ||
mInputEventConnectionCount = std::make_unique<size_t[]>(getFBInterfaceSpec().mNumEIs); | ||
} | ||
return true; | ||
} | ||
|
||
|
@@ -671,6 +674,18 @@ 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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use the eventchain execution thread which was used to triggere the R_TRIG fb and add the events to the internal event list. |
||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
//********************************** below here are CTF Tracing specific functions ********************************************************** | ||
#ifdef FORTE_TRACE_CTF | ||
void CFunctionBlock::traceInputEvent(TEventID paEIID){ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/************************************************************************* | ||
*** FORTE Library Element | ||
*** | ||
*** This file was generated using the 4DIAC FORTE Export Filter V1.0.x NG! | ||
*** | ||
*** Name: E_TRIG | ||
*** Description: Service Interface Function Block Type | ||
*** Version: | ||
*** 1.0: 2025-01-08/mario - - | ||
*************************************************************************/ | ||
|
||
#include "E_TRIG_fbt.h" | ||
#ifdef FORTE_ENABLE_GENERATED_SOURCE_CPP | ||
#include "E_TRIG_fbt_gen.cpp" | ||
#endif | ||
|
||
#include "iec61131_functions.h" | ||
#include "forte_array_common.h" | ||
#include "forte_array.h" | ||
#include "forte_array_fixed.h" | ||
#include "forte_array_variable.h" | ||
|
||
#include "resource.h" | ||
|
||
DEFINE_FIRMWARE_FB(FORTE_E_TRIG, g_nStringIdE_TRIG) | ||
|
||
const CStringDictionary::TStringId FORTE_E_TRIG::scmDataInputNames[] = {g_nStringIdEVENTTYPE}; | ||
const CStringDictionary::TStringId FORTE_E_TRIG::scmDataInputTypeIds[] = {g_nStringIdSTRING}; | ||
const TDataIOID FORTE_E_TRIG::scmEIWith[] = {0, scmWithListDelimiter}; | ||
const TForteInt16 FORTE_E_TRIG::scmEIWithIndexes[] = {0}; | ||
const CStringDictionary::TStringId FORTE_E_TRIG::scmEventInputNames[] = {g_nStringIdREQ}; | ||
const TForteInt16 FORTE_E_TRIG::scmEOWithIndexes[] = {-1}; | ||
const CStringDictionary::TStringId FORTE_E_TRIG::scmEventOutputNames[] = {g_nStringIdCNF}; | ||
const SFBInterfaceSpec FORTE_E_TRIG::scmFBInterfaceSpec = { | ||
1, scmEventInputNames, nullptr, scmEIWith, scmEIWithIndexes, | ||
1, scmEventOutputNames, nullptr, nullptr, scmEOWithIndexes, | ||
1, scmDataInputNames, scmDataInputTypeIds, | ||
0, nullptr, nullptr, | ||
0, nullptr, | ||
0, nullptr | ||
}; | ||
|
||
FORTE_E_TRIG::FORTE_E_TRIG(const CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer) : | ||
CFunctionBlock(paContainer, scmFBInterfaceSpec, paInstanceNameId), | ||
var_EVENTTYPE(""_STRING), | ||
conn_CNF(this, 0), | ||
conn_EVENTTYPE(nullptr) { | ||
}; | ||
|
||
void FORTE_E_TRIG::setInitialValues() { | ||
var_EVENTTYPE = ""_STRING; | ||
} | ||
|
||
void FORTE_E_TRIG::executeEvent(const TEventID paEIID, CEventChainExecutionThread *const paECET) { | ||
switch(paEIID) { | ||
case scmEventREQID: | ||
const TEventTypeID eventTypeId = CStringDictionary::getInstance().getId(var_EVENTTYPE.c_str()); | ||
if (eventTypeId != CStringDictionary::scmInvalidStringId) { | ||
triggerEvents(getResource(), eventTypeId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use the paECET for triggereEvents so that you do not need to use the external events everywhere. |
||
sendOutputEvent(scmEventCNFID, paECET); | ||
} | ||
break; | ||
} | ||
} | ||
|
||
void FORTE_E_TRIG::readInputData(const TEventID paEIID) { | ||
switch(paEIID) { | ||
case scmEventREQID: { | ||
readData(0, var_EVENTTYPE, conn_EVENTTYPE); | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
void FORTE_E_TRIG::writeOutputData(TEventID) { | ||
// nothing to do | ||
} | ||
|
||
CIEC_ANY *FORTE_E_TRIG::getDI(const size_t paIndex) { | ||
switch(paIndex) { | ||
case 0: return &var_EVENTTYPE; | ||
} | ||
return nullptr; | ||
} | ||
|
||
CIEC_ANY *FORTE_E_TRIG::getDO(size_t) { | ||
return nullptr; | ||
} | ||
|
||
CEventConnection *FORTE_E_TRIG::getEOConUnchecked(const TPortId paIndex) { | ||
switch(paIndex) { | ||
case 0: return &conn_CNF; | ||
} | ||
return nullptr; | ||
} | ||
|
||
CDataConnection **FORTE_E_TRIG::getDIConUnchecked(const TPortId paIndex) { | ||
switch(paIndex) { | ||
case 0: return &conn_EVENTTYPE; | ||
} | ||
return nullptr; | ||
} | ||
|
||
CDataConnection *FORTE_E_TRIG::getDOConUnchecked(TPortId) { | ||
return nullptr; | ||
} | ||
|
||
void FORTE_E_TRIG::triggerEvents(forte::core::CFBContainer* paContainer, TEventTypeID paEventType) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. paContainer is not really needed you could call the getResoruce here. |
||
if (paContainer != nullptr) { | ||
if (paContainer->isFB()) { | ||
static_cast<CFunctionBlock*>(paContainer)->triggerEventsOfType(paEventType); | ||
} | ||
if (paContainer->isDynamicContainer()) { | ||
for (auto child: paContainer->getChildren()) { | ||
triggerEvents(child, paEventType); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/************************************************************************* | ||
*** FORTE Library Element | ||
*** | ||
*** This file was generated using the 4DIAC FORTE Export Filter V1.0.x NG! | ||
*** | ||
*** Name: E_TRIG | ||
*** Description: Service Interface Function Block Type | ||
*** Version: | ||
*** 1.0: 2025-01-08/mario - - | ||
*************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include "funcbloc.h" | ||
#include "forte_string.h" | ||
#include "iec61131_functions.h" | ||
#include "forte_array_common.h" | ||
#include "forte_array.h" | ||
#include "forte_array_fixed.h" | ||
#include "forte_array_variable.h" | ||
|
||
class FORTE_E_TRIG final : public CFunctionBlock { | ||
DECLARE_FIRMWARE_FB(FORTE_E_TRIG) | ||
|
||
private: | ||
static const CStringDictionary::TStringId scmDataInputNames[]; | ||
static const CStringDictionary::TStringId scmDataInputTypeIds[]; | ||
static const TEventID scmEventREQID = 0; | ||
static const TDataIOID scmEIWith[]; | ||
static const TForteInt16 scmEIWithIndexes[]; | ||
static const CStringDictionary::TStringId scmEventInputNames[]; | ||
static const TEventID scmEventCNFID = 0; | ||
static const TForteInt16 scmEOWithIndexes[]; | ||
static const CStringDictionary::TStringId scmEventOutputNames[]; | ||
|
||
static const SFBInterfaceSpec scmFBInterfaceSpec; | ||
|
||
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); | ||
|
||
public: | ||
FORTE_E_TRIG(CStringDictionary::TStringId paInstanceNameId, forte::core::CFBContainer &paContainer); | ||
|
||
CIEC_STRING var_EVENTTYPE; | ||
|
||
CEventConnection conn_CNF; | ||
|
||
CDataConnection *conn_EVENTTYPE; | ||
|
||
CIEC_ANY *getDI(size_t) override; | ||
CIEC_ANY *getDO(size_t) override; | ||
CEventConnection *getEOConUnchecked(TPortId) override; | ||
CDataConnection **getDIConUnchecked(TPortId) override; | ||
CDataConnection *getDOConUnchecked(TPortId) override; | ||
|
||
void evt_REQ(const CIEC_STRING &paEVENTTYPE) { | ||
var_EVENTTYPE = paEVENTTYPE; | ||
executeEvent(scmEventREQID, nullptr); | ||
} | ||
|
||
void operator()(const CIEC_STRING &paEVENTTYPE) { | ||
evt_REQ(paEVENTTYPE); | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move to E_TRIG FB