Creating an external event handler [message #1835142] |
Wed, 25 November 2020 14:46 |
Noname Noname Messages: 6 Registered: October 2020 |
Junior Member |
|
|
Hello,
I'd like to create a simple handler that sends an external event to an FB when certain external conditions are met.
I've scoured the forums and found some previous posts of interest (1)(2).
The answer in (1) seems to present an outdated method of registering handlers. Handler registration seems to now be done by including a line in CMakeLists.txt, as indicated by the answer in (2).
I have looked at some existing handlers (FDSelectHandler, OPC UA remote and local handlers etc.), but there are still some parts of external event handlers I do not understand.
Is an instance of the handler created automatically if I register the handler type by adding the line to CMakeLists.txt? If so, where does this instance live and how do I access it?
If an instance is not created automatically, what is the preferred method of creating and accessing the handler instance? Does the FB spawn a thread which runs the handler? If I have multiple FBs using the same handler, how do I make the handler known to all the FBs?
If there are tutorials or forum posts regarding these questions that I've missed, I'd appreciate if you directed me to them.
Cheers!
Ninja edit: rephrased first sentence
(1) https://sourceforge.net/p/fordiac/discussion/708250/thread/fd7de0a9/
(2) https://www.eclipse.org/forums/index.php/m/1829767/
[Updated on: Wed, 25 November 2020 14:48] Report message to a moderator
|
|
|
|
Re: Creating an external event handler [message #1835153 is a reply to message #1835147] |
Wed, 25 November 2020 19:17 |
|
I see only one/two options when an external event handler has not an own thread:
1. it wraps an interrupt and the processing of the external event is done in the interrupt service routine. Although here it is also advisable to have only short processing in the interrupt and the longer in an separate thread
2. call back method from a library and therefore executed in the context of the library
|
|
|
Powered by
FUDForum. Page generated in 0.02987 seconds