LabVIEW Channel Wires

cancel
Showing results for 
Search instead for 
Did you mean: 

Channel wires vs NI QMH and DQMH

What are the disadvantages of using channel wires (currently my favorite way to communicate asynchronously between parallel loops) vs the NI QMH or DQMH templates?

 

The QMH templates look at first blush to be more complicated than they're worth to me. I've been developing code with channel wires, and just wondering what features I'm missing out on.

0 Kudos
Message 1 of 10
(3,980 Views)

Sorry I didn't visit this earlier.  I am a fanatic enthusiast in the use of Channel Wires.  I believe I coined the term "Channel Message Handler" (CMH), as opposed to the QMH, before NI (I gave a talk at NIWeek called "Using and Abusing Channel Wires") and vastly prefer using them as more intuitive metaphors for asynchronous communication.  I'm currently developing a reasonably-sophisticated application for a biomedical device that uses LabVIEW Real-Time to control an instrument -- I was originally developing in LabVIEW 2019, but there was a "problem" with the Messenger Channel that made it problematic for the code running on the Real-Time side, but by LabVIEW 2021, that got "fixed".  What a pleasure to replace Queues with Messenger (or Stream, depending on whether we're talking "State Machine" or "Producer/Consumer" design) Channels!

 

Bob Schor

Message 2 of 10
(3,594 Views)

 

Bob, do you know of a way to programmatically create a Channel Wire connection at runtime ?

 

0 Kudos
Message 3 of 10
(3,584 Views)

@Dmitry wrote:

 

Bob, do you know of a way to programmatically create a Channel Wire connection at runtime ?


I'm unsure I understand what you want to do (I underlined "what" because sometimes I'm asked a "how do I" question when the real question is "Is that what you want to do?").

 

Here's an example.  Suppose you have a CMH (Channel Messenger Handler) where the "Message" is a Cluster of two elements that I'll call "State" (an Enum, though it could also be a String) and a Variant called "Data" in case the State needs to chew on a parameter or three.

 

Anyway, I made a little demo, throwing in (for free) a Producer/Consumer design that uses the Stream Channel Wire, showing some nice "extra features" of the Stream Channel.  I generated this in LabVIEW 2019, the "oldest" version I currently have installed, even though there's a somewhat-flawed version of the Messenger Channel (called "Messenger2") in that year.  I believe it was fixed in LabVIEW 2020 (becoming, again, a Messenger Channel), and is definitely fixed in LabVIEW 2021.  I'll try to also post a LabVIEW 2021 version in about 10-15 minutes.

 

Bob Schor

 

Download All
0 Kudos
Message 4 of 10
(3,567 Views)

As promised, here is the LabVIEW 2021 version of the Lenny of Piso demo, showing a Channel Message Handler and a Producer/Consumer with a Stream Channel.

 

Bob Schor

Download All
Message 5 of 10
(3,565 Views)

@Bob_Schor wrote:

@Dmitry wrote:

 

Bob, do you know of a way to programmatically create a Channel Wire connection at runtime ?


I'm unsure I understand what you want to do (I underlined "what" because sometimes I'm asked a "how do I" question when the real question is "Is that what you want to do?").

 


OK. I have a Data Producer Loop that needs to send data to a location (Data Consumer) specified at runtime (say by passing Data Producer a Queue Refnum of a Data Consumer MHL.

 

Can I somehow specify to Data Producer at runtime where it should be sending its data via its Channel Wire Endpoint ?

 

My understanding is that Channel Wire Endpoints are created at Design Time (in LabVIEW IDE) and cannot be passed to a Data Producer loop at runtime, unless it is somehow possible to create a Refnum type for Channel Wire Endpoints (like we do it with LV Queues) ...

 

0 Kudos
Message 6 of 10
(3,529 Views)

Here are a couple options for switching consumers at runtime.  The first would make it easy to select among a few options.  The second would allow for more dynamic selection.

Message 7 of 10
(3,520 Views)

I see mostly advantages with channel wires and use them all the time, but some disadvantages are:

* If you are on LV2019 or earlier, there were some issues with them. Not sure its entirely fixed but I haven't had issues since LV2020.
* If the data is a class, they don't handle namespace change.
* They cannot be in an lvlib if you want to use a channel wire probe. (At least not in LV2020, haven't tried it since then)

 

I can't say that I so far am missing a feature with channel wires themselves, except that I would like to see data direction. I also wish someone to create a framework for them for using them as actors. Jeff K had an interesting presentation about that a few years ago.

 

Certified LabVIEW Architect
0 Kudos
Message 8 of 10
(3,481 Views)

@jkodosky wrote:

Here are a couple options for switching consumers at runtime.  The first would make it easy to select among a few options.  The second would allow for more dynamic selection.


I really like the 2nd option 🙂

 

The first one (case statement) violates Open-Closed Principle ("O" in SOLID), but since one can pass a Channel Wire to a Dynamic Dispatch Method (I tried in LV2020 - does not break the BD) I can create an abstract Consumer class hierarchy and implement multiple Consumers as its child classes ...

 

0 Kudos
Message 9 of 10
(3,439 Views)

I did option 2 using Start asynchronous call in LV2018:

thols_0-1669710557384.png

I think it was because I couldn't resolve how to do dynamic dispatch. So it is good to hear that that works too.

 

Certified LabVIEW Architect
0 Kudos
Message 10 of 10
(3,418 Views)