F_VN_InitMatrixStruct

F_VN_InitMatrixStruct 1:

Initialize a struct of the type TcVnMatrix extending a buffer with metainformation so that it can be used as a matrix.

Syntax

Definition:

FUNCTION F_VN_InitMatrixStruct : HRESULT
VAR_INPUT
    pSrcBuffer   : PVOID;
END_VAR
VAR_IN_OUT
    stDestMatrix : TcVnMatrix;
END_VAR
VAR_INPUT
    nRows        : UDINT;
    nCols        : UDINT;
    eElementType : ETcVnElementType;
    hrPrev       : HRESULT;
END_VAR

F_VN_InitMatrixStruct 2: Inputs

Name

Type

Description

pSrcBuffer

PVOID

Source buffer

nRows

UDINT

Matrix rows

nCols

UDINT

Matrix columns

eElementType

ETcVnElementType

Type of the matrix elements

hrPrev

HRESULT

HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.)

F_VN_InitMatrixStruct 3: In/Outputs

Name

Type

Description

stDestMatrix

TcVnMatrix

Returns completed matrix struct

F_VN_InitMatrixStruct 4: Return value

HRESULT

Further information

The function F_VN_InitMatrixStruct creates a matrix structure of the type TcVnMatrix from any memory area.

Parameter

Data buffer

The pointer pSrcBuffer must point to the memory area containing the data for the matrix. This could be an array, for example.

Matrix description

The matrix must be described by the number of rows nRows and columns nCols as well as by the data type of the element eElementType.

Result matrix

The matrix structure stDestMatrix of the type TcVnMatrix is returned as the result.

Application

The creation of a 3×3 matrix looks like this, for example:

VAR
    aMatrixArray    :   ARRAY [0..2, 0..2] OF USINT := [
        -1, 0, 1,
        -2, 0, 2,
        -1, 0, 1
    ];
END_VAR

hr := F_VN_InitMatrixStruct(
    pSrcBuffer      :=  ADR(aMatrixArray),
    stDestMatrix    :=  stMatrix,
    nRows           :=  3, // must match with array dimensions
    nCols           :=  3, // must match with array dimensions
    eElementType    :=  TCVN_ET_USINT, // must match with array type
    hrPrev          :=  hr
);

Required License

TC3 Vision Base

System Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT V3.1.4024.54 or later

PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU

Tc3_Vision