UA_ConnectGetStatus

UA_ConnectGetStatus 1:

This function block checks the connection status of an existing connection to another OPC UA Server. The connection is referenced via the respective connection handle. The status is then returned as E_UAConnectionStatus. The connection status is determined based on the internal session info or the OPC UA heartbeat, no additional communication (read or similar) is performed.

The service level of the OPC UA Server can be read out via the additional input parameter GetServiceLevel. For this purpose, a read command is sent to the server in the background to determine this information.

UA_ConnectGetStatus 2: Inputs

VAR_INPUT
    Execute            : BOOL;
    ConnectionHdl      : DWORD;
    GetServiceLevel    : BOOL;    
    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 of an existing communication link.

GetServiceLevel

BOOL

Reads out the ServiceLevel of the OPC UA Server.

Timeout

TIME

Time until the function is aborted. DEFAULT_ADS_TIMEOUT is a global constant, set to 5 seconds. The value must be set to match the ST_UASessionConnectInfo.tConnectionTimeout. The rule of thumb is: ADS Timeout > 2 * ConnectionTimeout.

UA_ConnectGetStatus 3: Outputs

VAR_OUTPUT
    Done             : BOOL;
    Busy             : BOOL;
    Error            : BOOL;
    ErrorID          : DWORD;
    ConnectionStatus : E_UAConnectionStatus;
    ServerState      : E_UAServerState;
    ServiceLevel     : BYTE; 
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 error code of the most recently executed command.

ConnectionStatus

E_UAConnectionStatus

Connection status (see E_UAConnectionStatus).

ServerState

E_UAServerState

Server state (see E_UAServerState).

ServerState

BYTE

ServiceLevel of the OPC UA Server.

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT 3.1

Win32, Win64, CE-X86, CE-Arm®

Tc3_PLCopen_OpcUa

PLC library

Required version

Tc3_PLCopen_OpcUa

>= 3.2.11.0