F_VN_ExportContainer

F_VN_ExportContainer 1:

Export the container elements into a buffer (e.g. an array). Only possible for containers with basic elements.

Syntax

Definition:

FUNCTION F_VN_ExportContainer : HRESULT
VAR_INPUT
    ipContainer : ITcVnContainer;
    pBuffer     : PVOID;
    nBufferSize : ULINT;
    hrPrev      : HRESULT;
END_VAR

F_VN_ExportContainer 2: Inputs

Name

Type

Description

ipContainer

ITcVnContainer

Container with basic elements

pBuffer

PVOID

Buffer to store the container elements (Make sure to allocate enough memory! The required size in bytes can be determined using the function F_VN_ExportContainerSize)

nBufferSize

ULINT

Size of the buffer memory in bytes

hrPrev

HRESULT

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

F_VN_ExportContainer 3: Return value

HRESULT

Further information

The function F_VN_ExportContainer exports a container to a data buffer. Make sure that sufficient memory is allocated at the place of the pointer in order to write the container data to it! The required size in bytes can be determined with the function F_VN_ExportContainerSize. You can allocate the memory, for example, by creating an array of the appropriate size.

Application

The export of a container of the type Vector_REAL with 10 elements looks like this, for example:

VAR
    aArray: ARRAY [0..9] OF REAL;
    ipContainer: ITcVnContainer;
    nBufferSize: ULINT;
END_VAR

hr := F_VN_ExportContainerSize(ipContainer, nBufferSize, hr);
IF nBufferSize = SIZEOF(aArray) THEN
    hr := F_VN_ExportContainer(
        ipContainer:=ipContainer,
        pBuffer:=ADR(aArray),
        nBufferSize:=nBufferSize,
        hr
    );

END_IF

WARNING

Memory access

It must be ensured that the type and length of the container correspond to the size of the memory area at the pointer. Otherwise, this can lead to a system crash or invalid data.

Related functions

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