FB_MlSvrPrediction

FB_MlSvrPrediction is a TcMlServer client that provides asynchronous and optionally hardware-accelerated AI model inference for the PLC.

The function block is located in the PLC library Tc3_MlServer.

Syntax

Declaration:

fbMlSvr : FB_MlSvrPrediction;

Definition:

FUNCTION_BLOCK FB_FTR_IIRCoeff
VAR_INPUT
    stPredictionParameter : ST_PredictionParameter;
END_VAR
VAR_OUTPUT
    bError                : BOOL;
    nErrorCode            : HRESULT;
    bConfigured           : BOOL;
    nMaxInferenceDuration : UDINT;
END_VAR

FB_MlSvrPrediction 1: Inputs

Name

Type

Description

stPredictionParameter

ST_PredictionParameter

Configuration structure of the Machine Learning Server session

FB_MlSvrPrediction 2: Outputs

Name

Type

Description

bError

BOOL

TRUE if the currently pending asynchronous request to the TcMLServer was canceled with an error.

nErrorCode

HRESULT

Return code for the currently pending asynchronous request to the TcMlServer.

bConfigured

BOOL

TRUE if the configuration was successful. Indicates whether the function block has a valid session with the TcMlServer. If FALSE, "configure" must be called. Please note: bConfigured can change to FALSE due to an error during the execution of the request at the TcMlServer.

nMaxInferenceDuration

UDINT

Maximum number of PLC cycles required to execute an inference. See also Execute AI model.

FB_MlSvrPrediction 3: Methods

Name

Definition location

Description

Configure

Local

Create a session for the FB instance on the TcMlServer according to the configuration defined in stPredictionParameter.

Deconfigure

Local

End a session of the function block on the TcMlServer. The allocated resources on the server are released again.

GetCustomAttribute_array

Local

Get custom attributes of type ARRAY of the AI model

GetCustomAttribute_bool

Local

Get custom attributes of type BOOL of the AI model

GetCustomAttribute_fp64

Local

Get custom attributes of type LREAL of the AI model

GetCustomAttribute_int64

Local

Get custom attributes of type LINT of AI model

GetCustomAttribute_str

Local

Get custom attributes of type STRING of the AI model

Predict

Local

Transmission of an asynchronous inference request to the TcMlServer

PredictBatched

Local

Transmission of an asynchronous, bundled inference request to the TcMLServer