Create a Message Diagram in LabVIEW Queued Message Handler Template

Updated Aug 3, 2023



  • LabVIEW

This article is part of the Queued Message Handling series. Refer to the Queued Message Handling (QMH) overview documentation for general information on the QMH architecture.

A message diagram is the subdiagram of a Case structure, located in a Message Handling Loop, that handles a particular message. It is similar to a state in a state machine.
The message diagram uses a string selector and executes when the MHL receives a message that matches this label.

This tutorial utilizes the Queued Message Handler LabVIEW template. This an advanced LabVIEW architecture and this tutorial assumes knowledge with basic programming practices. In this tutorial, you will add a message diagram to the template to receive messages and execute code based on messages received.

Creating a Message Diagram

  1. Open the LabVIEW Queued Message Handler template and create a Message Handling Loop (MHL).
  2. In the MHL that represents the task, add a subdiagram to the Case structure.
    • Tip: If you are adding a message diagram to the MHL included in the template, you can automatically include the data and error wires in the new message diagram by duplicating the "---Copy This Frame---" case.
  3. In the case selector label, enter the text of the message that will trigger this message diagram to execute.
    • For example, the following message diagram executes when LabVIEW reads New Message from the message queue
  1. Add code that executes upon receiving this message. As you do this, pay attention to the following guidelines:
  • To ensure that you track all errors, use the Merge Errors function to merge errors coming from all nodes in the subdiagram.
  • To access and modify task data, use the Unbundle By Name and Bundle By Name functions:
  • To access message data, wire the Message Data input tunnel to a Variant to Data function:
  • To send a message to a message queue, use the Enqueue Message VI.
  1. To execute the message diagram, send a message to the MHL. The message you send must match the label of the message diagram that you entered in previous steps.

Defining Data that a Message Handling Loop Needs

In the template, UI Data.ctl is the typdef that defines the cluster of data that the MHL can access:

Modify this typedef according to the needs of your application.
  • For example, if more than one message diagram in an MHL needs to modify the same Boolean control, add a Boolean control to this typdef.
  • If you have more than one MHL, create a typedef for each one. This design prevents errors by ensuring one MHL cannot access the data of another.

Next Steps

Send a Message to a Message Handling Loop in LabVIEW Queued Message Handler Template