LabVIEW Development Best Practices Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

LVClass Private Data Reference in Run-Time

Is there a method/property to get a reference to the private class data cluster in the run-time environment (i.e. executables)?

You can do this through scripting in the development environment but it does not work in a run-time system. (shown below)

Get Private Class Data Refnum.png

Using Flatten to XML will return the private data as long as data is defined in the class:

Get Private Class Data XML.png

Any help would be greatly appreciated!

-Ryan

(Using LV2011)

0 Kudos
Message 1 of 29
(13,782 Views)

Not that I know of, altough I'm awfully interested in why you want it. Are you just looking for the datatype of an element? Or are you trying to change it?

Yes, you can get the value (or, at least, the string representation of the value) using Flattern to XML, but the more appropriate way to ge the actual data, of course, is through an accessor method...





Copyright © 2004-2018 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
0 Kudos
Message 2 of 29
(2,367 Views)

Hi Chris,

I'm only interested in getting the data types and properties set within the private class cluster (such as control descriptions, ranges, etc.). Rather than creating an accessor/dynamic dispatch VI for every message in the actor framework, I would like the ability to get the properties programmatically.

0 Kudos
Message 3 of 29
(2,367 Views)

Yeah, that would be kinda neat, but I'm sorry - I don't think you can.





Copyright © 2004-2018 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
0 Kudos
Message 4 of 29
(2,367 Views)

Ryan Pacini wrote:

Rather than creating an accessor/dynamic dispatch VI for every message in the actor framework, I would like the ability to get the properties programmatically.

An accessor method is how you get the properties programmatically. Making object properties truly private was a design decision that can't be circumvented. Fortunately, the default wizard for creating accessors from defined properties allows you to select all properties and quickly generate Read/Write VIs for each of them. It shouldn't take more than 30 sec to create and save a batch of accessor methods for each class you design. You can probably make a custom script that runs headlessly to make it even easier.

0 Kudos
Message 5 of 29
(2,367 Views)

DavidStaab wrote:

An accessor method is how you get the properties programmatically. Making object properties truly private was a design decision that can't be circumvented. Fortunately, the default wizard for creating accessors from defined properties allows you to select all properties and quickly generate Read/Write VIs for each of them. It shouldn't take more than 30 sec to create and save a batch of accessor methods for each class you design. You can probably make a custom script that runs headlessly to make it even easier.

I think what Ryan was after was not something to get all the property values, but just the datatypes. I'm guessing h wants a generic VI that will work on all classes at runtime.

PS: cool link to the LabVIEW Object-Oriented Programming: The Decisions Behind the Design document - I hadn't seen that before





Copyright © 2004-2018 Christopher G. Relf. Some Rights Reserved. This posting is licensed under a Creative Commons Attribution 2.5 License.
0 Kudos
Message 6 of 29
(2,367 Views)

Hi David,

When I talk about a 'property' of a control, I mean the VI Server Property such as description, tip strip, label text, range, etc.

Is there a way to extract VI Server properties of a private class control using LVClass accessors? (that can also run in executables)

0 Kudos
Message 7 of 29
(2,367 Views)
Highlighted

Some of what you're asking for is available in run-time, but not all. 

The reason for this is because the front panel of the class control is not included in the built executable (nor can you force it to be included, as far as I know).

The trick to getting the available information (data types, default values, text labels), is knowing that although the class control doesn't exist on disk, it does exist in memory as long as the class is loaded. You can obtain a reference to it just as you would any ctl in memory - using Open VI Reference.  To open it, wire (as a string) 'classname.lvclass:classname.ctl' to Open VI Reference.

Running in development, you can use property nodes to access 'Panel' then 'Controls[]' (same as your solution above, without requiring scripting)... but this won't work in run time since the front panel can't be included.

What you can do in runtime, is use the VI Server Method 'Control Value >> Get' to get the control value as a variant.  Hint: the name of the control (if you haven't modified it) will be 'Cluster of class private data'.

LVClassPrivDataInRunTime.png

From here you can use flatten to XML, then do some string parsing to get basic information.

I can't think of many use cases for this, but I think that what Ryan is attempting is legit.

For a long time I've considered this a secret little nugget of mine. 

Were other people aware of this solution?

Message 8 of 29
(2,367 Views)

Thanks for the example, it's a starting point. I overlooked the fact that the Control VI is still loaded in memory without its FP. Bellow is a VI snippet that also handles nested classes in libraries (for use within Libraries (*.lvlib) and Packaged Project Libraries (*.lvlibp))

Get Private Class Data Variant.png

An example project for testing this functionality in the run-time environment can be found at: LVClass Private Data as Variant in Run-Time

0 Kudos
Message 9 of 29
(2,367 Views)

What in the world are you trying to do? You do realize that this will get the properties of the class, but not for a particular object, right?

0 Kudos
Message 10 of 29
(2,367 Views)