LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Put Cluster in empty Cluster

Solved!
Go to solution

Is there a way to simply put one cluster into a new empty cluster, without specifing the datatype?

In my case (see screenshot) I want to store one part of a configuration cluster to a configuration ini. The configuration cluster consists of a few subclusters, which have to be saved independendly but to the same file.

The data structure is like this:

[Powermeter_config]
Key1 = ...
Key2 = ...

[Laser_config]
Key3 = ...
Key4 = ...

[..._config]
...

Everything works fine if the config file already contains all entries. But if the config.ini is still empty and I save only one subcluster (for example Powermeter_config) then the Keys get scatterd in the ini-file without belonging to one cluster.

I can work around this problem by putting the subcluster in an empty cluster as I did in the screenshot.

 

But is there a better way to do this? As you can see the LARA_config_input is a Typedef, so I can change it easily. But I don't now how to create the "empty" cluster dynamically, because with my way I have to use a cluster-constant, which is hardcoded to specific content...

 

Save_ini.PNG

0 Kudos
Message 1 of 5
(3,201 Views)

A simple Bundle will put anything in a cluster. Not sure if that will work, I have no idea why the VI would require the cluster to be in a cluster. But it will "Put Cluster in empty Cluster".

Message 2 of 5
(3,166 Views)
Solution
Accepted by topic author jusaca

It has to do with how the Write INI Cluster_ogtk.vi is implemented. It convert your cluster to an array of variants and for each element, depending of the variant element type, it will use the Write Key_ogtk.vi (default value) or the Write Section Cluster_ogtk.vi (if the element is a cluster). Since your cluster contain a string and a cluster of double, there are 2 array elements. The string will be written to a section (probably named Powermeter_config) and the second cluster element will have its own section.

If  you embed your cluster in an empty cluster, this new cluster when converted to to an array of variant will have a single element: your cluster,  and will then be written to a single section PowerMeter_config. The bundle function will do the trick.

 

Ben64

Message 3 of 5
(3,152 Views)

What does your LARA Config control look like? The following two diagrams generate the exact same INI file for me:

Capture.PNG

[Instr 1]
Parameter = "one"
Numeric = "<size(s)=2> 1 2"

[Instr 2]
Parameter = "two"
Numeric = "<size(s)=2> 3 4"

 

0 Kudos
Message 4 of 5
(3,143 Views)

Too easy! The Bundle function works a treat, thanks. 

 

You are right, I just realised that the problem occurs only when I have another cluster inside this module cluster, in my case the two numerics are bundled in a cluster (despite the fact that the configs are still placeholders, something like this might happen). But as I said, the additional bundle functions is all it took.

0 Kudos
Message 5 of 5
(3,124 Views)