LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Configuration File

Hello,

 

I have been thinking about OO lately and I have a question regarding Configuration files.  Currently I store all my data in one big clustersarus.  I use Open G's write ini cluster to write the values to an INI file.  If I go to an OO paradigm the open G Write INI cluster VI doesn't like classes.  How do I save data stored in a class hierarchy to an ini file?

 

Example_VI_BD.png

Dan Shangraw, P.E.


   

0 Kudos
Message 1 of 10
(4,500 Views)

For classes I prefer xml for storing class data.  Flatten to xml- write *.txt.  Read *.txt and unflatten from xml it is wicked fast.


"Should be" isn't "Is" -Jay
Message 2 of 10
(4,491 Views)

Thanks

 

The class to xml string is cool and is what I am looking for, however the xml string that is generated isn't as easy to read as an ini file.

 

Is xml the only way to go or does anyboday have a function to save data in a class to an ini file?

 

Thanks

Dan Shangraw, P.E.


   

0 Kudos
Message 3 of 10
(4,484 Views)

I have not done much with classes so I may misunderstand some things.

 

Could you create a method VI within the class which uses the ogtk VI internally?

 

Lynn

0 Kudos
Message 4 of 10
(4,464 Views)

Depending on your skill with OOP, the character lineator could be a good fit for what you want to do:

https://decibel.ni.com/content/docs/DOC-24015

What the character lineator gives you (along with many other tools for doing to/from string) is that it forces you to treat each value as a separate field you get and set and it tries to force you to use version numbers, so that your code can safely mutate from version 1.0 to version 1.1. The code is pretty heavy, but thats the basic idea.

 

I would personally recommend against "flatten to XML" because it is very inflexible. If you make any change to your data (even changing enums, for example), I've found that "unflatten" will pretty much always fail. At present the only reliable way I know to do flatten/unflatten in LabVIEW is to do it element-by-element (that is, manually build the string and parse the string, or use something like the character lineator as a tool to help you do that). That having been said it depends on how often you want to change the code and how much effort you want to invest. I usually do end up using flatten to XML or JSON just because its so easy.

 

 

0 Kudos
Message 5 of 10
(4,450 Views)

h, you want something a bit more human editable than a flattened string.

 

I would still go XML for class data Still flatten to XML string but write to XML File. not a straight .txt

 

It looses a bit of speed over flattened xml data but not as much as other methods that can be opened in a browser.  (like 100x the speed of parsing a JSON or "Non LV Schema" XML File  DOMUserDefREF.DLL must run single threaded in the UI Thread 


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 10
(4,438 Views)

OK I think I am on to something.

 

I could create a method called "Save Config Data".  The VI would look something like this

 

Class 1.lvclass_Save Config File_BD.png

 

I would like to make this a template of the above VI and then drag it into my Class.  How would I do that?

 

Thanks

Dan Shangraw, P.E.


   

0 Kudos
Message 7 of 10
(4,258 Views)

Save it with a *.vit extension in

C:\Program Files (x86)\National Instruments\LabVIEW 2013\templates\MyClass Methods\

 

The File>>New...Dialog will let you create a new vi from that template

 

CAUTION: Wire The Error chain- Get a File Path input in there and for gosh sakes use the name of the class as the section name (The default section [Data] would be common among all of your classes)


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 10
(4,247 Views)

I would have to have a generic object in the template, how would I do that?  How do a assign the VI created from a template to a class?  

 

I agree with you caution statements.  I was just being lazy in wanting to show the general form of my idea.

 

Thanks

Dan Shangraw, P.E.


   

0 Kudos
Message 9 of 10
(4,240 Views)

Currently you need to use file new... and save the vi

Then add it to your class.

 

Spoiler
One feature that might release in an planned 8-Ball Tool Kit would simplefy the process and allow New... as a RCM for Classes and Property foldersSmiley Happy

"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 10
(4,235 Views)