From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain unit string from variant?

Hi all,

I am starting to use and like the varaint data type especially in combination with clusters. What I now want to do:
I hold all measured data and states in different physical units and types (DBL and Bool) in one large cluster which is typedef'd.
For communication and storage in spreadsheet-readable files I want to convert this data cluster into a tab-separated string
and use 2 lines of headers in the file which contain the name of the cluster element and the physical unit.
Getting the data converted into a tab'ed string is easy and the names will work too, but I am not sure yet how to get
the unit string out of the variant? There is a function in the openg library that gets the unit out of the varaint but this is
a cluster of two integers. I have no idea how to convert this into the appropriate string. Another issue: The openg function
throws an error if a varaint has no unit (it seems) how can I avoid this and rather get an empty string back?

This is much harder and I probably leave it that way: I would prefer to use the units I defined in my cluster rather than
base units. e.g. I measure a flow in l/min and it gets converted into cubic meters per second which is very unconvenient.
I am afraid there is no easy way to achieve this in an elegant way which works with different clusters and physical units?

Thanks,

Olaf
0 Kudos
Message 1 of 12
(3,666 Views)
Hi Olaf,

Sorry but could you post the VI that you made, because is difficult to understand without an example...and I can see if I can help you...

Best Regards.

Matthieu
0 Kudos
Message 2 of 12
(3,649 Views)
Here is the graphics of a vi that explains what I am looking for:
0 Kudos
Message 3 of 12
(3,645 Views)
One correction: The desired input control for this vi will later be an array of variant not a cluster!

Olaf
0 Kudos
Message 4 of 12
(3,637 Views)
Hi Olaf,

It would be great if you can post your VI, better to work...and to have all settings of your VI..

Best Regards.

Matthieu
0 Kudos
Message 5 of 12
(3,634 Views)
Here is the vi. It is in 8.20 and you need the current openg variant library.

Olaf
0 Kudos
Message 6 of 12
(3,630 Views)
Hi Olaf,

without the "Cluster to Array of VData__ogtk.v" and the "Format Variant Into String__ogtk.v", I can see if there is a possibility to help you...
and I doesn't found this 2 VI's on the web or on the NI Site...

Best Regards...

Matthieu
0 Kudos
Message 7 of 12
(3,620 Views)
Hi Olaf,

Now I see your problem but a solution is to use the Label and The caption for the numerical input and work with this...
I think there is no other way to do that...

Let me know what do you mean or if you have another solution...

Best Regards...

Matthieu
0 Kudos
Message 8 of 12
(3,616 Views)


@Matthieu Papaux wrote:
Hi Olaf,

without the "Cluster to Array of VData__ogtk.v" and the "Format Variant Into String__ogtk.v", I can see if there is a possibility to help you...
and I doesn't found this 2 VI's on the web or on the NI Site...

Best Regards...

Matthieu



The vi's are freely avaibalbe (open source) and should be in the oglib_lvdata and oglib_string package at:

http://forums.openg.org/

and can be downloaded via the following tool:

http://jkisoft.com/vipm/

Olaf
0 Kudos
Message 9 of 12
(3,613 Views)


@Matthieu Papaux wrote:
Hi Olaf,

Now I see your problem but a solution is to use the Label and The caption for the numerical input and work with this...
I think there is no other way to do that...

Let me know what do you mean or if you have another solution...

Best Regards...

Matthieu





Obtaining the labels is no problem, that already works in my code,  but I need to use physical units for some other reasons so I cannot mimick that with using captions instead.

Olaf
0 Kudos
Message 10 of 12
(3,611 Views)