ST_DriveRef for using with the functionblocks of the library

TYPE ST_PlcDriveRef :
  STRUCT
    aNetId     : T_AmsNetIdArr; (* AmsNetId (array[0..5] of bytes) of the EtherCAT master device. *)
    nSlaveAddr : UINT; (* Address of the slave device. *)
    nDriveNo   : BYTE; (* Drive number *)
    nDriveType : BYTE; (* Drive type *)
  END_STRUCT
END_TYPE

The drive reference can be linked in the System Manager between PLC and drive. The link can be done to an instance of the ST_PlcDriveRef, which needs to be declared with "AT %I*". The 'aNetID' goes to 'netId', 'nSlaveAddr' goes to 'port' and 'nDriveNo' goes to 'Chn0' (A) or 'Chn1' (B). Drives with more than one channel share the 'netId' and the 'port'-number because it is the same EtherCAT-Slave for the channels.

ST_DriveRef for using with the functionblocks of the library 1:
TYPE ST_DriveRef :
  STRUCT
    sNetId     : T_AmsNetId; (* AmsNetId (string(23)) of the EtherCAT master device. *)
    nSlaveAddr : UINT; (* Address of the slave device. *)
    nDriveNo   : BYTE; (* Drive number*)
    nDriveType : BYTE; (* Drive type *)
  END_STRUCT
END_TYPE

The function blocks of the library TcDrive.lib are using an instance of the structure ST_DriveRef. The difference compared to the structure ST_PlcDriveRef is that here the NetID is of the type T_AmsNetId (STRING(23)) instead of the byte array. The function F_CreateAmsNetId() of the TcSystem.lib can be used to convert the byte array to the T_AmsNetId.

stDriveRef.sNetId     :=F_CreateAmsNetId(stPlcDriveRef.aNetId);
stDriveRef.nSlaveAddr := stPlcDriveRef.nSlaveAddr;
stDriveRef.nDriveNo   := stPlcDriveRef.nDriveNo;
stDriveRef.nDriveType := stPlcDriveRef.nDriveType;