05-02-2018 12:53 PM
I am working on an application that will dynamically run a user provided VI. The application will set the value of a control on the front panel of the user provided VI before running it. This value is configured by the user during a configuration session. The label of the control to set is known before hand, but the type of the control is not known. It could be a numeric, string, cluster, etc. To allow the user to configure the value of this unknown control, I was planning on loading the user provided VI into a subpanel, sizing the subpanel to the control, and setting the origin of the user provided VI so that only the control of interest is visible in the subpanel. The user can then manually set the value of the control through the UI. This all works fine, except that I am not sure how to tell when the value of the control changes. I can get a reference to the control and use a dynamic value change event if the user defined VI is running, but I am not sure what to do if it is not running (I don't want it to be running during configuration). Perhaps I could read the value using a property node at the end of the configuration session or using polling, but I am wondering if there is some way to use events to tell when the value changes without running the user provided VI.
Solved! Go to Solution.
05-02-2018 01:19 PM
you can also use global variable to pass the data.
05-02-2018 01:27 PM
@Tapan_Mojidra wrote:
you can also use global variable to pass the data.
Don't do that
There is a Method to set a controls value property. you need a reference to the vi. You got one when you called the vi. the Name of the control (Label) you seem to have that too! and it takes a parameter, as variant!, for the value.
05-02-2018 04:30 PM
The vi doesn't have to be actually executing for dynamically registered value change events to work. Try it.
05-02-2018 05:59 PM
I was originally assuming that I could get a value change event from the control even if the VI that the control belongs to is not running. This didn't seem to work in my application. I tried it again using two simplified VIs and I get error 1027 if the VI is not running when I try to register the value change event of the control. I have included my simplified code here. Is there a different way of doing this than I tried?
05-02-2018 06:59 PM
Hi cbf,
It should work if you wire in a static, strictly typed, VI reference to "open vi reference". Not sure if this helps in your application though since it sounds like you don't want things to be static.
05-03-2018 03:13 AM
"Running" means two things in LabVIEW:
-- loaded by the LabVIEW execution system and capable of being executed
-- actually executing
You need the former to register for events. But you don't need the later. You've done the opposite: done lots of code to avoid loading the VI in the execution system, but you've placed a loop in the subVI to make it capable of continuous execution.
05-03-2018 03:25 AM
Here's a quick example. I actually call the subVI once, just to get the control reference, after which the subVI never executes.
05-03-2018 07:47 AM
I see that a static reference to the user provided subVI would make this work, but unfortunately I can't use a static reference. This subVI is not known at design time, it is either selected by the user or found by a search of a folder on disk.
05-03-2018 07:59 AM
Then you need to use Open VI Ref to get a strict reference dynamically.