FB_StringRingBuffer

FB_StringRingBuffer 1:

The FB_StringRingBuffer function block allows strings to be written into a ring buffer, or for strings that have previously been written there to be removed from the ring buffer . The buffer operates as a FIFO; data records are read from it in the same sequence in which they were first written into the ring buffer.  This means that the oldest entries are the first ones that are read. The buffer storage is  provided to the function block via the input variables pBuffer / cbBuffer. Writing and reading the strings is controlled by action calls. The function block features the following tasks:

Internal the FB_MemRingBuffer function block is used. See also the description of the function block: FB_MemRingBuffer.

 

VAR_INPUT

VAR_INPUT
    bOverwrite  : BOOL;
    putValue    : T_MaxString := '';
    pBuffer     : DWORD;
    cbBuffer    : UDINT; 
END_VAR

bOverwrite: If TRUE and buffer overflow => overwrite the oldest entry. If FALSE and buffer overflow => report error (bOk = FALSE).

putValue: String value to be written.

pBuffer: Address of PLC variable (e.g. ARRAY[...] OF BYTES ) that is to be used by the function block as buffer storage. The address can be determined with the ADR operator.

cbBuffer: The maximum size, in bytes, of the PLC variables that is to be used as buffer storage. The size can be determined by the SIZEOF operator.

 

VAR_OUTPUT

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

bOk: Supplies TRUE if a new data record was inserted/deleted successfully. Supplies FALSE if a buffer overflow occurs or  if no more entries do exist in the buffer.

getValue: This output contains the recent read string value.

nCount: Supplies the current number of buffered data records.

cbSize: Supplies the current number of stored data bytes in the buffer. The number of  occupied data bytes is always bigger than the actual number of written value data.Each data record is complemented by addtional information to be localised later.

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v2.10.0 Build >= 1327

PC or CX (x86, ARM)

TcUtilities.Lib