Apama Analytics Builder 10.6.6 | Using Apama Analytics Builder for Cumulocity IoT | Wires and Blocks | Values sent on a wire | Value types
 
Value types
The following types are referred to as value types:
*boolean
*string
*float
*any when used to hold a boolean, string or float value
Value types are useful for modeling measurements such as sensor values, which may be read intermittently, or sampled. In between readings, the physical property being measured (such as temperature) will still have some value, as it is a continuous property. For practical reasons, a sensor may not give a continuous stream of output but instead a periodic sampling, or provide new readings only if the value being measured has changed (within whatever measurement resolution the sensor provides). Between sample points, blocks will use the most recent value, as that is the most up to date value being provided. In general, blocks assume that a value stays at whatever the most recent reading of that value is until a new value is received.
For example, consider a pair of temperature sensors. One provides a reading every 10 seconds regardless, while another only provides a new reading if the value has changed by 0.5 degrees. If we connect these to a Difference block, then we may have inputs as shown in the following table, with the corresponding result from the Difference block's Absolute Difference output:
Time
Sensor 1 (reads every 10s)
Sensor 2 (output if changed by 0.5)
Difference block: Absolute Difference output
10:00:00
20.0
10:00:03
22.0
2
10:00:10
20.0
2
10:00:20
20.0
2
10:00:23
22.5
2.5
10:00:28
23.0
3
10:00:30
21.1
1.9
10:00:35
23.5
2.4
10:00:40
22.8
24.0
1.2
Note that two inputs (to different input ports of the block) to the same block with the same timestamp only generate a single output. For each wire within a model (and each input block), there can only be a single value for a given point in time. An input block cannot generate more than one output for the same timestamp. If it receives multiple events at the same time, then it is undefined which of the events is picked.
In general, blocks will not consider there to be any significance to a wire receiving the same boolean, float or string value as before. Most blocks will not change behavior. This is true for any arithmetic blocks, such as the Difference block in the example above: the output is still 2 on the repeated readings from sensor 1. There are some exceptions, such as the Missing Data block when the Ignore Repeated Inputs check box is not selected (false).
If a single block has a numeric value input and pulse signals such as reset, the absence of a new value when a pulse signal occurs means that the value is treated as having the same value still. Thus, when an Average (Mean) block is reset, its output will be equal to the most recently received input (assuming it has received an input since the model has started). In the example below, the Average (Mean) block's duration has not been set, while the output threshold is set to 0.05; this means the block will generate new output even if there is no new input (see Common block inputs and parameters).
Time
Reset signal
Sensor 2
Average (Mean) block output
Notes
10:00:00
Reset
No output. There has been no input value yet.
10:00:03
22.0
22.00
With no history, the output value is the input value.
10:00:23
22.5
All of the values up to this point have been 22, so the average value is still 22 (thus, no new output is generated).
10:00:25.22
22.05
Average of 20 seconds at value 22 and 2.22 seconds at value 22.5.
10:00:28
23.0
22.10
Average of 20 seconds at value 22 and 5 seconds at value 22.5.
10:00:30
Reset
23.00
The input is still 23 (we just have not received a new event), and reset only discards the history. With no history, the output value is the input value.
10:00:35
23.5
10:00:35.56
23.05
Average at various points in time, when the output changes by 0.05.
10:00:36.25
23.10
10:00:37.14
23.15
10:00:38.33
23.20
10:00:40
24.0
23.25
Average of 5 seconds at value 23 (from reset at :30 to :35) and 5 seconds at value 23.5 (from :35 to :40).
The following graph illustrates the inputs to the Average (Mean) block and the output of this block:
Note how the effective input value is unchanged until a new measurement input occurs, and the Average (Mean) block operates on this effective value (the red line in the above graph). When reset, the block outputs the current effective input, which at the second reset at 10:00:30 is 23. Note that when the Output Threshold parameter is set, new outputs can be generated even if no new input occurs, and will asymptotically approach the last input value. Note that this behavior differs from Apama queries or stream queries.
If the Average (Mean) block was configured with a window of 10 seconds, then the window would apply as illustrated below:
Time
Reset signal
Sensor 2
Effective input value
Average (Mean) block output
Values in window history
Notes
10:00:00
Reset
10:00:03
22
22
22.00
First value after start: the window is empty, so the Average (Mean) block uses the input value for the output.
10:00:23
22.5
22.5
22
10:00:23 - 10:00:28
22.5
increasing from 22.00 to 22.20
22, 22.5
Proportion of window that is 22 or 22.5 changes over time, thus the output changes.
10:00:28
23
23
22.25
22, 22.5
10:00:28 - 10:00:30
23
increasing from 22.25 to 22.40
22, 22.5, 23
10:00:30
Reset
23
23.00
Window is reset and thus now empty; the current (effective) input is 23, so the Average (Mean) block uses that for the output.
10:00:35
23.5
23.5
23
10:00:35 - 10:00:40
23.5
increasing from 23.00 to 23.20
23, 23.5
10:00:40
24
24
23.25
23, 23.5
Window is now full (10 seconds since reset).
10:00:40 - 10:00:45
24
increasing from 23.25 to 23.75
23, 23.5, 24
10:00:45
24
23.75
23.5, 24
Value 23 is now finally expired from the window (this was the effective input until 10:00:35, which is 10 seconds ago).
10:00:45 - 10:00:50
24
increasing from 23.75 to 24
23.5, 24
10:00:50
24
24
24
Value 23.5 is now finally expired from the window (this was the effective input until 10:00:40, which is 10 seconds ago). The window now contains 10 seconds worth of measurements, all with value 24.
In the above, note how the current value only has any weighting in the window (that is, contributing to the output value) after the measurement is received. At the point the measurement is received, it has zero weighting compared to the previous history. As before, the sensor's value remains the effective input until it is replaced with a newer value (note that this is different to aggregates with timed-based windows in Apama queries or stream queries). For example, the block has an effective input value of 23.5 from 10:00:35 to 10:00:40, and the value 23.5 is thus only finally expired from the window at 10:00:50, 10 seconds after it ceased to be the current effective input value, rather than 10 seconds after it first entered the window. Finally, note that when the window is empty, the effective input is used as the output instead, as the window is zero-length.