07-13-2023 12:20 PM - edited 07-13-2023 12:20 PM
I have a subVI that loops for an indeterminant amount of time (at least a few seconds) while polling a piece of hardware for data. I want to let the user stop the polling loop prematurely from the main VI.
I thought I would be able to create a reference to the control that stops the polling loop in the subVI and use that reference with a property node to stop the polling loop from the main VI. But that does not work because when I create a reference on the subVI and copy/paste it into the main VI, it creates a new control on the main VI and the reference no longer refers to the control in the subVI.
I've attached simplified examples that demonstrate the problem. Any ideas?
Solved! Go to Solution.
07-13-2023 12:35 PM
I would feel more inclined to use a Notifier to stop the subVIs. You "obtain" the Notifier in the top level VI and pass the reference down to the subVIs. The subVIs can then Wait On Notification with a timeout (this can replace your wait). The top level VI can then send the notification to tell the subVIs to stop.
07-13-2023 01:24 PM
@crossrulz wrote:
I would feel more inclined to use a Notifier to stop the subVIs. You "obtain" the Notifier in the top level VI and pass the reference down to the subVIs. The subVIs can then Wait On Notification with a timeout (this can replace your wait). The top level VI can then send the notification to tell the subVIs to stop.
Yes, that works perfectly. Here is the updated code (for posterity).
07-13-2023 01:28 PM
I make it even simpler. Set the data type of the Notifier to a boolean. You can then wire the stop condition straight to the output of the Wait On Notification.
07-13-2023 01:34 PM
Good call. Thanks for the help!
07-13-2023 04:53 PM
After you created the reference, if you made a constant of the reference, you can copy that without causing a new control to be created.
07-14-2023 03:31 AM - edited 07-14-2023 03:45 AM
The simplest modification of your original vi would be to wire the reference to a subvi input and read its value via a property node there.
Still, if this will be part of a large, scalable project, there are probably better ways.