08-25-2023 05:10 AM
I am building a software where data production and data saving are done by two different actors in two separate libraries. For one acquisition line, Data is a collection of Digital values with different unit labels (GHz, V, degC, etc.). It is therefore not compatible with an array. I plan to collect the data in a cluster.
The actor responsible of saving the data in a file (number and unit) should cycle through the cluster, and should be able to do that for different data providers, so with number of data and units not defined in advance.
The property node of a reference to a Numeric control is able to recover the Value and UnitLabel.Txt. Above the propert node, data is recognized as "DigNum (strict)". If I cast the reference with "to more specific class" with "Digital", the displayed value is actually what is displayed in the box, not the real value with hidden digits, and there is no easy way to extract the unit.
Similarly, indexing a cluster with a reference does not allow to make a strict typecast do DigNum. Are there tools in Labview that I am missing? Are there easy way to do that?
Solved! Go to Solution.
08-25-2023 06:08 AM
Hi fb,
@fb35 wrote:
Are there tools in Labview that I am missing? Are there easy way to do that?
Did you try the GetNumericInformation function in the DataTypeParsing palette?
08-25-2023 04:40 PM
Units don't pass through wires, but physical quantities do.
You might find the attached files somewhat useful.
Unfortunately, the description out gives everything in terms of fundamental units;
so 'voltage' comes out as: (Length^2 * Mass) / (Time^3 * Electric Current)
08-28-2023 03:36 AM
It would help us help you if you simply posted a VI...
And if you post images, embed them:
You're not really stating what your goal is...
I suppose you have a few options if you do something like this:
08-28-2023 08:01 AM - edited 08-28-2023 08:28 AM
From the FP I can infer somethings.
Yes, the Unit MHz lost the Prefix (choosing a format specifier as "%u" an a unit of Hz would help there)
The Temperature... Changes from DegC to the base CDeg. That will require adding some code to r8ecast the value. Not sure how to do that 🤔 You might try adding or subtracting 0CDeg.
There are some wildcard unit specifiers (I Read about them in the Help File! Years ago!!!) They worked for the limited case I need a working solution for. Then I PROMPTLY filled up the office "swear jar" and tried to forget Units for a while.
Regardless, you need to recover not 1, but 2 data values. The Unit as String and the Unit Prefix as string. Then reapply the Unit Label for a simplex Unit Label. A working solution will take longer if you're working with mW/M^3*sec (That'll be a "moment" <groan at bad pun>) so, you really need Units[] Prefixes[] Operands[] and Constants[]
08-29-2023 08:27 AM
I found a solution using OpenG. Variants with type "double float with unit" are known also as "Double precision physical quantity" is the "type descriptors" in labview online documentation.
It is possible to extract the value and the units. Units can be simplified (for examples "lm" instead of "sr cd", "W" instead of "s^-3 m^-2 kg^-1).
Conversions from Cdeg to degC still to be done.
Library with tools and test files attached.
08-30-2023 02:38 AM - edited 08-30-2023 02:41 AM
@fb35 wrote:
I found a solution using OpenG. Variants with type "double float with unit" are known also as "Double precision physical quantity" is the "type descriptors" in labview online documentation.
It is possible to extract the value and the units. Units can be simplified (for examples "lm" instead of "sr cd", "W" instead of "s^-3 m^-2 kg^-1).
Conversions from Cdeg to degC still to be done.
Library with tools and test files attached.
So it's not the unit but the quantity ("physical group") that's in the wire.
The unit (e.g. kg, m) is how the quantity (weight, length) is visualized.
To get the unit you'd need a reference to the control or indicator, because the unit simply is not in the data type ('wire'). The quantity is. And it's the quantity what makes the wire break if it doesn't match, not the unit.
Still not sure what the end goal is (as you never told us)...
08-30-2023 09:22 AM
For a variant of "double precision physical quantity" (also double with unit) has a type that is indeed in the type.
To visualise the type, with right click on the variant display select "show type".
The unit is visible in the "type descriptor". This is also stated in the "type descriptor" page : the type descriptor for a double is a length, "xx1A" (reserved), the number of base units (rad, sr, s, m, kg, A, K, mol, cd) in the unit, and a sequence of units with power, as seen by the OpenG "Get PhysicalUnits_ogtk.vi". Since the variant knows only the unit in base units, this is the display that is capable of reconstructing a "standard" unit. Unfortunately this capability is not offered to the standard labview user :
Different numerical values with different units have therefore different types, hence the "wire breaking" when ones tries to connect to such quantities.
08-30-2023 09:31 AM
I’m sorry to not have made the goal clearer.
In my application, I have objects that provide the data (measurements) in form of values with units.
The data provider should not care of what is the data to be saved, in which format, etc.
Thus a measurement is a collection of numbers, gathered in a cluster (in an array, all data should have the same unit), for example :
That data should be read as a variant, with no a-priori on the number of data and units.
08-30-2023 09:34 AM
@fb35 wrote:
Unfortunately this capability is not offered to the standard labview user :
That's one reason why nobody ever uses units 😁 .
I actually use them to convert the prefix (/1000, X1000, X1000000 etc.), the user fills in mm, m are stored. The unit could as well be mg, it's just the factor that I use. Although I use it at one place to show inches and store meters.
Using units like this, I don't need to programmatically access the units at all. It saves me the hassle of manually scaling the user input though.