UA_HistoryUpdate

UA_HistoryUpdate 1:

This function block sends historical data via OPC UA to a server that supports the OPC UA HistoryUpdate function, e.g. the TwinCAT OPC UA Server. With one call you can transfer a large number of values including time stamps to the server for a node handle. The server ensures that the values transmitted are saved in a data memory and are available via Historical Access.

UA_HistoryUpdate 2:

The function block can be instanced several times if values of several node handles (different variables) are to be transmitted.

Operation with TwinCAT OPC UA Server

The function block is well suited if you use Historical Access in the TwinCAT OPC UA Server and want to make data available from a certain time interval in which, for example, a special machine state prevailed. Values for the desired period can be purposefully transmitted.

If on the other hand values are sent cyclically and are to be made available in the server via Historical Access, then the Historical Access function on the server side is better suited, as in this case you only have to configure the recording node in the configurator and set the desired sampling rate.

See also: Program sample TF6100_OPCUA_HASample

UA_HistoryUpdate 3: Inputs

VAR_INPUT
    Execute        : BOOL;
    ConnectionHdl  : DWORD;
    NodeHdl        : DWORD;
    PerformInsert  : BOOL;
    PerformReplace : BOOL;
    DataValueCount : UINT;
    Timeout        : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR

Name

Type

Description

Execute

BOOL

The command is triggered by a rising edge at this input.

ConnectionHdl

DWORD

Connection handle previously output by the function block UA_Connect.

NodeHdl

DWORD

Node handle that was previously output by the function block UA_NodeGetHandle.

PerformInsert

BOOL

The default is TRUE.

PerformReplace

BOOL

The default is FALSE. If a value for the given timestamp already exists in the history, it should be replaced if the PerformReplace option is set (= TRUE). Currently this option can only be selected for SQL adapters. Other adapters do not support the option.

DataValueCount

UINT

Defines the number of values transferred. A maximum number of 1000 values is supported.

Timeout

TIME

Time until the function is aborted. DEFAULT_ADS_TIMEOUT is a global constant, set to 5 seconds.

UA_HistoryUpdate 4: Inputs/outputs

VAR_IN_OUT
    DataValues       : ARRAY[*] OF UAHADataValue;
    ValueErrorIDs    : ARRAY[*] OF DWORD;    
END_VAR

Name

Type

Description

DataValues (read-only)

ARRAY

All collected values are transferred in the form of a field of the type UAHADataValue. The length of the field is not prescribed, but it must correspond at least to the specification of DataValueCount. Internally the values are accessed only for reading.

ValueErrorIDs (write-only)

ARRAY

After execution of the command this field contains an error code for each value. The length of the field must correspond at least to the specification of DataValueCount. If one or more values report an error, it is also signaled via the outputs Error and ErrorID of the function block. With the help of this field you can then determine which error has occurred for which value. The error code 16#80000000, for example, signalizes a failed operation, meaning that the value could not be written.

UA_HistoryUpdate 5: Outputs

VAR_OUTPUT
    Done      : BOOL;
    Busy      : BOOL;
    Error     : BOOL;
    ErrorID   : DWORD;
END_VAR

Name

Type

Description

Done

BOOL

Switches to TRUE if the function block was executed successfully.

Busy

BOOL

TRUE until the function block has executed a command, at the most for the duration of the "Timeout" at the input. The inputs accept no new command as long as Busy = TRUE. It is not the connection time that is monitored but the reception time.

Error

BOOL

Switches to TRUE if an error occurs while executing a command. The command-specific error code is included in ErrorID.

ErrorID

DWORD

Contains the command-specific ADS error code of the most recently executed command.

UA_HistoryUpdate 6:

Number of values transferred

The larger the number, the greater the required computing effort and thus the longer the PLC execution time when executing the command.

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT 3.1 >= 4024.1

Win32, Win64, WinCE-x86

Tc3_PLCopen_OpcUa

>= v3.1.9.0