FB_ALY_TrendLine
The Trend Line function block provides for the forwarding of trends of the input signals for later use in the HMI dashboard. Any channels can be selected for forwarding; the number of channels can be controlled via NumChannels. One value per minute is then stored for each channel. This means that the function block is not suitable for signal forwarding, but rather for displaying trends for signals that change slowly.
Since the function of this function block is irrelevant for the analysis itself, it belongs to the Visualization Only category.
Syntax
Definition:
FUNCTION_BLOCK FB_ALY_StateHistogram_1Ch
VAR_OUTPUT
ipResultMessage: Tc3_EventLogger.I_TcMessage;
bError: BOOL;
bNewResult: BOOL;
bConfigured: BOOL;
fbLastValue: FB_ALY_DateTime;
nCountValues: ULINT;
END_VAR
Outputs
Name | Type | Description |
---|---|---|
ipResultMessage | 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 |
bNewResult | BOOL | When a new result has been calculated, the output is |
bConfigured | BOOL | Displays |
fbLastValue | FB_ALY_DateTime | Timestamp of the last data point added. |
nCountValues | ULINT | Number of valid values. |
Methods
Name | Definition location | Description |
---|---|---|
Call() | Local | Method for calculating the outputs for a specific configuration. |
GetChannelOutputArray() | Local | Getting the result array of a channel without adding new values. |
Reset() | Local | Resets all internal states or the calculations performed so far. |
SetChannelInitial() | Local | Initialization of the initial values of a channel, for example with persistent data. |
SetChannelValue() | Local | Method for passing values to the algorithm. |
SetInital() | Local | Initialization of internal states, for example with persistent data. |
Sample
VAR
fbTrendLine : FB_ALY_TrendLine(nNumChannels := 2);
fbSystemTime : FB_ALY_GetSystemTime;
fInput1 : LREAL;
nInput2 : ULINT;
END_VAR
VAR PERSISTENT
aTrends : ARRAY[1..2] OF ARRAY[1..10080] OF LREAL;
tLastValue : ULINT;
nCountValues : UDINT;
END_VAR
// Get current system time
fbSystemTime.Call();
IF bSetPersistent THEN
bSetPersistent := FALSE;
fbTrendLine.SetChannelInitial(1, ADR(aTrends[1]), SIZEOF(aTrends[1]));
fbTrendLine.SetChannelInitial(2, ADR(aTrends[2]), SIZEOF(aTrends[2]));
fbTrendLine.SetInitial(tLastValue, nCountValues);
END_IF
// Call algorithm
fbTrendLine.SetChannelValue(1, fInput1);
fbTrendLine.SetChannelValue(2, nInput2);
fbTrendLine.Call(fbSystemTime.tSystemTime);
fbTrendLine.GetChannelOutputArray(1, ADR(aTrends[1]), SIZEOF(aTrends[1]));
fbTrendLine.GetChannelOutputArray(2, ADR(aTrends[2]), SIZEOF(aTrends[2]));
tLastValue := fbTrendLine.fbLastValue.nRaw;
nCountValues := fbTrendLine.nCountValues;
Requirements
Development environment | Target platform | Plc libraries to include |
---|---|---|
TwinCAT v3.1.4024.0 | PC or CX (x64, x86) | Tc3_Analytics |