05-05-2011 07:49 AM
LV 2010
I'm new at using subpanels, but here's a situation where they solve my problem (since LV refuses to allow a TAB control within a cluster - arrgh).
I have a TypeDef. It's a cluster with indicators and graphs, describing a page to be printed.
One section of that is an instance of another TypeDef. (call it "X")
Because this section changes, according to what kind of file I'm dealing with, I want to display one of about five sets of info here.
A tab control would do it, but I can't have one within a cluster.
According to the HELP about SubPanels:
you cannot create an array of subpanel controls, and you cannot create a type definition of a subpanel control. You can place a subpanel control in a cluster to group the subpanel control with other controls, but the cluster cannot contain only a subpanel control or controls. --- So, I put a STRING and a STRING and a SUBPANEL in the X TypeDef. I put an instance of X on a new front panel.
According to the HELP: LabVIEW creates an Invoke Node on the block diagram with the Insert VI method selected.
Well, it doesn't do that if it's a TypeDef. Placing an instance of "X" on a panel doesn't do anything special.
So I get the CONTROLS[ ] property of the instance, select out item 2 (0, 1, 2), typecast it to a SubPanel reference, and then I can use the INSERT VI and it works.
But I want to have the subpanel be item #0, so that I can find it in multiple situations: In one case, I might have two strings and a subpanel, in another I might have three strings and a subpanel. If I adopted the convention that the subpanel was 0, then I could extract item 0 in either case and it would work.
But I can't do that. If I try to REORDER CONTROLS in CLUSTER for the TypeDef of X, the subpanel doesn't have a number. The strings are #0 and #1 - there is no #2.
So, is it a control, or isn't it? If it is, why can't I re-order it? If it isn't, why does it appear in the CONTROLS[ ] property of its parent?
Is it always going to be LAST in the CONTROLS[ ] array? What if there are two subpanels in a cluster? Which one is more lastest?
What are the rules here?
If I make the TypeDef NON-STRICT, I can create a direct property node on the panel. But I think that means I have to make the whole chain non-strict (A PAGE contains a BASIC PAGE + ADDITIONS, the ADDITIONS contains several SECTIONS, the SECTIONS contains X), and I don't want to do that. |
Blog for (mostly LabVIEW) programmers: Tips And Tricks
05-05-2011 08:14 AM
A test shows that if "X" has a subpanel in it (subpanel A), and then I add subpanel B, then subpanel B is item 2 in the CONTROLS[ ] array, and subpanel A is item 3.
In other words, adding a subpanel puts it IN FRONT OF any other subpanels already there.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
05-05-2011 08:28 AM
A couple of possible solutions, neither of which I have tried, as I am in the middle of an upgrade...
05-05-2011 08:55 AM
You can reorder a cluster by the order you put things into it. Have you tried dragging everything out, dragging the subpanel in, then dragging everything else back in?
Yes. Start with an empty cluster. Place a subpanel in it, then string A, then string B. String A is item #0, String B is item #1, and in the CONTROLS[ ] array, the subpanel is item #2.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
05-05-2011 08:57 AM
Looks like I made a mistake somewhere though. You CAN create an INVOKE node for the subpanel, even though it's in a STRICT typedef (I tried earlier and couldn't, but perhaps I gorched something).
So maybe that's the answer for me. It's not working yet, but I just now tried the first time.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
05-05-2011 09:01 AM
It does work, I was looking in the wrong place.
You CAN create an INVOKE NODE to a subpanel, even if it's within a strict typedef within a strict typedef, within a strict typedef.
The other questions still stand as points of confusion, but not as obstacles now.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
05-05-2011 09:41 AM
Hmm. I can make an INVOKE NODE to the panel on my main page, even if the subpanel is in a typedef inside a typedef, etc.
However, if I go and EDIT that typedef, even moving the subpanel a single pixel, the INVOKE NODE just disappears, leaving a broken wire.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
05-09-2011 01:46 PM
Hey Steve,
Can you attach the vi, and clarify what the remaining problem is?
Regards,
A. Zaatari
05-09-2011 04:15 PM
I've made a small test thing which showed up ANOTHER issue.
Open the top-level VI in the attached LLB.
Notice descriptions on diagram.
#1. Run it out of the box, as it is. Why are the displays BLANK? I am clearly executing the VI BEFORE it's inserted into the SubPanel. If you flip the switch, the displays react appropriately, so it's not caching anything.
#2: Make a change to the typedef and POOF! the INVOKE NODE disappears.
#3 is a request for clarification of the rules. If it's not a control, why is it in the CONTROLS array? If it IS a control, why can't I REORDER it in the Typedef?
Blog for (mostly LabVIEW) programmers: Tips And Tricks
05-10-2011 09:36 PM
Hey Steve,
I was able to recreate the issue, and will get back to you on why this is going on.
Regards,
A. Zaatari