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: 

Getting object by having GObject Refnum values

Solved!
Go to solution

Hi all,

 

I am trying to produce a XML file which contains all the objects(controls and Indicators) information. I have an array of all the GObject Refnums using Property Node, but I need to get objects out of these references. Does anyone have an idea how can I do that?

 

Thanks

Pari sa

Message 1 of 11
(4,237 Views)

No one???

Does anyone know how to get object, let us say control having its reference??

 

Any help is appriciated...

 

Pari sa

0 Kudos
Message 2 of 11
(4,211 Views)

You need the 'to more specific class' cast prim. Then check for all possible classes, and if you have no error, process the properties of the more specific class. Then do this again for the even more specific types and recurse through the tree.

There is also a property that gives you the class name, but then you only have the most specific class and not the traversion through the tree -> you'd need a lot of duplicate code.

 

Felix

0 Kudos
Message 3 of 11
(4,205 Views)

Hey Felix,

 

thanks for your response. What about the output of 'to more specific class'? I have again a refnum!!!!! I need the object to pass it to the 'Flatten to XML'...

 

Pari sa

0 Kudos
Message 4 of 11
(4,199 Views)

What exactly are you trying to pass to the Flatten to XML?

 

You normally take a reference, feed it into a property node or invoke node, and read or write the properties you need, or use whatever method you need if you are acting on the object with the invoke node.

 

Remember, the refnum is just a number that gets generated at runtime to distinguish the different objects from each other.  The to more specific class takes a refnum and says "this is not just a control object but more specifically a numeric control" so that when you wire the refnum into a property node or invoke node structure, LabVIEW knows what kinds of properties and methods to make available to you.

0 Kudos
Message 5 of 11
(4,195 Views)

Try this:

 

1.) Use the Controls[] Property instead of All Objects[] so you can avoid To More Specific Class

2.) For each control reference (ie. For Loop) use the Value property, this will be a Variant which can be passed straight to Flatten To XML

 

 

0 Kudos
Message 6 of 11
(4,189 Views)

Hey all,

 

I want to convert a VI to an XML file. Wiring a control to Flatten to XML, I will have sth like:

<DBL>
<Name>TestNum</Name>
<Val>0.00000000000000</Val>
</DBL>

 

I want to have same information for all of the exsiting controls and indicators in the VI, putting them together and produce the XML file. With the help of Property Node I get an array of all of the existing objects... but an array of refnums...

Using Value property does not help either as it has only the Val information. Any other ideas?!?!

 

Cheers,

Pari sa

0 Kudos
Message 7 of 11
(4,154 Views)

Hi,

 

have a look at this code. I guess you can format this outputs into XML and do what you want. Below is also attached the png as snip it for LabVIEW 2009.

 

LabVIEW 2010 Code

 

Regards

TomBaum

0 Kudos
Message 8 of 11
(4,124 Views)
Solution
Accepted by topic author pari sa

I don't know what you mean by Value Property has only the Val information, if you follow my instructions you see that the Value is a variant with all of the info you get by wiring the control directly, with a little extra since it is wrapped in a variant.  See example where I also show a quick way to remove the variant wrapper which helps readability, but I would skip this if you want to read the file later and reverse the process.

 

ControlsToXML.png

0 Kudos
Message 9 of 11
(4,102 Views)

Hey all,

 

thanks for your responses. Finally I have an XML file containing all the Control objects in the VI!

The last problem is that, is there any way to differentiate in the xml file between Controls and Indicators???

 

Cheers

Pari sa

0 Kudos
Message 10 of 11
(4,085 Views)