Client - Write Data (SetAllDataValues, SetDataValues)

This sample shows the use of the "SetAllDataValuesReq" and "SetDataValuesReq" methods of the client function block.

Download TwinCAT XAE Project (*.zip): Sample09.zip

The example described here uses the state machine that is described in the "General Client project structure" chapter. The States 0, 1, 11 and 100 are identical to the state machine described there. Other states were modified for the example or new states were also added.

Sample project

In the FB_IEDClient function block and State 10, several IF instructions are listed that activate commands (method calls) of the client function block. Each command in the IF statement is activated by a rising edge at one of the Boolean variables. The Boolean variables are defined in the declaration part of the "FB_IEDClient" function block. For test purposes, the user can set the values of the Boolean variables to "TRUE" in the online view and in this way activate the command execution. After that, the system switches to state 11, where the method "ipResult.Execute()" is called in further PLC cycles until the command processing has been completed. This is the case when "ipResult.IsBusy()" returns the value "FALSE".

Following the successful execution of a command, the state machine is set to State 0. If several of the Boolean variables are set to "TRUE", then the topmost IF statement is processed first with the respective command. Some of the Boolean variables are listed in the tables below. In addition, they contain the method names and a description of the function.

Variable name

Method name

Description

bSetAllDataValues_LPHD1_DC

similar variables (commands):
bSetAllDataValues_LLN0_DC
bSetAllDataValues_MMXU1_DC
bSetAllDataValues_XCBR1_DC
bSetAllDataValues_CSWI1_DC
bSetAllDataValues_LEDGGIO1_DC
bSetAllDataValues_LEDGGIO2_DC
bSetAllDataValues_LEDGGIO3_DC
bSetAllDataValues_LEDGGIO4_DC
bSetAllDataValues_LEDGGIO5_DC
bSetAllDataValues_LEDGGIO6_DC
bSetAllDataValues_LEDGGIO7_DC
bSetAllDataValues_LEDGGIO8_DC

SetAllDataValuesReq

As soon as this Boolean variable is set to "TRUE", all data values of all subelements of the logical node: "LPHD1" and the functional group "DC" are written. To enable this, the method call uses as parameter an interface pointer to the logical node to be written: "LPHD1" and the specification of the functional group: "E_AcsiFc.DC".

bSetDataValues_MMXU1_CF_TotW

similar variables (commands):
bSetDataValues_LEDGGIO1_CF_AnOut1_sboClass
bSetDataValues_LEDGGIO1_CF_AnOut1_ctlModel
bSetDataValues_LEDGGIO1_CF_AnOut1_units
bSetDataValues_LEDGGIO1_CF_AnOut1_units_SIUnit
bSetDataValues_LEDGGIO1_CF_AnOut1_units_multiplier

SetDataValuesReq

As soon as this Boolean variable is set to "TRUE", all data values of all subelements of the data object: "TotW" of the logical node "MMXU1" and the functional group: "CF" are written. To enable this, the method call uses as parameter an interface pointer to the data object to be written: "MMXU1.TotW" and the specification of the functional group: "E_AcsiFc.CF".

The naming of the Boolean variables is only an example and can be adapted as desired. It is only intended to show which values can be written by connecting the variables.