FB_MllPrediction

FB_MllPrediction 1:

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

FB_MllPrediction 2: Inputs

Name

Type

Description

stPredictionParameter

ST_MllPredictionParameters

General Prediction parameters

eTraceLevel

TcEventSeverity

Eventlogger trace level. Default = Critical. Must be set before Configure method is called

FB_MllPrediction 3: 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

FB_MllPrediction 4: Methods

Name

Description

CheckPreferredIODataTypes

 

CheckSupportedIODataTypes

 

Configure

 

GetCustomAttribute_array

 

GetCustomAttribute_fp64

 

GetCustomAttribute_int64

 

GetCustomAttribute_str

 

GetEngineIdFromRef

 

GetInputDim

 

GetMaxConcurrency

 

GetModelName

 

GetOutputDim

 

Predict

 

PredictRef

 

Reset

 

SetActiveEngineOptions

 

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.

System Requirements