FB_XmlSrvWrite

FB_XmlSrvWrite 1:

The function block FB_XmlSrvWrite can be used for writing the value of a PLC variable into 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 written is identified unambiguously by the symbol address and size.

VAR_INPUT

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

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

ePath: this input can be used to select a TwinCAT system path on the target device for opening the file.

nMode: this input can be used to control which data are written into the XML file. XMLSRV_SKIPMISSING and XMLSRV_ADDMISSING modes are available for the XmlSrvWrite command. In XMLSRV_SKIPMISSING mode, only those subelements of a PLC symbol that already exist in the XML file are written to the XML file. In XMLSRV_ADDMISSING mode, missing subelements are added to the XML file. From product version 3.2.31.0 it is possible to write the comments from the declaration section into the XML file with the parameters XMLSRV_SERIALIZESYMCOMMENT and XMLSRV_SERIALIZETYPECOMMENT.

pSymAddr: address of the PLC variable to be written to the XML file.

cbSymSize: size of the PLC variable to be written to the XML file.

sFilePath: contains the path and file name of the file to be opened. The path can only point to the local computer’s file system! This means that network paths cannot be used here!

sXPath: 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: the function block is enabled via a positive edge at this input.

tTimeout: maximum time that must not be exceeded when the function block is executed.

VAR_OUTPUT

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

bBusy: This output is set when the function block is activated. It remains set until feedback is received.

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

nErrId: Returns the TC3 XML server error number, if a bError output is set.

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v3.1 Build 4011

PC or CX (x86, x64, ARM)

Tc2_XmlDataSrv