03-30-2016 07:05 AM
Hi guys,
i just found some 10-year-old discussions about cluster that aren´t flexible and I´m wondering if there is already a solution?
I´m working with a cluster of about 40 elements which will be saved/loaded as XML-file. The problem is for example, if I add another element, it´s not working anymore due to the changed typ of the cluster.
So what I´m looking for is an alternative to clusters? Or is there another way to safe/load the cluster?
Additionally, I´d like to encrypt/decrypt the data! But that may be worth another post.
Thanks for your answers!
03-30-2016 07:20 AM - edited 03-30-2016 07:22 AM
Hi,
just try out this as shown in imagethere wont be any issue. you can add as many inputs to the cluster as you want.
Hope this helps
Kudos 🙂
03-30-2016 07:24 AM
Hi,
how often do you want to change the cluster? If were talking about sporadically adapting it as you need to process more information in a newer version of your program or a similar scenario, I would take a look at typedefs. That is assuming, of course that you haven't already done that.
If you want to dynamically add and remove data during run time you could think about using a dynamic data format like Variant or Strings. The data processing for this would be a bit of a pain, but it's certainly possible.
Can you give us some more context about what your Data looks like and what Data you expect to be added to that?
Is the XML file a given? In your case it could be a solution to use a Datalog format since it will adapt with the typedef.
03-30-2016 07:35 AM - edited 03-30-2016 07:35 AM
I normally use the OpenG Variant Configuration File VIs - they allow reading/writing of clusters to INI files and the best part is that they handle the mutation (changing) of clusters over time - using default values (that you can specify) if any INI key is missing.
03-30-2016 07:46 AM
03-30-2016 07:46 AM
With XML, the option I have seen done is to also store a version of the cluster in the XML and then you can load whichever version of the cluster was saved and then convert to the latest. This may be easier to do with objects.
But going with the OpenG configuration file would be the simplest way, but it does not use XML.
03-30-2016 09:00 AM
Thanks for the fast answers!
I attached some jpgs, I hope that will help.
The cluster is actually a cluster of 11 elements, containing amongst other things 2 typedefs with 24 and 7 elements, and so on...
As you can see the file is already given ( or I do create default elements if it doesn´t exist). I don´t know how often the cluster will change yet, but I expect it should be able to adapt in future tasks/versions (and possibly create an UI automatically?). The added data could be numeric 1D/2D arrays with parameters.
I didn´t do a lot of research about encryption yet, but i thought about AES? That looks like a simple way to make the text file unreadable for anyone not having the program.
Alright I will see if I´m allowed to use this openG file!
04-27-2016 03:00 AM
Hello again,
i did mess around with possibilities to get this going but still couldnt find a solution.
I tried openG and cluster toolkit packages which are quite usefull for add/remove data during run time.
But even if i work with variant, Labview needs the datatype input to format it into a cluster. So if i open a file that has added data, it cant be read.
That means for a xml file: I cant unflatten the string. Can i manually unflatten the string? Like scan the string and create the datatypes myself? Is there any code provided by now?
Basically i my new cluster will be similar to the default one. So i need the differences of the two strings and then transform it?
@crossrulz: i had a look at config files but cant find any good examples how that works. First step would be writing my given "default" cluster into the .ini file? It seems to not work as easy as the flatten_to_xml.vi.
04-27-2016 04:49 AM
@NauOrNever wrote:
i had a look at config files but cant find any good examples how that works. First step would be writing my given "default" cluster into the .ini file? It seems to not work as easy as the flatten_to_xml.vi.
Are you sure you looked at the OpenG extension to the inbuilt LabVIEW config feature? OpenG has VIs for writing clusters.
Personally, I use a JSON Library (available on LAVA) for this kind of thing. Like OpenG, it isn't so strict on type like the inbuilt LabVIEW functions often are, so one can easily add/subtract cluster elements. JSON is a more natural match to nested clusters than either XML or INI formats.
04-27-2016 05:53 AM
You´re right, my bad. Thats actually working.
Looking at how to convert it back to a cluster, i need the datatype again. Same for json, at least with the standard tools in labview.
Is it different with this json library? Again, i need to get the data structure of a file without knowing the structure.