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 » Problem creating External Event Handler
Problem creating External Event Handler [message #1829767] Fri, 10 July 2020 10:56 Go to next message
Niklas Huhs is currently offline Niklas HuhsFriend
Messages: 32
Registered: October 2019
Member
Hello,

I am trying to implement an External Event Handler for some FBs I use for communication.
For this I looked at the FDselectHandler and tried to use most of the Code from there with a couple changes.
I changed the addComCallback function to use CEvenSourceFB instead of CComCallback and made the same changes in the run() method.
Of Course i also changed the Name from CFDSelectHandler to my own class.

When compiling I get a linker error telling me "undefined reference to mHandlerIdentifier". I still use the DECLARE_HANDLER and DEFINE_HANDLER macros and didnt Change anything there.

is there another step to doto Register the handler?

thanks in advance
Re: Problem creating External Event Handler [message #1829768 is a reply to message #1829767] Fri, 10 July 2020 11:05 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,

you need to add

forte_add_handler(CLASS_NAME FILE_NAME_OF_THE_CLASS_WITHOUT_EXTENSION)

in the CMakeLists.txt file.

Example:

forte_add_handler(CFDSelectHandler sockhand)
Re: Problem creating External Event Handler [message #1829769 is a reply to message #1829768] Fri, 10 July 2020 11:14 Go to previous messageGo to next message
Niklas Huhs is currently offline Niklas HuhsFriend
Messages: 32
Registered: October 2019
Member
thanks a lot.
everythings working now.
Re: Problem creating External Event Handler [message #1829792 is a reply to message #1829769] Fri, 10 July 2020 15:12 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

May I ask what changes you need in the FDSelecthandler? Is it something that we should also do in the public version?

If it is just because of the CComCallback I want to point out that C++ allows multiple inheritence and you can inherit your FB from CEvenSourceFB and CComCallback. To be more specific the CComCallback was introduced for such use cases.

Cheers,
Alois
Re: Problem creating External Event Handler [message #1830186 is a reply to message #1829792] Mon, 20 July 2020 08:35 Go to previous messageGo to next message
Niklas Huhs is currently offline Niklas HuhsFriend
Messages: 32
Registered: October 2019
Member
Hello
Sorry for the late answer.
Yes it was to make it use CEventSourceFB instead of CComCallback. So probably not for the public Version.

Thanks for the tip. I will add the inheritance from CComCallback to the FB and use the FDSelectHandler.

Best regards,
Niklas Huhs
Re: Problem creating External Event Handler [message #1830210 is a reply to message #1830186] Mon, 20 July 2020 19:01 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

I hope this makes your live easier. If not please let us know so that we can fix issues that you may discover.
Re: Problem creating External Event Handler [message #1830314 is a reply to message #1830210] Thu, 23 July 2020 08:49 Go to previous messageGo to next message
Niklas Huhs is currently offline Niklas HuhsFriend
Messages: 32
Registered: October 2019
Member
Hello again

I have encountered one issue when using the fdselect handler for my own FBs.
in the line:
startNewEventChain(callee->getCommFB());

the function "virtual CBaseCommFB *getCommFB()" gets called.

I tried using a reinterpret_cast<CBaseCommFB*>(this) in my own FB but then I get an Error in forte saying: [CDeviceExecution] Couldn't start new event chain because the event has no CEventChainExecutionThread

Is it necessary to add CBaseCommFB to the inheritance?(causes more errors when compiling the FB)

Best regards
Niklas Huhs
Re: Problem creating External Event Handler [message #1830349 is a reply to message #1830314] Thu, 23 July 2020 19:25 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

Hi,

mhmh. in addition inheriting from CBaseCommFB is not a good idea. Can you try changing the virtual CBaseCommFB *getCommFB() to CEventSourceFB*...

Which should fix the compilation problem. But the real problem behind the error message is that you havent set the CEventChainExectuioThread in your event souce FB. The simplest way to do this is to take the CEventchainExectionTrhead from the resource your FB is located in. you can have a look in CBaseCommFB for this.

BR,
Alois
Re: Problem creating External Event Handler [message #1830383 is a reply to message #1830349] Fri, 24 July 2020 13:32 Go to previous messageGo to next message
Niklas Huhs is currently offline Niklas HuhsFriend
Messages: 32
Registered: October 2019
Member
Hi,

thanks for your help.
I made the changes and everything is compiling.
I will be able to test it again on my device at the start of next week and will let you know if everything is working.

Best regards,
Niklas

Re: Problem creating External Event Handler [message #1830395 is a reply to message #1830383] Fri, 24 July 2020 16:27 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

Great to hear that. I'll keep my fingers crossed and looking forward to hear from you.
Re: Problem creating External Event Handler [message #1830463 is a reply to message #1830395] Mon, 27 July 2020 08:39 Go to previous messageGo to next message
Niklas Huhs is currently offline Niklas HuhsFriend
Messages: 32
Registered: October 2019
Member
Good morning,

so after a bit of work and google, I'm not sure anymore it's possible to just use the FDselectHandler.
-Using CEventSourceFB* getCommFB(){... in the code of my FB doesn't work. (Function won't override because of the missing "const")
-Using CEventSourceFB* getCommFB() const{... returns "invalid convariant type" error.
-same when using FORTE_MyFB* getCommFB() const{...
-using:
forte::com_infra::CBaseCommFB* getCommFB() const{
        return const_cast<forte::com_infra::CBaseCommFB*>(reinterpret_cast<const forte::com_infra::CBaseCommFB*>(this));
    }

comiles and overrides the getCommFB() function but returns the "[CDeviceExecution] Couldn't start new event chain because the event has no CEventChainExecutionThread" even though I added
setEventChainExecutor(pa_poSrcRes->getResourceEventExecution());

in the constructor. (I'm a bit confused here because this worked with my own External Event Handler).

maybe I just don't see the obvious solution right now but I might go back to using a custom handler with CComcallback but without the "getCommFB" function

Best regards,
Niklas Huhs
Re: Problem creating External Event Handler [message #1830482 is a reply to message #1830463] Mon, 27 July 2020 17:09 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

hmh did you alse change the getCommFB in the commcallback class?
Re: Problem creating External Event Handler [message #1830485 is a reply to message #1830482] Mon, 27 July 2020 17:55 Go to previous messageGo to next message
Niklas Huhs is currently offline Niklas HuhsFriend
Messages: 32
Registered: October 2019
Member
Well, I wanted to avoid changing existing forte Code and wasn't sure if that was what you meant in the earlier post but I guess that will work.
Thanks again for taking the time to help.
Re: Problem creating External Event Handler [message #1830494 is a reply to message #1830485] Mon, 27 July 2020 19:34 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1560
Registered: January 2014
Senior Member

Ah sorry for not being to clear about it. Yes I expected that changes to the comcallback would be needed. But I would find such a change something worthwhile to consider for the next 4diac FORTE version.

BR,
Alois
Re: Problem creating External Event Handler [message #1830502 is a reply to message #1830494] Mon, 27 July 2020 22:13 Go to previous message
Niklas Huhs is currently offline Niklas HuhsFriend
Messages: 32
Registered: October 2019
Member
No worries. This will definitely save some time for me. I don't expect it to cause any issues but if it does, i will let you know.

Best regards
Niklas Huhs

[Updated on: Mon, 27 July 2020 22:26]

Report message to a moderator

Previous Topic:4diac Client and Python Server
Next Topic:HardFault_Handler
Goto Forum:
  


Current Time: Fri Mar 29 01:54:39 GMT 2024

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

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

Back to the top