Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Receive Msg.vi

Hi all, Can some brief regarding the use case and functionality of "Receive msg.vi" override in actor framework...

0 Kudos
Message 1 of 21
(2,368 Views)

Receive Message is called every time a message is received by an Actor.

When you call the parent method, the message is handled normally.

 

You can use an override to filter or adjust messages, for example like this:

cbutcher_0-1622783145151.png

Here I override Receive Message to check if the message is one of 4 different types: Last Ack, Stop, Report Error or "Stop Relauncher Msg". The first 3 are built-in to Actor Framework, and the last is a specific message for this class.

 

Here the Actor behaves somewhat similarly to the Linked Endpoint Actors. This actor generally forwards messages to a nested actor, but some messages (the 4 mentioned) need to be handled normally by this Actor.

 

If the message is a different one, then it is forwarded in the error case (taking care not to connect the error wire!)

cbutcher_1-1622783259985.png

 


GCentral
Message 2 of 21
(2,360 Views)

Here is an example project. Root Actor Recieve Msg.vi is overridden in order to exchange messages between parallel nested actors without need to define forwarding messages in Root Actor.

 

https://forums.ni.com/t5/Actor-Framework-Discussions/Communicate-Between-Parallel-Nested-Actors/m-p/...

0 Kudos
Message 3 of 21
(2,338 Views)

The primary use case for Receive Msg is to create network proxies for distributed actor systems. Most actors receive a message and then act on it. But network proxies say, “Actually, this actor isn’t really here, it’s across the network.”

0 Kudos
Message 4 of 21
(2,307 Views)

I have tried to redirect a message to a Grandchild actor which was sent from Parent actor to Child Actor. For which, I have overrided Receive Msg.vi in the Child actor. But Once i have overrided it, no msgs are getting communicated from Parent to Child, but when I checked after removing the override, the messages are getting communicated. I have attached the Project zip file. Can someone guide me with the issue....

0 Kudos
Message 5 of 21
(2,224 Views)

I didn't exhaustively check your project, it's not immediately clear that you have the correct set of messages to forward vs handle (in Child1, right?) but the problem is here:

 

cbutcher_0-1623326862577.png

 

You can't use Equals to compare these effectively, instead you want to know if they're the same class. To do that, use the To More Specific node and check for an error.

cbutcher_1-1623327111662.png

 

Note that this won't work still, because some messages are almost certainly meant to be handled by the receiving actor here, rather than being forwarded - for example Stop Msg.

However, this structure should now work in terms of filtering - you just need to check what you're filtering and what you're receiving (note you could do both, if you wanted...)

 


GCentral
0 Kudos
Message 6 of 21
(2,220 Views)

Hi cbutcher, Thanks a lot for your prompt reply. I did changes as you suggested, now Stop msg is communicated and actor specific msg is also received but the msg i need to divert is not working properly. When I send that msg, the concerned actors get abruptly stopped. I have attached the screenshot for your ref. Thanks in advance.

Download All
0 Kudos
Message 7 of 21
(2,212 Views)

@mahalakshmi05 wrote:

 I did changes as you suggested


You misses the "Not".  cbutcher's code looks for any not-error; yours looks for any error (and there will always be an error)

0 Kudos
Message 8 of 21
(2,209 Views)

Error code- 1

Generate User Event in Child 1.lvlib:Child 1.lvclass:Message Child.vi->Child 1.lvlib:Message Child Msg.lvclass:Do.vi:3750001->Actor Framework.lvlib:Actor.lvclass:Receive Message.vi:1040001->Child 1.lvlib:Child 1.lvclass:Receive Message.vi:1040001->Actor Framework.lvlib:Actor.lvclass:Actor Core.vi:5880002->Child 1.lvlib:Child 1.lvclass:Actor Core.vi:5880001->Actor Framework.lvlib:Actor.lvclass:Actor.vi:6640006->Actor Framework.lvlib:Actor.lvclass:Actor.vi.ACBRProxyCaller.BF800039


Getting this error in the error out of Receive msg.vi

0 Kudos
Message 9 of 21
(2,207 Views)

Error will come only when "Message in" is not in the specified class, right? 

0 Kudos
Message 10 of 21
(2,204 Views)