LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

QMH : how SubVi MHL access control data?

Hi,

 

In the process of learning QMH architecture I'm creating an acquisition and logging program.
I started with the NI template and follow the NI documentation.

 

I now have it working with a 'Data acq Message handling loop' and now adding a 'Logging MHL'.

 

Now I have this question : How should a SubVi Message Handling Loop access Main Vi front panel control info?

 

Let's say 'Create file button' is pressed on Main front panel :
1. Event Handling Loop sends 'Create file' message to UI MHL.
2. UI MHL send 'Create file' message to 'Logging MHL'
3. Now 'Logging MHL' needs to know what are the data in 'File Name' and 'File path' controls.

 

What is the good way to handle that?
Send the controls infos in the message data from the UI MHL?

 

Thank you,

 

0 Kudos
Message 1 of 4
(2,073 Views)

Hi Patrem,

 

In short, any data needed to handle a message should be sent with the message (for data that changes frequently) or in the message handling loop's shift register (e.g. for data that doesn't change much). I would suggest to avoid setting off a chain reaction of messages. 

What is the UI MHL? Is that just a loop that updates front panel indicators? If so, it should not need to be able to tell the Logging loop to save a file (or even know that a logging loop exists).

 

One strategy is to have a message broker loop. So the event to save a file is fired off to the message broker, and it tells the different loops what they need to do. You may also fall into the trap of thinking that every single function needs its own loop. However, if you step back a little you might realize that your real task is to record data, in which case data acquisition and logging could be in a single loop. I'm not saying that's the case here, maybe you really need data to be acquired as quickly as possible and saving a file would take too much time, but I have found if you zoom out a little bit it can save you from sending a lot of messages between tightly coupled loops for little or no gain.

0 Kudos
Message 2 of 4
(2,061 Views)

Hi Gregory,

 

Thank you for your anwser, 

 

I was not clear about that but in fact the 'UI MHL' is acting as the message broker loop, and also updating front panel controls, like enabled/disabled. 

I'm also looking at the 'Continuous Measurement and Logging (NI-DAQmx)' project exemple from NI, and they never send message directly from the Event handling to the 'Acq MHL' or 'Logging MHL' so I did the same. 

 

In my case I really want the acquisition and logging to be seprate. 

But I'm wondering what I will do for live data display, like a chart(s), numeric displays etc. 

In the exemple above they only have one chart in a little loop. 

 

What are your thoughts on this?

 

Thank you, 

0 Kudos
Message 3 of 4
(2,046 Views)

For complex tasks like this, a wonderful tool is Pencil and Paper (or, if you prefer, a Computer and a Word-Processing Program of your choice).

 

Write (in whatever language you feel most accomplished -- I tend to use English) a description of what you want your program to do.  Don't focus on how you will accomplish it, just list the major tasks and how they relate to each other.  Pay attention to "what's important", to "data flow" (for example, if you are taking 5 channels of data at 1 kHz, do you want to save all of the data?  probably "Yes"; do you want to display all of the data?  probably "No", but maybe a few channels at a rate of at most 50 points/second, which suggests some averaging or data decimation).

 

You'll find that you "naturally" divide up your Programs into sub-Tasks (VIs?) that are, in turn, driven by the flow of data (and LabVIEW is, after all, a Data-Flow Language).  Now you can start building the Tasks and sub-Tasks, and start worrying about the "How" you will accomplish the "filling in the details".

 

In the Old Days of Software Development, this process was called "Write the Documentation First".  It is still good advice, rarely followed (and I'm as guilty as the next guy, but I do break out the Word Processor when I "get stuck").

 

Bob Schor

0 Kudos
Message 4 of 4
(1,997 Views)