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 » Receiving exernal event on genfb (ex.: subscribe)
Receiving exernal event on genfb (ex.: subscribe) [message #1863578] Mon, 12 February 2024 15:05 Go to next message
paulo nunes is currently offline paulo nunesFriend
Messages: 10
Registered: January 2024
Junior Member
Hello, i would like to know how can i implement the receiving of an external event on a generated block, like subscriber_1, or if the steps are the same as https://eclipse.dev/4diac/en_help.php?helppage=html/development/externalEvent_example.html.
edit: the callback function that receives the event is inside the generated block code.

[Updated on: Mon, 26 February 2024 20:37]

Report message to a moderator

Re: Receiving exernal event on genfb (ex.: subscribe) [message #1863970 is a reply to message #1863578] Fri, 08 March 2024 12:18 Go to previous message
paulo nunes is currently offline paulo nunesFriend
Messages: 10
Registered: January 2024
Junior Member
after some reading about external events on this forum, i still don't know what the best approach is. i'm creating a generated block subscriber for a layer 2 OSI protocol from a library that already has its functions implemented, i simply integrated the library into FORTE. i already tested the function that subscribes to data from layer 2 inside 4diac and it's working.

what i'm not being able to do is receive an external event inside the same block, and still don't know if it's the right way, as the data can arrive multiple times in a short time interval and i've read in some posts that i can't simply output an event into 4diac, i must generate an external event and receive inside the block so that it may be thread-safe.

Edit: After some time experimenting with external events, i was able to start and receive an external event on a generated block.
For anyone with the same problem: the generated block class inherits from "CGenFunctionBlock<CEventSourceFB>" similar to "basecommfb" header and source, and has every setting of a generated block. Also, it's necessary to create a handler class that will inherit from "CExternalEventHandler" and "CThread". I created the handler based on the way they are used on any protocol of the "com" folders (like MQTT):

I - a CSyncObject is created to enter the critical region when creating the external event.
II - a CSinglyLinkedList<"generated_block_class_here"*> object is created to hold the instances of the generated blocks during runtime (the instance will be added to the list during the creation of the generated block). For that, it's necessary to include the generated block header into the handler header.
III - two new functions on the handler: one will register the instance (example: mlayers.pushback of "mqtt" source) and the other will create the external event (example:
::getexternalevhandler(instance)...Startneweventchain(instance) also in "mqtt" source).

in the generated block source, you will include the handler header and will create a handler object that will call the register function with the pointer "this" and everytime you need to create the external event, call the event creation function from the same handler object with some parameter that identify the instance you are trying to generate an external event on (example: i created a handler function that passes a string as parameter to compare with a instance variable through a loop on the singlylinkedlist, that also is on the "mqtt" source).

[Updated on: Tue, 19 March 2024 19:13]

Report message to a moderator

Previous Topic:Import Structured Text
Next Topic:IDE 2.0.1 export feature and FORTE develop branch
Goto Forum:
  


Current Time: Sat Apr 27 13:35:19 GMT 2024

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

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

Back to the top