LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control values in a subpanel vi

Solved!
Go to solution

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.

0 Kudos
Message 1 of 15
(5,393 Views)

you can also use global variable to pass the data.

CLD
0 Kudos
Message 2 of 15
(5,378 Views)

@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.

 

 


"Should be" isn't "Is" -Jay
Message 3 of 15
(5,374 Views)

The vi doesn't have to be actually executing for dynamically registered value change events to work.  Try it.

0 Kudos
Message 4 of 15
(5,345 Views)

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?

0 Kudos
Message 5 of 15
(5,338 Views)

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.

Message 6 of 15
(5,329 Views)

"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.

Message 7 of 15
(5,303 Views)

Here's a quick example.   I actually call the subVI once, just to get the control reference, after which the subVI never executes.  

subVI codesubVI codeMain VI codeMain VI code

Message 8 of 15
(5,302 Views)

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.

0 Kudos
Message 9 of 15
(5,287 Views)

Then you need to use Open VI Ref to get a strict reference dynamically.

 

Dynamic Opening VI.png

Message 10 of 15
(5,283 Views)