Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Actor Framework-Handle Last Ack core

Solved!
Go to solution

Can someone brief about this override VI of Handle Last Ack? What is the use of it? Where is it called ? And what it calls ?

0 Kudos
Message 1 of 19
(3,629 Views)

Upon terminating, an Actor sends a Last Ack Message to it's caller to notify it that the (nested) Actor has shut down.

Handle last Ack defines the behaviour of the calling Actor, when it receives a Last Ack Message.

 

Both sending the Last Ack and handling a Last Ack Message are part of the framework. 

Message 2 of 19
(3,622 Views)
Solution
Accepted by topic author mahalakshmi05

Every actor sends a Last Ack message to its parent when it stops. This message contains the state of the actor and an error report.

When the calling actor receives a last ack message it will execute the "Handle Last Ack Core" vi. By overriding this vi you can change the way it reacts when a nested actor stops.

 

In the "Handle Last Ack Core" vi you can "Read Error Report" to get the nested actors error so the caller can react to this e.g. restart the nested actor or shutdown the entire application.... If you don't override the it will read the error report and output it to the caller, so this is the vi that makes sure your caller gets the error of it's nested actor when that stopped.

 

Or you can use the "Read Actor" in your "Handle Last Ack Core" to get the nested actor's state and read out all the data if you have public property method to access its private data. The output of the "Read Actor" is of the type "Actor.lvclass" so you can use a "to more specific" to check which nested actor has stopped.

 

Hope this brief explanation helps you.

 

Best Regards,

Stefan Lemmens

Intersoft Electronics

Message 3 of 19
(3,621 Views)

With the Last Ack message, you also get the nested actor's enqueuer.  A given actor's enqueuer is unique, so you can use it to identify which of your nested actors just terminated.

Message 4 of 19
(3,576 Views)

Thanks a lot. I have one more doubt, I have handle error.vi and Handle last ack.vi in my parent actor. If my child actor stops due to error, it will be handled in the handle error.vi first, hence my error would be cleared there before entering the Handle last ack core.vi , then how will I get the error data of the closed child actor?

0 Kudos
Message 5 of 19
(3,569 Views)

It is actually the other way around as you can see from the actor framework's MHL which is inside the actor core.vi

StefanLemmens_0-1608018983853.png

 

 

The Last Ack is handled first. If there is an error it will output it so that the Handle Error can handle it.

"Last Ack" is handled by the caller just like every other message. So the "Handle Last Ack Core" (which is inside the Do.vi of the Last Ack Message class) will be executed when the message is received. If this results in an error the "Handle Error" will be executed. 

 

If you however clear this error by an override of the "Handle Last Ack Core" it won't reach the "Handle Error". 

 

The "What a Software Architect needs to know when using the actor framework." gives a good overview of the common life cycle of an actor. It's on slides 31-32. Slide 49 also explains a bit more about your question on how to handle or report errors from nested actors.

 

Best Regards,

Stefan Lemmens

Intersoft Electronics

0 Kudos
Message 6 of 19
(3,548 Views)

Thanks, That was very clear. My further doubts are:

1. What happens to the error generated in the Parent itself? How does it differentiate between those called in its child and parent?

2. Can there be a communication between handle error.vi and its actor core so that some crucial error can be handled in Actor core?

0 Kudos
Message 7 of 19
(3,525 Views)
  1. Error generated by other messages in the parent actor are always handled by the "Handle Error.vi" If you handle an error inside the "Handle Last Ack Core.vi" this error is always originating from a nested actor.
  2. I am not sure if I understand your second question well but if "Handle Error.vi" stops the actor then the override actor core of this actor will also be stopped. Otherwise "Handle Error.vi" is the vi that should handle the errors; so if it doesn't stop the actor it can send a message to its self-enqueuer in order to take further actions.

Best Regards,

Stefan Lemmens

Intersoft Electronics

 

 

0 Kudos
Message 8 of 19
(3,500 Views)

Assume I have 5 nested actors. I have overrided Handle Last Ack core.vi in my parent VI. I need to check if the all the nested actors are closed, hence I plan to get the enqueuers of the nested actor in Handle Last Ack and maintaining it in an array. I will self stop the parent actor after all my nested actors are stopped. When I keep breakpoints in the case where enqueuers are added, the flow is correct and project gets stopped. But If I remove the breakpoints, my project does not gets stopped. 

What could be the reason? 

Can you suggest some alternate ways to implement this logic?

0 Kudos
Message 9 of 19
(3,367 Views)

As you launch all of your nested actors, store their enqueuers in an array in your caller actor's private data. In Handle Last Ack, remove each enqueuer from the stored array. When the array is empty, do Send Stop Msg to your caller actor's self enqueuer (do this inside Handle Last Ack). That should work. If it doesn't, post a diagram of your Handle Last Ack code.

0 Kudos
Message 10 of 19
(3,355 Views)