To modify data before communicating it to other entities, a device can use a set of configured conversions. The conversion is applied to the value generated by a data point or an event's argument in a device to derive a new value.
Procedure
- From the Config Tool homepage, open the Plugins task.
- Select the Industrial IoT plugin role from the entity browser.
-
Click the Conversions tab and click Add a
conversion (
).
-
Enter the following details:
- Name
- A unique name to identify this conversion.
- Description
- Description of the conversion
Conversions- Apply existing conversion
- Apply the behavior of an already created conversion. The conversion must already have been saved for it to be available.
- Mathematical operation
- The output of a mathematical operation always has the value type as
Double. Choose one of the following:
- Apply mathematical formula
- It is a user-defined formula that is applied on the
input. The input must be a number, but a string can be
converted to a number sometimes. If the input is not a
number or cannot be converted into a number, the
conversion fails.
- Variable
- The name of the variable that represents the input into the formula. This variable name can only contain letters from the English alphabet or number and must begin by a letter.
- Formula
- The formula to be applied to the input.
- The following mathematical operations are
supported, from the highest to the lowest priority
in the below order:
- Parenthesis ()
- Exponentiation ^
- Multiplication *, Division / and Modulo %
- Addition + and Subtraction -
- sin(a)
- cos(a)
- asin(a)
- acos(a)
- tan(a)
- cot(a)
- atan(a)
- acot(a)
- loge(a)
- log10(a)
- logn(a,b)
- sqrt(a)
NOTE: a and b are any valid mathematical expression and b is the base of the logarithm.
- Round number
- It is a user-defined precision to which numbers are
rounded, and defines how to treat middle-point rounding.
The input can be a number, but a string can be converted
too sometimes. If the input is not a number or cannot be
converted into a number, the conversion fails.
- Floating point precision
- Set the floating point precision to positive to keep the number of digits after the decimal separator. Example: 1211.578 rounded to 2 results is 1211.58.
- Set the floating point precision to negative to round the number of digits before the decimal separator. Example: 1211.578 rounded to -2 results is 1200.
- Midpoint rounding method
- The midpoint rounding method defines how a
number can be rounded up. Select one of the following:
- Round to nearest even
- Use this method to round up numbers either up or down so the last digit is even. Example: 15.875 rounded to 2 digits is 15.88
- Round away from zero
- Use this method to round numbers either up or down so that the absolute value of the result is always the greatest possible. Example: 15.885 rounded to 2 digits is 15.89.
- String manipulation
- The output of a string manipulation is always a string. Choose one
of the following:
- Apply regular expression
- Extracts information from data to parse it into device
and data point abstractions.
- Regular expression
- A group of characters which is captured by the regular expression to be extracted.
- Apply regular expression replace
- Matches a string and changes it to a chosen value.
- Replacement
- Characters that are used to replace the matched regular expression.
- Extract from JSON
- Allows protocols to extract information from
abstractions.
- JSON path
- Expression that specifies a path to an element in a JSON structure.
- Extract from XML
- Allows you to select a certain child node in an XML
string.
- XML path
- The XML path is an expression that specifies a path to an element in an XML structure.
- Format string
- A data point value can be inserted into any string by using {0}.
- Value type conversion
- Convert any value into the defined value type for further
consumption using this option. The conversions can be done on the
below value types:
- Boolean
- Byte
- Double
- Float
- Int16
- Int32
- Int64
- Signed byte
- String
- UInt16
- UInt32
- UInt64
- Click Apply.
- (Optional) To keep the original raw data and also view the converted data, it is recommended to duplicate a data point and view converted data. Data points can be duplicated multiple times, and each duplicate data point can have a specific conversion or no conversion at all.