FB_MllPrediction
Syntax
Definition:
FUNCTION_BLOCK FB_MllPrediction
VAR_INPUT
stPredictionParameter : ST_MllPredictionParameters;
eTraceLevel : TcEventSeverity;
END_VAR
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
ipResultMessage : I_TcMessage;
hrErrorCode : HRESULT;
END_VAR
Inputs
Name | Type | Description |
|---|---|---|
stPredictionParameter | General Prediction parameters | |
eTraceLevel | TcEventSeverity | Eventlogger trace level. Default = Critical. Must be set before Configure method is called |
Outputs
Name | Type | Description |
|---|---|---|
bBusy | BOOL | True if a asynchronous action is taking place |
bError | BOOL | Indicates error in method |
ipResultMessage | I_TcMessage | Contains the last invoked error |
hrErrorCode | HRESULT | Unique error code |
Methods
Name | Description |
|---|---|
Checks if the supplied I/O data types are preferred by the currently loaded model. | |
Checks if the supplied I/O data types are supported by the currently loaded model. | |
Configures the FB with the given parameters. It returns true if the configuration or reconfiguration is done | Please call this method only from one task context at the time. | |
Retrieves a custom array attribute (int8/16/32/64 or fp32/64) from the machine learning model, which can be of any data type (requires casting after retrieval) and can be an array. | |
Retrieves a custom floating-point attribute (converted to 64-bit floating point) from the machine learning model. | |
Retrieves a custom integer attribute (converted to 64-bit signed int) from the machine learning model. | |
Retrieves a custom string attribute from the machine learning model. | |
Retrieves the numeric engine id from its (optional) reference name. | |
Retrieve the size of the input dimension from the currently loaded model. | |
Retrieves the maximum number of threads that can concurrently use the loaded model via individual EngineIds. | |
Retrieves the name of the loaded model. | |
Retrieves the size of the output dimension from the currently loaded model. | |
Performs a prediction using the currently loaded model, expecting that the input data has been already written to the input buffer prior to call and output data will be retrieved from the output buffer after prediction. | |
Performs a prediction using the currently loaded model, expecting that the input data has been already written to the input buffer prior to call and output data will be retrieved from the output buffer after prediction. | |
Resets an error | |
Allows to set special engine options to the currently active engine. |
General information
The FB_MllPrediction is a central Function Block for the usage of TC3 Machine Learning in the PLC. The Function Block offers a variety of Methods as described above. Basically, the FB_MllPrediction offers the functionality to load and to execute ML models. Hence, it is an interface to the TwinCAT 3 integrated inference engine (ML Runtime).
Error handling
Note that all methods of FB_MllPrediction return a BOOL which indicates if the execution on the method caused any error, e.g.
bFailed := fbprediction.GetInputDim(nInputDim);The evaluation of the return value of the methods is equivalent to the evaluation of the Output bError of FB_MllPrediction.
Further, FB_MllPrediction references the TwinCAT 3 EventLogger and thus ensures that information (events) is provided via the standardized interface I_TcMessage. The trace level can be adjusted using TcEventSeverity.
Sample Code
Sample code for the usage of the Function Block is available here.