LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically opening and closing the user interface using the actor framework

I'm currently using the actor framework included in 2012 to build my project.  My top level actor serves as my user interface.  Under normal operation I want my front panel to close if someone presses the X on the window or the abort button I created on the front panel.

 

However if a critical error occurs that causes the program to shut down I want the front panel to remain open so the operator can see the final state as well as additional error information.

 

Normally I'd do this by checking if there is an error on output and if not closing the front panel with an invoke node, however this doesn't work.  I assume this has to do with the actor being reentrant and not being able to get a reference to the specific reentrant copy in memory.  I tried just making my actor core none reentrant but this broke the project.  So I guess my question is three fold:

 

1.  Am I correct in assuming that referencing the VI front panel doesn't work because the VI is reentrant?

2.  Is there a standard way of fixing this problem without making the VI non reentrant?

3.  If not, how do I go about making this non reentrant without breaking my project?

0 Kudos
Message 1 of 10
(2,610 Views)

Hi Gollum,

 

Do you actually get an error off of that invoke node when trying to close it down?  Or does the front panel simply not close?

Cole R.
National Instruments
Software Engineer
0 Kudos
Message 2 of 10
(2,571 Views)

The front panel doesn't close, although it seems to flicker.... not sure if it is closing one and opening another.

0 Kudos
Message 3 of 10
(2,569 Views)

Did you try with some debugging techniques to check if the front panel is really closing? In this way we can figure out the cause of the issue

0 Kudos
Message 4 of 10
(2,545 Views)

At this point I've already taken it out and gone back to using the VI settings to open and close the front panel and using a dialog box to alert the user of a critical error if need be.

 

I'm pretty sure the issue boils down to the question "how can I get a reference to the current VI from within a reintrant VI?"

0 Kudos
Message 5 of 10
(2,540 Views)

Hi Gollum,

 

It's good to hear you've found a work around. Now to answer your question.


@Gollum wrote:

At this point I've already taken it out and gone back to using the VI settings to open and close the front panel and using a dialog box to alert the user of a critical error if need be.

 

I'm pretty sure the issue boils down to the question "how can I get a reference to the current VI from within a reintrant VI?"


I'm taking this from "Using the Actor Framework 3.0 in in LabVIEW"
While in 2012 you are probably using AF 4.x, this should be the same:

 

In the section, "User Interfaces for Actors"

"Include a reference in your actor’s private data to either your Actor Core.vi or to its front panel objects. Bundle these references into the actor before invoking the Call Parent node. Your actor can then access these references from within any of its methods. This method allows your methods to control the user interface of the Actor Core.vi, although it may not be the most efficient approach. This approach works well for interfaces that are only displaying information and not reacting to users’ actions."

 

This advice applies to your reentrant Actor VI's.

Joey S.
Senior Product Manager, Software
National Instruments
0 Kudos
Message 6 of 10
(2,511 Views)

Ok, I believe I found the solution:

 

I was using Open VI Reference with the Current VI's Path to get my VI reference.  I'm assuming this won't work to give you a specific reference to a reentrant VI (why would it after all since the only info you've handed it is the path).  If I instead use the This VI reference found under Application Control > VI Server Reference, then everything works fine.

0 Kudos
Message 7 of 10
(2,490 Views)

I think you are right. With the Open Vi Reference in the way you have done it, you will only get the "base" VI, and not the clone in menory.

 

To get a reference to the clone, you need to specify the whole name of the clone.

You can get the clone vi name by using the Call Chain vi. This will give you a array of name of vi's in the chain, with the first element being the name of the Vi in memory that used the Call Chain.

You can then use the first element in the array as a input to the Open Vi Reference.

As the clone Vi is already in memory, the Open Vi Reference only needs the whole name of the clone Vi, not the complete path.

 

Hope this helped.

 

 

0 Kudos
Message 8 of 10
(2,463 Views)

Is there any difference between the call chain method and just using the This VI reference?

0 Kudos
Message 9 of 10
(2,447 Views)

I don't thing so, but I don't know for sure.

 

With the Call Chain you can get a reference to any vi in the chain.
So you could have a sub-vi getting a reference of its caller.

0 Kudos
Message 10 of 10
(2,423 Views)