Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Creating an external event handler(Questions regarding external event handling)
Creating an external event handler [message #1835142] Wed, 25 November 2020 14:46 Go to next message
Noname Noname is currently offline Noname NonameFriend
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 #1835147 is a reply to message #1835142] Wed, 25 November 2020 16:03 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 199
Registered: February 2016
Senior Member
Hi,

the handlers are created automatically and live in the CDeviceExecution class, which is part of the CDevice. For each instance of forte, you have one device.

The CMakelist commands populates the file deviceExecutionHandlers.cpp.in, which basically has a function that creates all handlers registered with the CMakelist commands. This function is then called by the CDeviceExecution

The external event handlers normally run on their own thread, but it's not mandatory. I'm not sure how it's managed when they don't run on their own.

To access the handler froma fb use the function from src/core/utils/exevhandlerhelper.h
Re: Creating an external event handler [message #1835153 is a reply to message #1835147] Wed, 25 November 2020 19:17 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1582
Registered: January 2014
Senior Member

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
Previous Topic:4DIAC 1.13.0 IDE
Next Topic:Unable to open CFBs of my old project in 4diac 1.10 - 1.13
Goto Forum:
  


Current Time: Fri Apr 19 03:40:27 GMT 2024

Powered by FUDForum. Page generated in 0.02226 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top