LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Struggling With References in Queued Message Handler

Solved!
Go to solution

I am trying to connect my UI data cluster to my references from the front panel. They are both the same types but LabVIEW keeps telling me they're not and I keep getting broken wires and the error is saying they are different types. I have followed the examples from the LabVIEW training books and still no luck. 

I included a screen shot. Also I am using LabVIEW 2014 Home Edition

0 Kudos
Message 1 of 7
(2,996 Views)

Just because you named the parts of the cluster as references, doesn't make it so.  You are trying to wire references to typed values.  e.g. You can't tie a Boolean reference to a Boolean data type; it has to be a Boolean Refnum data type.

 

Not quite sure what you're trying to do, but I'm fairly positive you're going about it the wrong way.

0 Kudos
Message 2 of 7
(2,969 Views)

I recommend you read NI's White Paper on the QMH here.  The whole idea (in my humble opinion) of the QMH is that you can have a Message, say "New File Path", and associated (variant) Data, namely the New File Path, itself!  There are no references -- with an apology to Marshall McLuhan, The Message is the Message.

 

Bob Schor

0 Kudos
Message 3 of 7
(2,930 Views)
Solution
Accepted by topic author russ_comer

Right-click your references and select "create constant".  Then use the refnum constant you've created in your cluster.

Message 4 of 7
(2,902 Views)

I did try that, I even tried changing the references that I dropped in the cluster to indicators as well and still no luck. I have just taken core 3 so I understand the fundamentals of how the QMH works. I'm stuck on the technical details of this one. It's been 4 years since I've taken Core 1 and 2. 

 

I started from the template of the QMH and wanted to replace the <replace me> functions. So I did and I have gotten error after error. I went back to the Core 3 material and they give the new data cluster to input so we never went over how to actually create the data cluster references. I'm so confused by this. The purpose of these references is to tie the data cluster into the front panel correct? 

0 Kudos
Message 5 of 7
(2,881 Views)

So I got it, I was creating a constant on the bundle and not the actual reference. Thank you I think I got it straight. Now I have to go through and clear the long list of error that i have caused on my own. 

0 Kudos
Message 6 of 7
(2,872 Views)

Arrrghhh!  Now I understand your problem/confusion -- you have been "betrayed" by (what seems to me) a very poor, confusing Template!  I have to confess that I had not actually looked at the Template, itself, but relied on readings and talks I'd heard about the QMH, including some interesting LVOOP talks on QMH versus the "Object" way of accomplishing similar tasks.

 

Without referring to the Template code (I'm still reeling with confusion), I'm going to try to "talk you through" what it seems to be doing.  First, let's simplify and do away with an Array of Message Queues, and have a single Message Queue into which you can put a single "Message".  Look at how a Message is defined (by the Message Cluster TypeDef) -- a Message (string) and Data (variant).  The QMH takes a (single) Queue and removes the (oldest) element on the Queue, pausing if there's nothing there.  So let's say you want to have a Display that originally says "Initial Display", a button that says "Button 1 Pushed", and a button that says "Button 2 Pushed".  Let's define the following Messages and what we want to happen:

  • Initialize -- make Display say "Initial Display"
  • Button 1 Pushed -- make Display say "Button 1 Pushed"
  • Button 2 Pushed -- make Display say "Button 2 Pushed"
  • Exit -- make Display say "Exiting", and stop the program.

This is dirt-simple.  The QMH has 4 "Cases" named for the four Messages, and does the obvious thing.  Note that in this (very simple) example, we know what we want to display, so don't need the Data part of the message, but can simply write the desired String to the Display indicator (put a Shift Register with data to Display, and wire it to Display when the Shift Register wire exits from the Case Statement, still within the While Loop).  It is driven by a simple Event Loop that looks for Value Changed events for the three Controls, and puts the appropriate Message on the Queue.

 

Before entering the QMH loop, you create the Queue and manually enqueue the Initialize Message.  And you are done!

 

But let's get cute -- let's add a Knob control, and another Boolean that says "Read Knob".  Let's add another Message, "Knob Value", that displays "Knob set to <N>", where you put the Knob value in place of <N>.  First, what's the appropriate Event?  Well, another Value Changed on "Read Knob" (not on the Knob, itself, mind you).  It reads the Knob and puts its value in the Data part of the Message (to be passed to the QMH).

 

Now the QMH gets the Read Knob Message.  It "knows" that this Message contains Data, so it takes the Data, converts the Variant to an Integer (I'm assuming you are using an Integer Knob), and (using Format into String) creates the message "Knob set to %d" (where %d is the numeric value of the Knob).  Done!

 

And so conceptually simple.  Once you understand the Simple Concept, you can Fancy it up and add Arrays of Queues, libraries to do the work for you, etc., but first understand the Concept

 

Please, start from scratch with a new VI.  Create a Message Cluster TypeDef with Message and Data as described above.  Create the simple Demo I described above.  Try it -- it should work, and you'll go "Wow, that was easy ...".

 

Bob Schor

Message 7 of 7
(2,870 Views)