Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Launching nested Actor tries to relaunch parent actor over and over

Hey so I have actor A that inherits from the Actor class and I would now like to launch Actor B which inherits from Actor A so I can access some of the private data of A in the Actor B, but it continuously tries to relaunch Actor Core of A over and over because this is the parent Actor Core.

I have tried using a to more generic type cast on the wire going into the Actor Core with an instance of Actor A as the type cast but it doesn’t work. Actor core is still the Actor Core of A.

How do I avoid this? I would ideally like Actor B to act just as Actor A and launch the actor framework implementation of Actor core and just handle messages. Am I missing Something here?

Thanks.

0 Kudos
Message 1 of 12
(5,032 Views)

Do you need both Actors A and B?

In general if you are inheriting from A you are doing so to extend its behavior. So, then you would just launch Actor B. Not launching Actor A at all.

I also have a red flag go up when you say that you want to use Actor B to access its private data. If you have 2 actors they do not get access to each other's data by inheritance. The only way to share data between 2 actors is by messages. A can send messages to B. This is presuming two actors running concurrently.

You can access data stored in the parent class, but this is NOT 2 actors running concurrently. It is a single instance of the child actor.

Hope that helps.

Casey

Casey Lamers


Phoenix, LLC


casey.lamers@phoenixwi.com


CLA, LabVIEW Champion


Check Out the Software Engineering Processes, Architecture, and Design track at NIWeek. 2018 I guarantee you will learn things you can use daily! I will be presenting!

0 Kudos
Message 2 of 12
(4,181 Views)

So, just to clarify:  You launch A.  A launches B, which inherits from A.  A has an override of Actor Core, and I assume B does not (from your description).  Is this correct?

If it is, you are seeing expected behavior.

A and B will both run instances of Actor Core, because they are two different actors.  Since B does not have its own override of Actor Core, it will run a copy of the same VI that A runs, becuase all actors have an Actor Core.  B will *not* have access to A's data, even though it inherits from A, because, again, they are two different actors.

0 Kudos
Message 3 of 12
(4,181 Views)

The behavior you are seeing of launching continuously can be explained this way:

You start the program by Launch Root Actor on Actor A.

Actor Core runs on Actor A and launches Actor B.

Actor B, because it inherits from Actor A runs Actor Core for its parent (Actor A) which launches another copy of Actor B. You now have 2 copies of B. The second copy runs Actor Core and launches a 3rd copy of Actor B. Repeat until computer CPU is pegged or memory runs out.

I think what you want to do is run Launch Root Actor on just Actor B.

Casey

Casey Lamers


Phoenix, LLC


casey.lamers@phoenixwi.com


CLA, LabVIEW Champion


Check Out the Software Engineering Processes, Architecture, and Design track at NIWeek. 2018 I guarantee you will learn things you can use daily! I will be presenting!

0 Kudos
Message 4 of 12
(4,181 Views)

Thanks guys, yes I misunderstood how that works that makes sence that i cant access the data of A in Actor B.

But the problem of Actor core B relaunching Actor A still exists. And yes I have made an override for Actor Core B but that parent implementation of the block diagram is always the Actor Core of A. I would like it to launch the Actor Framework Implementation of actor core so it doesnt go into a continious loop of launching Actor Core A.

.

Thanks.

0 Kudos
Message 5 of 12
(4,181 Views)

Thanks Casey,

Just to clarify why I want to do this, I could handle all the processing I want to do inside Actor A if I wanted but the only problem is that I want to have 2 popup windows available that are not modal, for different processing techniques (i.e. so both windows can be open and interacted with at the same time) instead of using tabs on the front panel of Actor A which would get messy and cluttered very quick. Is there a better suggestion or approach to my problem maybe? Any Input is greatly appreciated.

Thanks Again!

0 Kudos
Message 6 of 12
(4,181 Views)

You can solve your problem this way:  Make an Actor Core override for Actor B.  If Actor B does not need a GUI, you do not need to add any GUI code to Actor B's override of "Actor Core.vi".

Instead, on the wire leading from your actor's object control (input terminal) to the "Actor Core.vi" Call Parent Method, insert a "Downcast" node, and cast the wire to "Actor.lvclass".

That should solve your problem.  What you're doing is telling your Actor B's "Actor Core.vi" override to "jump over" the CPM of Actor A and run the CPM of Actor.lvclass instead.  This will prevent Actor B from launching a copy of Actor A's GUI.

-t

0 Kudos
Message 7 of 12
(4,181 Views)

I would recomment creating a launcher Actor that is in charge of launching the different actors. Have it launch different actors for each UI.

I would also suggest looking into the Model-View-Controller (MVC) software achitecture. I think in the long run that decoupling the UI (View) from the behind the scenes processes is desirable.

Casey

Casey Lamers


Phoenix, LLC


casey.lamers@phoenixwi.com


CLA, LabVIEW Champion


Check Out the Software Engineering Processes, Architecture, and Design track at NIWeek. 2018 I guarantee you will learn things you can use daily! I will be presenting!

0 Kudos
Message 8 of 12
(4,181 Views)

Thanks, so what I would like is for actor B to have access to a portion of the data inside actor A. Is the only way to do this by sending a message From Actor A to Actor B containing the data I wish to share?

0 Kudos
Message 9 of 12
(4,181 Views)

Sorry Guys just wanted to clarify, if I want Actor B to Have access to some of Actor A's class data then the only way to do this is to send a message to Actor B, From A with the data I wish to share? Is the correct?

Thanks

0 Kudos
Message 10 of 12
(4,181 Views)