LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the configuration of a FXP number via property nodes or other methods.

Hello all,

I am attempting to store in plain-text the value and configuration specifics of the LV FXP datatype. (please do not suggest I cast it to integer).

The ini config format does not support FXP. So we'd like to; using property nodes, interrogate the specifics of a FXP numeric control on the FP.

It appears this is not exposed by control ref's and property nodes.
Oddly enough, you cannot even interrogate the detailed type of an INT if it is a U8, I8 or I16 etc?! via property nodes, the deepest you can go is 'digital'.

Specifically, you need to know the following to 'reconstruct' a FXP:
1. Value
2. Signed\unsigned
3. Word length
4. Integer word length

Without this, there is a risk of corrupting the value during conversion.i.e we want to load initial FXP from disk at application startup. This is a critical application and we cannot tolerate rounding\conversion errors accumilating with numerous reads\writes of FXP settings.

 

It is odd that you cannot interrogate via property nodes the details of a numeric type. ie. you cannot 'discover' via the property node of an INT if it is a U8, I8 or any other type.


Regards
Jack Hamilton

PS: Don't suggest XML either....

0 Kudos
Message 1 of 13
(3,842 Views)

You can get information about the type of data stored in a numeric using functions in the VariantDataType library (vi.lib\Utility\VariantDataType).  For information about a fixed-point, use GetNumericFxpInfo.vi.

 

However, why is this necessary?  Why not simply use "Number to Fractional String" and "Fract/Exp String to Number" to convert to and from strings when writing and reading the ini file?  They can handle fixed-point values.  Also, if you're concerned about corrupting bits, make sure you write out a sufficient number of decimal places (you can calculate how many based on the number of fractional bits in the fixed-point value).

Message 2 of 13
(3,833 Views)

Getting this information from a control is a truly wrong way to go about it. The control/indicator is just a display. You want to get this information from the value that you wired in directly. So first get a strict control reference (if you do not see a gold star on the FP control/indicator, pop up on your control reference and select "Include Data Type"). Then use the Value property to read the value of the control, and then figure out how to save that value. Normally I would just suggest "wire it to Flatten To String" and then save the string into the config file, but I'm guessing there's something special that you're seeing with the fixed-point data type that keeps you from doing that. So instead, use various data manipulation functions (like the "Mantissa & Exponent" function) to get the parts that you need to save into the file and later reconstruct your number.

 

Now if you truly do not know the fixed-point type that you're harvesting such that you cannot get a strict control type, then you'll have to get the value as a variant and use the approach that nathand recommends. Either way, you don't want to work with the control/indicator as much as possible since that involves UI thread swaps and panel performance overhead. Use the value in the diagram whereever possible.

0 Kudos
Message 3 of 13
(3,818 Views)

Using string conversion you lose the actual 'configuration' of FXP, as there are several types.

 

For example, knowing a number is an INT, but wrongly converting it to a U8 when in fact it's holding a U16 value would result in a radically different value. Then your missle crashes into your grandma's home, etc...

 

There are several very specific type of FXP and converting without corruption is not simple. Read this NI white paper:


http://www.ni.com/white-paper/9221/en

 

..second post telling me the 'propertys' of a control have nothing to do with the value is bizzare - via 'properties' for a LV control is the ONLY way to configure the specific type of a numeric...so via the numeric 'property nodes' should\would be able to query it's configuration.

 

Gosh guys, this is like asking for directions to New Jersey and being told "You don't wanna go to New Jersey"... pls stay on topic and don't recommend I simply go around the issue. I don't post trivial questions.

 

Regards (been programming in LV for +23 years)

Jack Hamilton

0 Kudos
Message 4 of 13
(3,810 Views)

 

 

The Variant tools don't completely solve the problem. As when casting the Variant back to the value you need to 'prototype' the 'From Variant' function.

 

If you don't know the FXP type and use a different FXP prototype - the variant data will be converted to the prototype value, regardless of that actual variant descriptor, and since you cannot via property nodes or scripting, dynamically get\set these properties I don't immediately see how to do this elegantly.

 

Odd too, is the "Mantissa & Exponent' function which should describe the FXP quite well, does not handle FXP types...NI has some catching up to do.

 

Regards

Jack Hamilton

 

 

 

 

0 Kudos
Message 5 of 13
(3,807 Views)

@Alias name here wrote:

... 

Gosh guys, this is like asking for directions to New Jersey and being told "You don't wanna go to New Jersey"... pls stay on topic and don't recommend I simply go around the issue. I don't post trivial questions.

 

Regards (been programming in LV for +23 years)

Jack Hamilton


If nathand and Aristos answers are not what you wanted to read, what was it you wanted to read?

 

I am at a loss for what to tell you.

 

Give us a hint and maybe we can figure something out.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 13
(3,806 Views)

Alias name here wrote:

..second post telling me the 'propertys' of a control have nothing to do with the value is bizzare - via 'properties' for a LV control is the ONLY way to configure the specific type of a numeric...so via the numeric 'property nodes' should\would be able to query it's configuration.


I do not see any way to set these things through the properties...

Untitled.png

0 Kudos
Message 7 of 13
(3,803 Views)

Wait... you're talking about the Property Dialog. Ah.

 

Yes, the editor has support for modifying the configuration of the numerics for fixed point. The execution system does not. I'm guessing the feature just wasn't added by the people who wrote fixed point.

0 Kudos
Message 8 of 13
(3,799 Views)

@Aristos Queue wrote:

Alias name here wrote:

..second post telling me the 'propertys' of a control have nothing to do with the value is bizzare - via 'properties' for a LV control is the ONLY way to configure the specific type of a numeric...so via the numeric 'property nodes' should\would be able to query it's configuration.


I do not see any way to set these things through the properties...

 


I think he means by right clicking the control on the front panel and configuring with the properties dialog. The properties are exposed there, but not within the property nodes.

 

Edit: You beat me.

0 Kudos
Message 9 of 13
(3,796 Views)

I agree it appears the FXP point datatype is not completely supported yet. As discovered, by my numerous attempts to perform some fundamental operations and interrogations on the datatpes.

 

Here is what I want to do: load a FXP from file in a human readable format. Config.ini is our preferred format. I would be happy to create my own FXP Sections with several keys that describe the FXP details, using Variant.

 

This is also a sbRIO system with FPGA, so I need the FXP datatype native support.

 

Why am I stuck on FXP?, because this system software must be validated and there will be questions as to why the value is stored as float, then converted to FXP by the code. During validatation it will have to be proved, it was converted correctly. Having done validatations, this can be hard to prove with 'just because, as good as, the same as arguments'.

 

The simplest way to do this is to store the number plainly as FXP and then display the FXP...Am I asking too much ?

 

Regards

Jack Hamilton

0 Kudos
Message 10 of 13
(3,790 Views)