From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Persisting SubVI Selections during Runtime.

Solved!
Go to solution

I'm using an instrument from Keysight, and creating a simple VI for taking measurements. 

 

I am wanting to create a SubVI that allows you to select multple configurations for this instrument so that if the user doesn't like the default configurations he can go in and alter them by clicking a simple "Configure" button. 

 

Currently my code passes in the VISA and opens the Configure SubVI, and you can change the configuration of the instrument, but when you close the configuration window it closes the SubVI and then if the user then wishes to open the configuration window again all the defaults are loaded and the previous configuration is lost. 

 

Is there a way to persist decisions made by the CURRENT user of the VI during the time they are using the VI, without completely changing the default selections of this SubVI? Perhaps just hiding the VI and showing it again if needed? 

 

I was wanting to use a AE but there are so many inputs/outputs that it wouldn't really work for me unless I'm missing something.

 

Thanks,

 

Kellen


 

Measure VIKeysight Electrometer.png


Configure SubVI

Keysight Configure.png

0 Kudos
Message 1 of 10
(3,712 Views)

Look into Action Engines / Functional Global Variables.

 

Functional Global Variable here: https://decibel.ni.com/content/docs/DOC-2143

Action Engine here: https://decibel.ni.com/content/docs/DOC-34948

 

These use a property of uninitialized shift registers, and will allow you to hold values between VI calls.

Jon D
Certified LabVIEW Developer.
0 Kudos
Message 2 of 10
(3,706 Views)

I have used AEs quite a bit lately and am familiar with them, but what properties are used to open and close a VI if you are using it as an AE? I'd like the user to be able to pop up the "Configuration Panel" and choose the configurations, and have the window go away until needed again.

0 Kudos
Message 3 of 10
(3,691 Views)

I need to ask first, is the configuration panel subVI yours, or someone elses? (ie, can you make changes to it?)

Jon D
Certified LabVIEW Developer.
0 Kudos
Message 4 of 10
(3,686 Views)
Solution
Accepted by topic author rkmadse

A common technique for persisting Configuration data is to have a Configuration File that (by default) is read by your Program when it starts and loads all of the (mostly-constant) Configuration Parameters that you need.

 

If you want to change the Parameters, your "Configure" button calls a sub-VI that (a) reads the Configuration File, showing you the values, (b) invites you to change/edit those values, and (c) prompts you to save the Configuration file back to disk so that it can be used the next time.  You can decide for yourself if you want a single Configuration File that gets overwritten, or if you want to maintain two or three "common" Configuration Files and have the User choose which to use ("16-Channel, 1KHz", "8-Channel, 500Hz", "16-Channel 500Hz", for example).

 

One common "user-friendly" format for Configuration files, with support VIs in LabVIEW's File I/O Palette, are .INI files, which (if done right) are Human-readable.

 

Bob Schor

0 Kudos
Message 5 of 10
(3,677 Views)

Yes, The configuration panel is something I threw together.

0 Kudos
Message 6 of 10
(3,672 Views)

This is an example I threw together where the Configuration panel is the Action Engine as well.  The first time you call it or if you want to revert to the default values, pass it the 'Reset' command when you call it.

 

Bob's example is also a good one if config files are not an issue, with the advantage that the changes can persist through powerdown/closing of the main program, my example only lasts as long as the main program is in memory.

 

 

Jon D
Certified LabVIEW Developer.
Download All
Message 7 of 10
(3,665 Views)

A major problem with this concept Bob is that the settings come from a lot of different controls. Bools, Ints, Dbls... etc. So how does one go about saving and retracting all of that information sucessfully from an .ini file?

 

0 Kudos
Message 8 of 10
(3,655 Views)

The same way you would do just one of any of them.  You just have to string together mulitples reads/writes.    I'd create a For Loop and have the "i" terminal connect to a case structure inside.  Each case is the read/write relating to one of the many different controls you are trying to work with.

Message 9 of 10
(3,646 Views)

If you are looking for a quick way to get all control values, there is a method on VIs called "Control Values-->Get All".  It returns an array of clusters of name/value pairs.  The name is the label of the control and the values are variants because of the varying data types.  I missed wiring a TRUE to the "Controls", otherwise all you get is the Indicators by default.

 

Get all Values.png

 

Get all Values-FP.png

Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



Message 10 of 10
(3,636 Views)