Purpose :
To demonstrate how by overriding framework (Workers Palette) API VIs in either a Worker or Worker base class, a developer can either extend and/or replace the default behavior of the framework VI.
Introduction
The ability to override framework (Workers palette) API VIs is a powerful feature of the framework, and we have the framework's foundational use of LVOOP to thank for it.
Every new Worker is created with only a single VI (Main.vi) and on this VI exists the Worker's QMH. Inheriting each Worker from the common ancestor class of all Workers (Worker.lvclass) allows each Worker to use and share the many common framework VIs used by every Worker's QMH. This way each Worker does not need to have its own copy of VIs that perform the same task, significantly reducing the number of VIs required by each Worker.
While this feature allows every Worker to exist with the same shared and common basic functionality, each Worker (or Worker base class) can also extend the common functionality of these VIs with their own unique implementation of these VIs. And by exploiting the ability to override framework VIs you can do just that: create your own version of a Worker's common QMH VIs that are automatically used in place of the framework VIs.
Method
Let's take an example. Let's say that you wanted to extend the behavior of the framework's Error Handler VI that exists at the end of every Worker's MHL (and EHL). This VI's default behavior is to send any error wired into it to the Workers Debug Server application.
However, in addition to its default behavior, let's say you also want this VI to send any error wired into it to the Worker's Caller for processing by the Caller.
To do this, to extend the default behavior of the framework's Error Handler VI, you can simply override this VI and then add your own custom functionality for a Worker to this VI, while allowing the override VI to also call the framework's Error Handler VI. This way you can have your cake and eat it too! ๐
Step 1 : Override a Framework VI
In a Worker that you want to override a framework VI for, select the Worker in the Project Explorer -> New -> VI for Override -> (the framework VI that you want to override).
The screenshot below shows how you would do this to override the framework's Error Handler VI for a Worker called Worker A.
After this step is complete, you will see a new VI appear in your Worker called Error Handler.vi. Now if you look at the block diagram of the Worker's Main VI, you will notice that the frameworks Error Handler VI has been replaced by the override VI that was created. You can see this because the Error Handler VI has now been replaced by the Worker's own Error Handler.vi as shown in the screenshot below.
Step 2 : Add your custom code into the override VI
Now open the block diagram of the Worker's new Error Handler VI and add code to extend the default behavior of the VI. By default the override VI will also call the framework's Error Handler VI. In addition, you can also call the framework's Pass Error to Owner VI as shown in the screenshot below. This way, when an error occurs in both the Worker's MHL or EHL, the error will not only be sent to the Workers Debug Server, but will also be sent to the Worker's Caller.
Note: The use of the framework's Pass Error to Owner VI is explained in Method 2 of the article here: community/workers...
Conclusion
By following the steps above, you can override any framework VI (those that are dynamic dispatch VIs) and extend the standard functionality of the overridden VI with your own additional code.
Source Code
The example source code for the method above can be found in the Workers Community Additional Example Projects repository here.
You can use https://download-directory.github.io/ to download individual folders directly from the GitHub repository.