Client (FB)

FUNCTION_BLOCK PUBLIC FINAL Client EXTENDS CBML.LConC IMPLEMENTS IClient

Function block for establishing a connection to an OPC UA server.

Usage (Declaration):

sPolicySHA256 : STRING := 'http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256';
sURL  : STRING := 'opc.tcp://xxx:4840';
sSession : STRING := 'urn:xxx:CODESYS:UA.Client';

UAPolicy : UA.SecurityPolicy := (
    sPolicy:=sPolicySHA256,
    eSecurity:=UA.SECURITY_MODE.SIGN_AND_ENCRYPT
);

UAAuth : UA.UserNameAuth := (sUserName:=sUser, sPassword:=sPass);

UAClient : UA.Client := (
    sURL := sURL,
    sSession := sSession,
    itfPolicy := UAPolicy,
    itfAuth := UAAuth,
    udiTimeout := 100000
);
InOut:

Scope

Name

Type

Initial

Comment

Inherited from

Input

xEnable

BOOL

LConC

Output

xBusy

BOOL

LConC

xError

BOOL

LConC

Input Const

itfAsyncProperty

IAsyncProperty

0

sClientName

STRING

‘CODESYS OPC UA Client’

sURL

URL

sSession

SESSION

itfPolicy

ISecurityPolicy

0

itfAuth

IAuthentication

0

udiTimeout

UDINT

0

itfNamespaceArray

INamespaceArray

0

Output

eErrorID

ERROR

xActive

BOOL

TRUE if a Connection is established

itfConnection

IConnection

The established connection to the related server
Valid, as long xActive = TRUE

eState

CONNECTION_STATE

CONNECTION_STATE.UNKNOWN

Methods:

Structure: