AddDevice

TwinCAT
Devices DEPRAG devices Sequence controller

ns=2;s=DEPRAG Smart/Devices/DEPRAG/AST/AddDevice

Adds a new device to the ActiveDevices list. The device type is specified via the "AstType" variable.

Parameters:

    Username
    User name for authentication on the device.
    Password
    Password for authentication on the device.

Returns:

    AddDevice
    A variable of type OpcMethodReturnValueInt32. The Result property contains the command-specific return values.
      Result
      Unique list index to retrieve the device in the ActiveDevices list.

Examples:

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

Beckhoff parameter:

    bAstAddDevice
    A boolean variable that can be used to trigger the execution of the Add command.
    outputAstAddDevice
    An instance of the ST_Int32OutputData structure into which the return value of the Add method is written.
    hrAstAddDevice
    This can be used to monitor the execution of the command. Error codes have the type HRESULT.
    fbAst
    An instance of the FB_AST function block supplied with the DEPRAG Smart library.
    AstType
    Specifies the device type.
    sIpAddress
    A string variable that specifies an IP address representing the device that will be added.
    sUserName
    A string variable specifying the username to authenticate with on the specified device.
    sPassword
    A string variable that specifies the password to be used to authenticate to the specified device.
    ConnectionHandle
    "ConnectionHandle" received when establishing a connection between DEPRAG Smart Server and your OPC UA client.


VAR
     bAstAddDevice      : BOOL;  
     outputAstAddDevice     : ST_Int32OutputData;                                            
     hrAstAddDevice      : HRESULT;

     fbAst   : FB_AST;
END_VAR

hrAstAddDevice := fbAst.AddDevice(
       bExecute   := bAstAddDevice, 
       ConnectionHandle  := depragSmartConnection.ConnectionHandle, 
       AstType    := AstTypes.Ast12, 
       sIpAddress   := '0.0.0.0', 
       sUserName   := 'username', 
       sPassword   := 'password',
       OutputData   => outputAstAddDevice);
IF hrAstAddDevice <> S_FALSE THEN 
 bAstAddDevice := 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".