Support:Howto:Application Binding
From Guiliani
Contents
Intro
Assumed knowledge
- C++
- General Handling of Visual Studio
- Basic Handling of GSE
Prerequisites
- Any Installed SDK: Desktop or Board based
- Installed CMake Version 3.0 or higher
- IDE matching the used SDK
Guiliani Event Flow
The most common way the Guiliani Event flow is triggered is a user interaction, like a touch on the display. The Guiliani Input device will be triggered or will poll a device driver and generate a GUIEvent which will then processed by the Event handler. That will forward it to affected controls. If the control shall interact with other controls or the application, it will queue a command or interacts with the datapool. Both methods are describe later. The control draws itself after that by calling the Graphics Wrapper which will handle the platform independent graphics library. The customer application can also queue commands or set values to the datapool.
DataPool
The datapool can be understood as a kind of database, which is easy-to use. Controls can observe from or set values to the data pool. The application can set to or get from values using the datapool asynchronously. The Datapool can be used for fast changing values, due to the low execution time and low latency.
Commands
Commands will be executed in the event loop. They’re queued until executed. Guiliani defines several standard commands and can be used with GSE by default:
Command Name | Description |
---|---|
CMD_DIALOG_TRANSITION | Changes to another dialog using an animated transition |
CMD_LOAD_DIALOG | Loads and displays a dialog at once |
CMD_QUIT | Quits the application |
CMD_SETOBJECTSTATES | Manipulates another object, like hides/shows it |
CALLAPPLICATIONAPI | Defines a Text API to do application binding |
When using commands in GSE it can be populated to GSE with a custom extension.
Custom Extensions
The Application normally consists of the Guiliani library, user code and custom extensions code. GSE consists of a GSE library, Guiliani and the same sources of Custom Extensions as the application. For further information on events please read our documentation.
DataPool
Create Controls
You can either create a new project from scratch or just modify an existing project for this Howto. First create these Controls on one or more dialogs with the given IDs:
Control Type | ID |
---|---|
Gauge | OBJ_GAUGE_DPOOL |
Text field | OBJ_TEXTFIELD_DPOOL |
Horizontal slide | OBJ_HOR_SLIDER_DPOOL |
Vertical Slide | OBJ_VER_SLIDER_DPOOL |
The ID names are not important. but it is important that you can identify them later. The Gauge has different standard parameters than the others. To the values correctly, set the following attributes:
Attribute | Value |
---|---|
MinAngle | 45 |
MaxAngle | 225 |
MaxValue | 200 |
Manage Datapool
Using the menu item "Resources->Manage datapool" it is possible to bind the control to a datapool entry. First we add a new Entry. You might change the name and add a description here. Now add the previously created controls as observers and close the dialog.
See the effect
To see the effect choose File->Run Simulation... to simulate the results. When dragging one slide each of the controls at once shows the same value.
CallApplicationAPI
To demonstrate the CallApplicationAPI this Howto will let you add a button which will divide the DataPool value by two. As described above, the CallApplicationAPI is a builtin command which defines a Text API to do application binding. It requires two Strings:
- ApplicationAPI: Here you can define an API name
- Parameter: A paramter to this API
Configure CallApplicationAPI in GSE
First add a new Button two a dialog of you project. You may want to change the text of the button to i.e. Divide by two. This can be done by unfolding StandardText and write your text into the Text Attribute.
To use the CallApplicationAPI unfold GUICommand and change CommandClassID to CMD_CALLAPPLICATIONAPI. You will see that the Attributes ApplicationAPI and Parameter appeared.
Enter attribute ApplicationAPI to "divide" and Parameter to 2.
Update generated sources
Simulation or Export also generate headers that are used in both GSE and your application. If you added IDs that you want to use in your application you need to copy the newly generated files into the application's include directory.
Since Guiliani 2.1 GSE can copy these files automatically when checking Overwrite Headers in StreamRuntime.
In Guiliani 2.0 or earlier it is needed to copy all headers from either the directory temp when you were simualting the application or the directory you exported to. Copy all header files from there to your application/include/GUIConfig.
Using CMake to create your IDE project
Startup CMake. Set Path to your Application/projects/cmake as source code path. The Binary folder hosts the generated project. Enter a folder of your choice and press configure.You will now see a dialog where you can choose your IDE. After selecting the IDE press Finish. In the main window press Generate.
Implement CallApplicationAPI
Open File Path to your Application/src/custom_extension/CallApplicationAPICmd.cpp.
The main method of a Command is the Do method. it is called when a command is processed.