How to combine Custom variables and Device mapper scripting
In this guide we want to demonstrate a real-life use of custom variables and device mapper scripting. Device mapper scripting can solve problems of the sort "If I have one or more input signals from my GPS device and I want to decide what to do in the output using different formulas". On the other side, Custom Fields allow us to assign non-standard properties to our vehicles/units like registration number, fuel tank size, vehicle color, etc. A practical case using both solutions would be for example if we have different fuel tanks in different vehicles (vehicles can have different fuel tank sizes). How can I adapt the fuel level signals to display the correct values (liters for example) for my fleet?. The difference between non-linear mapping is that in this case we will use a vehicle property and a GPS input to generate the correct output.
- Enable the required properties for your applications
- Input the Custom Variables
- Set the Custom Variable to your vehicle/s
- Input your script in your device mapper
- Testing the script
Enable the required properties for your applications
You will require enabling the following properties in your application “Privilegies and Roles”:
Input the Custom Variables
To add a Custom Variables we need to go to the Vehicle Panel -> Manage Custom Fields
We are going to input different Custom Variables in a form of a list and we are going to set our different tank types with their properties
Set the Custom Variable to your vehicle/s
To add the new property to our vehicles we need to edit the User Type to add this new field
The new property is located under “User details”. We should check both check boxes to set this parameter as mandatory for future new units.
Define the value for each vehicle by editing the vehicle.
Input your script in your device mapper
Go to Admin-> Device Mapper and select the correct device for your vehicles. The input signal we want to modify with our script needs to be mapped here.
In the example the input signal will be the Fuel level which is giving the number of Volts that reflect the capacity of the tank for the given vehicle.
Now we have to select “4.Scripts”, click on “+ Add”, select the Output signal (in this case the same as the input because we need to transform the volts to liters depending on the type of tank).
Testing the script
You can finally see the changes in your Tracking Points for a given vehicle when the signal Fuel level is received, and thanks to the Device Mapper scripting you can now have these values converted, for example, to liters (using the Tank type defined in the vehicle properties)
You can always make your tests within the Script Editor or if you want to submit signals to the platform to see the response you can also use SimOne
- Device mapper
- Device mapper scripting
- Non-linear mapping of device variables
- Changing variable names and values
- Adding custom variables
- Use scripting to avoid fuel theft
Discuss this blog post on the forum please