Hi. I I trying to learn to use the actor framework, and I think I have made good progress, but I have en issue killing my actors:
Starting from the actor framework template with actors alpha and beta, I tried to create my own actor gamma (see picture 1 below). I have tried to implement it in the exact same way and the beta actor. I.e. I have given the gamma actor a stop method similar to beta's. I have managed to get my root actor to launch an instance of the gamma actor and talk to it. The gamma actor has a method, which does some math and sends it to the logger on the front panel of the root actor (see picture 2 below). It also writes the message "I am alive!" every second. My problem is that the gamma actor does not seem to stop, when I hit the stop all button. At least, the program ends up in a weird state, and I assume that killing my gamma actor is the problem. The weird state I refer to can be seen in picture 3 below. All actors are locked, and I cannot edit them. They seem to be still running. When I try to trace the stop signal send out by the actor code, I end with a horrible amount of VI's open, and I basically loose the trace.
I have been through a lot of the existing documentation and tutorials, but I have still not found out, how you stop nested actors properly. Hope you can help!
Solved! Go to Solution.
Can you post Gamma actor? It's hard to debug a picture.
Also I would highly recommend MGI's Monitored Actor tool- it'll tell you which actor is hanging at the end of your program.
Typically when an actor doesn't stop it's because a helper loop is stuck doing something else or isn't receiving a Stop command like you think it is. Actor Core may stop, but helper loops won't be simply aborted- you have to actually Stop them in some way.
Thanks for your reply!
- Sure, I have attached the folder of the actor.
- I will check out the tool you recommend. So far I have been using the "Labview task manager" LAVA tool, but without much luck. I can't get any of the running vi's to abort, when I hit abort, but that is a side issue, so nvm that.
- The only helper loop I have introduced in my gamma actor, is in the actor core, and I am pretty sure I stop it, but I could be wrong. I stop it in a way similar to what happens in the beta actor core - that is with a user event.
I haven't run your whole project yet, but I'm pretty sure I see the problem- you're calling Destroy User Event right after creating it! The Stop user event can't fire in Stop Core because the event reference is invalid. I bet if you take that out it'd work fine.
Put the Destroy User Event on the output of the Event structure after Unregister For Events (use the error wire to force Destroy User Event to happen *after* Unregister)
Ah! Thanks, that makes sense! Unfortunately it did not fix it. I tried to use the error wire like you suggested (see below), and I tried to delete the "destroy event" from the vi. Non of the two methods worked.
Ah, found the issue- your Bundle By Name's output isn't wired either, so Stop Signal isn't getting bundled into the Actor's data. Remember these classes are by-value, not by-ref.
For further debugging techniques, you could try setting up a testbed to keep your main actor running, but then send a Stop Actor message to Gamma. That'll tell you if it's Gamma that's hanging (which it probably, but not definitely, is).
MGI's Monitored Actor will also let you know of actors with hung helper loops.
Ah, I found another problem! By comparing my gamma actor to the beta actor, I noticed a slight difference in the wiring of the gamma data wire. In my initial program, I has the stop signal read in parallel with calling the parent method (see picture 1 below). In my new fixed version, I have it in series (see picture 2)! I would have guessed that my initial version would have worked, but apparently not
EDIT: Ah, you found the issue as well. Thank you very much for your help!