FB_XmlSrvReadByName

FB_XmlSrvReadByName 1:

The FB_XmlSrvReadByName function block can be used to initialize a PLC variable with data from an XML file. The input variable sXPath has to point to a valid node in the XML file specified via sFilePath. The symbol to be initialized is identified unambiguously by the symbol name.

FB_XmlSrvReadByName 2: Inputs

VAR_INPUT
    sNetId      : T_AmsNetId;
    ePath       : E_OpenPath := PATH_GENERIC;
    nMode       : WORD := XMLSRV_SKIPMISSING;
    sSymName    : T_MaxString;
    sFilePath   : T_MaxString;
    sXPath      : T_MaxString;
    bExecute    : BOOL;
    tTimeout    : TIME := T#60s;
END_VAR

Name

Type

Description

sNetId

T_AmsNetId

String containing the network address of the TwinCAT 3 XML Server. For the local computer (default) an empty string may be specified.

ePath

E_OpenPath

A variable of this type can be used to select a generic or TwinCAT system path on the target device for opening a file. The default is PATH_GENERIC.

nMode

WORD

This input can be used to control how the XML file is evaluated. Only the XMLSRV_SKIPMISSING mode is currently supported for the command XmlSrvReadByName.

sSymName

T_MaxString

Name of the PLC symbol to be written with the data from the XML file.

sFilePath

T_MaxString

Contains the path and file name for the file to be opened. The path can only point to the local file system of the computer. This means that network paths cannot be used here.

sXPath

T_MaxString

Contains the address of the tag in the XML document from which the data are to be written. The address must be a valid XPath instruction. The name of the tag must be different from the name of the symbol.

bExecute

BOOL

The function block is activated by a positive edge at this input.

tTimeout

TIME

Maximum time allowed for the execution of the function block.

FB_XmlSrvReadByName 3: Outputs

VAR_OUTPUT
    bBusy   : BOOL;
    bError  : BOOL;
    nErrId  : UDINT;
END_VAR

Name

Type

Description

bBusy

BOOL

This output is set when the function block is activated and remains set until feedback is received.

bError

BOOL

This output is set up after the bBusy output has been reset if there has been an error in transmission of the command.

nErrId

UDINT

If the bError output is set, this parameter returns the TwinCAT 3 XML Server error number.

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v3.1 Build 4011

PC or CX (x86, x64, Arm®)

Tc2_XmlDataSrv