FB_ALY_BatchNShift_1Ch

The BatchNShift 1Ch buffers the values of the input signal according to the buffer size and the sample mode. The number of output channels in which the buffered input values are stored corresponds to the buffer size. With the help of the sample mode it is possible to distinguish between two different operating modes of the algorithm. If the sample mode Flow is selected, a ring buffer or shift register is realized (Shift). The values are written to the buffer one after the other and shifted by one position of the buffer in each cycle. If the buffer is full, the last value falls out. In the Wait mode, the buffer is instead completely emptied and filled with new values whenever it is completely full, so that the values are processed in the form of batches (batch). At the beginning of an analysis, the system also waits until the buffer is completely filled before writing the values to the buffer. Therefore, the function block supplies valid values only from the cycle (BufferSize + 1).

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_BatchNShift_1Ch
VAR_OUTPUT 
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
END_VAR

FB_ALY_BatchNShift_1Ch 1: Outputs

Name

Type

Description

ipResultMessage

I_TcMessage

Contains more detailed information on the current return value. This special interface pointer is internally secured so that it is always valid/assigned.

bError

BOOL

This output is TRUE if an error occurs.

bNewResult

BOOL

When a new result has been calculated, the output is TRUE.

bConfigured

BOOL

Displays TRUE when the function block is successfully configured.

FB_ALY_BatchNShift_1Ch 2: Methods

Name

Definition location

Description

Call()

Local

Method for calculating the outputs for a specific configuration.

Configure()

Local

General configuration of the algorithm with its parameterized conditions.

FB_init()

Local

Initialize the number of output channels (size of the internal buffer).

GetChannelOutputValue()

Local

Method for getting individual output values from the output array.

GetOutputArray()

Local

Method for getting the entire output array.

Reset()

Local

Resets all internal states or the calculations performed so far.

SetChannelValue()

Local

Method for passing values to the algorithm.

Sample

VAR
    fbBatchNShift : FB_ALY_BatchNShift_1Ch(nBufferSize := 100);
    eSampleMode : E_ALY_SampleMode := E_ALY_SampleMode.Flow;
    bConfigure : BOOL := TRUE;
    nInput : INT;
    aBuffer : ARRAY[1..100] OF LREAL;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;

    fbBatchNShift.Configure(eSampleMode);
END_IF

// Call algorithm
fbBatchNShift.SetChannelValue(nInput);
fbBatchNShift.Call();
fbBatchNShift.GetOutputArray(ADR(aBuffer), SIZEOF(aBuffer));

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics