What is a Worker?

Workers Fundamental Concepts

Concept definition

What is a Worker and why is the framework called “Workers” ? In a company, there exists a worker hierarchy, with every worker in the company being an ‘asynchronous’ entity, meaning that everyone in the company works independently (usually) on their own tasks that they have been assigned. These tasks are usually assigned from another worker (their manager), who exists above them in the management hierarchy. Their manager will ask them to perform certain tasks, based on the worker’s own unique set of skills, and the worker will report back to their manager when their tasks are complete. In addition, each worker may also be a manager and delegate work to their own assistants or ‘sub-workers’ that exist below them in the company's worker hierarchy. At the top of the company is the CEO, he is the head worker of the company, and his team of top-level managers (who are also in-fact workers) each have a specific task and a team of workers below them.

Similarly to how people are arranged into worker hierarchies in a company, Workers provides you with a way to create a LabVIEW application that follows the same asynchronous hierarchy… multiple processes each possessing a unique skill-set, working on some task alone, communicating to each other through the hierarchy, yet working all together at the same time.

Framework definition

The Worker concept here (also known as an Actor in other frameworks) is represented as a modular QMH in the framework.

In more specific LVOOP terms, a Worker is a QMH and its supporting code that is encapsulated in a class, which inherits from the common ancestor class Worker.lvclass.

As with a regular QMH, you assign your Workers a specific task, e.g. as a user interface or data logger, acquisition module, etc., but because a Worker is modular, you can easily re-use your Workers again in multiple projects, or even use multiple instances of them within the same application.

Good to know

For developers without LVOOP experience, you can simply think of a Worker's class as a really cool library that has its own data-type.

Project Contents

You can create new Workers and add them to your LabVIEW projects using the Create/Add Worker tool. A new Worker created by the tool contains only the following items:

New Worker.lvclass

This is the Worker itself: a class that contains your Worker's VIs and typedefs, i.e. *.vi and *.ctl files. Because every Worker is a LabVIEW class, the Worker takes the extension *.lvclass.

New Worker.ctl

New Worker.ctl is a typedef that is private to the Worker and its VIs and is represented by the Worker's Main Data Wire. Here you can add any data elements that you wish to store between the Worker's Message Handling Loop (MHL) iterations.

Initialization Data.ctl

Initialization Data.ctl is a typedef that is used to pass data into the Worker's MHL when the Worker is initialized.

Response Cases.ctl

Response Cases.ctl is a typedef that holds multiple MHL case names belonging to a Worker's Caller, and is used to register Public Response messages so that asynchronous messages can be sent from the Worker to its Caller. (see Section Response Cases.ctl).

Main.vi

This VI is referred to as a Workers Main VI and contains the Worker's QMH (see The Workers Main VI). This VI is a reentrant shared-clone.

Last updated