08-03-2012 01:07 PM
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)
Using Flatten to XML will return the private data as long as data is defined in the class:
Any help would be greatly appreciated!
-Ryan
(Using LV2011)
08-03-2012 01:13 PM
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...
08-03-2012 02:07 PM
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.
08-03-2012 02:17 PM
Yeah, that would be kinda neat, but I'm sorry - I don't think you can.
08-03-2012 06:11 PM
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.
08-03-2012 09:17 PM
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
08-04-2012 12:13 PM
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)
08-06-2012 01:31 PM
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'.
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?
08-06-2012 06:05 PM
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))
An example project for testing this functionality in the run-time environment can be found at: LVClass Private Data as Variant in Run-Time
08-12-2012 09:36 PM
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?