05-02-2023 08:40 AM - edited 05-02-2023 08:41 AM
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.
Solved! Go to Solution.
05-02-2023 09:46 AM
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!
05-02-2023 09:47 AM
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.
05-02-2023 09:53 AM
@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.
05-02-2023 09:54 AM
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.
05-02-2023 09:55 AM
@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.
05-02-2023 09:59 AM - edited 05-02-2023 09:59 AM
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.
05-02-2023 10:02 AM
@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.
05-02-2023 10:06 AM
@govindsankar Haha You are right. Let's focus on what you need help with. Thanks for advice. It is humbly accepted.
05-02-2023 10:07 AM
@govindsankar, here's the VI saved in 2016. Please let me know if something doesn't work.