ADTF Qt5
Loading...
Searching...
No Matches
adtf::javascript::scripting::cScriptFilter Class Reference

#include <filter.h>

Inherits QObject.

Signals

void connected ()
 
void propertiesChanged ()
 
void propertyChanged (const QString &strName, const QVariant &oValue)
 

Public Member Functions

Q_INVOKABLE QObject * createInputPin (const QString &strName, bool bForwardTriggerViaOutputPins=true)
 
Q_INVOKABLE QObject * createOutputPin (const QString &strName, const QJSValue &oStreamType=QJSValue())
 
Q_INVOKABLE QObject * createRunner (const QString &strName, bool bForwardTriggerViaOutputPins=true)
 
Q_INVOKABLE QObject * createInterfaceClient (const QString &strName, const QString &strInterface)
 
Q_INVOKABLE void linkTrigger (const QString &strSource, const QString &strDestination)
 
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.

Member Function Documentation

◆ connected

void adtf::javascript::scripting::cScriptFilter::connected ( )
signal

Emited after all Pins have been connected.

◆ createInputPin()

Q_INVOKABLE QObject * adtf::javascript::scripting::cScriptFilter::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 * adtf::javascript::scripting::cScriptFilter::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 * adtf::javascript::scripting::cScriptFilter::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 * adtf::javascript::scripting::cScriptFilter::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.

◆ enablePropertyValueOverride()

void adtf::javascript::scripting::cScriptFilter::enablePropertyValueOverride ( )

Enables overriding property values from scripts.

◆ getProperty()

Q_INVOKABLE QVariant adtf::javascript::scripting::cScriptFilter::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 adtf::javascript::scripting::cScriptFilter::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.

◆ propertiesChanged

void adtf::javascript::scripting::cScriptFilter::propertiesChanged ( )
signal

Emited if the properties changed.

◆ propertyChanged

void adtf::javascript::scripting::cScriptFilter::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 adtf::javascript::scripting::cScriptFilter::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* adtf::javascript::scripting::cScriptFilter::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
}
}

The documentation for this class was generated from the following file: