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

Weiterführende Informationen

Die Funktion F_VN_InitMatrixStruct erstellt eine Matrix-Struktur des Typs TcVnMatrix aus einem beliebigen Speicherbereich.

Parameter

Datenbuffer

Der Pointer pSrcBuffer muss auf den Speicherbereich mit den Daten für die Matrix zeigen. Dies kann z. B. ein Array sein.

Matrix-Beschreibung

Die Matrix muss durch die Anzahl der Reihen nRows und Spalten nCols sowie durch den Datentyp der Element eElementType beschrieben werden.

Ergebnis-Matrix

Als Ergebnis wird die Matrix-Struktur stDestMatrix vom Typ TcVnMatrix zurückgegeben.

Anwendung

Die Erstellung einer 3×3-Matrix sieht z. B. so aus:

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.44 or later

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

Tc3_Vision