Methods and properties

With version 1.12 it is possible to access PLC properties in the HMI and to call PLC methods in the HMI.

PLC properties

The properties must be made visible in the PLC with an attribute pragma via ADS.

{attribute 'monitoring' := 'call'}
PROPERTY Prop : BOOL

You can then access the property in the TwinCAT HMI.

Methods and properties 1:
Methods and properties 2:

PLC properties can only be used explicitly in the HMI by linking the property individually to a control attribute. If the entire function block is linked to a control attribute, the property is not called. This is the case when a function block is used as the source data of the DataGrid or as a user control parameter.

PLC methods

The methods must be switched visible in the PLC with an attribute pragma via ADS.

{attribute 'TcRpcEnable'}
METHOD MyMethod : BOOL
VAR_INPUT
bInput : BOOL;
END_VAR

Afterwards you can see the methods in the TwinCAT HMI. Within the TwinCAT HMI Configuration Window, you can call them explicitly.

Methods and properties 3:

At runtime in the client, you can call the methods using a JavaScript/TypeScript function and the Framework API. Below you will find an example for the call via Framework API.

// call of method without parameter
TcHmi.Symbol.readEx2("%s%PLC1.MAIN.fbTest.MethodWithoutParam%/s%", function (data) {
console.log(data);
});

// call of method with parameter
TcHmi.Symbol.writeEx("%s%PLC1.MAIN.fbTest.MyMethod%/s%", { bInput: true }, function (data) {
console.log(data);
});

If the method has a return value, you can access the return value within the callback function in the Result object.

Methods and properties 4:

In a future version of the TwinCAT HMI, it will be possible to call the methods directly via the Actions and Conditions Editor without using JavaScript/TypeScript.

Methods and properties 5:

Methods must always be called explicitly and cannot be used as a control attribute. Note that calling a method from the HMI results in the execution of PLC code.

Methods and properties 6:

Available from version 1.12.