LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I test for the bas unit enterd in a control?

Solved!
Go to solution

How can I to create a polymorphic vi where the user can enter either volume or temperature.

how can Labwiev test for the base unit entered

 

pseudocode example:

input X

if X.base_unit == m^3 do ....... 

 

thanks for any suggestion to resolve or avoid my problem

0 Kudos
Message 1 of 7
(2,999 Views)
The LabVIEW Help indicates how to deal with Polymorphic Units.
0 Kudos
Message 2 of 7
(2,983 Views)
I know this help page, but it doesen't seem to apply to my problem. I don't want to to the same thing for different units, but LV has to branch depending on the unit the user did enter.
0 Kudos
Message 3 of 7
(2,975 Views)
Solution
Accepted by topic author schaerm

Hi schaerm,

 

you have to dig deeper.

An idea is this one:

getunit.png

getunit_FP.png

The red marked word is containing the unit - in a coded way. Somewhere in the LV help you can find the description of this coding (I remember a chapter on memory representations of all LV datatypes...). (There surely is an easier or better way - but the example is done quic&dirty.)

 

You can also format the number into a string and analyze the unit here...

Message Edited by GerdW on 02-07-2010 07:21 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(2,969 Views)

Thank you GerdW!

The variant solution works perfect! 

 

(LV does not allow to format a number with unit to a string)

 

Best regards Mark 

0 Kudos
Message 5 of 7
(2,959 Views)

Hi schaerm,

 

"(LV does not allow to format a number with unit to a string)"

 

Ofcourse it does!

FormatStringUnit.png

(using a simple FormatIntoString...)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 7
(2,956 Views)

Sorry, I was testing the the wrong functions (number2nstring)

 

just getting tired

 

Best regards Mark 

0 Kudos
Message 7 of 7
(2,950 Views)