Macrofilters play an important role in developing bigger programs. They are subprograms providing a means to isolate sequences of filters and re-use them in other places of the program. After creating a macrofilter, you can create its instances. From outside an instance looks like a regular filter, but by double-clicking on it, you navigate inside and can see its internal structure.
When you create a new project, it contains exactly one macrofilter, which is named "Main". This is the top level macrofilter from which the program execution will start. Further macrofilters can be added by extracting them from existing filters or by creating them in the Project Explorer window.
Extracting Macrofilters (The Quick Way)
The most straightforward way of creating a macrofilter is by extracting it from several filters contained in an existing macrofilter. This is done by selecting several filters in the Program Editor and choosing the Extract Step... command from the context menu, as depicted in the picture below:
After completing this operation, a new macrofilter class is created and the previously selected filters are replaced with an instance of this macrofilter. Now, additional inputs and outputs of the new macrofilter can be created by dragging and dropping connections over the new macrofilter instance.
Remark: The "Extract Task (Advanced)..." command creates a new Task macrofilter which should be used only in special cases. Execution of the Task macrofilter is more complex than execution of the Step macrofilter. Usage of the Task macrofilter for reducing macrofilter complexity may be inappropriate. For more details please read section about Task macrofilters.
Defining the Interface
Being inside of a macrofilter other than "Main" you can see two special blocks: the Macrofilter Inputs and the Macrofilter Outputs. The context menus of these blocks allow to add new inputs or outputs. Another method of adding them is by dragging connections and dropping them over these blocks.
Before the new port is created you need to provide at least its name and type:
The context menus of macrofilter input and output blocks also contain a command for adding macrofilter registers, Add Macrofilter Register...:
Creating Macrofilters in the Project Explorer
All macrofilter classes that are contained in the current project can be displayed in the Project Explorer window (by default it is behind the Toolbox on a tab page). Using this control, the user can create or edit macrofilters, but it also acts as a filter catalog from which instances can be created by dragging and dropping the items into the Program Editor.
To create a new macrofilter in the Project Explorer click the Create New Macrofilter... button. Then a new window will appear, when you will be able to select the name and the structure of the new macrofilter.
The StartUp Program
It is sometimes useful to have several programs in a single project. The most common scenarios are:
- When some more complex data, e.g. custom OCR models or calibrated reference images, need to be prepared in a separate program.
- When it is convenient to have multiple versions of a single program customized for different installations.
- When the highest reliability is important and sets of automated tests need to be performed on recorded images.
In Adaptive Vision Studio a program can be any Task macrofilter that does not have any inputs and outputs. The list of all macrofilters fulfilling this criterion can be seen in the StartUp Macrofilter combo box on the Application Toolbar. This control makes it possible to choose the program that will be run. The related macrofilter will be displayed in the Project Explorer with the bold font.
Macrofilters organize big projects, but it is the responsibility of the user to make this organization clean and effective. When a project grows, especially under the pressure of time, it is easy to forget this and create programs that are difficult to understand and maintain. To avoid this, please follow the following guidelines:
- For program clarity it is recommend to create a macrofilter at least when there are more than 16 filters (about 2 screens) in a single view of the Program Editor.
- Macrofilter names do not affect the program execution, but they are very important for effective maintenance. Choose precise and unambiguous English names, follow the verb + noun naming convention whenever possible and avoid abbreviations (this applies also to names of macrofilter ports).
- A single macrofilter should have a single purpose. Avoid doing two unrelated things in a single macrofilter.
- If data visualization is needed for HMI, try to compute results in one macrofilter and then prepare the visualization in another. This will make the data flow more clean.
|Previous: Connecting and Configuring Filters||Next: Creating Models for Template Matching|