Lua Transform Component
The Lua Transform component provides a Lua scripting engine with several XRT-specific Lua functions.
Available XRT-specific Lua Functions
The following XRT-specific Lua functions are available for use:
- pub_alloc, as described in pub_alloc Lua Function
- sub_alloc, as described in sub_alloc Lua Function
- pub_free, as described in pub_free Lua Function
- sub_free, as described in sub_free Lua Function
- publish, as described in publish Lua Function
pub_alloc
Lua Function
The pub_alloc
Lua function allocates an XRT Bus publisher.
Example pub_alloc
Lua Function:
pub_alloc (Bus, topic)
pub_alloc
Lua Function Parameters
The following table describes the parameters used with the pub_alloc
Lua Function:
Parameter | Description |
---|---|
Bus |
Reference to the Bus component
This is available as the iot_Bus global variable |
topic | String to publish on |
return | Returns a Lua object representing the publisher |
sub_alloc
Lua Function
The sub_alloc
Lua function allocates an XRT Bus subscriber.
Example sub_alloc
Lua Function
sub_alloc (Bus, callback, match)
sub_alloc
Lua Function Parameters
The following table describes the parameters used with the sub_alloc
Lua Function:
Parameter | Description |
---|---|
Bus |
Reference to the Bus component
This is available as the iot_Bus global variable |
callback |
Lua function invoked when data matching the topic is published
The function is passed two parameters, which consist of a Lua table containing the following:
|
match | String to match against event topics |
return | Returns a Lua object representing the subscriber |
pub_free
Lua Function
The pub_free
Lua function frees the publisher object.
Example pub_free
Lua Function
pub_free (pub)
pub_free
Lua Function Parameters
The following table describes the parameters used with the pub_free
Lua Function:
Parameter | Description |
---|---|
pub | Publisher object created using pub_alloc |
sub_free
Lua Function
The sub_free
Lua function frees the subscriber object.
Example sub_free
Lua Function
sub_free (sub)
sub_free
Lua Function Parameters
The following table describes the parameters used with the sub_free
Lua Function:
Parameter | Description |
---|---|
sub | Subscriber object created using sub_alloc |
publish
Lua Function
The publish
Lua function publishes event data using the supplied publisher object.
Example publish
Lua Function
publish (pub, data)
publish
Lua Function Parameters
The following table describes the parameters used with the publish
Lua Function:
Parameter | Description |
---|---|
pub | Publisher object created using pub_alloc |
data | Lua value to publish |
Lua Transform Configuration Variables
The following table describes the configuration variables that can be used with the Lua Transform component:
Parameter | Type | Description | Valid Values | Required Y/N |
---|---|---|---|---|
Bus | String | The name of the Bus component to use | The name of an existing Bus component | Y |
Logger | String | The name of the Logger component to use | The name of an existing Logger component | N |
ScriptFile | String | The name of the Lua file script to load | The path and filename of the Lua script file | Y |
ForceGC | Boolean |
Specifies whether to trigger the Lua garbage collector after a Lua script callback has been invoked
The default value is as follows:
|
Valid values are as follows:
|
N |
Configuration Example
The following example configures a Lua Transform component that uses the fft.lua script located in the config directory:
{
"Bus": "Bus",
"Logger": "logger",
"ScriptFile": "config/fft.lua"
}