Actor Framework Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Embed a Nested Actor's Front Panel into a Caller's Subpanel

The attached project demonstrates two ways to embed a nested actor's front panel into a caller's subpanel.  The example uses protection proxy classes to prevent users from misusing the actors' VI and subpanel references.

 

What is Included in the Example

 

When you open the project, you will find two classes, Protected SubPanel and Protected VI Reference.  You will also find three actors:  SubPanel Actor, Simple Actor, and Insertable Panel.

 

Protected SubPanel and Protected VI Reference are wrappers for a sub panel reference and a VI reference, respectively.  You create one of these objects with its Create method.  The other methods of these classes let you do various things with the original reference – specifically, insert a VI into a sub panel (Protected Sub Panel lets you remove a VI as well).  But that’s all you can do with one of these objects.  I cannot, for example, use a Protected VI Reference to abort the VI in question.  This lets me share the desired reference without exposing myself to mischief.

 

Protected SubPanel and Protected VI Reference are examples of a protection proxy, an object that controls access to some other object, usually when different users need different access rights.  Actor Framework's Message Queue is another example of a protection proxy; take a close look at it if you want an idea of how far you can take the concept.

 

Insertable Panel is an abstract actor that defines two ways to interact with a caller’s subpanel.  If you pass this actor a Protected SubPanel,  it will add its front panel to the subpanel.  If you don’t, it will pass a Protected VI Reference to its caller.

 

Insertable Panel includes a protected method called Insert Me.  Children of Insertable Panel call this VI where needed to insert themselves into their caller’s subpanel.  There is also an accessor to let you specify a Protected SubPanel if that’s the mechanism you want to use; call this accessor before you launch an Insertable Panel.

 

If you do not provide a Protected SubPanel, Insertable Panel will assume you want the caller to manage insertions.  When you invoke Insert Me, Insertable Panel will send a message to its caller that contains a Protected VI Reference.  The caller can then use this object to manage the insertion.  Note that this message is an abstract message; the caller must provide the implementation details.

 

The version of Simple Actor included in this example is modified from the one used in Actor-Oriented Design in LabVIEW This version has been changed to inherit from Insertable Panel, and the front panel management code has been removed.  Instead, it invokes Insert Me in its Actor Core, right before invoking Call Parent Method.

 

SubPanel Actor launches two instances Simple Actor, and provides subpanels for them.  SubPanel Actor uses both methods to insert Simple Actors into its subpanels – it provides one nested actor with a Protected Subpanel Reference, and receives a Protected VI Reference from the other one.  The actor provides a method, Insert Nested Actor, to make use of the Protected VI Reverence, and a message to invoke that method.  (The message is a concrete child of Insertable Panel’s abstract message).

 

To run this example, open and run Launch SubPanel Actor.

 

How to Use this Example in Your Project

 

I opted for the minimalist approach on this example.  It is easy to over-complicate an AF application, and it’s worth spending some time thinking about what really light solutions to certain problems can look like.  I fully expect you to take this example and modify it for your specific needs, or even start over.

 

You can certainly use Insertable Panel and the two protection proxies as-is.  Insertable Panel assumes that you will embed the subpanel when the nested actor is launched, and that you will only remove it when the nested actor is destroyed.  In that case, I would recommend picking one of the two embedding methods (pass a Protected SubPanel to the nested actor, or pass a Protected VI Reference to the caller), and removing the other from Insertable Panel entirely.  Personally, I think giving the SubPanel to the nested actor is cleaner, since you don't need the abstract message class, but passing the VI reference to the caller might work better for your application.

 

You may want to keep your nested actor alive when its panel is not embedded - a likely scenario if you have several nested actors, but only one subpanel.  In that case, I would recommend creating a message for Insert Me (you'll need to make the method public).  You'll need to capture the reference to your nested actor's actor core in that case.  You can either modify Insert Me to take a SubPanel as an input, or rely on getting the VI reference from the nested actor.

 

As always, your comments are appreciated.

Comments
Oli_Wachno
Active Participant Active Participant
Active Participant
on

Thanks for the brilliant example, Allen.

I have just linked an old thread discussing this topic.

drjdpowell
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast
on

Not AF, but here is another example and discussion on embeding running processes in a subpanel of the main process.

RVines
Member
Member
on

Just in case this happens to others. In LV 2017 you have to change the re-entrant settings for both "Actor Core.vi" files for it to run.

CanadaGuy
Member
Member
on

@RVines I ran it okay, so maybe they fixed something? Either way, runs fine for me on 2017 64 bit.

nlhnt
Member
Member
on

Hey,

I wanted to build on this code, could you please provide a license or is it not-licensed?
How should I credit original author if I want to use that in my project?

Researcher @ Gdańsk University of Technology
Python enthusiast
Contributors