Moving Average block
The Moving Average block calculates a time-weighted average value for each input field.
Moving Average block
Description
A moving average is calculated by taking the average value of a field over a window. The window moves forward as time progresses. The calculated value is the average of the past N seconds of the signal where N is the window span.
Moving average block
Block Type
Statistical block (Moving window)
Input/Output ports
The input port may only contain fields of type double. There is one output field and 3 quality fields for every input field. The 3 quality fields have the following postfixes appended to the configured output field name (by default the configured output field has the same name as the input field):
-
_DurationBad
-
_DurationGood
-
_Windowspan
If a new field is added to the input port an output field will be created. The output field will have the default window span and quality threshold. The default window span and quality threshold is either the last configured window span and quality threshold or, if no new value was specified, it takes on the default block window span and quality threshold values.
In order for this block to run, the input port must be connected to a valid source that contains only double fields. All configured window spans must also be larger than 0 seconds.
There is also a parameter port of type double. During configuration, the parameter ports' fields can be used to substitute the fixed window span and quality thresholds values. During execution, the first value of the parameter field (that was used to substitute fixed values) is then used as the value for the window span and quality threshold
Input field name = Asset
“Outport1” port’s field name: Asset
“Quality” port’s field names:
-
Asset_DurationBad
-
Asset_DurationGood
-
Asset_Windowspan
Parameter port
The parameter port does not have to be used. The block reads its parameters from the parameter port, if it's configured to do so.
On the first execute, the block will read the value(s) from the parameter field(s) and lock on that value.
Note : The parameter value will not change during execution.
Why are parameter ports great?
f you have 10 Moving window blocks and you want to change the configured quality threshold and window span, you only have to change it in one place.
Functions performed on tags
-
On the values: - The output value is the calculated moving average of the signal over the window.
-
On the timestamp - The output time stamp is always set to the execute time.
-
On the quality - The quality is set based on the quality threshold. The quality level is calculated as the number of seconds that the signal had good quality over the window. This quality level is expressed as a percentage of the window span. If the quality level is less that the quality threshold, the output quality is set to bad, otherwise it is good.
Example
Example of Moving average block
Related topics: