Creating a Database GUI
The StepsUI application allows users to manage "process recipes" with their associated "steps" and control some device by running selected "process recipes" that apply parameters in each step based on given timing.
Please note that the "recipe step" could have arbitary parameters depending on the use-case and the playback of steps could use some other feedback value, not just the timing criteria used in this example.
It uses a Sequencer module to control the flow of operations, interfacing with an SQLite database to store and retrieve data. The application also integrates with an OPC UA client for communication with emulated device by ServOPCUA application.
DBControl component is responsible for initializing the database tables and managing database operations. It sets up tables for recipes and steps with associated triggers to limit precision on numerical columns.
Upon application startup, the
DBControl component triggers the creation of the recipes and steps tables in the SQLite database. This is done through the
CreateSteps blocks, which execute the SQL statements to create the required tables and associated triggers.
CreateRes block executes an SQL statement to create a recipes table when needed. The table includes fields for the recipe ID, name, and description. The recipe ID is an auto-incrementing primary key, ensuring each recipe has a unique identifier.
CreateSteps block creates a steps table when needed with fields for step ID, recipe ID, name, and parameters such as speed, temperature, power, and duration. It also includes SQL triggers to round the values of these parameters for precision control.
InsertRecipe and InsertStep
These blocks handle the insertion of new recipes and steps into their respective tables. They use parameterized SQL queries with bound parameters.
SelectStepById, SelectAllSteps and SelectAllRecipes
These blocks are used to retrieve step details by ID and all steps or recipes, respectively. The retrieved data by
SelectStepById is stored in a BasicBlock based data object
StepObject that is used by all step manipulation operations and UI. The retrieved data by
SelectAllRecipes is used to populate the DataNodes based
RecipeList blocks that are linked to UI NodeTable widgets.
This block updates the details of a step when the user makes changes in the UI through
StepObject. It uses a parameterized SQL query to update the step parameters currently represented by the
DeleteStepById and DeleteRecipeById
These blocks remove a step or recipe from their respective tables based on the provided ID. This operation is reflected in the UI, where the corresponding item is removed from the list.
StepTimeControl block is a basic function block that triggers step execution with specific parameters. It transitions between states based on input events and executes step commands received from a message queue.
StepQueue is a message queue that serializes step commands to ensure orderly execution.
OPC UA Client
OPC-UA-Client interfaces with external systems, receiving data to be used in step execution. It maps incoming data to the appropriate output channels.
The applications user interface allows for interactive management of recipes and steps. Users can:
- Add, update, and delete recipes and steps.
- Execute a recipe, which sequentially processes its associated steps.
The integration between the Sequencer, database, and OPC UA client is achieved through message routing. Events are used to trigger transitions in the sequencer, which in turn execute database queries or step commands.
Running the Application
When the application starts, it initializes the database and sets up the necessary tables when needed. The user can then interact with the UI to manage the recipes and steps.
A typical flow of operations in the Steps UI application would be:
- User adds a new recipe through the UI.
- The new recipe is inserted into the database and displayed in the recipe list.
- User adds steps to the recipe, which are also stored in the database.
- User selects a recipe to run, triggering the sequencer to process each step.
- Step parameters are sent to the OPC UA client and the associated ServOPCUA application.
- Upon completion of all steps, the application returns to idle state, ready for the next operation.
This example highlights the seamless interaction between different components in a CDP application, showcasing the power and flexibility of the Sequencer module in process control and automation.