You are here: Start » HMI » Handling HMI Events

Handling HMI Events

Introduction

The HMI of Adaptive Vision Studio is based on the program loop – it sends values from the controls to the program when an iteration starts and sends computed values to the controls when the iteration finishes. This communication model is very easy to use in typical machine vision applications, which are based on a fast image acquisition loop and where the HMI is mainly used for setting parameters and observing inspection results. In many applications, however, it is not only required to use parameters set by the end user, but also to handle events such as button clicks.

In the loop-based model of Adaptive Vision Studio events are detected by the HMI subsystem independently of the program execution process. Then, when the execution process enters any macrofilter with an incoming HMI connection related to that event, the value on this connection changes for exactly one iteration. If this particular HMI output is connected in multiple macrofilters, the first read also resets the HMI control's value.

Events are typically used to realize the following types of requirements:

  1. Actions – for example, when the user wants to save the current input image to a file after clicking a button.
  2. State Transitions – when the user expects the application to switch to another mode of operation after clicking a button.

Here is a list of standard HMI controls that have event outputs:

  • ImpulseButton – with one boolean event of clicking.
  • VideoBox, ImageBox – with events related to mouse clicks etc.
  • KeyboardListener – with events related to key presses.
  • TrackBar – with an event signaling when the value has been changed.

Actions

When a button (ImpulseButton) is clicked, it will change its outValue output from False to True for exactly one iteration. This output is typically used in one of the following ways:

  1. As the forking input of a variant macrofilter, where the True variant contains filters that will be executed when the event occurs.
  2. As the input of a formula block with a conditional operator (?:) used within the formula to compute some value in a response to the event.
  3. As the input of a MakeConditional filter, which makes some part of the program executed conditionally – only when the button is clicked.

For an example with MakeConditional, please see "Recording Single Image" in the Recording Images article.

State Transitions

Handling events that switch the application to another mode of operation is described in the Programming Finite State Machines article.

Handling Events in Low Frame-Rate Applications

The HMI model of Adaptive Vision Studio assumes that the program runs in a fast, continuous loop, with cycles not longer than 100 ms (10 frames per second). If the main loop of the application is slower, e.g. when the camera is triggered and is not receiving any trigger signal for some time, then the HMI will also be slow or halted.

To solve the problem we need to handle the image processing and the HMI events at different frequencies. The recommended approach is to use an image acquisition filter with the timeout setting (100 ms) and process the images conditionally only in some iterations, while handling the HMI events continuously, at least 10 times per second. This can be done with GigEVision_GrabImage_WithTimeout, GenICam_GrabImage_WithTimeout or with any other image acquisition filter of this kind.

Below is a sample program structure with two separate step macrofilters handling the image processing part and the hmi event processing part at different frequencies. Note the conditional mode of execution of the "InspectImage" macrofilter.

An example program structure with a fast cycle of HMI processing and a slow cycle of image analysis.

Handling Events in Multiple Tasks

When there are multiple Task macrofilters that exchange data with the HMI, then communication structure may easily become difficult to understand. Please follow the recommendations described in the section HMI Interactions with the Program to avoid the most common problems.

Previous: Standard HMI Controls Next: Saving State of HMI Controls