Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Subactor in a subpanel

Dear actor frameworkers,

I would like to embed a subactor actor core frontpanel into a subpanel of the caller actor core. My UI is very complicated, and it is divided in several regions which fullfill a dedicated task each. At the moment subactors receive and send messages to a dedicated UI Actor, which opens the frontpanel and performs the user interaction. It seems simpler and more natural to me to embed the subactor core frontpanel directly and send only information which has to be processed somewhere else.

I would store a actor core vi reference in the private data cluster of each and insert the subactor actor core vi references into the according supanel.

Does anyone see obstacles in this plan or does it seem to be a good idea?

0 Kudos
Message 1 of 19
(6,254 Views)

Hi,

I'm doing what you described.

With the first implementation (I also tried your idea first), I had some issues (mainly race conditions), so here's my (now functional) setup:

Since I have multiple different Actors that go into the subpanel, I created a base-class for that functionality and the sub-actors derive from this class (and I would recommend you the same).

You should NOT store the actor core vi reference in the private data cluster of each.

Instead, only the Main Actor (that one containing the subpanel) should have the reference and control "access" to this ressource.

It then may receive the message to insert a specific VI reference (your sub-actors VI ref). This message you can send from any "Subpanel-able" Actor you have.

I also have a functionality to detach and attach those Actor VIs, so we can also view a few of these VIs at the same time.

-Benjamin

_________________________
CLA
0 Kudos
Message 2 of 19
(4,448 Views)

Hi,

I'm doing as you have described. I don't suffer from race conditions, since the SubActor is the only accessor.

Make sure, populating this piece of data is written right at the start of the Actor Core.vi

Actually, my architecture features Subpanels being settled with Actor SubPanels themselves.

But messaging architecture is a big piece of work!

Oli

0 Kudos
Message 3 of 19
(4,448 Views)

Ah okay, thank you.

I also already have a base actor class which is somehow enriched in funtionality and inherits from another base more general class .

But I do not understand why I shouldn't put my actor core vi reference into the actor private data cluster. If in my event loop for example a button is pressed I probably would like to send myself a messagew which not only changes private data but also changes some text. For example, if I have a login/logout button, I want to change on the text on the button from login to logout and set the username in the private data cluster. Or I put a text within the vi, which contains "Current User: <Username>".

On the level of the sub actor I rather would want to access the elements of the vi, and at the level of the caller I would to insert it into the subpanel.

I am wondering of this is a good idea at all, because if you have the ref to the actor core vi of an subactor you might be able to brake actor framework rules by manipulating the actor core frontpanel from outside.

0 Kudos
Message 4 of 19
(4,448 Views)

Actually, IMHO the SubActor should be the only one to access it's FP. It should not expose its' FP refnum to anyone else, since it looses control. If I want the SubActor to do anything, I should do so by sending a message.

0 Kudos
Message 5 of 19
(4,448 Views)

one way or the other, one of the two (main actor; sub-actor) needs to reveal one of its references for this to work.

the race condition, I was referring to relates to the use case, that I can remove the VI from the panel again to display it independently.

To display a VI, one first has to check if it is loaded in the subpanel (it must be removed before it can be opened outside)

Therefore, 2 VI server methods must be accessed - which cannot be done atomically in case the sub-actor is doing it (thus, in my case, the main actor handles these messages, AND it handles them serially).

Maybe you don't need this in the beginning, but I needed it as an additional feature - in which case you need to move all the logic into the main actor.

In my current case, yes the VI ref of the Sub-Actor Core VI is exposed. It is limited to a special use case and you should not otherwise run methods or modify properties on this reference, it is merely needed to insert it into the subpanel.

_________________________
CLA
0 Kudos
Message 6 of 19
(4,448 Views)
...

But I do not understand why I shouldn't put my actor core vi reference into the actor private data cluster. If in my event loop for example a button is pressed I probably would like to send myself a messagew which not only changes private data but also changes some text. For example, if I have a login/logout button, I want to change on the text on the button from login to logout and set the username in the private data cluster. Or I put a text within the vi, which contains "Current User: <Username>".

...

I would recommend storing the control refs to the contorls you want to use in private data and access control properties using these instead of going the whole way from the VI Refnum->FP->....->MyControl->Value

0 Kudos
Message 7 of 19
(4,448 Views)

stbe schrieb:

one way or the other, one of the two (main actor; sub-actor) needs to reveal one of its references for this to work.

...

Nope

Change perspective .... Controller can send the SubPanel Reference to the subactor with an "Embed in there message" no need to expose the VI Refnum

0 Kudos
Message 8 of 19
(4,448 Views)

Oli_Wachno wrote:

stbe schrieb:

one way or the other, one of the two (main actor; sub-actor) needs to reveal one of its references for this to work.

...

Nope

Change perspective .... Controller can send the SubPanel Reference to the subactor with an "Embed in there message" no need to expose the VI Refnum

In my system, I have a "controller" that implements control over the subpanels.  Any subactor can register a subpanle it owns, and any subactor can request a subpanel by sending the controller its refnum.  Currently, inserting and removing subactors is handled by the controller. 

Am I correct in my thinking that there would be just as many messages exchanged doing it my way vs having the controller send a message with the subpanel reference?

CLAD
0 Kudos
Message 9 of 19
(4,448 Views)

Oli_Wachno schrieb:

Change perspective .... Controller can send the SubPanel Reference to the subactor with an "Embed in there message" no need to expose the VI Refnum

Yes! Thank you! This was the idea I was looking for! This is brilliant. Like this the actor core vi ref stays hidden in itself. I would have had a very bad feeling if somebody later just would have accessed the child vi FP instead of sending a message.

I will do it in that way.

Why do you think that the information architecture is difficult? Is there some advice for me where I should be careful?

0 Kudos
Message 10 of 19
(4,448 Views)