09-28-2023 02:06 AM
Dear community,
I am checking out AF and playing around with it as a means to understand the concept.
If my caller actor has a subpanel and the caller actor calls a nested actor. How do I get the VI reference of the nested actor to the calling actor where it will be loaded in the subpanel?
Thanks in advace!
09-28-2023 04:04 AM
The reference can be passed like any data. I'm not into AF, but a reference is just data.
Alternatively (and this has my strong preference), I'd pass the subpanel reference to the nested actor and make the nested actor put itself in it.
The order of creation, inserting into a subpanel, registering for dynamic control events*, removing from subpanel, closing the VI is IMO a lot easier if it's done by the VI in the subpanel, not the owner of the subpanel.
Especially with nested subpanels and clones things can crash if this ordering (esp. closing\removing) isn't done exactly right.
* Dynamic control event registration is a pain. If the FP is closed, registration fails. But if it's open or hidden, inserting in the subpanel fails. So you need to either hided, register, close, insert or insert, register. Just for this reason alone, it's best to let the VI insert itself. If you send a message, you'd have to wait for a reply or you won't have a guarantee the FP is actually open. This is a hard to track bug that will depend on timing.
09-28-2023 08:43 AM - edited 09-28-2023 08:45 AM
Actor Framework is not complete without using MGI Panel Manager (in my opinion). That has the exact functions you want where it will launch a nested actor and tie it to a subpanel during launch. It also provides some other common things that you end up doing in actor framework all the time. It can be downloaded from VIPM, and is free. It adds an inheritance layer that your actors would inherit from, instead of directly from Actor itself.
Example from my code below. Create a SubPanel Type in MGI Panel Manager from the subpanel reference, then Launch the Nested Panel (Actor) while passing in that subpanel type.
09-28-2023 12:50 PM
Thank you both for your reply.
@ShockHouse
My intention is to pass The VI Reference from the nested actor to the core actor in order for it to be loaded there in the subpanel. If I understood your code right, then your pass the subpanel reference to the nested, i.e the other way around.
09-28-2023 01:59 PM - edited 09-28-2023 02:04 PM
Yes that is correct. The Caller actor has the subpanel reference. When it launches the nested actor, it provides the subpanel reference as part of the launch process.In this way, the Nested Actor doesn't need to know it's in a subpanel, and it has no ties to that. That is all handled by MGI Panel Manager.
That toolset provides functionality on top of it as well for sending messages to show/hide the actor in the subpanel. This can be useful when your caller may have multiple nested actors and you want to show them one at a time in a subpanel, but keep them all running, etc... You can launch all the nested panels with the same subpanel reference from the caller, and then cycle through showing and hiding different ones depending on your needs.
If you are dead set on providing the VI Reference from the Nested Actor to the Caller, you could always use "Read Callers Enqueuer.vi" in the nested actor and send a message to the caller. But now that creates a dependency of some sort between them.