FB_ALY_TimespanOperation

The Timespan Operation performs a mathematical operation on two or more different input channels and returns the result of the mathematical operation. Timespans with a resolution of 1 ns are supported as inputs.

Syntax

Definition:

FUNCTION_BLOCK FB_ALY_MathOperation 
VAR_OUTPUT
    ipResultMessage: Tc3_EventLogger.I_TcMessage;
    bError: BOOL;
    bNewResult: BOOL;
    bConfigured: BOOL;
    fbTimespanResult: FB_ALY_Timespan;
END_VAR

FB_ALY_TimespanOperation 1: Outputs

Name

Type

Description

ipResultMessage

I_TcMessage

Contains more detailed information on the current return value. For this special interface pointer, it is ensured internally that it is always valid/assigned.

bError

BOOL

The 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.

fbTimespanResult

FB_ALY_Timespan

Outputs the result of the mathematical operation as a timespan.

FB_ALY_TimespanOperation 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

Initializes the number of input channels.

Reset()

Local

Resets all internal states or the calculations performed so far.

SetChannelValue()

Local

Method for passing values to the algorithm. Resolution of the time values in 1 ns.

Sample

VAR
    fbTimespanOperation : FB_ALY_TimespanOperation(nNumChannels := 2);
    eTimespanOperator : E_ALY_TimespanOperator := E_ALY_TimespanOperator.Addition;
    bConfigure : BOOL := TRUE;
    tInputCh1 : LTIME;
    tInputCh2 : LINT;
END_VAR
// Configure algorithm
IF bConfigure THEN
    bConfigure := FALSE;

    fbTimespanOperation.Configure(eTimespanOperator);
END_IF

// Call algorithm
fbTimespanOperation.SetChannelValue(1, tInputCh1);
fbTimespanOperation.SetChannelValue(2, tInputCh2);
fbTimespanOperation.Call();

Requirements

Development environment

Target platform

Plc libraries to include

TwinCAT v3.1.4024.0

PC or CX (x64, x86)

Tc3_Analytics