02-07-2018 11:09 AM
I finally managed to write a little something about how we use helper loops in our applications. Feel free to take a look at https://www.hampel-soft.com/blog/dqmh-actors-self-messaging-or-helper-loops/ and let me know if you have any further questions or comments
DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )
Solved! Go to Solution.
02-09-2018 09:41 AM
Nice post Joerg! I need to get round to writing mine! Your approach matches mine to a great extent. The bit that I've added is to have the helper loop enable/disable itself when the module is idle/active. So the timeout in the helper loop is set to -1 automatically when there's one or more messages in the message queue and reset to the helper loop period when the queue is emptied. That way I can be sure the helper loop never (or at least almost never) gets in the way of the operation of the module.
We're also using the second type of helper loop in a singleton module which manages (and provides the interface to) a cloneable module. The helper loop handles all messages coming from the cloneable modules (and any other external module we're interested in hearing from).
Now, this COULD be done using the main event handling loop of the DQMH, but I do prefer keeping the two loops separate - one loop for direct commands to the main module (i.e. the DQMH event loop) and one loop which I call the "External module event handler" which registers for the broadcast events of external modules...
Paul
02-11-2018 05:00 AM
Paul, thanks for commenting!
One interesting thing is that you point out that you don't want the helper loop to get in the way of the operation of the module. So far, for most (if not all) of our modules with helper loops, I'd not want the module to get in the way of the helper loop. This distinction is definitely something to keep in mind when designing the module. Let's talk about this some more next week in Madrid.
DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )
02-11-2018 05:12 AM
When talking to some LabVIEW friends about this blog post, I was confronted with reservations regarding using the timeout event of an event structure for periodic actions. It was pointed out that NI's core 3 training recommends not to use the timeout event for any critical actions.
I know from experience that timeout events used to be tricky (maybe even buggy?) some years ago, maybe in LV8.2 or 8.6 or so. I haven’t had any bad experiences with it ever since. Is there anyone who has more tangible things to say about this? Does NI still recommend to not use it for critical stuff?
DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )
02-11-2018 07:40 AM - edited 02-11-2018 08:04 AM
wrote:
When talking to some LabVIEW friends about this blog post, I was confronted with reservations regarding using the timeout event of an event structure for periodic actions. It was pointed out that NI's core 3 training recommends not to use the timeout event for any critical actions.
I know from experience that timeout events used to be tricky (maybe even buggy?) some years ago, maybe in LV8.2 or 8.6 or so. I haven’t had any bad experiences with it ever since. Is there anyone who has more tangible things to say about this?
Hi Joerg,
02-11-2018 08:15 AM - edited 02-11-2018 10:28 AM
Thanks, Fab. I didn't even think of the timeout case being starved by other events being called because we don't use it that way. It might be worth adding that caveat to the original blog post.
And yes, I remember listening to Justin being interviewed by Michael for the 3rd VI Shots episode, and him talking about Steen triggering that event timeout epiphany.
DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )
02-11-2018 12:11 PM
Yep, mine is more of an "idle time" helper loop... When no-one's talking to the module, the module talks to itself to keep itself
We're using DQMH for a motion application and the end user can physically move the motion stages around without software input. The helper loop makes the DQMH periodically poll it's controller for any change in encoder position value and then we can broadcast that out to the application to update any UI which shows system position in real time. The module already sends its positions out during moves so there's no need for the helper loop to run...
Anyways, looking forward to a chat, perhaps over a beer?!
Paul
02-11-2018 03:06 PM
joerg.hampel wrote:
Does NI still recommend to not use it for critical stuff?
I would have to review the specifics of the LabVIEW Core 3 course to understand the exact scenario being described, but I can definitely see a recommendation to avoid using a Timeout event for handling "critical" events in an Event Structure that is also handling other "critical" events.
But in the case of a helper loop, the Timeout event *is* the critical event. As you mention above, it is critical that other requests *not* interfere with the operation of the helper loop (other than what was mentioned...enabling/disabling the helper loop, and the Stop Module request).
I have never had reservations about using the Timeout event for the helper loop use case, and I am unaware of any feature limitations or bugs in LabVIEW that should prevent any of us from doing so.
03-02-2018 11:43 AM
Thank you for your blog post a very interesting read. I am currently using your type 2 broadcast helper loop.
One question I have is how to find the constant user event refnum as mention in your quote below.
"Initially, we only supply a constant of the UI.System Message user event refnum for the event registration node. This allows us to create the corresponding event case. Beware that our helper loop is only loaded, but not yet armed."
For my DQMH module that is broadcasting I can find a Broadcast Events clust containing a number of Broadcast events but I cannot seem to find the base constant.
03-02-2018 01:23 PM - edited 03-02-2018 01:30 PM
Hey Danny, thanks for your comment!
Regarding the constant, I know of two ways:
1.) In my blog post, in the picture after the one you quote, you can see how I enable the event registration for broadcast events in the helper loop. I place the Obtain Broadcast Events for Registration.vi
on the block diagram, wire its Broadcast Events cluster to an Unbundle By Name node, select the "System Message" user event refnum and wire it to the Register For Events node. This is the place where I get the constant: I pop up (right click) on the user event refnum wire and select "Create Constant" from the context menu:
2.) Drop the Broadcast Events--cluster.vi
on the block diagram, and drag the "System Message" constant out of the cluster. Because the cluster is a typedef, you cannot move the constant out of it. You need to copy it out by keeping your ctrl-key pressed while dragging:
DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )