Buffering and Filtering Data

Since data from Inputs can arrive at different frequencies (e.g., 10 times per second), it's often useful to buffer that data, observe some aspect of the values as a whole (e.g., the mean value), and/or filter the data.

📘

Note

An Observation's buffer can be thought of as a queue (FIFO buffer). When the buffer is full, the oldest value is removed from the buffer when a new value arrives in the buffer.

The steps below illustrate how to set up an Observation to buffer 100 input values from the light sensor included with the mangOH Red:

  1. Create an Observation for the mangOH Red's /redSensor/light/value sensor resource.
  2. Configure the Observation to send events to the cloud immediately.
  3. Enable Buffer Events.
  4. Enter 100 into Buffer size. This specifies the number of values to hold in the buffer.
  5. Click Save.

Applying Functions to Observation Buffers

When observing buffered data, it can be useful to perform a function on that data and observe the result of that function rather than just the most recent value. Octave provides functions to calculate the minimum, maximum, average, and standard deviation across all of values in the buffer.

The steps below build on the Observation configured above, to set up a function that calculates the average value of the buffer:

  1. Edit the Observation that buffers data.
  2. Locate the Buffer events option and set Buffer function to Mean (see Filtering Emitted Events by Rules below).
  3. Click Save to complete the modification to the Observation.

Filtering Emitted Events by Rules

When observing an Input or Sensor, or the result of a function, you can also apply a filter that defines a threshold that must be satisfied for the Observation to be passed to the destination. Octave includes filters that will pass the value when it's greater than, less than, or has changed by more than some user defined threshold.

Filtering and processing buffer outputs (e.g., mean, max, ...) is only available for Observations on numeric Resources. In this case, a Filter events option will be displayed on the New Observation popup, allowing you to enter the filtering condition. The screenshot below shows this for an analog input Resource (ADC1) that reports a numeric value:

900

The steps below build on the buffer configured in the previous sections, to set up a filter that will only pass the value to the destination when the mean value of the buffer is greater than 5:

  1. Edit the Observation that buffers data.
  2. Enable the Filter events option.
  3. Click on Value is greater than and set the value to 5.
  4. Click Save to complete the modification to the Observation.