ADTF  3.18.2
cScriptFilter

Provides the global 'filter' object within scripts. More...

Inheritance diagram for cScriptFilter:
[legend]

Signals

void connected ()
 Emited after all Pins have been connected.
 
void propertiesChanged ()
 
void propertyChanged (const QString &strName, const QVariant &oValue)
 Emited for each property change. More...
 

Public Member Functions

Q_INVOKABLE QObject * createInputPin (const QString &strName, bool bForwardTriggerViaOutputPins=true)
 Creates a new Input Pin. More...
 
Q_INVOKABLE QObject * createOutputPin (const QString &strName, const QJSValue &oStreamType=QJSValue())
 Creates a new Output Pin. More...
 
Q_INVOKABLE QObject * createRunner (const QString &strName, bool bForwardTriggerViaOutputPins=true)
 Creates a new Runner. More...
 
Q_INVOKABLE QObject * createInterfaceClient (const QString &strName, const QString &strInterface)
 Create a new interface client. More...
 
Q_INVOKABLE void linkTrigger (const QString &strSource, const QString &strDestination)
 Creates an internal Trigger Pipe between two Runners. More...
 
Q_INVOKABLE QVariant getProperty (const QString &strName)
 
Q_INVOKABLE void setProperty (const QString &strName, const QVariant &oValue, const QString &strType="")
 
void enablePropertyValueOverride ()
 

Properties

QQmlPropertyMap * properties
 

Detailed Description

Provides the global 'filter' object within scripts.

Definition at line 48 of file javascriptfiltersdk/src/filter.h.

Member Function Documentation

◆ createInputPin()

Q_INVOKABLE QObject* createInputPin ( const QString &  strName,
bool  bForwardTriggerViaOutputPins = true 
)

Creates a new Input Pin.

Example Usage

var input = filter.createInputPin("input")
input.sample.connect(function(sample)
{
console.info("sample with timestamp " + sample.timestamp)
})
Parameters
[in]strNameThe name of the Pin.
[in]bForwardTriggerViaOutputPinsIf true, triggers will be forwarded via all output pins after all callbacks have been called.
Returns
an instance of cScriptReader.

◆ createInterfaceClient()

Q_INVOKABLE QObject* createInterfaceClient ( const QString &  strName,
const QString &  strInterface 
)

Create a new interface client.

Example Usage

var recorder = filter.createInterfaceClient("recorder_control", "recorder")
var input = filter.createInputPin("input")
input.sample.connect(function(sample)
{
if (sample.data.value > 10)
{
recorder.start()
}
})
filter.connected.connect(function()
{
if (!recorder.connected)
{
throw "This script requires a connected recorder"
}
})
Parameters
[in]strNameThe name of the Interface Binding Pin.
[in]strInterfaceThe type of the interface. Currently supported are:
Returns
an instance of an interface client.

◆ createOutputPin()

Q_INVOKABLE QObject* createOutputPin ( const QString &  strName,
const QJSValue &  oStreamType = QJSValue() 
)

Creates a new Output Pin.

Example Usage

var outputType = types.createDefinition("my_data")
.add("value1", "tUInt32")
.add("value2", "tFloat32")
var output = filter.createOutputPin("output", outputType)
var runner = filter.createRunner("generate_data")
var counter = 0
runner.trigger.connect(function(timestamp)
{
output.write(timestamp, {value1: counter, value2: counter})
++counter
})
Parameters
[in]strNameThe name of the Pin.
[in]oStreamTypeThe stream type. See adtf::javascript::scripting::cScriptTypes.
Returns
an instance of cScriptWriter.

◆ createRunner()

Q_INVOKABLE QObject* createRunner ( const QString &  strName,
bool  bForwardTriggerViaOutputPins = true 
)

Creates a new Runner.

Example Usage

var runner = filter.createRunner("print_trigger_timestamp")
runner.trigger.connect(function(timestamp)
{
console.info("trigger at " + timestamp)
})
Parameters
[in]strNameThe name of the Runner.
[in]bForwardTriggerViaOutputPinsIf true, triggers will be forwarded via all output pins after all callbacks have been called.
Returns
an instance of cScriptRunner.

◆ getProperty()

Q_INVOKABLE QVariant getProperty ( const QString &  strName)

Example Usage

var myValue = filter.getProperty("my_property")
console.info("myValue = " + myValue)
Parameters
[in]strNameThe name of the property.
Returns
The value of a Property. Null if no such Property exists.

◆ linkTrigger()

Q_INVOKABLE void linkTrigger ( const QString &  strSource,
const QString &  strDestination 
)

Creates an internal Trigger Pipe between two Runners.

Parameters
[in]strSourceThe name of the first Runner.
[in]strDestinationThe name of the second Runner.

◆ propertyChanged

void propertyChanged ( const QString &  strName,
const QVariant &  oValue 
)
signal

Emited for each property change.

Example Usage

filter.setProperty("my_property", "default");
// Properties will be set during the filter initialisation
filter.propertyChanged.connect(function(name, value)
{
console.log("Changed: " + name + " " + value);
})

◆ setProperty()

Q_INVOKABLE void setProperty ( const QString &  strName,
const QVariant &  oValue,
const QString &  strType = "" 
)

Example Usage

filter.setProperty("my_property", "default");
// Properties will be set during the filter initialisation
filter.propertyChanged.connect(function(name, value)
{
console.log("Changed: " + name + " " + value);
})
Parameters
[in]strNameThe name of the property.
[in]oValueThe value of the property.
[in]strTypeOf the property.

Property Documentation

◆ properties

QQmlPropertyMap* properties
read

Example Usage

import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.0
Item
{
anchors.fill: parent
Component.onCompleted:
{
filter.setProperty("my_property", "default");
// this creates a QML property binding, so it will be updated
// each time the property value changes.
valueLabel.text = Qt.binding(function() { return "Value: " + filter.properties.my_property })
}
Label
{
id: valueLabel
anchors.fill: parent
}
}

Definition at line 1 of file javascriptfiltersdk/src/filter.h.