FB_VN_WriteMlModel
This FB writes a machine learning model to the hard drive.
Syntax
Definition:
FUNCTION_BLOCK FB_VN_WriteMlModel
VAR_INPUT
ipMlModel : Reference To ITcVnMlModel;
sFilePath : STRING;
bWrite : BOOL;
nTimeout : TIME;
END_VAR
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrorId : UDINT;
END_VAR
Inputs
Name |
Type |
Default |
Description |
---|---|---|---|
ipMlModel |
Reference To ITcVnMlModel |
|
The machine learning model to write |
sFilePath |
STRING |
|
Full path of the file or relative path to the default directory on the target pc (e.g. only a file name). If the string is empty, a file name will be generated (containing the current time). |
bWrite |
BOOL |
|
Writing the machine learning model is triggered by a rising edge at this input. |
nTimeout |
TIME |
VISION_ADS_TIMEOUT |
Indicates the time before the function is cancelled. |
Outputs
Name |
Type |
Description |
---|---|---|
bBusy |
BOOL |
This output remains TRUE until the function block has executed a command, but at the longest for the duration supplied to the 'nTimeout' input. While bBusy = TRUE, no new command will be accepted at the inputs. |
bError |
BOOL |
This output is switched to TRUE as soon as an error occurs during the execution of a command. The command-specific error code is contained in ‘nErrorId’. If the function block has a timeout error, 'bError' is TRUE and 'nErrorId' is 1861 (hexadecimal 0x745). Is reset to FALSE by the execution of a command at the inputs. |
nErrorId |
UDINT |
Contains the ADS error code or the command-specific error code of the last executed command. Is reset to 0 by the execution of a command at the inputs. |
Weiterführende Informationen
Der Funktionsblock FB_VN_WriteMlModel
speichert ein ML-Modell aus der SPS asynchron in einer Datei.
Parameter
Einige Parameter sind zentral im Kapitel File Access Parameter beschrieben.
ML-Modell
Das ML-Modell ipMlModel
wird unter dem angegebenen Dateipfad im Binärformat gespeichert.
Einen Sonderfall stellt das Speichern eines ITcVnColorModel
dar, da dieses zuerst noch mit der folgenden Zeile in ein ML-Modell gewandelt werden muss. Alternativ kann Color Model auch durch das ITcVnMlModel
mit den entsprechenden Funktionen ersetzt werden.
hr := ipColorModel.TcQueryInterface(IID_ITcVnMlModel, ADR(ipWriteMlModel));
Dateipfad und Format
Wenn sFilePath
leer ist, wird ein Dateiname mit der aktuellen Zeit generiert und die Endung vmlm verwendet.
Anwendung
Das Speichern eines ML-Models in die Datei C:\TcVision\MlModel.vmlm
sieht z. B. so aus:
fbWriteMlModel(
ipMlModel := ipWriteMlModel,
sFilePath := 'C:\TcVision\MlModel.vmlm',
bWrite := TRUE,
nTimeout := T#500MS);
IF NOT fbWriteMlModel.bBusy AND NOT fbWriteMlModel.bError THEN
// Ml-Model was written successfully to file
END_IF
Verwandter Funktionsblock: FB_VN_ReadMlModel.
Required License
TC3 Vision Base
System Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT V3.1.4024.59 or later | PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU | Tc3_Vision |