AddClient

TwinCAT
Network TCP/IP client

ns=2;s=DEPRAG Smart/Network/TCP/IP/AddClient

Creates a new, fully parameterized TCP/IP client. The client can be retrieved from the "ActiveClients" list via the returned index.

Parameters:

    ConnectionTimeoutInMilliseconds
    Maximum time in milliseconds for establishing a connection to the server. If no connection can be established within the time interval, an error is output.

Returns:

    AddClient
    A variable of type OpcMethodReturnValueInt32. The Result property contains the command-specific return values.
      Result
      Unique index with which the TCP/IP client can be retrieved from the "ActiveClients" list.

Examples:

In addition to the parameters already explained, the following variables must be created / transferred for the implementation in TwinCAT 3:

Beckhoff parameter:

    bTcpIpAddClient
    A boolean variable that can be used to trigger the execution of the AddClient command.
    OutputDataTcpIpAddClient
    An instance of the ST_Int32OutputData structure into which the return value of the AddClient method is written.
    hrTcpIpAddClient
    This can be used to monitor the execution of the command. Error codes have the type HRESULT.
    fbTcpIp
    An instance of the "FB_TcpIp" function block supplied with the DEPRAG Smart library.
    sHostAddress
    A string(255) variable representing the IP or DNS address of the server.
    nPortNumber
    A DINT variable that specifies the port of the host.
    nConnectionTimeoutInMilliseconds
    A DINT variable that specifies the maximum time in milliseconds for establishing a connection to the server. If no connection can be established within the time interval, an error is output.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
    bTcpIpAddClient    : BOOL;
    OutputDataTcpIpAddClient : ST_Int32OutputData;
    hrTcpIpAddClient   : HRESULT;

    fbTcpIp  : FB_TcpIp;
END_VAR

hrTcpIpAddClient := fbTcpIp.AddClient(
        bExecute       := bTcpIpAddClient, 
        ConnectionHandle     := depragSmartConnection.ConnectionHandle, 
        sHostAddress      := '10.10.222.101', 
        nPortNumber       := 4540, 
        nConnectionTimeoutInMilliseconds := 5000, 
        OutputData       => OutputDataTcpIpAddClient);
IF hrTcpIpAddClient <> S_FALSE THEN 
    bTcpIpAddClient := FALSE;
END_IF
                                                    

For examples and explanations regarding the calls of nodes via Siemens TIA Portal please refer to the sub-menu "Siemens TIA Portal" in section "Getting Started".