Enumeration Filter¶
The foglamp-filter-enumeration filter provides a mechanism to convert between numeric values and symbolic names that those numeric values represent.
The typical use of this filter is when a numeric data value represents a state that needs to be translated to a more meaningful, textual name for the state. It can also be used to convert from textual names to numeric values, which is useful within control pipelines to set some form of state that is represented by a numeric value, but is passed into the pipeline as a text string.
An example might be a device that returns the status of the device as an integer value, but we wish to translate that integer value into more user meaningful strings for pushing to a destination or use when matching rules based on the machine state.
Filter Configuration¶
The configuration options supported by the enumeration filter are detailed in the table below
Asset: The name of the asset to operate on.
Datapoint: The name of the datapoint that contains the state.
Values: A list of text strings for the enumeration and the associated numeric values.
Operation¶
The plugin will examine each reading and when it finds one with an asset name that matches the asset name in the configuration it will looked at the named data point. If the type of that datapoint is numeric, then the plugin will find the string that matches the numeric value and change the datapoint to be a string datapoint with the same name and the string value that matches the numeric value.
If the incoming reading has a string value for the configured asset and datapoint, then the process will work the other way around, the string will be looked up in the configured list and the datapoint replaced with one that has the same name but the matching numeric value.
Match Failures¶
If the incoming datapoint value is numeric and a match can not be found in the configured list of states then a warning will be written to the log and the value set to the string “Undefined X” where X is the numeric value that could not be found.
When converting from a string to a numeric value, a warning will be written to the log and the numeric value set to 0.
Example¶
Imagine we have a PLC that controls an item of spinning equipment, one of the values we read from the PLC is the state of the equipment, it can return a number of discrete states represented by values of an integer. The south plugin we are using will add this state into a data point called state, but we wish to have string representations such that we can write a rule based on the state using the state.
If the machine states represented by the numeric value is as shown in the table below
Value |
Symbolic Name |
Description |
---|---|---|
0 |
Idle |
The device is not rotating |
1 |
Accelerating |
The device is coming up to operating speed |
2 |
Operating |
At operating speed |
3 |
Decelerating |
Slowing down to stop |
4 |
Overspeed |
The device is rotated faster than is optimal |
We could use the enumeration filter to map between the numbers and symbolic names for the states. This would mean that the south plugin would read a numeric value and this filter would transform that to a string value.
The symbolic string values are generally easier to understand for a user doing upstream processing of the state and also have the advantage that if two different machines share these states but use different numeric values to represent them, the upstream process no longer has to be concerned with the differences between these machines.
Likewise, in control pipelines the enumeration filter can be used to allow the upstream processing to be done using generic, symbolic names, and then translated to physical values that need to be written to the machine or PLC controlling the machine.
See Also¶
foglamp-filter-asset - A FogLAMP processing filter that is used to block or allow certain assets to pass onwards in the data stream
foglamp-filter-conditional-labeling - Attach labels the reading data based on a set of expressions matched against the data stream.
foglamp-filter-expression - A FogLAMP processing filter plugin that applies a user define formula to the data as it passes through the filter
foglamp-filter-fft - A FogLAMP processing filter plugin that calculates a Fast Fourier Transform across sensor data
foglamp-filter-metadata - A FogLAMP processing filter plugin that adds metadata to the readings in the data stream
foglamp-filter-normalise - Normalise the timestamps of all readings that pass through the filter. This allows data collected at different rate or with skewed timestamps to be directly compared.
foglamp-filter-omfhint - A filter plugin that allows data to be added to assets that will provide extra information to the OMF north plugin.
foglamp-filter-python35 - A FogLAMP processing filter that allows Python 3 code to be run on each sensor value.
foglamp-filter-rename - A FogLAMP processing filter that is used to modify the name of an asset, datapoint or both.
foglamp-filter-rms - A FogLAMP processing filter plugin that calculates RMS value for sensor data
foglamp-filter-scale-set - A FogLAMP processing filter plugin that applies a set of sale factors to the data
foglamp-filter-statistics - Generic statistics filter for FogLAMP data that supports the generation of mean, mode, median, minimum, maximum, standard deviation and variance.