Check out our VI Scripting Code Repository Files and visit the LabVIEW Wiki VI Scripting article
Tags |
(This content has not been tagged yet)
|
![]() |
Apr 11 2004, 06:47 AM
Post
#1
|
|||
![]() Confucius say: Crowded elevator always smell different to midget Admin ![]() Posts: 2402 Joined: 13-October 02 From: Planet Earth Member No.: 2 Using LabVIEW Since:1994 LV:8.5 ,8.2.1 ,7.1.1
My Blog
My Gallery
|
Well, a very BIG thank you to PJM for this post! He's opened up a whole can of worms. I immediately started diving into the different classes and tried to figure out the hierarchy. Now I can finally get the feature I knew NI would never add to LabVIEW. I think our wish list will slowly disappear since if we need something we can just program it ourselves.
I always wanted to have LabVIEW automatically color my diagram a slight shade of grey. But I also wanted every other structure to have white. So you would end up with grey-white alternating. Well, I just created a VI to do this! The process of building this VI was fascinating. It turns out that the VI diagram reference is only useful for listing diagram objects outside of structures. If you want to explore objects inside of structures then you must get a diagram reference to each structure. In addition, each frame of a structure requires another diagram reference. A simple comparison can be made between this and nested clusters in controls on the front panel. Of course this could only be resolved with recursion. I've attached the complete code that does this. By the way, If you don't need alternating colors then just make both colors the same. Hmmm.... what should I create next.
Attached File(s)
-------------------- Thank You
Michael Aivaliotis - Follow me on Twitter - My Personal Blog Search the LabVIEW Web - Build the LabVIEW Web - Got VIPM? ![]()
|
||
|
|
|||
| Ad |
Apr 11 2004, 06:47 AM
Post
#
|
||
|
|
|
||
|
|
|||
Apr 11 2004, 05:41 PM
Post
#2
|
|||
![]() Extremely Active JKI ![]() Posts: 624 Joined: 19-June 03 From: Bay Area, CA (USA) Member No.: 121 Using LabVIEW Since:1998 LV:8.5.1 ,8.6 ,8.2.1
My Blog
|
Hi Michael
That utility was far on my todo list but it was there. Thanks for shorting my list ! QUOTE Well, a very BIG thank you to PJM for this post! He's opened up a whole can of worms. I immediately started diving into the different classes and tried to figure out the hierarchy. Now I can finally get the feature I knew NI would never add to LabVIEW. I think our wish list will slowly disappear since if we need something we can just program it ourselves. You are welcome. This scripting is indeed extremely usefull.QUOTE It turns out that the VI diagram reference is only useful for listing diagram objects outside of structures. If you want to explore objects inside of structures then you must get a diagram reference to each structure. In addition, each frame of a structure requires another diagram reference. A simple comparison can be made between this and nested clusters in controls on the front panel. This was indeed what did stop me initially, but once I recognize (like you did) that a diagram is very similar to a giant cluster, I went on writing my own recursive VI to get different type of objects on the diagrams (such as Functions, SubVi, Diagram, Wire, Decoration, All Objects ). Since my grasp of recursion using Call by ref is weak, I wrote a recursive VI using a while loop (see Attached image). Also, I notice the following class hierarchy (can simplify the recursion): Structure [downcast to = (-->) ] -->MultiFramStructure ------>EventStructure ------>CaseSelector ------>Sequence Loop -->WhileLoop ------>TimedLoop (Whatever it is) -->ForLoop FlatSequence is alone (downcast to nothing) So really, when trying to get for example "All Objects" one does have to recursively check only for Structure, Loop and FlatSequence. QUOTE Hmmm.... what should I create next. There are actually so many things that can be done with it, that it is quite hard to select what to try next --------------------
|
||
|
|
|||
Apr 11 2004, 06:31 PM
Post
#3
|
|||
|
Changing the world, one VI at a time. JKI ![]() Posts: 1717 Joined: 22-October 02 From: San Francisco, CA Member No.: 17 Using LabVIEW Since:1995 LV:8.2.1 ,8.5 ,7.1.1
My Blog
My Gallery
|
One, "next step", that I suggest is a VI that outputs the inheritance hierarchy of a specific class. This can be represented as a path or and array of strings. The inheritance hierarchy of all VI Server objects could be stored (inside the VI) in a linked list. From this, one could populate a Tree Control with the structure of the VI Server inheritance hierarchy as well as doing more functional programming tasks.
I propose that these utilities and type definitions be organized in an OpenG package so that we can more easily collaborate and use the utilities. For example, I would like to create an OpenG package that puts the "New VI Object" and "Open VI Object Reference" (as well as some other recently discovered tools) into the palettes for easy access. --------------------
|
||
|
|
|||
Apr 11 2004, 06:56 PM
Post
#4
|
|||
![]() Extremely Active JKI ![]() Posts: 624 Joined: 19-June 03 From: Bay Area, CA (USA) Member No.: 121 Using LabVIEW Since:1998 LV:8.5.1 ,8.6 ,8.2.1
My Blog
|
Hi Jim,
QUOTE One, "next step", that I suggest is a VI that outputs the inheritance hierarchy of a specific class. This can be represented as a path or and array of strings. The inheritance hierarchy of all VI Server objects could be stored (inside the VI) in a linked list. From this, one could populate a Tree Control with the structure of the VI Server inheritance hierarchy as well as doing more functional programming tasks. QUOTE I propose that these utilities and type definitions be organized in an OpenG package so that we can more easily collaborate and use the utilities. For example, I would like to create an OpenG package that puts the "New VI Object" and "Open VI Object Reference" (as well as some other recently discovered tools) into the palettes for easy access. Sure, I am willing to donate what I have wrote so far to the OpenG community. PJM --------------------
|
||
|
|
|||
Apr 11 2004, 07:14 PM
Post
#5
|
|||
|
Changing the world, one VI at a time. JKI ![]() Posts: 1717 Joined: 22-October 02 From: San Francisco, CA Member No.: 17 Using LabVIEW Since:1995 LV:8.2.1 ,8.5 ,7.1.1
My Blog
My Gallery
|
Well, there are only 88 Private Classes so how long could it take? Let's see... 88! = 1.855e+134. But, I bet if we apply a little logic it shouldn't take quite that long
And, I bet that with the scripting tools that are exposed you can even create an "intelligent brute-force" utility that writes the "to more generic class" conversion and then runs it to test to see if it is valid. For example, start with any object and try to convert its reference type to a more specific class over all object classes. The types that do not result in an error are ancestors. Now perform the same test within (and only within) this set of ancestors to determine the inheritance hierarchy. Once these ancestors are determined, you no longer need to determine them. So, the tree structure can be generated dynamically and efficiently. One caveat... when you do the object typecast test you must be referring to a valid VI Server object, not just a null object that flows out of a Class Specifier Constant. --------------------
|
||
|
|
|||
Apr 11 2004, 08:31 PM
Post
#6
|
|||
![]() Extremely Active JKI ![]() Posts: 624 Joined: 19-June 03 From: Bay Area, CA (USA) Member No.: 121 Using LabVIEW Since:1998 LV:8.5.1 ,8.6 ,8.2.1
My Blog
|
QUOTE (Jim Kring @ Apr 11 2004, 01:14 PM) One caveat... when you do the object typecast test you must be referring to a valid VI Server object, not just a null object that flows out of a Class Specifier Constant. Jim, Actually I just remember that the "to more generic class" has broken wire if one does not wire the appropriate class (in the appropriate "order"). So this way it should not be necessary to get a reference to the a valid VI server Object. To find out if a wire is broken or no, one just have to invoke the run method and a broken wire should return an error (Wire conflict probably). PJM --------------------
|
||
|
|
|||
Apr 11 2004, 08:51 PM
Post
#7
|
|||
|
Changing the world, one VI at a time. JKI ![]() Posts: 1717 Joined: 22-October 02 From: San Francisco, CA Member No.: 17 Using LabVIEW Since:1995 LV:8.2.1 ,8.5 ,7.1.1
My Blog
My Gallery
|
Actually, I think that you don't need to run the VI. You should be able to interogate the state/type of the wire to determine if is is (un)broken.
--------------------
|
||
|
|
|||
Jan 24 2005, 08:12 PM
Post
#8
|
|||
![]() Active Member Posts: 14 Joined: 4-December 04 From: Boston, Massachusetts Member No.: 1180 Using LabVIEW Since:1993 LV:7.1.1 ,7.0 ,8.5
|
So, guys, does a hierarchical list of class specifier constants exist yet? I couldn't find it on the site.
Specifically, I'm currently looking for the highest levels at which I can elicit the Label.Text property. --------------------
|
||
|
|
|||
Jan 25 2005, 12:00 AM
Post
#9
|
|||
![]() Extremely Active JKI ![]() Posts: 624 Joined: 19-June 03 From: Bay Area, CA (USA) Member No.: 121 Using LabVIEW Since:1998 LV:8.5.1 ,8.6 ,8.2.1
My Blog
|
QUOTE (SULLutions @ Jan 24 2005, 02:12 PM) So, guys, does a hierarchical list of class specifier constants exist yet? I couldn't find it on the site. Specifically, I'm currently looking for the highest levels at which I can elicit the Label.Text property. I believe this this what you are looking for. Note: this is for labview 7.0. New classes have been introduced in 7.1, but the end result is similar. If people are interested, I can post the code for 7.1. PJM --------------------
|
||
|
|
|||
Jan 25 2005, 12:27 AM
Post
#10
|
|||
![]() Active Member Posts: 14 Joined: 4-December 04 From: Boston, Massachusetts Member No.: 1180 Using LabVIEW Since:1993 LV:7.1.1 ,7.0 ,8.5
|
QUOTE (PJM_labview @ Jan 24 2005, 07:00 PM) I believe this this what you are looking for. Thanks, PJM, that is exactly what I needed. --------------------
|
||
|
|
|||
Jan 30 2005, 04:45 PM
Post
#11
|
|||
![]() Active Member Posts: 14 Joined: 4-December 04 From: Boston, Massachusetts Member No.: 1180 Using LabVIEW Since:1993 LV:7.1.1 ,7.0 ,8.5
|
PJM,
QUOTE This was indeed what did stop me initially, but once I recognize (like you did) that a diagram is very similar to a giant cluster, I went on writing my own recursive VI to get different type of objects on the diagrams (such as Functions, SubVi, Diagram, Wire, Decoration, All Objects ). In the thumbnail attached to this post, there is an apparent OpenG Scripting palette. I can't find it on this or the OpenG site. Is it available? This post has been edited by SULLutions: Jan 30 2005, 04:49 PM --------------------
|
||
|
|
|||
Jan 31 2005, 02:04 AM
Post
#12
|
|
![]() Confucius say: Crowded elevator always smell different to midget |