Parameter conversion
The parameters received directly from the device can be converted. For this purpose, you should specify the conversion operation in the Parameter field of the sensor properties. The situations in which this operation can be applied are described below.
Bitwise parameter control
Bitwise parameter control allows you to control a specific bit of a parameter. This operation is used if the device shows different data in one parameter: the first bit can correspond to the state of the alarm (on/off), the second to the state of the driver door (open/closed), the third to the state of the headlights, and so on.
The bits are numbered starting from 1 in the monitoring system. To control, for example, the third bit of the parameter param199, type a colon and the bit number after its name:
param199:3
In this way, you can create several sensors on the basis of one parameter to control different bits.
The parameters of the double type are automatically converted into the int type, after which a bit is retrieved.
Bitwise parameter control can be also applied to 64-bit parameter values, but consider the following particularity. When displaying a number with the 64th bit filled, this bit is regarded as a minus sign for the number contained in the remaining 63 bits. Thus, parameter values greater than (2^63 - 1) = 9223372036854775807 are displayed as negative ones.
For more information, see Sensors: Working with иits.
Conversion of text parameters
The values of text parameters can be converted to decimal integers. If a sensor has an expression parameter which contains a text parameter, the text value must be converted to numeric to obtain the correct result. For conversion, use the operator :
(colon) after the parameter name and specify the numeral system from which you want to convert the original value to decimal. Wialon supports conversion from binary, octal, decimal and hexadecimal systems.
Numeral system of original value | Formula for conversion to decimal system | Explanation |
---|---|---|
Binary | text_param:2 |
Use this formula to treat text parameter values as binary and convert them to decimal. For example, if the original value is 100 (in binary), the final value is 4 (in decimal). |
Octal | text_param:8 |
Use this formula to treat text parameter values as octal and convert them to decimal. For example, if the original value is 100 (in octal), the final value is 64 (in decimal). |
Decimal | text_param:10 |
Use this formula to treat text parameter values as decimal and output them as such. For example, if the original value is 100 (in decimal), the final value is 100. |
Hexadecimal | text_param:16 |
Use this formula to treat text parameter values as hexadecimal and convert them to decimal. For example, if the original value is 100 (in hexadecimal), the final value is 256 (in decimal). |
Determination of the day number in a year
You can convert the UNIX time of the message to the day number relative to January 1st. To do this, create a custom sensor with the parameter time:d.
For example, for 11:00:00 (UTC) March 28, 2017, the UNIX time is 1490698800. Therefore,
time = 1490698800
time:d = 87