value-converter
Description
The value-converter block performs a linear conversion of a numeric value from one range to another. It has one input and one output. The input may be connected to multiple blocks.
The block accepts only numeric values. Non-numeric values and numeric values outside the configured input range are ignored.
The block supports both ascending and descending ranges. This means that configurations such as 0 -> 100 and 100 -> 0 are both valid.
Configuration parameters
| Parameter name | Value |
|---|---|
Name (name) |
Name displayed on the block in the editor. Enter a name that helps identify the block; if left empty, value-converter is displayed. |
Precision (precision) |
Required parameter specifying the number of decimal places at the output. Enter 0, 1, 2, or 3. The same precision also limits the maximum allowed number of digits after the decimal point in the range parameters. Changing this setting updates the step of the range boundary fields to 1, 0.1, 0.01, or 0.001 respectively and rechecks their validity. |
Input range begin (input_range_begin) |
Required parameter specifying the beginning of the input range. The allowed range is from -1500000.000 to 1500000.000. The fractional part must not have greater precision than the value specified by “Precision”. |
Input range end (input_range_end) |
Required parameter specifying the end of the input range. The allowed range is from -1500000.000 to 1500000.000. The fractional part must not have greater precision than the value specified by “Precision”. The value must be different from “Input range begin”. |
Output range begin (output_range_begin) |
Required parameter specifying the beginning of the output range. The allowed range is from -1500000.000 to 1500000.000. The fractional part must not have greater precision than the value specified by “Precision”. |
Output range end (output_range_end) |
Required parameter specifying the end of the output range. The allowed range is from -1500000.000 to 1500000.000. The fractional part must not have greater precision than the value specified by “Precision”. The value must be different from “Output range begin”. |
Input handling
The block reacts only to numeric values that are inside the input range.
Operating rules:
- For the value set in “Input range begin”, the output is exactly the value set in “Output range begin”.
- For the value set in “Input range end”, the output is exactly the value set in “Output range end”.
- For all other values from the input range, a linear rescaling to the output range is performed.
- The result is rounded to the number of decimal places specified by “Precision”.
- Half values are rounded away from zero, so for example
1.235becomes1.24, and-1.235becomes-1.24.
The block does not require the use of inputs labeled using the tag block.
Block outputs
| Output number and name | Output description |
|---|---|
| 1. Rescaled value. | Returns the numeric value calculated based on the current input and output ranges. The result type is automatically set to either an integer or a floating-point number depending on the final value after rounding. |
Block status description
After each successful conversion, the description shown below the block takes the form <left> -> <right>, where:
leftis the input value without a unit,rightis the converted output value, also without a unit.
If the textual representation of either side cannot be obtained, unknown appears in its place.
Errors returned by the block
The block can return the following errors:
| Error code | Error description |
|---|---|
Invalid precision configuration. |
“Precision” was not provided or has a value other than 0, 1, 2, or 3. |
Invalid input_range_begin configuration. |
“Input range begin” is invalid, has a value outside the allowed range, or has too many decimal places relative to “Precision”. |
Invalid input_range_end configuration. |
“Input range end” is invalid, has a value outside the allowed range, or has too many decimal places relative to “Precision”. |
Invalid output_range_begin configuration. |
“Output range begin” is invalid, has a value outside the allowed range, or has too many decimal places relative to “Precision”. |
Invalid output_range_end configuration. |
“Output range end” is invalid, has a value outside the allowed range, or has too many decimal places relative to “Precision”. |
Invalid input range configuration. |
“Input range begin” and “Input range end” have the same value. |
Invalid output range configuration. |
“Output range begin” and “Output range end” have the same value. |
Input disconnected. |
No other block is connected to the block input. |