Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

When does Stop Core run relative to Actor Core overrides?

Solved!
Go to solution

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 🙂

0 Kudos
Message 1 of 5
(3,864 Views)
Solution
Accepted by topic author BertMcMahan

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...

 

Sam Taggart
CLA, CPI, CTD, LabVIEW Champion
DQMH Trusted Advisor
Read about my thoughts on Software Development at sasworkshops.com/blog
GCentral
Message 2 of 5
(3,857 Views)

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.

0 Kudos
Message 3 of 5
(3,818 Views)

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.

Sam Taggart
CLA, CPI, CTD, LabVIEW Champion
DQMH Trusted Advisor
Read about my thoughts on Software Development at sasworkshops.com/blog
GCentral
0 Kudos
Message 4 of 5
(3,814 Views)

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.

Sam Taggart
CLA, CPI, CTD, LabVIEW Champion
DQMH Trusted Advisor
Read about my thoughts on Software Development at sasworkshops.com/blog
GCentral
Message 5 of 5
(3,812 Views)