Finding out LabVOOP object runtime class
#1
Posted 04 December 2006 - 10:57 AM
-jimi-
#2
Posted 04 December 2006 - 12:23 PM
With OpenG' Data tools, you can have maybe these informations formated into String.
#3
Posted 04 December 2006 - 05:00 PM
Those tools won't tell you about a LVClass. They predate LVClasses. Unless someone has issued a patch that I don't know about.You can convert LabVOOP wire to variant (To Variant function). It gives information on type and value (check show type on Variant indicator).
With OpenG' Data tools, you can have maybe these informations formated into String.
#4
Posted 04 December 2006 - 05:29 PM
You are correct. The OpenG variant tools do not yet handle LVClass.Those tools won't tell you about a LVClass. They predate LVClasses. Unless someone has issued a patch that I don't know about.
#5
Posted 04 December 2006 - 07:22 PM
#6
Posted 04 December 2006 - 07:45 PM
Does anybody know how to interpret the type string output of "Variant To Flattened String" node when a class is connected to the variant input?
Yes, Stephen knows, I'm sure
It probably wouldn't take a whole lot of
#7
Posted 04 December 2006 - 08:12 PM
I just wonder if there are many special cases that may affect the type string such as the class belonging to a library or the class being derived from another class etc. And later on when there are classes implementing interfaces and such the code should still work, and it may not if we are not certain about the special cases.It probably wouldn't take a whole lot of
reverse engineeringthoughtful inspection to figure it out.
#8
Posted 04 December 2006 - 09:09 PM
I just wonder if there are many special cases that may affect the type string such as the class belonging to a library or the class being derived from another class etc. And later on when there are classes implementing interfaces and such the code should still work, and it may not if we are not certain about the special cases.
My guess (I haven't tested anything, yet) is that the type descriptor of an lvclass only references it by name and you will need to open a VI server reference to the .lvclass, in order to get all the nitty gritty info.
#9
Posted 04 December 2006 - 10:14 PM
But you don't know the path to the class by just knowing the in memory name. And there is not such a scripting property I know of that would return "All Classes in Memory". Of course you can get "All VIs in memory" and then try to figure out which class each VI belongs and store them to some sort of set of all classes and then you can compare your class agains all the classes in the "set of all classes"... well complicated. Anyhow for my purposes I just would like to use the class name in a indicator that would be able to show at least some information of all the classes...My guess (I haven't tested anything, yet) is that the type descriptor of an lvclass only references it by name and you will need to open a VI server reference to the .lvclass, in order to get all the nitty gritty info.
Hmmm... there is this probe for objects. I wonder if it's implemented in pure G and if the block diagram is not locked...
#10
Posted 04 December 2006 - 10:55 PM
But you don't know the path to the class by just knowing the in memory name. And there is not such a scripting property I know of that would return "All Classes in Memory". Of course you can get "All VIs in memory" and then try to figure out which class each VI belongs and store them to some sort of set of all classes and then you can compare your class agains all the classes in the "set of all classes"... well complicated. Anyhow for my purposes I just would like to use the class name in a indicator that would be able to show at least some information of all the classes...
Hmmm... there is this probe for objects. I wonder if it's implemented in pure G and if the block diagram is not locked...
Jim is correct the type string and the data string both just contain the class name (which can easily be extracted). To get a VI reference, just build the private data cluster (which must be in memory). My example is "TestClass.lvclass:TestClass.ctl". From here you can get the path and even the private data cluster.
Download File:post-987-1165272751.vi
Download File:post-987-1165272777.vi
Download File:post-987-1165272895.zip
(*.lvclass extension is not allowed?)
Brian
#11
Posted 04 December 2006 - 11:13 PM
But you don't know the path to the class by just knowing the in memory name. And there is not such a scripting property I know of that would return "All Classes in Memory". Of course you can get "All VIs in memory" and then try to figure out which class each VI belongs and store them to some sort of set of all classes and then you can compare your class agains all the classes in the "set of all classes"... well complicated. Anyhow for my purposes I just would like to use the class name in a indicator that would be able to show at least some information of all the classes...
Hmmm... there is this probe for objects. I wonder if it's implemented in pure G and if the block diagram is not locked...
Here is a tool that should work (I just whipped it up). It depends on the OpenG oglib_lvdata library. After some testing and clean-up, I'll add it to the oglib_lvdata library.
Cheers,
-Jim
Download File:post-17-1165273923.zip
#12
Posted 04 December 2006 - 11:27 PM
Thanks. I try these out tomorrow, it's getting late here. Did you try if your solutions work if the class is embedded into a library i.e. the name is something like this: MyLib1.lvlib:MyLib2.lvlib:MyClass3.lvclass?
#13
Posted 05 December 2006 - 12:52 AM
Brian and Jim,
Thanks. I try these out tomorrow, it's getting late here. Did you try if your solutions work if the class is embedded into a library i.e. the name is something like this: MyLib1.lvlib:MyLib2.lvlib:MyClass3.lvclass?
Yes, the type string contains the full Library path (TestLibrary.lvlib:TestClass.lvclass) so just add ":TestClass.ctl" and Open VI reference works just as before.
#14
Posted 05 December 2006 - 03:20 AM
Jim: Test cases would be a simple class, a class owned by another library and the all important LabVIEW Object class. LVObject is actually encoded slightly different to guarantee that even if you clever users try to name a class "LabVIEW Object" that we can still distinugish the real LV Object class. The encoding for most classes is:Here is a tool that should work (I just whipped it up). It depends on the OpenG oglib_lvdata library. After some testing and clean-up, I'll add it to the oglib_lvdata library.
Cheers,
-Jim
name = length | cpstrlist
cpstrlist = [lenghth | text]+
length = a single character (byte)
(where | means "followed by" and + means "repeat one or more times as needed)
The encoding for LabVIEW object is simply
name = length | "LabVIEW Object"
#15
Posted 05 December 2006 - 03:32 AM
#16
Posted 28 January 2007 - 03:40 PM
What do bytes 08-11 in type string of a LVClass mean? The bytes get a hex value 0xFFFFFFFF for LabVIEW Object but the value for other labview classes varies. The variation does not depend on the class but something else. Does this somehow refer to the current application instance or has anyone figured out the meaning of these bytes? The indexes above are assumed to start from zero i.e. byte 08 is the 9th byte in the type string.LVObject is actually encoded slightly different to guarantee that even if you clever users try to name a class "LabVIEW Object" that we can still distinugish the real LV Object class. The encoding for most classes is:
name = length | cpstrlist
cpstrlist = [lenghth | text]+
length = a single character (byte)
(where | means "followed by" and + means "repeat one or more times as needed)
The encoding for LabVIEW object is simply
name = length | "LabVIEW Object"
The first two bytes define the length of the type string in a big-endian form. The bytes 02-07 are always the same for all LabVIEW classes and I assume these refer to LabVIEW classes in general. The type string for these bytes seems to be always 0x4070001E0000.
#17
Posted 06 February 2007 - 01:22 PM
What do bytes 08-11 in type string of a LVClass mean? The bytes get a hex value 0xFFFFFFFF for LabVIEW Object but the value for other labview classes varies. The variation does not depend on the class but something else. Does this somehow refer to the current application instance or has anyone figured out the meaning of these bytes? The indexes above are assumed to start from zero i.e. byte 08 is the 9th byte in the type string.
The first two bytes define the length of the type string in a big-endian form. The bytes 02-07 are always the same for all LabVIEW classes and I assume these refer to LabVIEW classes in general. The type string for these bytes seems to be always 0x4070001E0000.
Looks suspiciously like the 16bit typestring array in older Flatten to String functions. The first word 0x4070 is the actual type with the higher 8 bits being flags such as indicator/control etc, and 0x70 being the typecode for any LabVIEW refnum. Then follows a refnum type word and after that a variant (C union, not LabVIEW variant) construct depending on the refnum type. 0x001E seems to be the refnum type for LabVIEW classes. 0x0008 is for all kind of VI server refnums for instance.
Rolf Kalbermatter
Rolf Kalbermatter
CIT Engineering Netherlands
A division of Test & Measurement Solutions
#18
Posted 06 February 2007 - 04:44 PM
Looks suspiciously like the 16bit typestring array in older Flatten to String functions. The first word 0x4070 is the actual type with the higher 8 bits being flags such as indicator/control etc, and 0x70 being the typecode for any LabVIEW refnum. Then follows a refnum type word and after that a variant (C union, not LabVIEW variant) construct depending on the refnum type. 0x001E seems to be the refnum type for LabVIEW classes. 0x0008 is for all kind of VI server refnums for instance.
Rolf is correct. LVClasses are not refnums, but internally I borrowed some of their syntax and it was easiest to make them a (get this) "by value form of refnum." That's not as much of a hack as it sounds -- refnum is sort of a misnomer at this point, and internally refnums would be better named as "any data type with a hierarchy". I wasn't even the first to use a by-value hierarchy -- credit for that goes to one of the DAQ groups.
Bytes 8 thru 11 are a hex value that indicates which application instance this LV class is loaded in. It will be different every time the class loads into memory (and is ignored when flattening/unflattening to disk). Notice that I could have Alpha.lvclass loaded into one application instance which has as its private data two ints. In another application instance I could have a different Alpha.lvclass that has a string. The name of the class is not enough to distinguish the datatype -- we need to know which context to look at. The FFFFFFFF for LabVIEW Object is a special code for "union of all app instances" -- I only have a single instance of LabVIEW Object class that is used by all app instances. Occassionally you will see values other that FFFFFFFF in a LV Object type descriptor when data from a specific class has been upcast onto an LVClass wire.
There's also 4 bytes for flags. This is pretty much left as room for future expansion of the data type. It's a reflex of mine -- when building something that will be very hard to mutate and where the penalty for bad design could have effects lingering for generations, leave yourself some extra bits to encode mutation. ;-)
#19
Posted 06 February 2007 - 06:26 PM
Tomi
#20
Posted 16 February 2007 - 04:38 PM
Tomi












