Skip to main content

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 binding
    BindingSourceEnum: 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:

    <cgi-studio-root>/cmake/Candera/PlayerConnector
    as source code location. To buildConstructing the project,library right-clickwith PlayerConnectorDllthe connector library binary contained in Visualthe Studiodelivered andpackage click(PlayerConnectorLibrary) Build. WhenInitializing the build finished

    //TODO

    Python Connector Library

    The library consists of a python class CanderaAppConnector. This class haswith the methodsasset forbinary

    gettingOptionally and setting values to databinding items. Also callbacks can be registered that are invoked when aregister data binding valuecallbacks hasContinuously beencalling changed.step to invoke the render loop and internal message delivery Interact with data bindings. Note that internally, changes to the data bindings are reflected on the view when step is called Shutdown library and gracefully exit program

    Documentation

    Constructor

    Creates and instance of this class. Expects and absolute or relative path to the player connector binary as parameter.

    Parameters
    1. BinaryLibraryPath: Absolute or relative path to the player connector binary

    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
    1. AssetPath: Absolute or relative path to the asset binary
    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
    1. BindingSourceItem: Enum that specifies the binding source item. Enum is defined in Generated/BindingSourceEnum.py
    2. Value: The integer value
    Returns Boolean if operation was successful

    SetBoolValue

    Sets a bool value to a predefined databinding source item. 

    Parameters
    1. BindingSourceItem: Enum that specifies the binding source item. Enum is defined in Generated/BindingSourceEnum.py
    2. Value: The bool value
    Returns Boolean if operation was successful

    SetStringValue

    Sets a string to a predefined databinding source item. 

    Parameters
    1. BindingSourceItem: Enum that specifies the binding source item. Enum is defined in Generated/BindingSourceEnum.py
    2. Value: The string
    Returns Boolean if operation was successful

    SetFloatValue

    Sets a float value to a predefined databinding source item. 

    Parameters
    1. BindingSourceItem: Enum that specifies the binding source item. Enum is defined in Generated/BindingSourceEnum.py
    2. Value: The float value
    Returns Boolean if operation was successful

    GetIntValue

    Gets an int value from a predefined databinding source item.

    Parameters
    1. BindingSourceItem: Enum that specifies the binding source item. Enum is defined in Generated/BindingSourceEnum.py
    Returns The integer value

    GetBoolValue

    Gets a bool value from a predefined databinding source item.

    Parameters
    1. BindingSourceItem: Enum that specifies the binding source item. Enum is defined in Generated/BindingSourceEnum.py
    Returns The bool value

    GetStringValue

    Gets a string from a predefined databinding source item.

    Parameters
    1. BindingSourceItem: Enum that specifies the binding source item. Enum is defined in Generated/BindingSourceEnum.py
    Returns The string

    GetFloatValue

    Gets a float value from a predefined databinding source item.

    Parameters
    1. BindingSourceItem: Enum that specifies the binding source item. Enum is defined in Generated/BindingSourceEnum.py
    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
    1. CallbackFn: Callable type with two 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