LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

About channel message template

Solved!
Go to solution

Hi all, I wonder if there is somewhere a Channel (Channel Wires) Message (just like Queue Message Handler) Template?

 

LabVIEW provides an example but its not like a template.

Thanks!!

0 Kudos
Message 1 of 5
(1,482 Views)

Not that I know about, but I've used (what I call) the Channel Message Handler for quite a few years, now.  I do it by defining two TypeDefs and two VIs.  The TypeDefs I call "State" and "Message".  "State" is equivalent to the "Message" parameter in the QMH -- it is an Enum (or a String) that (uniquely) identifies what "Case" of the CMH's Case Structure you want to execute (for example, "Initialize", "Sample", "Analyze"), while the "Message" type is a Cluster having "State" and "Data" (a Variant, in case you want to pass in some data).

 

The two VIs are "Send Message", which takes State and Data as inputs, creates the Message Cluster, then outputs a Messenger Reference, and "Receive Message", which does the opposite.  The CMH is structured otherwise like the QMH, but is much simpler in appearance.

 

I've got to run to a meeting right now, but I'll try to post an example in an hour or so.

 

Bob Schor

0 Kudos
Message 2 of 5
(1,431 Views)
Solution
Accepted by topic author yamelbio

When Channels first became widely available (LabVIEW 2016), I tried to give a talk to the Rochester LabVIEW Users Group about Channel Wires, only to find out that nobody in Rochester (including the people at the company where the meetings were held) knew how to convene a meeting (they were strictly run by NI, and two years of attempts by others and me to contact NI and schedule a meeting failed).  I finally prepared a talk (which went for about 4 hours) for a group of colleagues and students about my LabVIEW practices, and discussed the Channel Message Handler.

 

Here is a picture, from a LabVIEW RT routine, showing a QMH running the main RT Message-Handling Loop (there is no Event loop in a LabVIEW RT VI).  The Queue is created in the VI "Initialize RT" (and the first "Message" put on the Queue), it is dequeued and the Message extracted, the Message is broken apart into the Message Cases (which I called "State") and the variant Data (which, in the case illustrated holds Configuration data).  To get to the next State, the "next State" (and any Data, not illustrated here) is placed on the Queue (I use the Send Message VI to do this).  The Queue "passes through" a Message Error Handler to "do the right thing" if there is an error.  Note that it is not at all obvious how the new Message (or Messages) get back to be dequeued on the next loop.

S-Lab_RT_QMH.png

Here's the same thing, using Messenger Channels (important!) rather than Queues.  The important thing is that now the Channel shows "the flow" of the Messages.

S-Lab_RT_CMH.png

Note that the "Initialize" VI has been broken apart into one that does "non-CMH-related" stuff, and the initialization of the CMH, which is simply to create and "send" the initial Message, "Initialize".  The single "Message Recipient" sits just inside the CMH and receives the Message -- I prefer to break it apart into the State (top String Wire) and the Data (bottom Variant Wire).  Note that the Channel stops with the Channel Reader (inside "Receive Message") -- it doesn't show up in the Block Diagram until a new Message is generated (at the end of the illustrate Message Case).  And, should the Error Handler see an Error on the Error Line, it can add a Message to the Message Channel (this is a little tricky -- sort of an "Advance Topic") before the Message "metaphorically" makes its way from the output of the CMH Loop to its input.

 

And that's how simple the CMH is.  You don't really need a Template.  You create two Type Defs to define your Message, write one VI to create and Send a Message from its components, write another to Receive and "present" the Message to the "Process Message" Case structure, and then all you need to do is configure your Messages.

 

I went on to write a monitoring routine based on the CMH that used this technique heavily.  It created up to 24 independent asynchronously-running VIs, each of which was a CMH containing 3 other CMH loops running in parallel with it.  Works like a charm.

 

Bob Schor

 

0 Kudos
Message 3 of 5
(1,422 Views)

I got it !! Its clear that I will read again and again your answer, but I got the main idea.

 

Actually I have a (prety developed) project using Arduino, some acquisition channels and an interface on LabVIEW that uses Channel Messages, those pipes really works for me!

 

I found that absolutely illustrative about the flow of the messages.

 

So, I was wondering if there was somewhere an "oficial template", wich I didnt found.

 

THANK YOU so much! for your time Bob!

 

What you wrote, I think, should be stored and consulted more often!

0 Kudos
Message 4 of 5
(1,413 Views)

Hi, LabVIEW 2020 includes a Channeled Message Handler template. 

0 Kudos
Message 5 of 5
(1,317 Views)