01-04-2018 07:32 PM
I'm trying to build my first AF project so please correct me if I'm headed down the wrong path.
I have an actor that is sending out continuous DAQ data. I have a helper loop in the Actor Core override that continually fills the DAQ buffer. I have an "Update data" message that is sent to the actor when that data needs to change.
My confusion regards exiting the secondary loop. It has a very simple command queue; one message for "update data" and one for "stop". Its timeout is set to 0, so it only pauses if it has a message; the DAQ buffer is filled in the timeout case. (I don't feel this needs to be a separate actor since it needs to continually ignore the command buffer and instead just continually fill the DAQ.)
I need to send a "Stop" message to this helper loop when the actor receives the Stop message. I assumed I could send this message in Stop Core, but I can't quite tell when it actually executes. Does Stop Core execute within the parent "Actor.lvclass:Actor Core" after it receives the Stop message, but before exiting the VI, or does it happen *after* the override Actor Core finishes executing?
If it happens within the parent Actor Core then I can just send the Stop message in a Stop Core override, but if it happens *after* the child Actor Core is finished then it will never actually stop.
I hope that explains my confusion a bit. Thanks for any help 🙂
Solved! Go to Solution.
01-04-2018 07:50 PM
Take a look at the Actor Core of the parent Actor (ie. Actor.lvclass).
So in your Actor Core Override you have the call parent method and your helper loop. The call parent method is doing the message handling. When it get's stop message, the message handling loop stops and immediately after that the stop core is called (technically stop is called, which calls the dynamic dispatch vi Stop Core.vi as a subvi). Then the call parent method will exit.
You are correct that the normal place to stop a helper loop is in the Stop Core override.
Hopefully that helps...
01-05-2018 10:23 AM
Thanks Taggart, that helps. I was getting a little confused with all of the overrides and thought Stop Core might have been getting called "behind the scenes" somewhere else.
01-05-2018 12:10 PM
if you do a right click Find All Instances, you will see that is the only place it is being called (aside from the Call Parent node in any of your overrides).
Everyone has to start somewhere and you are right, it can get a little confusing/overwhelming at first.
01-05-2018 12:14 PM
Oh, as a side note, because that is the only place the stop core override get's called (and the stop core override is where you usually close refs) that is why you need to be careful to make sure that on an error in prelaunch init (which will cause the launch to fail - ie. actor core and therefore your stop override never run), you need to have a case structure in pre-launch init to close any refs you generate there on an error. There is some documentation in the AF class on that - see this thread https://forums.ni.com/t5/Actor-Framework-Discussions/Error-in-Pre-Launch-Init-override/td-p/3703215 for more info.