LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting elements of an array using property nodes

Does the package handle arrays (1d and 2d, esp. with clusters in them), and
enums in the cluster? Those are the tricky controls.

I finally succeeded in splitting an array ref into an array of variants
(representing the array elements, inc. correct data).

I made this (using only pure LabVIEW) to use in ini files (save/load
functions). I can now put a reference of a panel, control, tabcontrol into
the VI, and get a format similar to the ini format as a result. It is
recursive, and handles tab controls, clusters, etc. fairly nice...

However, the code is a mess. Also, it's one way traffic, I cannot jet write
data back to a panel (nor have I tried).

Regards,

Wiebe.


"Jean-Pierre Drolet" email> wrote in message
news:506500000005000000519C0000-1027480788000@exchange.ni.com...
> Johan,
>
> You didn't tell us yet if you actually solved your problem using OpenG
> Tools.
>
> If not, here is how:
> to extract a cluster element from the variant array, use "Index
> Array.vi" from the lvdata toolset. It will output a variant cluster
> that is the required element. Then use "Get Cluster Elements Names.vi"
> to, needless to say, get an array containing the names of each cluster
> element. To split the cluster into its elements, use "Cluster to
> VArray.vi" that outputs an array of variant data corresponding to each
> element.
>
> If you goal is to write this data to inifile, then use the
> variantconfig packages that does use lvdata VIs to do the above steps.
> For example, the released version can write an error cluster as a ini
> section, e.g.
>
> [error]
> status=True
> code=1
> source="Bad input"
>
> The next release is able to write each element of the cluster on its
> own i
ni line:
>
> error.status=True
> error.code=1
> error.source="Bad input"
>
> and this is done recursively for embedded cluster to any level.
0 Kudos
Message 31 of 35
(2,342 Views)
Currently the variantconfig package supports write/read:

All simple datatypes and enums by string (not numeric value)
Numeric arrays of any number of dimension
Cluster (and embedded clusters) of combination of the two type above . A cluster can be put on its own section or with expanded name (clustername.elementname=...)

DataTypes not listed above are stored as a flattened string so ultimately all datatypes can be written and read back.

The package eases the read/write operation for many variables. If you have to write ten parameters on an ini file just bundle them in a cluster and call "Write Key (Variant).vi once. You don't have to make ten write operations specifying the n
ame of each parameter.

Thanks to a well done set of low level VIs, the code is very clean, "Pure G" and easily adaptable to support more datatypes (it will). For example to write an array of clusters you could convert it to an array of variants, and in a for loop use "Write Key (Variant).vi" changing the keynames to "Element(0,0)" "Element(0,1)" etc.

There are VIs to write a whole front panel on ini and read it back, merely calling the Read/Write Key (Variant) VIs for each control.

I'll release new version today and annouce it on a new thread.


LabVIEW, C'est LabVIEW

0 Kudos
Message 32 of 35
(2,340 Views)
Well, this sounds a lot like what I've done. My VI works with with refs to
controls, in stead of the value. The reference can also be a panel or tab.
This should be very easy to add to your toolkit (if it's not already in it);
it is very handy.

Regards,

Wiebe.



"Jean-Pierre Drolet" wrote in message
news:5065000000050000009B9C0000-1027480788000@exchange.ni.com...
> Currently the variantconfig package supports write/read:
>
> All simple datatypes and enums by string (not numeric value)
> Numeric arrays of any number of dimension
> Cluster (and embedded clusters) of combination of the two type above .
> A cluster can be put on its own section or with expanded nam
e
> (clustername.elementname=...)
>
> DataTypes not listed above are stored as a flattened string so
> ultimately all datatypes can be written and read back.
>
> The package eases the read/write operation for many variables. If you
> have to write ten parameters on an ini file just bundle them in a
> cluster and call "Write Key (Variant).vi once. You don't have to make
> ten write operations specifying the name of each parameter.
>
> Thanks to a well done set of low level VIs, the code is very clean,
> "Pure G" and easily adaptable to support more datatypes (it will). For
> example to write an array of clusters you could convert it to an array
> of variants, and in a for loop use "Write Key (Variant).vi" changing
> the keynames to "Element(0,0)" "Element(0,1)" etc.
>
> There are VIs to write a whole front panel on ini and read it back,
> merely calling the Read/Write Key (Variant) VIs for each control.
>
> I'll release new version today and annouce it on a new thread.
0 Kudos
Message 33 of 35
(2,035 Views)
But you can change the array element if you use the array shown only as a hidden array indicator from which to obtain the values through property nodes. You can then have another control array which you can change the values onscreen with, which is copied to the hidden array indicator.

As always i have included an example for you.

Kim
0 Kudos
Message 34 of 35
(2,035 Views)
As far as data is used, a tab is only an enum. Unlike cluster data there is no information in tab data about embedded controls. You need a tab reference to retrieve references and data of controls on the tab.

The main difference between variant based and reference based kind of tools is that the reference needs an actual control being in memory and holding the data. With variant you only have to create a wire with the data to be able to use them.
References has the advantage that you can get more information about data display format (like precision or date/time display) that you can use to format the data in the ini file. With variant this info could be attached
as variant attributes.


LabVIEW, C'est LabVIEW

0 Kudos
Message 35 of 35
(2,035 Views)