From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Actor Framework Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I shutdown a nested actor

How can I shutdown a nested actor automatically, while the root actor exit.

I'm an AF beginner

I saw the prject template in LabVIEW named actor framwork in "create project", in which there are two nested actors are auto-shutdown when root actor exit.

I have written an actor framwork demo by myself and it runs ok without the N2 actor, but when I create the actor N2 in Actor Core.vi of the root actor, the program will not exit while I press the stop button.

I stop N1Actor by pass a normal stop msg,and I want to stop N2Actor automatically with the exit of root actor, but it doesn't work....

I've struggle with this problem for days, please help me......

Comments
CaseyLamers1
Active Participant Active Participant
Active Participant
on

Without looking at the code...

If you set the boolean on "Launch Nested Actor.vi" to not stop by default you need to provide another way of stopping.

Here is the method I used prior to the automatic stopping:

When you launch the nested actor there is an enqueuer for that nested actor as an output from the "Launch Nested Actor.vi". You need to store that in the private data of your parent actor(N1Actor). So open the control for the private data of N1Actor and add a message enqueuer constant and name it appropriately (N2Actor Q). When you launch N2Actor wire the Enqueuer into a Bundle By Name on N1Actor into N2Actor Q.

Now you need to make sure that N1Actor sends a stop message at some point to N1Actor. A simple way to do this is to override Stop Core.vi. In the N1Actor override Stop Core.vi. In the override do an unbundle by name on N2Actor Q. Put a "Send Normal or EmergencyStop" with the code wired into it on the N2Actor Q.

Now when your N1Actor stops it will send N2Actor the stop message.

I suggest that once you go beyond a program convincing yourself that you can use AF that you spend some time thinking about how you want things to stop. You are about to do some real software engineering and usually you don't want to just pull the plug on the whole thing. Are you going to need to do a sequenced shutdown? Does something need to happen in one area before you can do something in another area. Map it out. Add booleans or other items to the private data of each actor that gives it the things it needs to know when and how to stop. Expect to spend some quality time doing this if you have anything sufficiently complex.

An example of a complex shutdown that has gone around previously is a drilling machine. Imagine that stopping means telling a drill to slow down, removing the drill from the hole, stopping the drill, moving the drill to a home position, powering down a motor, etc. You would not just send a stop to everything.

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!

DMurrayIRL
Member
Member
on

It might just be a simple case that you are not wiring the "Launch Nested Actors" functions in series. Try below and see if that helps.

Wire Nested Actors in Series.jpg

xiaoyou_1314
Member
Member
on

OOOh! Yes! I Got it ~ IT DOES WORK! Thank you very much~

xiaoyou_1314
Member
Member
on

I've got a lot of benefit from your reply, thank a lot. I feel it will take a loooong time for me to have a deeply understanding on  the AF so that I can use it expertly...

Contributors