How to access members of REFERENCE-TO-X in TwinCAT 3 HMI Engineering

233 views Asked by At

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

Within an HMI project, I want to be able to access variables from an instance in a PLC project that is exposed as REFERENCE TO X. Let's say a REFERENCE TO MyFB.

According to Beckhoff, references can be resolved in the TwinCAT HMI since v1.12.748.0 (I am on 1.12.760.48):

With version 1.12.748.0, references, pointers and interface pointers can be resolved in the HMI. This makes it possible to access the original variable being pointed to via the pointer or reference. This can be read and written when accessing via the pointer or reference. The resolved pointers or references are listed as usual under the variables in the TwinCAT HMI Configuration Window

(source: https://infosys.beckhoff.com/english.php?content=../content/1033/te2000_tc3_hmi_engineering/10740011531.html&id=)

Given the explanation above, I would suspect that a variable of type REFERENCE TO X would show up in the HMI configuration window and that it would be possible to access the members of X.

The observation, however, is that this is only partly the case. The referenced variable is showing, but I cannot access its members, as can be seen from the image below:

enter image description here

  1. The original instance
  2. The instance exposed through an interface pointer (IMyFB)
  3. The instance exposed through a POINTER TO MyFB
  4. The instance exposed through a REFERENCE TO MyFB

Only the interface pointer seems to work as expected, where the members of the original instance are visible (only the properties of course)

When looking at the data type schema of the REFERENCE-TO-MyFB, it came to my attention that there is an attribute allowImplicitAccess that is set to false. This is odd, since I would expect this to be true.

{
  "allOf": [
    {
      "allowImplicitAccess": false
    },
    {
      "$ref": "tchmi:server#/definitions/PLC1.MyFB"
    }
  ],
  "id": "tchmi:server#/definitions/PLC1.REFERENCE-TO-MyFB"
}

I tried setting this attribute to false by manually adjusting this file: {solutionFolder}{hmiProjectFolder}\Server\TcHmiSrv\TcHmiSrv.Config.default.json (Since I couldn't find another way to adjust the schema.)

Setting it to true didn't help, but removing the attribute did work:

"PLC1.REFERENCE-TO-MyFB": {
     "allOf": [
         {
                 "$ref": "#/definitions/PLC1.MyFB"
         }
     ]
}

The referenced variable is now showing as I would expect:

enter image description here

There are a few annoyances however:

  • Unmapping and remapping will cause the 'AllowImplicitAccess to re-appear, so you will have to do this again
  • When removing the AllowImplicitAccess, you will get a warning on the mapped symbols that the schema of the linked symbol is different than the type. This is a bit annoying, but so far I have not found a real problem with this.
  • This does not feel like the right way to solve this issue.

My question is: Is there a setting that needs to be enabled in order to allow member access on REFERENCE-TO-X types, or are there better solutions to this problem? (same goes for POINTER-TO-X) Why is it by default disallowed to access these members, or is this a bug?

Some additional remarks:

  • All used properties have the {attribute 'monitoring' := 'call'} attribute
  • All permissions are active for the mapped symbol

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

1

There are 1 answers

0
Heru Prayogo On

I got struggle on this issue also. What I've done is just access the reference symbol on the control's property and put the other symbol name after the reference on the property box. enter image description here

But the cons is the variable can't be used as two way access. To make it two way I just make a struct that consist of the reference of all the symbol as the members.