LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Flexible cluster?

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!

 

0 Kudos
Message 1 of 27
(4,791 Views)

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 🙂

Certified LabVIEW Developer
Best LabVIEW Programmer @NIDAYS 2015
0 Kudos
Message 2 of 27
(4,775 Views)

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.



Remember Cunningham's Law
0 Kudos
Message 3 of 27
(4,766 Views)

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.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 27
(4,754 Views)
One way would be to not use the built-in unflatten from XML function and instead parse the XML manually in code -- which might be something to consider anyway. Remember that XML is just a text file and so can be changed/corrupted by anyone who can use a text editor.

You mention encryption, how secure does your data really need to be?

If you are willing to look beyond XML files a database would be a lot more future-proof and provide enhanced security.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 27
(4,735 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 27
(4,734 Views)

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!

Download All
0 Kudos
Message 7 of 27
(4,708 Views)

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.

 

 

 

0 Kudos
Message 8 of 27
(4,505 Views)

@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.

Message 9 of 27
(4,485 Views)

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.

0 Kudos
Message 10 of 27
(4,468 Views)