SPS-Funktionsbausteine zur Speicherfunktion der Lizenz-Dongles

SPS-Funktionsbausteine zur Speicherfunktion der Lizenz-Dongles 1:

Mindestens TwinCAT 3.1 Build 4022 und PLC Lib: Tc2_Utilities Version 3.3.26.0

Die beschriebenen Funktionalitäten erfordern mindestens TwinCAT 3.1 Build 4022 und die PLC Lib: Tc2_Utilities Version 3.3.26.0

Achtung: Um ein License Response File in einem TwinCAT-3-Lizenz-Dongle speichern zu können, darf der Dateiname maximal 32 Zeichen lang sein.

Auslesen der StorageInfo und des Dateiverzeichnisses eines Lizenz-Dongles

FUNCTION_BLOCK FB_LicFileGetStorageInfo

Der Funktionsbaustein liest die StorageInfo des Lizenz-Dongles und das Dateiverzeichnis aus.

Die StorageInfo enthält Verwaltungsdaten des Datenträgers (wie Kapazität, Anzahl der freien Bytes, Anzahl der Dateien, …) und ein Array auf die einzelnen Dateieinträge (Name, Größe, Attribute, … der Datei).

VAR_INPUT
    sNetId           : T_AmsNetId;(* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPort            : UINT;      (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    bExecute         : BOOL;      (* Rising edge on this input activates the fb execution *)
    dwPassCode       : DWORD;     (* Passcode for file access *)
    tTimeout         : TIME       := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy            : BOOL;      (* True as long as the FB is busy *)
    bError           : BOOL;      (* True in case of an error *)
    nErrorId         : UDINT;     (* Error code in case of an error *)
    nFileEntries     : UDINT;     (* Amount of files on dongle *)
END_VAR
VAR_IN_OUT
    stStorageInfo    : ST_LicStorageInfo;   (* Header + files infos from dongle *)
END_VAR

Erzeugen einer Datei auf einem Lizenz-Dongle

FUNCTION_BLOCK FB_LicFileCreate

Der Funktionsbaustein erzeugt eine Datei auf dem Lizenz-Dongle. Die Daten aus dem Buffer (pWriteBuff und cbWriteLen) werden bei steigender Flanke an bExecute direkt in eine neue Datei auf dem Dongle geschrieben.

VAR_INPUT
    sNetId      : T_AmsNetId;(* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPort       : UINT;     (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    sFileName   : STRING;   (* File name to write to dongle *)
    pWriteBuff  : PVOID;    (* Buffer address for write *)
    cbWriteLen  : UDINT;    (* Count of bytes for write *)
    bExecute    : BOOL;     (* Rising edge on this input activates the fb execution *)
    dwPassCode  : DWORD;    (* Passcode for file access *)
    tTimeout    : TIME := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy       : BOOL;     (* True as long as the FB is busy *)
    bError      : BOOL;     (* True in case of an error *)
    nErrorId    : UDINT;    (* Error code in case of an error *)
END_VAR

Löschen einer Datei auf einem Lizenz -Dongle

FUNCTION_BLOCK FB_LicFileDelete

Der Funktionsbaustein löscht eine Datei auf dem Lizenz-Dongle. Hierfür werden der Dateiname und die Dateilänge genullt, die Datenbytes der zu löschenden Datei werden auf dem Dongle zwar freigegeben aber nicht überschrieben.

VAR_INPUT
    sNetId      : T_AmsNetId;(* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPort       : UINT;     (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    sFileName   : STRING;   (* File name to delete from dongle *)
    bExecute    : BOOL;     (* Rising edge on this input activates the fb execution *)
    dwPassCode  : DWORD;    (* Passcode for file access *)
    tTimeout    : TIME       := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy       : BOOL;     (* True as long as the FB is busy *)
    bError      : BOOL;     (* True in case of an error *)
    nErrorId    : UDINT;    (* Error code in case of an error *)
END_VAR

Lesen einer Datei der Klemme/des USB-Dongle

FUNCTION_BLOCK FB_LicFileRead

Der Funktionsbaustein liest über eine steigende Flanke an bExecute eine Datei vom Lizenz-Dongle in einen bereitgestellten Buffer (pDestBuff und cbReadLen). Der Buffer muss groß genug für die Datei sein, sonst wird nur der vordere Teil der Datei gelesen.

VAR_INPUT
    sNetId      : T_AmsNetId;(* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPort       : UINT;     (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    sFileName   : STRING;   (* File name to write to dongle *)
    pDestBuff   : PVOID;    (* Buffer address for read *)
    cbReadLen   : UDINT;    (* Count of bytes for read *)
    bExecute    : BOOL;     (* Rising edge on this input activates the fb execution *)
    dwPassCode  : DWORD;    (* Passcode for file access *)
    tTimeout    : TIME       := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy       : BOOL;     (* True as long as the FB is busy *)
    bError      : BOOL;     (* True in case of an error *)
    nErrorId    : UDINT;    (* Error code in case of an error *)
END_VAR

Kopieren einer Datei von der Festplatte auf die Klemme/den USB-Dongle

FUNCTION_BLOCK FB_LicFileCopyToDongle

Der Funktionsbaustein kopiert eine Datei von der Festplatte auf den Lizenz-Dongle. Ist die Datei größer als der Buffer (cbCopyLen), dann wird die Datei automatisch in mehreren Lese- und Schreibzugriffen kopiert, bis die komplette Datei kopiert ist, erst dann geht das bBusy auf FALSE.

VAR_INPUT
    sNetIdSrc         : T_AmsNetId;    (* Ams net id of PC ('' is local PC) *)
    sNetIdDest        : T_AmsNetId;    (* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPortDest         : UINT;          (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    sFilePathNameSrc : T_MaxString;    (* File path name on disk *)
    sFileNameDest     : STRING;        (* File name for file on dongle *)
    pCopyBuff         : PVOID;         (* Buffer address for write *)
    cbCopyLen         : UDINT;         (* Count of bytes for write *)
    bExecute          : BOOL;          (* Rising edge on this input activates the fb execution *)
    dwPassCode        : DWORD;         (* Passcode for file access *)
    tTimeout          : TIME := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy             : BOOL;          (* True as long as the FB is busy *)
    bError            : BOOL;          (* True in case of an error *)
    nErrorId          : UDINT;         (* Error code in case of an error *)
END_VAR

Kopieren einer Datei von der Klemme/dem USB-Dongle auf die HDD

FUNCTION_BLOCK FB_LicFileCopyFromDongle

Der Funktionsbaustein kopiert eine Datei vom Lizenz-Dongle auf die Festplatte. Ist die Datei größer als der Buffer (cbCopyLen), dann wird die Datei automatisch in mehreren Lese- und Schreibzugriffen kopiert, bis die komplette Datei kopiert ist, erst dann geht das bBusy auf FALSE.

VAR_INPUT
    sNetIdSrc         : T_AmsNetId;    (* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPortSrc          : UINT;          (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    sNetIdDest        : T_AmsNetId;    (* Ams net id of PC ('' is local PC) *)
    sFileNameSrc      : STRING;        (* File name for file on dongle *)
    sFilePathNameDest : T_MaxString;   (* File path name on disk *)
    pCopyBuff         : PVOID;         (* Buffer address for write *)
    cbCopyLen         : UDINT;         (* Count of bytes for write *)
    bExecute          : BOOL;          (* Rising edge on this input activates the fb execution *)
    dwPassCode        : DWORD;         (* Passcode for file access *)
    tTimeout          : TIME            := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy             : BOOL;          (* True as long as the FB is busy *)
    bError            : BOOL;          (* True in case of an error *)
    nErrorId          : UDINT;         (* Error code in case of an error *)
END_VAR

Siehe auch: