From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

EHL and MHL-DAQ and MHL-Log

Hi, I am looking for some feedback on the basic QMH (Queued Message Handler) design pattern I have attached.

My main question:

Have I done anything 'wrong' in my code?

 

0 Kudos
Message 1 of 6
(2,772 Views)

I think it might be worth noting a couple of things:

 

Several of your error wires will never change, but you're merging them every time. In addition, you don't keep previous errors using a shift register, which could cause you to miss temporary errors. That could be by design, but make sure you notice

 

Using a timeout to trigger acquisition from the event handler is a little unusual, because if you extend the event handler to manage more events, it might make your acquisition quite irregular. An alternative is to have the middle loop loop through a sort of state machine and prompt itself to acquire unless it receives a message otherwise, after receiving start. Be careful to avoid unintended loss of control here. 

 

Is there a reason for the named queues? If you don't need to access them by name anywhere, not wiring them reduces the possibility of choosing to open them by name somewhere else and not being able to easily trace where you're using the queue.


GCentral
Message 2 of 6
(2,757 Views)

Thank you for the feedback cbutcher. 

 

I realize now that I neglected to write in my original post the reason why I was posted this VI. The reason being: I am planning on using this as a template for a project I am working on. That is why I am naming the queues. 

Thank you for the note about the "timeout" issue I might encounter. I did not consider that if I added more events that the acquisition could become irregular. 

 

 

0 Kudos
Message 3 of 6
(2,752 Views)

Have you looked at the Continuous Acquisition and Logging template?

 

It's quite similar to what you have but it is well commented and if I recall correctly has a little more detail in the lower loops.

 

It uses 3 queues, I believe, but the purpose is very similar to what you've already written. It was what I first used when starting LabVIEW and although it was a little overwhelming for me at first I'm sure you will understand it much better given you've already grasped the concepts involved.


GCentral
0 Kudos
Message 4 of 6
(2,746 Views)

To be perfectly honest - I have taken a look at it. However, I didn't want to use that template exactly as it was. Thank you for the advice though!

0 Kudos
Message 5 of 6
(2,738 Views)

I thought you might have. I guess it's not for everyone but its probably a good example of the type of code you're writing and when I wrote my project I more or less copied the template so that I could understand its workings. I only suggested it here because I think that the acquisition loop includes a VI (Acquisition Message Loop.vi) handling state transitions in a way that might be helpful. It receives messages to Start, Stop, Acquire, Initialize and Exit, among others, and has two states inside the loop - Acquiring and Idle. The combination of these two inputs determine its behaviour in each loop iteration.

 

Good luck with your code!

 


GCentral
Message 6 of 6
(2,713 Views)