Skip to main content

Scripted interface

A scripted interface offers the ability to dynamically compute and generate signals using custom scripts. Scripted signals allows the RemotiveBroker to provide signals using VSS or signals intended for Android. It is also possible to provide custom aggregation or custom events as signals. Unlike signals statically described in a signal database, a scripted signal is generated on-the-fly according to the logic defined in a script. For more information see how to configure a scripted interface.

Example Use Case

Imagine you need to monitor the percentage of battery remaining in your vehicle. However, your signal database only includes signals for remaining battery capacity and total battery capacity. By leveraging a scripted interface, you can write a simple Lua script to define a new signal that calculates and returns the battery percentage.

With a simple Lua script, it is possible to define a scripted signal that returns the battery percentage. You can find an example of such a script in our samples repository: Vehicle.Powertrain.TractionBattery.StateOfCharge.Displayed.lua.

Scripted signals database

A scripted signal database provides the ability to configure simple signal name remapping and specify the location of custom signal transformation scripts.

Defining a scripted signal

To get an idea of how to define scripted signals, investigate example code in our samples repository together with RemotiveCloud Demo or with your own RemotiveBroker.

There are three things that need to be put in place:

Simple mappings

The scripted signals database allows you to rename signals from different namespaces, making them more intuitive. For example, if you want to subscribe to a signal named Vehicle.Speed but your signal database names it ID257DIspeed.DI_vehicleSpeed, you can use a scripted interface to remap it with the following database:

{
"simple_mapping": {
"Vehicle.Speed": {
"namespace": "VehicleBus",
"name": "ID257DIspeed.DI_vehicleSpeed"
}
}
}

Take a look at this example or the configuration example for more inspiration.

Changing frequency of signals

A specific kind of computation you can perform with scripted signals is to change the frequency of emitted signals.

Let's say you wish to change the frequency to 10 updates per second. Take a look at an example script for inspiration on how to achieve that.

Video guide on how to iterate to create a custom signal with a Lua script