LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Learn QMH with multiple loops

Solved!
Go to solution

Hello,

 

I am trying to learn LabVIEW QMH with multiple loops. There are no good YouTube tutorials. There are tutorials for one event handling loop and one message handling loops, but not with multiple message handling loops. So from some tutorials I made an idea and created an example myself. It's just generate two random numbers, add or subtract or multiply or divide those two numbers. Addition, Subtraction, Multiplication and Division are each a separate message handling loop. The program works fine. But I don't think this is the eloquent QMH solution. Can anyone go through it and update it to the eloquent QMH way. Thank you. 

0 Kudos
Message 1 of 42
(2,493 Views)

Hi Govind,

 

For starters, you don't need to obtain the queue every time you use it. Create once, use it as long as you need it, then release it. It makes it a bit easier to follow the execution. Queues and other such messaging mechanisms generally break the execution flow, because you are sending a message to someplace else for some action to be taken, but at least you can see where all queues are being generated, who all are using them, and where they are released. Please see attached "one way to do it". There are many other (better) ones.

 

While developing real-world applications, we generally start with some template or framework, like DQMH, rather than starting from scratch, to avoid common mistakes. 

 

Many improvements can be made to this code, and there are many ways to do it better, faster, more efficiently, etc. I'm sure a few others will point out why you are doing it this way in the first place and not this other, much better way. But there is no substitute for learning the absolute basics. Queues (in one form or another) are one of the most basic elements of most advanced frameworks. So you're on the right path. Keep going!

0 Kudos
Message 2 of 42
(2,457 Views)

I just looked a look at your code. You don't need four loops. You can simplify your code with only 2 loops. Note: You only use multiple loops if necessary. If your code is gigantic and works well, but mine is small and works as good as yours. Guess who is winning? I'm winning. Simplicity is the key. You don't need 4 loops. 

0 Kudos
Message 3 of 42
(2,455 Views)

@GRCK500, I know I can do that in two loops. But the objective of this is for me to familiarize with QMH with multiple loops. That's why I am using multiple loops, which I have explained in my initial message. 

0 Kudos
Message 4 of 42
(2,449 Views)

Hi GRCK5000, please don't make these forums about "winning" some championship and how your code is better than someone asking a question.

 

For this code, maybe he doesn't even need any loops other than the one with the event structure. But that's not the point. He only asked because he's learning how to use queues and QMH.

 

We all started somewhere. Let's please stay humble.

Message 5 of 42
(2,447 Views)

@Ravi_Beniwal. Thank you for your solution. But could you save it in a previous version. I am using LabVIEW 2016 and hence cannot open your VI. Could you save it in 2016 please. Thank you. 

0 Kudos
Message 6 of 42
(2,444 Views)

Hi Ravi,

I'm just letting him know that simplicity is the key. I'm not trying to degrade him or something. Sorry if it sounded offensive, but that's not the case. I'm not like that. I don't care if I'm a loser. I just want to help. 

0 Kudos
Message 7 of 42
(2,442 Views)

@GRCK5000. Thank you for willingness to help. But help me for what I requested. So for that first read what my doubt is. I clearly explain it in my first message that I need to know how QMH with multiple loops work. So next time when you want to help someone, just read what they are asking and then reply. 

0 Kudos
Message 8 of 42
(2,434 Views)

@govindsankar Haha You are right. Let's focus on what you need help with.  Thanks for advice. It is humbly accepted. 

0 Kudos
Message 9 of 42
(2,430 Views)
Solution
Accepted by topic author govindsankar

@govindsankar, here's the VI saved in 2016. Please let me know if something doesn't work.

Message 10 of 42
(2,426 Views)