Some devices allow transferring user data. In Wialon, this data is registered as unsigned integers by default, regardless of the form in which it is sent from the device. In order for the reports and messages in Wialon to display "clear values", that is, the values as they are sent from the device, you can use the bitwise parameter control method. This guide describes three examples of using this method to work with source data.
For more information, see the expert article Sensors: Working with Bits.
Example 1
Consider the case when a unit sends data, for example, in the user_d1 parameter as two double-byte unsigned integers. In Wialon, this data is registered as user_d1=2646793773.
Convert the received number in Wialon to the binary system: 2646793773 → 10011101110000101101111000101101.
In Wialon, bits are calculated from one.
- Divide the resulting number by two (according to the double-byte number count): 1101111000101101 and 1001110111000010.
Create a custom sensor numeral_1 in the unit properties in Wialon. In the Parameter field, specify the following formula:
user_d1:1*const1+ user_d1:2*const2+ user_d1:3*const4+ user_d1:4*const8+ user_d1:5*const16+ user_d1:6*const32+ user_d1:7*const64+ user_d1:8*const128+ user_d1:9*const256+ user_d1:10*const512+ user_d1:11*const1024+ user_d1:12*const2048+ user_d1:13*const4096+ user_d1:14*const8192+ user_d1:15*const16384+ user_d1:16*const32768
Create a custom sensor numeral_2. In the Parameter field, specify the following formula:
user_d1:17*const1+ user_d1:18*const2+ user_d1:19*const4+ user_d1:20*const8+ user_d1:21*const16+ user_d1:22*const32+ user_d1:23*const64+ user_d1:24*const128+ user_d1:25*const256+ user_d1:26*const512+ user_d1:27*const1024+ user_d1:28*const2048+ user_d1:29*const4096+ user_d1:30*const8192+ user_d1:31*const16384+ user_d1:32*const32768
As a result, the reports and messages in Wialon display the values of two double-byte sensors (numeral_1=56877 and numeral_2=40386) instead of user_d1=2646793773.
Example 2
In this example, consider the case when a unit sends data as a number with floating point (float). In Wialon, the data is registered as user_d3=1017282565.
- Convert the received number in Wialon to the binary system: 1017282565 → 111100101000101000000000000101.
Create a custom sensor float in the unit properties in Wialon. In the Parameter field, specify the following formula:
const-1^user_d3:32*const2^((user_d3:24*const1+user_d3:25*const2+user_d3:26*const4+user_d3:27*const8+user_d3:28*const16+user_d3:29*const32+user_d3:30*const64+user_d3:31*const128)-127)*(const1+(user_d3:1*const1+user_d3:2*const2+user_d3:3*const4+user_d3:4*const8+user_d3:5*const16+user_d3:6*const32+user_d3:7*const64+user_d3:8*const128+user_d3:9*const256+user_d3:10*const512+user_d3:11*const1024+user_d3:12*const2048+user_d3:13*const4096+user_d3:14*const8192+user_d3:15*const16384+user_d3:16*const32768+user_d3:17*const65536+user_d3:18*const131072+user_d3:19*const262144+user_d3:20*const524288+user_d3:21*const1048576+user_d3:22*const2097152+user_d3:23*const4194304)/const8388608)
The formula for the sensor parameter is created on the basis of the formula for converting to the 32-bit IEEE 754 format: F=(-1)S2(E-127)(1+M/223).
As a result, Wialon displays the values of the float sensor instead of user_d3=1017282565.
Example 3
Consider the case of the Teltonika FMT100 device when the io_258 parameter registers the values of the accelerometer on three axes when exceeding the values specified in the device. The data of this parameter is useful when working with the Eco Driving application. In Wialon, the data is registered as io_258=932034904003. The values should be converted into g.
The image below shows the parameter structure.
The values on the axes are signed. In Eco Driving, only the values on the X and Y axes are used. On the X-axis, depending on the sign, the acceleration and braking are determined. On the Y-axis, the transverse acceleration is determined which will be used as an absolute value (module) because the sign (left/right) is not taken into account in Eco Driving.
Create a custom sensor Accel_MAX in the unit properties in Wialon. In the Parameter field, specify the following formula :
(((io_258:48*const32768)-(io_258:33*const1+io_258:34*const2+io_258:35*const4+io_258:36*const8+io_258:37*const16+io_258:38*const32+io_258:39*const64+io_258:40*const128+io_258:41*const256+io_258:42*const512+io_258:43*const1024+io_258:44*const2048+io_258:45*const4096+io_258:46*const8192+io_258:47*const16384))*io_258:48)/const1000
Create a custom sensor Brk_MAX. In the Parameter field, specify the following formula :
((-(io_258:33*const1+io_258:34*const2+io_258:35*const4+io_258:36*const8+io_258:37*const16+io_258:38*const32+io_258:39*const64+io_258:40*const128+io_258:41*const256+io_258:42*const512+io_258:43*const1024+io_258:44*const2048+io_258:45*const4096+io_258:46*const8192+io_258:47*const16384))*(io_258:48-const1))/const1000
Create a custom sensor Crn_MAX. In the Parameter field, specify the following formula:
(-(io_258:17*const1+io_258:18*const2+io_258:19*const4+io_258:20*const8+io_258:21*const16+io_258:22*const32+io_258:23*const64+io_258:24*const128+io_258:25*const256+io_258:26*const512+io_258:27*const1024+io_258:28*const2048+io_258:29*const4096+io_258:30*const8192+io_258:31*const16384))*(io_258:32-const1))/const1000+(((io_258:32*const32768)-(io_258:17*const1+io_258:18*const2+io_258:19*const4+io_258:20*const8+io_258:21*const16+io_258:22*const32+io_258:23*const64+io_258:24*const128+io_258:25*const256+io_258:26*const512+io_258:27*const1024+io_258:28*const2048+io_258:29*const4096+io_258:30*const8192+io_258:31*const16384))*io_258:32)/const1000
Two bytes are provided for the Y-axis. The bit numbers in Wialon are from 17 to 32. Since the module (absolute) values are taken into account, the formula is a little longer than the previous ones.
The given examples show that the application area of the bitwise control is not limited to the control of a specific bit. This is a comprehensive tool which allows creating custom sensors in Wialon. You can formulate the logic and calculation of such sensors on your own to fulfil the most challenging tasks.