LabVIEW

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

How can I put a numeric indicator into a case structure using VI scripting

Solved!
Go to solution

I'm using VI scripting and I'm trying to add a numeric indicator inside a case structure.  I'm able to add the case structure and the numeric indicator just fine, but as soon as I specify the case structure as the "owner" of the numeric (as opposed to the block diagram being the owner) I get error 1060.  Is there any way around this?

 

Note:  The reason I am doing this is because this specific pattern (indicator in a case structure) will prevent a VI from being inlined when it is being built.  This pattern will provide no functionality in itself, it only prevents the inlining.  It is added to a larger VI which is use to initialize objects in a simulation, and there are many of them in the total simulation.  If they are inlined, it takes a VERY long time to generate the C code, and performance on this VI isn't an issue since it is performed only once at the beginning of the simulation.  The rest of the VIs do need to be inlined for performance reasons.  Therefore, I'm open to other options to prevent a VIs from being inlined if the "indicator in a case structure" cannot be performed via scripting.

 

If any of this is unclear please let me know and I can clarify.  Thanks.

0 Kudos
Message 1 of 11
(1,343 Views)

The Case Structure itself is not the owner, you need to specify which frame to place the indicator.  Use the Frames[] property and Index Array to select the desired case.

0 Kudos
Message 2 of 11
(1,339 Views)

I just gave that a try.  I used the Frames[] property and selected index 0 and used that object reference as the owner of the numeric and I got the same error: 1060.  Any other thoughts?

0 Kudos
Message 3 of 11
(1,331 Views)

In this case you could create a VI which contains the Case Structure and Indicator.  This VI can be placed as a SubVI on the BD and then inlined.  I'll post an example when I get to my other machine.

0 Kudos
Message 4 of 11
(1,328 Views)

Ran out of edit time.

 

This should work.

 

1) Create the Case Structure and get the reference to the desired frame

2) Create the Numeric Indicator owned by the VI

3) Get the ControlTerminal reference for the Indicator using the Terminal Property

4) Use the Move Method of the ControlTerminal to move it into the Case Structure by specifying the Owner

 

I'll wager you were using the Control Reference instead of its Terminal Reference.

0 Kudos
Message 5 of 11
(1,323 Views)

Unfortunately I had already tried that.  What happens is the small VI with the case structure and indicator do not get inlined into the main VI (which is the one that inlines very slowly), but the very slow VI still does get inlined.  I was hoping this would work, but instead we are still left with a very slow-inlining VI (the original problem) with a useless non-inlined subvi within it (which really performs no useful function).

0 Kudos
Message 6 of 11
(1,322 Views)

I am not fully understanding the last post.

 

I am referring to the following steps:

 

1) Create the simple subVI with Case Structure and Indicator

2) Create a New VI object in the main VI of type subVI with the path of the simple subVI

3) Call the Inline method on that subVI object, it will simply place the code onto the BD as if you wired it up yourself.  This is separate from LV's subVI inlining which is I what I think you are trying to thwart.

 

I do this all the time instead of scripting things from scratch.

0 Kudos
Message 7 of 11
(1,316 Views)

I now understand what you were saying about inlining a subvi.  I did as you said and made a subvi with a case structure and an indicator within it.  I use the New VI Object node to add that subvi to the slow-inlining parent VI.  Then I tried to inline it using the invoke node, but I got error 1399, which make sense.  Is this what you meant for me to do, or did I misunderstand?

 

Also, I tried the ControlTerminal reference approach you mentioned earlier.  Unfortunately when I called the move method on the control terminal property and had the 0th frame of the case structure as the owner I got error 1060 again.

 

I really appreciate your help.  Do you have any other thoughts?

0 Kudos
Message 8 of 11
(1,309 Views)
Highlighted
Solution
Accepted by topic author hillchri
08-27-2015 04:09 PM

Sorry about the mess, this works for me.

 

ScriptCaseIndicator.png

 

Don't mind the empty cluster constants.

Message 9 of 11
(1,306 Views)

Eureka!

 

I just misunderstood what you meant by control terminal reference.  I did Control->Terminal->Control instead of Control->Terminal->Reference.  I don't really understand the difference, or why it works, but it works, and that makes me happy.

 

Thanks for the help, its greatly appreciated!

0 Kudos
Message 10 of 11
(1,301 Views)