Python-based Data Binding
WORK IN PROGRESS
The Python Connector Library is a simple library written in python and c++ that provides functionality to start and load scene composer binary assets and interact with a predefined set of data binding items (Variant) through python scripting.
BuildingPython Connector Library Package
OnThe host,main functionality of the projectlibrary is contained in two files, CanderaAppConnector.py [1] and BindingSourceEnum.py [2]. These files contain three classes.
CanderaAppConnector: This is the main class to be used to play assets and interact with them using data bindingBindingSourceEnum: A python enum generated by the build pipeline that contains the enum keys to be used when setting and getting data binding items. The keys underlay the nomenclature "SOURCE<sourceIndex>ITEM<itemIndex>". Source - and item index start at one and go to ten, as we currently have ten predefined binding sources and ten items per source.
Logger: Logger class that my be used to generate logs with compliant format and logging levels
The sources and types listed above are contained in a file system python package that can be built,installed with pip.
pip install path/to/python/library/root/folder
Note: It is suggested to install the library to a virtual environment and not to the global python installation. For an exemplary usage refer to the Blood Pressure Sample documentation and source code.
[1]: cgi_studio_player/src/PlayerConnector/Python/CanderaAppConnector/CanderaAppConnector.py
[2]: cgi_studio_player/src/PlayerConnector/Python/Generated/BindingSourceEnum.py
Workflow
The general workflow using the newpython cmakeconnector environmentlibrary andpackage byconsists settingof:
//TODO
Python Connector Library
The library consists of a python class CanderaAppConnector. This class haswith the methodsasset forbinary
Documentation
- Constructor
- Init
- Step
- SetIntValue
- SetBoolValue
- SetStringValue
- SetFloatValue
- GetIntValue
- GetBoolValue
- GetStringValue
- GetFloatValue
- RegisterCallback
- ShutDown
Constructor
Creates and instance of this class. Expects and absolute or relative path to the player connector binary as parameter.
| Parameters |
|
Init
Initializes the player with the provided asset path. Expects an absolute or relative path to the asset binary as parameter. Must be called before every other method. Returns a bool if the operation was successful.
| Parameters |
|
| Returns | Boolean if operation was successful |
Step
Invokes the internal message processing and render loop execution. Needs to be called continuously. Databinding updates are reflected internally during the invocation of this method. Returns a bool if the operation was successful.
| Parameters | None |
| Returns | Boolean if operation was successful |
SetIntValue
Sets an integer value to a predefined databinding source item.
| Parameters |
|
| Returns | Boolean if operation was successful |
SetBoolValue
Sets a bool value to a predefined databinding source item.
| Parameters |
|
| Returns | Boolean if operation was successful |
SetStringValue
Sets a string to a predefined databinding source item.
| Parameters |
|
| Returns | Boolean if operation was successful |
SetFloatValue
Sets a float value to a predefined databinding source item.
| Parameters |
|
| Returns | Boolean if operation was successful |
GetIntValue
Gets an int value from a predefined databinding source item.
| Parameters |
|
| Returns | The integer value |
GetBoolValue
Gets a bool value from a predefined databinding source item.
| Parameters |
|
| Returns | The bool value |
GetStringValue
Gets a string from a predefined databinding source item.
| Parameters |
|
| Returns | The string |
GetFloatValue
Gets a float value from a predefined databinding source item.
| Parameters |
|
| Returns | The float value |
RegisterCallback
Registers a callback method. Multiple methods can be registered. Passed method must have two parameters. First param is BindingSourceItem and second parameter is value.
| Parameters |
|
| Returns | Boolean if operation was successful |
ShutDown
Shuts down the asset player and frees up allocated resources.
| Parameters | None |
| Returns | Boolean if operation was successful |