UA_Connect

This function block establishes an OPC UA Remote connection to another OPC UA Server, which is specified via ServerUrl and SessionConnectInfo. The function block returns a connection handle that can be used for other function blocks, such as UA_Read.
Inputs
VAR_INPUT
Execute : BOOL;
ServerUrl : STRING(MAX_STRING_LENGTH);
SessionConnectInfo : ST_UASessionConnectInfo;
Timeout : TIME := DEFAULT_ADS_TIMEOUT;
END_VAR
Name | Type | Description |
---|---|---|
Execute | BOOL | The command is triggered by a rising edge at this input. |
ServerUrl | STRING(MAX_STRING_LENGTH) | OPC UA Server URL, i.e. 'opc.tcp://172.16.3.207:4840' or 'opc.tcp://CX_0193BF:4840'. |
SessionConnectInfo | ST_UASessionConnectInfo | Connection information (see ST_UASessionConnectInfo) |
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. |
Outputs
VAR_OUTPUT
ConnectionHdl : DWORD;
Done : BOOL;
Busy : BOOL;
Error : BOOL;
ErrorID : DWORD;
END_VAR
Name | Type | Description |
---|---|---|
ConnectionHdl | DWORD | OPC UA connection handle. |
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. |
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT 3.1 | Win32, Win64, CE-X86, CE-Arm® | Tc3_PLCopen_OpcUa |