|
Re: Basic FB as Event Source [message #1738555 is a reply to message #1738384] |
Wed, 20 July 2016 20:08 |
|
Hi,
great to here that 4diac worked well for you.
In the general architecture of forte it is not allowed for classic basic FBs to act as event sources. However you can take the generated C++ code of your basic FB and adapt it to your needs.
First of all: You must not invoke the function sendOutputEvent from your data processing thread!!!! This can lead to severe race conditions.
What you need is to have an class which inherits from CExternalEventHandler. This class is typically a singleton and would handle the call-back from your dll. In the call back you can then transfer any data to your basic FB (which should now inherit from CEventSourceFB). After that you can invoke CExternalEventHandler's startNewEventChain() function. This function will activate the CEventChainExecutionThread of your FB and will send your FB an inputEvent with the value cg_nExternalEventID. In your FB you can check now for cg_nExternalEventID perform any further data processing update any fb outputs if necessary and then send the according output events.
Unfortunately this is not very well documented sofar. An example you could take as reference is the way how the timing FBs (e.g., E_CYCLE, E_DELAY) are implemented.
I hope this helps. You can also contact me in skype if this not helping.
BR,
Alois
|
|
|
|
|
Re: Basic FB as Event Source [message #1738588 is a reply to message #1738582] |
Thu, 21 July 2016 07:20 |
|
To add to Jose's comment, normally we have one instance of an External Event Handler per event source (i.e., your callback function) managing external events for several FBs. Therefore FBs are regsitered at the external event handler during the initialization of the FB. The external event handler can then determine in the call back or in its thread for which FB the external event was and perform the steps as described by Jose.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03550 seconds