Non-linear mapping of device variables
Mapping variables in a non-linear function using the device mapper scripting tool.
This guide explains how to map analog signals received from your device to GpsGate Server variables in a non-linear function.
It is possible to map analog values to GpsGate Variables in a non-linear function. This can be useful when taking a sensor value from a vehicle (e.g. a fuel tank) and mapping it to a GpsGate Variable (e.g. “Fuel level”) when the sensor value is not proportional/linear to the actual fuel volume.
First, map the fuel signal from the device to an analog variable on GpsGate Server (e.g CustomAnalog1) using the Device Mapper.
Now the calibration can be started by analyzing the fuel consumption of the vehicle, take notes of the readings from the fuel indicator on the vehicle and the equivalent values obtained in GpsGate Server. The terminal can be used to check out these values.
Starting with the fuel tank full, a table like this one should be obtain after some trips:
Generating a graph of the function it could be seen that the consumption is non-linear:
At this point a formula with the following syntax needs to be created:
INx and OUTx are numbers, which defines intervals. The IN-interval maps to the OUT-interval.
For the example used before the formula would be:
A value 5.80 from the tracker will map to 70 in the GpsGate Variable. A value 5.20 will map to 60 and any value in between 5.80 and 5.25 would be mapped according to a linear function.
Device mapper scripting
Lastly, a script has to be added using Device Mapper Scripting to get the proper values.
Go to Admin > Device Mapper and select your device’s device mapper you want to modify.
Select the Fuel Level variable (for example) as the output value for the script and then edit the script so it should be like this:
Now the FuelLevel variable is displayed in liters and should be ready to use in Event Rules and Reports.
If the expected values are not being obtained then it might be caused by wrong data or the calibration is not correct. Enabling the CustomAnalog1 variable (which contains the original value) on the trackpoints list in the application and then selecting a vehicle and a track, the values should be displayed like this:
Make sure the readings make sense, if the vehicle is consuming fuel the readings should be lower so CustomAnalog1 should be decreasing until next refill of the fuel tank. If the values show zero-like readings they might be producing wrong information in reports. In that case those readings can be ignored by adding 0:0#null at the beginning of the formula used on Device Mapper Scripting.
In case the signals from the device are right then the values for the variable FuelLevel (which is the output of the script) should be checked following the same steps as for CustomAnalog1. If they are wrong then the calibration is not right and the formula needs to be changed on Device Mapper Scripting. It is important to remember that after changing the script it will be needed to reprocess data to get the new values when using the FU100x reports