From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Make current value default of a control programmatically

I know, i know.  This has been posted before but that was 2 years ago :P.

I'm writing a program that is going to be compiled and distributed.  Within that program I have a rather elaborate array of clusters (that contain array of clusters) that the user has to interact with in order to set the parameters of a state machine.

If the program was not going to be a compiled program but just a VI running in LabVIEW, I could make use of the "Make current value default" of the particular control when the VI was not running.  However, because this will be a compiled program it will either be open and running or closed.

What would be the most graceful way to save my control array of clusters?  I'm basically interested in the control array of clusters retaining their values between loads.  I don't particularly want to get in the nitty gritty of creating a flat-file format for the data and have overly complicated save and load stages in my program.  If the case is that the best approach is a flat-file one, can I have some recommendations on how I should go about it?

Thanks for all of you input.

-Nic

0 Kudos
Message 1 of 11
(11,363 Views)
You can use this or the OpenG VIs mentioned there. You can read some more about this here and in various other places.

___________________
Try to take over the world!
0 Kudos
Message 2 of 11
(11,356 Views)
Thanks for the links!
0 Kudos
Message 3 of 11
(11,348 Views)
I've read through the provided links and I think I'm more confused than when I started...

Not sure why NI hasn't provided a simple solution in LabVIEW yet.

Is there a simple "Save Control State" Vi, and "Restore Control State" Vi that takes a reference of the control as the input along with a file name?
0 Kudos
Message 4 of 11
(11,333 Views)
Since it sounds like you have one control, you could use the XML Vis or binary write.  However, if you ever change the structure or type of your data, then these files will not properly read back to the new control state.  For example, if you add a numebr to your cluster, these canned NI VIs will error out when you use the new control type to read the old files.

Some of the files that you were pointed to do not have this limitation.
0 Kudos
Message 5 of 11
(11,330 Views)
I think I know what is going on now and am attempting to use the MGI Write Anything/Read Anything VIs.  That article had me more loss than anything.  A little over my head.

But you say there is a way to use a built in function for reading and writing the data?  I'd rather use the built in funciton since I'm not too worried about the data structure changing and even if it does it isn't a big deal to re-work the settings of this state machine.
0 Kudos
Message 6 of 11
(11,328 Views)
You can use Write to XML File and Read from XML File along with Flatten to XML and Unflatten from XML to create XML files of your control settings.

You can also use Write to Binary File and Read from Binary File to have a non-human readable file.  This same result can be achieved using Flatten to String and Unflatten from String and the Write to String File and Read from String File.
0 Kudos
Message 7 of 11
(11,325 Views)
Awesome...for some reason I thought that those read/write file types were only used for waveform data... didn't realize I could dump my controls to them.  That is the simple solution I was looking for.

Can't believe how much time I've waisted on this today Smiley Sad.
0 Kudos
Message 8 of 11
(11,323 Views)
Using the XML VIs work equally as well as saving the binary data.  Going with the XML data format is prefered since there is more flexibility there than in a propietary binary format.

Thanks again.
0 Kudos
Message 9 of 11
(11,316 Views)

For another option, have a look here.

 

In that thread, I mentioned some changes which could help this.

I have done them quickly, but haven't planned or tested them, so what I'm uploading is just an example.


___________________
Try to take over the world!
0 Kudos
Message 10 of 11
(11,285 Views)