LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Intialise cluster controls

Can I intialise the default values of controls in a cluster to values read from a file whilst running the VI?

0 Kudos
Message 1 of 9
(3,511 Views)

Right Click Control>Data Operation>make Current Value Default

0 Kudos
Message 2 of 9
(3,505 Views)
Perhaps default is the wrong word. I'd like to save the control cluster values, change them, and then load the saved values back in. All in run mode, not edit.
0 Kudos
Message 3 of 9
(3,494 Views)

What you are looking for is called configuration file. This is the way to save certain settings of an application, and when the user launches the app again, it looks for the file, loads data, and initialise controls or attributes (for example if the user changed Graph curve colours, etc).

 

I usually use OpenG configuration file VIs, see some discussions in this thread (also info about mutation --> when you change your typedef control, how you deal with old config files missing some new values of the cluster, etc...):

http://forums.ni.com/t5/LabVIEW/Saving-application-state-for-later-resume/m-p/3225945/highlight/true...

 

Edit: I also like the MGI addon, and it saves programming time: http://sine.ni.com/nips/cds/view/p/lang/en/nid/209753

I attach an example I made some time ago how to use the MGI Save/Restore FP Data & Settings VIs:

 

MGI_save_and_restore_example.png

0 Kudos
Message 4 of 9
(3,482 Views)

When you play with my above example, you can find the created settings.ini file in your default data directory, in my case:

c:\Users\Andras\Documents\LabVIEW Data\settings.ini

You can open this ini file with a text editor (I prefer Notepad++), and change values in the file as needed.

 

[Data Values]
MGI RWA Section Options=2.0.1 %04Y%02m%02d %02H%02M%S%25u*~|.%d*~|.;*~|.%#_13g
stop=FALSE
Save=FALSE
Numeric=458
Numeric 2=4242
Numeric 3=4534
Numeric 4=52322
Boolean=FALSE
Boolean 2=TRUE
Cluster.Boolean=TRUE
Cluster.String=blabla!
Restore=FALSE
XY Graph=<0>
0 Kudos
Message 5 of 9
(3,469 Views)

The easiest built in way is to read/write an XML file.

ConfigCluster.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 9
(3,415 Views)
But guess with the limitation of not handling cluster mutation well?
0 Kudos
Message 7 of 9
(3,411 Views)

@Blokk wrote:
But guess with the limitation of not handling cluster mutation well?

Not too well, no. I haven't tried it too much with mismatching clusters. That shouldn't be an issue in a deployed program anyhow.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 9
(3,395 Views)

The Save panel to INI, and Load panel From INI OpenG functions handle cluster mutation as best as you can expect.  By that I mean it doesn't throw and error and will load all the things it can.  It will then have an output stating if all things were found or only some.  These functions are in the Variant Configuration package and works well as long as your data structures aren't loo large.  Once you have arrays of clusters of arrays of clusters the load and save time can be a bit long.

Message 9 of 9
(3,380 Views)