04-24-2018 10:55 AM
ok Blokk thanks! I will try to mess around with that idea and see if I can implement and fully understand what you are describing. Thanks!
04-24-2018 05:38 PM
I recently gave a talk to a group of colleagues (I've been asking for two years to give a presentation on Channel Wires to the Rochester (NY) Users Group, but noone from NI seems to remember that we exist, and noone seems to know who would be interested). I spoke for over four hours and covered lots of "new stuff" for them, including using
Channels instead of Queues for what I took the liberty of called the Channel Message Handler Design (CMH).
Using a CMH, it is really easy to build the system you want. Here's a description (it's interesting to "do it yourself", so I'll wear my Professor hat ...):
There! What's more, when you actually draw this up, it is so logical -- you see the feedback as Messages go from the output side of the CMH to the Input side to be acted upon, you see the various Messages being combined (FIFO style), it is compact, data flows as one expect (I've always been bothered by the retrograde "flow of data" from an Enqueue), and it's pretty.
As to Priority -- there is no way (at present) to make a Priority Channel. That was an Original Design Feature (I know, because I asked in 2015, and I was convinced). You also cannot (easily) "Flush" a Channel Wire. There are a few other restrictions, some of which have "cheats" (ask me at NI Week).
Bob "Channel" Schor
07-05-2020 01:35 PM
That explanation deserves 1000 enqueued KUDOS.
Bob Schor, it is possible to Do this?:
1) Event case send "Set filter default" (for example), message to the CMH.
2) Now user wants that the corresponding case do TWO things, Set default to filter values and stop filtering. Those two things happends in other cases in the CMH.
My question is that if one case in the CMH can enqueue MORE than one message to itself.
Probably there is another way to solve that but it is possible what I am asking?
07-07-2020 08:22 AM
Yamelbio: Build an array of the messages you want to send. Put the Write endpoint inside a For Loop inside the event structure. Wire the array to the Write endpoint, thereby creating an autoindexing tunnel on the For Loop. Done! 🙂
07-07-2020 08:38 PM
I totally agree with AQ's method. As I'm sure you know, order you call them in the Array is the order they'll be processed.
Bob Schor
07-08-2020 03:44 AM
@yamelbio wrote:
Bob Schor, it is possible to Do this?:
1) Event case send "Set filter default" (for example), message to the CMH.
2) Now user wants that the corresponding case do TWO things, Set default to filter values and stop filtering. Those two things happens in other cases in the CMH.
Please don't do that. Sending "messages" to oneself, in order to combine two actions in one, is a common poor design that leads to hard to find bugs.
Imagine, for example, you want a filter that is default except for on filter parameter. You might send:
"Set filter default"
"Set parameter A=5"
"Start Filtering"
You would expect to now be filtering with A=5, but instead, because "Set filter default" sent two messages, placed on the back of the message queue, you actually have:
"Set filter default" --> does nothing but send the two messages
"Set parameter A=5"
"Start Filtering"
"Set default to filter values"
"Stop filtering"
Thus you you both overwrite the parameter change and leave your filter not running.
The rule of thumb for messages is that they should do what they say when executed. "Set filter default" should mean that the filter has been set to default, when the very next message is handled.
This example bug is actually a very minor one, as it is very obvious and will thus be found and fixed. Much more dangerous are potential race conditions, where the bug only shows itself randomly based of details of exactly when messages get sent.
You can send messages to yourself, but not as a way to execute subactions of your current message, even if those subactions are available as potential messages.
07-08-2020 09:54 AM
jdpowell is right. I answered the "can you"... ne answered the "should you". 🙂
Use a subVI for the common functionality of the two events. Sending messages to yourself should be done only for continuing operations, not sub-operations. For example, it is common for a loop that has to poll some piece of hardware to finish one poll and then post a message to itself for the next poll because that allows other parts of the system to interject messages between polls. (Note that there are alternate designs for this that are often better, but it is a legitimate use case sometimes. The sub-operations use case is never legit, in my experience.)