How to access properties of user-control parameters in TwinCAT 3 HMI Engineering

406 views Asked by At

This question is about the Beckhoff product TE2000 | TwinCAT 3 HMI Engineering. (using v1.12.760.48)

Within a PLC project, I declared an instance of a function block (MyFB) that exposes get+set properties (e.g. MyFB.TestStringAsProperty). The properties are visible in the HMI project and can be read and set when using a direct binding (e.g. MAIN.MyFBInstance.TestStringAsProperty); this works as expected.

However, when I attempt to use a user control in combination with parameters, I encounter a problem. I've defined a user-control MyFBView with a parameter : Model : MyFB. When trying to bind a TextBox.Text, the string property Model.TestStringAsProperty is showing and gives the illusion that this should work.

In practice, I've noticed that the string value of the property does not display, and typing text in the TextBox has no effect. Additionally, an error message appears in the console:

Failed to read value by path because the token: "TestStringAsProperty" does not exist below path: "MyFbView_1::Model" in current value. Domain: TcHmi.System.Symbol

So my question is: Is there a specific step or configuration needed to enable property access from a parameter of a user-control? If not, what would be a proper way to work around this issue?

A way around is of course to bind to the backing variables themselves, but this undermines the use of properties: protecting backing variables and data hiding.

Some additional remarks:

  • The property itself is working fine, and the value is correct in both the PLC online view and when binding directly in the HMI (without user-control + parameter).
  • The declaration of the property in the PLC project includes {attribute 'monitoring' := 'call'}
  • The binding to the property is defined as two-way with binding event: onTextChanged
  • The model parameter itself is bound and this binding is functional (since binding to variables of "MyFbView_1::Model" works.
  • The model parameter itself is bound and updates on change (not polling)
  • The model parameter has Allow SymbolExpressions in object enabled

Any guidance or insights on resolving this issue would be greatly appreciated.

1

There are 1 answers

0
SIDDHANT BORA On

the 'object resolver' function is used to resolve a collector object such as mapped FB or a structure and list all its member variables and properties. This feature can be used with standard variables as HMI can read all variables of each collector object.

The problem with properties is that the get and set methods are not variables but methods executed from Remote Procedure Call (RPC). For security reasons the methods are not executed from object resolver, as HMI can not be sure call a method 'get' will only return a readable value or execute some other code in the system.

So you will have to create a special HMI object either FB or struct that can be linked to HMI, and does not need getter setter.