.. SimpleUI documentation master file, created by
sphinx-quickstart on Sat May 16 14:23:51 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Architecture of application solutions
========================================
Application solutions in SimpleUI, referred to as *configurations*, are JSON objects of a specific structure that describe visual forms and application logic. Typically, these are JSON files (with the .ui extension), but broadly speaking, a configuration can be any JSON structure string. It can be transferred to the device as a file (literally opened by the SimpleUI application) or as a string (eg, from a variable in a handler or via a request).
The application interprets the configuration: it creates screens and other interface elements, executes event handlers using various interpreters (local and in external systems).
SimpleUI configurations are very compact, which means deployment and updates rarely take more than 0.5 seconds. The same applies to loading the application solution. Due to this compactness, there is also a special type of configuration called *process files* (.suip), which combine the configuration and data in a single file, similar to an Excel file with macros.
A SimpleUI application solution typically consists of a set of processes with screens containing fields and controls. Elements (and other events on screens or outside them) generate various events. These events are handled by handlers written in Python or other languages, and data from forms or events is passed to handlers through a variable stack. This section covers the composition of a configuration and how data and handlers are structured.
What Objects Are Included in the Configuration?
------------------------------------------------
Processes
~~~~~~~~~~
Configurations consist of **processes**. Usually, a process represents a business process, but this is not mandatory—a process can also serve auxiliary or other roles. A process has a name, which can be used to reference it in code.
A process consists of one or more **screens** and essentially acts as a container for screens. It can be called from the menu (when a process starts, the first screen is always launched). The process itself has no additional logic—all logic is concentrated in the screens.
By default, processes added to the configuration are displayed in the process menu when the configuration is launched, unless the menu is overridden. To hide a process from this menu, you can check the "Do not show in menu" option.
You can also specify that a process should launch at startup (eg, for login).
The "Back" button can be disabled for a process to override its default behavior (when the Back button is pressed, the process screen will not close and return to the main menu; instead, an ON_BACK_PRESSED event will be generated and handled by the developer).
Additionally, a process can be a standalone file-process (check the SUIP option). This is covered in the chapter *Standalone Processes*.
Background Service
~~~~~~~~~~~~~~~~~~~
.. note:: The background service is not the only mechanism for background and asynchronous work. It is just one of several in SimpleUI. See *Background Work*.
When the application starts, a service for background tasks is launched and remains active. It has no visual functionality but can still be a source of events. The background service handles the following by default:
* Reading barcodes via Bluetooth scanners
* Subscribing to intents from external applications
* WebSocket client
* SimpleBus client
* Background speech recognition (outside running processes)
* Other handlers if control is passed to the background service via the `BackgroundCommand` (you can delegate handler execution to the background service; this differs from asynchronous execution—from the system's perspective, processing on the background service remains resident indefinitely. To delegate, send a `BackgroundCommand` with any string parameter (treated as a command), which will trigger the general event `onBackgroundCommand`).
Process Menu and Options Menu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. image:: _static/menu_pic.png
:scale: 55%
:align: center
By default, the process menu is automatically populated with all processes (except those marked with "Do not show in menu"). Processes are launched from this menu, and upon completion, the user returns to it.
The process menu can also be considered an object of the application solution because, beyond simply launching processes, it can be overridden as a standalone object. Essentially, this would function like a screen with its own logic but with somewhat limited functionality. Launching processes (from buttons, list items, etc.) would need to be manually scripted using `StartProcess` commands.
Under *Configuration > Initial Screen*, you can set the menu type to "Process" and select a process (specified in the "Menu Process" field) to display as the menu when the configuration is launched (the screen to which all processes return). The first screen of the process is displayed.
.. note:: The menu does not support all the functionality available on a process screen. Features such as hardware interaction, on-screen keyboard input, etc., do not work. The functionality is roughly equivalent to a dialog window or a list of cards.
Events occurring on the screen (eg, button clicks, menu loading) are not handled in the process defined for the menu (which is only for rendering) but in the *General Handlers* `onInputMenu` and `onStartMenu`.
.. image:: _static/2025_arch_1.png
:scale: 55%
:align: center
The options menu (top right) contains a set of standard items but can be overridden in the *Main Menu* tab:
* If at least one item is selected on the *Main Menu* tab, the menu is considered overridden, and only the selected items will be displayed. This allows customization of the standard items.
* Custom menu items can be added (*Custom menu item*), which must have a numeric ID and optionally display in the toolbar (can be set as an Awesome icon; see the *General Functions* section). When custom items are added, the background service triggers the general event `onBackgroundCommand` with `listener="menu_