05-02-2023 10:17 AM
@GRCK5000, I apologize; I'm sure you're a fantastic person and didn't mean to be offensive.
I believe that the initial steps in learning something new can't be hastened too much. Not much can be built on a foundation that's not solid.
05-02-2023 10:28 AM
@Ravi_Beniwal. This is exactly what I needed. Thank you very much. Now using your solution, I need to create another example program. I dont have an idea for that now?My work today is over and I will come back and do it tomorrow and see how it goes. Thank you.
05-02-2023 10:30 AM
@Ravi_Beniwal. Great job!!! That's what I'm talking about. Let's help each other. @govindsankar don't forget to Ravi's answer as the solution 😉
05-02-2023 12:37 PM
Late to the party here, but ...
Personally I hate the QMH and its examples, too many loops and too confusing.
I highly recommend playing around with the JKI State Machine. You can download it from VIPM. It is a type of "QMH", the message queue is the shift register string. Everything is contained in a single loop, much easier to debug and visualize. If you need to link multiple JKI State Machine, you can pass User Events as messages.
05-02-2023 12:45 PM - edited 05-02-2023 12:45 PM
@mcduff Thanks for sharing. Single loop!!!! Wow. That is so great!!! I definitely need it. I'm downloading the JKI state machine now.
05-02-2023 01:10 PM
@mcduff, the state machine, JKI, or any other implementation, while very useful and easy to troubleshoot, serves a different use case.
When you need multiple parallel processes, you just need them. As for passing messages between them via Queues or User Events, both have their strong points and can't be seen as a replacement for each other, though there is an overlap in functionality. Actor Framework and DQMH, two of the most common frameworks used for large application development, are both QMH.
When you don't need parallel processes, state machines are great. I know my applications, and those of most others I know, are composed of state machines and QMHs in different proportions, depending on the needs of the application.
That said, I do share your emotions around the shipping examples for QMH 🙂
05-02-2023 01:25 PM
@govindsankar wrote:
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.
I saw that you got an answer to this original question. After you get comfortable with the QMH and QMH state machines you could check out the LabVIEW actor framework. It is built in to LabVIEW and abstracts the QMH and state machines to an object oriented messaging system that builds on the underlying QMH and state machines. There is a good paper with more info here:
05-02-2023 01:27 PM
@Ravi_Beniwal wrote:
@mcduff, the state machine, JKI, or any other implementation, while very useful and easy to troubleshoot, serves a different use case.
When you need multiple parallel processes, you just need them.
Wholeheartedly Agree. But, my gripe with the QMH examples is that it has parallel loops just for the sake of having parallel loops which makes it harder to debug, maintain, etc. I see no advantage of a multi-loop template for QMH. The two parallel loops in the QMH template do not make anything faster.
Aside: From a NI rep. The origin of the QMH came from a LabVIEW test where the question was "Make a State Machine for ...". One test taker used a queue to queue up states and a separate loop to implement it. That response was shared internally and the QMH was born.
When I need multiple parallel loops I link JKI State Machines with User Events. Sometimes it is overkill, but easier to add to if needed for future work. The other advantage of linking via User Events is that multiple messages can go to the same "mailbox". The same loop can handle a UI event, User Event, DAQ event, etc. Queues are great but less flexible.
05-02-2023 02:27 PM
@Jay14159265, thank you for the advice, but actually I am learning actor framework. That is the idea. So I start with QMH, then I move onto OOP. Both QMH and OOP I know the concept, i need to practice it. So thats what I am doing now. Once I have mastered both, I will start actor framework. It was my idea all along to learn actor framework.
05-02-2023 02:42 PM
The two-loop NI QMH design is one of the worst designs in LabVIEW. The JKI template, though misleadingly named a "state machine" (it isn't), is a better design.