LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Learn QMH with multiple loops

Solved!
Go to solution

@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.

Message 11 of 42
(1,346 Views)

@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. 

0 Kudos
Message 12 of 42
(1,345 Views)

@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 😉

0 Kudos
Message 13 of 42
(1,340 Views)

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.

Message 14 of 42
(1,308 Views)

@mcduff Thanks for sharing. Single loop!!!! Wow. That is so great!!! I definitely need it. I'm downloading the JKI state machine now.

0 Kudos
Message 15 of 42
(1,303 Views)

@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 🙂

Message 16 of 42
(1,292 Views)

@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: 

https://readthedocs.web.cern.ch/download/attachments/5571215/Using%20the%20Actor%20Framework%203.0%2...

______________________________________________________________
Have a pleasant day and be sure to learn Python for success and prosperity.
0 Kudos
Message 17 of 42
(1,278 Views)

@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.

Message 18 of 42
(1,276 Views)

@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. 

Message 19 of 42
(1,246 Views)

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.

Message 20 of 42
(1,243 Views)