Connect

TwinCAT TIA
Devices Multi-vendor devices Open Protocol devices OpenProtocolDevices One device

ns=2;s=DEPRAG Smart/Devices/General/OpenProtocol/OpenProtocolDevices/0/Connect

Establishes the connection to an Open Protocol device. DEPRAG Smart acts as an Open Protocol client that establishes the connection to an Open Protocol server.

Parameters:

    Ip
    IP address of the device at which the Open Protocol Server can be reached.
    Port
    Port of the device under which the Open Protocol Server can be reached.
    TimeoutInSeconds
    Maximum time in seconds for establishing a connection to the Open Protocol Server. If no connection can be established within the time interval, an error is output.
    EnableKeepAlive
    Specifies whether keep-alive messages should be sent to verify that the connection to the Open Protocol Server is still established.
    Revision
    Describes how the sent message is to be interpreted. A message can have different change states (=revision).

Returns:

    Connect
    A variable of the OpcMethodReturnValueVoid type. The method has no command-specific return values.

Examples:

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

Beckhoff parameter:

    bOpenProtocolConnect
    A boolean variable that can be used to trigger the execution of the connect command.
    OutputDataOpenProtocolConnect
    An instance of the "ST_VoidOutputData" structure into which the return value of the Connect method is written.
    hrOpenProtocolConnect
    This can be used to monitor the execution of the command. Error codes have the type "HRESULT".
    fbOpenProtocol
    An instance of the "FB_OpenProtocol" function block supplied with the DEPRAG Smart library.
    sDeviceId
    A DINT value that identifies the device in the list of devices registered with the DEPRAG Smart OPC UA Server.
    sIp
    A STRING(255) variable containing the IP address of the device at which the Open Protocol Server can be reached.
    nPort
    A DINT variable describing the port of the device under which the Open Protocol Server can be reached.
    nTimeOutInSeconds
    A DINT variable containing the maximum time in seconds for establishing a connection to the Open Protocol Server.
    bEnableKeepAlive
    A boolean variable that specifies whether to send keep-alive messages.
    nRevision
    A DINT variable that describes how the sent message is to be interpreted. A message can have different change states (=revision).
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
            bOpenProtocolConnect    : BOOL;
            OutputDataOpenProtocolConnect   : ST_VoidOutputData;
            hrOpenProtocolConnect    : HRESULT;

            fbOpenProtocol   : FB_OpenProtocol;
END_VAR

hrOpenProtocolConnect := fbOpenProtocol.Connect(
            bExecute    := bOpenProtocolConnect,
            ConnectionHandle := depragSmartConnection.ConnectionHandle,
            sDeviceId   := '0',
            sIp     := '000.000.000.000',
            nPort    := 4545,
            nTimeOutInSeconds  := 5,
            bEnableKeepAlive := TRUE,
            nRevision   := 1,
            OutputData   => OutputDataOpenProtocolConnect);
IF hrOpenProtocolConnect <> S_FALSE THEN 
            bOpenProtocolConnect := 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".