FB_StringRingBuffer

FB_StringRingBuffer 1:

The function block FB_StringRingBuffer can be used to write string variables into the ring buffer or read previously written string variables from the ring buffer. The written strings are read out according to the FIFO principle in the same order in which they were previously written to the ring buffer. This means that the oldest entries are the first ones that are read. The buffer memory is made available to the function block via the pBuffer/cbBuffer input variables. Writing/reading of strings is controlled via action calls. The function block features the following tasks:

FB_StringRingBuffer 2: Inputs

VAR_INPUT
    bOverwrite : BOOL;
    putValue   : T_MaxString := '';
    pBuffer    : POINTER TO BYTE;
    cbBuffer   : UDINT;
END_VAR

Name

Type

Description

bOverwrite

BOOL

If TRUE and in the event of a buffer overflow the oldest entries are overwritten. If FALSE an error is reported in the event of a buffer overflow (bOk = FALSE).

putValue

T_MaxString

String to be written into the ring buffer.

pBuffer

BYTE

Address of a PLC variables (e.g. ARRAY[...] OF BYTES) to be used as buffer memory by the function block. The address can be determined with the ADR operator.

cbBuffer

UDINT

Max. byte size of the PLC variable to be used as buffer memory. The size can be determined with the SIZEOF operator.

FB_StringRingBuffer 3: Outputs

VAR_OUTPUT
    bOk      : BOOL;
    getValue : T_MaxString := '';
    nCount   : UDINT;
    cbSize   : UDINT;
END_VAR

Name

Type

Description

bOk

BOOL

Returns TRUE, if a new string was added or removed successfully. Returns FALSE in the event of a buffer overflow or if no more entries are available in the buffer.

getValue

T_MaxString

This output returns the last string that was read from the ring buffer.

nCount

UDINT

Returns the current number of buffered strings.

cbSize

UDINT

Returns the current number of assigned data bytes in the buffer. The number of assigned data bytes is always greater than the actual number of written value data. Each string is complemented with additional information, so that it can be located later.

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_Utilities (System)