Fleetrun
Hecterra
NimBus
Other apps
Wialon for Android/iOS
Logistics
Wialon Local
Wialon Hosting
WiaTag
Configurator
LeaseControl
en
Contents
Parameter Conversion
  • sensors
  • sensor_parameters

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 Bits.

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

Conversion of driver, trailer and passenger sensor parameters

Conversion of text and numerical parameter values is available for the sensor types Driver assignment, Trailer assignment and Passenger sensor. To convert a parameter value, you must specify an expression in the Parameter field of the sensor properties, which can include functions and mathematical operations.

Functions can only apply to text values, while mathematical operations apply to numeric ones.

Converted values are used as follows:

Functions

The functions apply only to text values of the parameters. Their description is in the table below, where param is the name of the parameter in which the device sends the text value.

FunctionDescriptionExample of the value beforeExample of the value after
ltrim(param) or ltrim(param,'0')

Trims all zeros to the left. By default, '0' is trimmed, but it can be applied to other characters as well. The character is specified in single quotes.

0000AA
rtrim(param) or rtrim(param,'0')

Trims all zeros to the right. By default, '0' is trimmed, but it can be applied to other characters as well. The character is specified in single quotes.

A0000A
lower(param)Converts characters to lowercase.Aa
upper(param)Converts characters to uppercase.aA
reverse(param)Reverses the characters order.A12344321A
reverseb(param)

Reverses the order of characters by two. If a string has an odd number of characters, it is first appended with a leading zero to the left, and then the string is reversed.

C1B2A2A1B0C
lfill(param,5,'0')

Adds the specified character (third function parameter) to the left until the string contains the required number of characters (second function parameter).

The added character is specified in single quotes.

A0000A

rfill(param,5,'0')

Adds the specified character (third function parameter) to the right until the string contains the required number of characters (second function parameter).

The added character is specified in single quotes.

AA0000
sequence(param,2,3,5,4,1,0,1414)

Changes the sequence of the characters. The characters are arranged in the order specified after the parameter name. If a non-existent index is specified, 0 is put in place of that character.

The indices are counted from left to right, starting from 0.

0C1B2A1BA2C00
hex(param)Converts from the decimal system to the hexadecimal one.10a
dec(param)Converts from the hexadecimal system to the decimal one.00A10
hextoascii(param)Converts from hexadecimal to ASCII.3A29:)
concat(param,substr(param,1,4),'00')

Sticks strings together. More than two strings can stick together. 

In the example, it is used together with the substr function (see below), that is a part (substring) extracted from the parameter string is joined to the same parameter string. Two '00' characters are also appended.

The characters are specified in single quotes.

0C1B2AD35E0C1B2AD35EC1B200
substr(param,1,4)

Extracts specified characters from the parameter value. The extracted characters make a substring.

There are 3 mandatory parameters for the function:

  1. source string,
  2. index from which the searched substring starts, 

  3. length of the searched substring, that is. how many characters should be extracted.

The indices are counted from left to right, starting from 0.

The extracted substring can be combined with another string using the concat function as in the example above.

0C1B2AD35EC1B2
len(param)

Returns a number that specifies the number of characters in the string. You can perform mathematical operations on the result because it is a number.

For example, the expression substr(param,len(param)-4,4) uses the expression len(param)-4 as an index. It means that the substring will be counted from the fourth character from the end.

0C1B2AD35E10

Mathematical operations

Mathematical operations of addition (+) and subtraction (-) are possible only with numeric values. With text values they are possible only after their conversion into numeric values (see the example for the len function above).

If one of the elements in an expression with a mathematical operation is not numeric, the result will show 0.

If you find a mistake in the text, please select it and press Ctrl+Enter.
Thank you for your feedback!
Report a mistake
Text with the mistake Comment
Maximum 500 characters