Skip to main content



      Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » User defined function in basic function block(How to factor out common code ?)
User defined function in basic function block [message #1872285] Sun, 27 October 2024 06:37 Go to next message
Eclipse UserFriend
Hello experts,

I am creating a new basic function block and there's some code which is repeated in algorithms (in some cases within the same algorithm, in other cases in different algorithms).

Is there any way to create a user-defined function ? I need to pass parameters and get a return value.

Thanks,
Guido

[Updated on: Sun, 27 October 2024 06:38] by Moderator

Re: User defined function in basic function block [message #1872294 is a reply to message #1872285] Sun, 27 October 2024 14:11 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

you have two options:
1. IEC 61131-3 functions: for methods that you would like to use from different FBs.
2. Methods for FB local methods. You just start with Method methoName : returntype .... END_METHOD. With VAR_INPUT and VAR_OUTPUT you can define your method's interface. Furthermore methods have access to inputs, outputs and internal vars.
Re: User defined function in basic function block [message #1872297 is a reply to message #1872294] Mon, 28 October 2024 01:00 Go to previous messageGo to next message
Eclipse UserFriend
Hi, thank you for your reply, but... where am I supposed to input code ? The only place I found where I can input ST code is the Basic Function Block algorithm editor, and in there I can only input algorithms. Is there any other place I can create functions and methods ?

I am using the IDE which I found in the download page: Version: 2.0.1, Build id: 2023-10-23_0926. Should I upgrade to a newer version ?
Re: User defined function in basic function block [message #1872312 is a reply to message #1872297] Mon, 28 October 2024 04:19 Go to previous messageGo to next message
Eclipse UserFriend
The algorithms tab is for entering all textual code of an FB. So there you can enter all algorithms, and methods of a single FB. Given your feedback we may need a better name for that tab. Suggestions are welcome.

In 4diac IDE currently each function is located in an own file. You can create that via New -> Type and then select Function from the template.
Re: User defined function in basic function block [message #1872318 is a reply to message #1872312] Mon, 28 October 2024 05:00 Go to previous messageGo to next message
Eclipse UserFriend
It would seem the "Function" template is not available, when I select "New -> Type" I have the following options:

Adapter
Basic
Composite
ServiceInterface
Simple
Struct
SubApp
TemplateBasic
TemplateSimple

What I am doing wrong ?
Re: User defined function in basic function block [message #1872321 is a reply to message #1872318] Mon, 28 October 2024 05:20 Go to previous message
Eclipse UserFriend
A sorry I missed that you are using the last release version. As I wrote in another post for all these features you need the latest RC for the upcoming 3.0.0 release: https://download.eclipse.org/4diac/updates/rc/
Previous Topic:READ data from file
Next Topic:Problem with release built from source
Goto Forum:
  


Current Time: Sat Jun 14 06:47:31 EDT 2025

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

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

Back to the top