ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic dispatch in State Pattern design

Good afternoon, I started using actor framework and State pattern design few weeks ago and now I find myself into trouble about dynamic dispatch behaviour in a State Pattern design. I created a parent Actor (A for semplicity) inheriting from "State Actor" class. I created 2  class A's child classes (B and C). I implemented, as reccomended in documentation, the overrides of "Actor core" (for class A) and "substitute Actor" (for class A), transition methods for (class A, B, C) and one other method to pick a numeric value (Pick_value.vi). The last one has been implemented either in class A and B and C. When I use this method as "vi" in other method --> it works properly and the dynamic dispatch is respected. When i use it by calling with a message (send ...) the dispatch doesn' work.

What I mean is, after change the state from B to C and then call method on C (by message), the numeric value generated is from B implementation of the method, not from C implementation.

Are there any recommendation or flags to check, etc ?

Hope someone could help me

thanks a lot

 

Thanks

0 Kudos
Message 1 of 8
(1,258 Views)

Could you attach your code? I suspect your "switch actor" has some issues.

0 Kudos
Message 2 of 8
(1,237 Views)

I'll post the code as soon as I can. In the meantime I can tell you that switching actor should work fine (as far as i Know). I tried to use popup window to verify it and the actor changes states and executes "Entry" method properly.

 

0 Kudos
Message 3 of 8
(1,213 Views)

FilActor85_0-1743492780143.png

That is the "substitute actor" override. At this stage of the development I don't have data to share between actors. I have just put "to more specific class" for future data exchange.

 

Thanks

0 Kudos
Message 4 of 8
(1,206 Views)

I have just posted an example with 2 childs actor A and B and a Father actor. I tried to use "substitute actor" without any inheritance from "state actor" class. If I change state from A to B and call the method "ciao" only the B implementation of ciao is returned.

0 Kudos
Message 5 of 8
(1,192 Views)

Could you backsave to 2023 or prior? I don't have the newest version yet.

0 Kudos
Message 6 of 8
(1,173 Views)

As request 2023 version.

 

Thanks for your kind support

0 Kudos
Message 7 of 8
(1,165 Views)

I found the issue. The "Do.vi" of the messages referring to the transitions methods were not connected properly. I did them by the automatic "create message" and refreshed with"rescript message" functions but the connections were still wrong.

I changed manually the connecttions and it works. Hoping these help someone on the AF way.

Thanks

0 Kudos
Message 8 of 8
(1,152 Views)