[This is a follow-up on my presentation TS 8237 "State Pattern Implementation for Scalable Control Systems" delivered at NI Week.]
Consider the following state machine:
.
Consider also an implementation of this using the State Pattern, where the different states are objects.
Now examine the desired behavior for exit and entry actions for the transitions D to E and D to F.
D to E: We expect to execute the exit method for D and the entry method for E (but not the entry or exit methods on the parents).
D to F: We expect to execute the exit methods for D and B and the entry methods for C and F (but not the entry and exit methods on A).
In other words, when executing exit and entry actions we want to stop at the least common ancestor (LCA) of the main source and main target states. [There is a good description of this here: http://www.amazon.co...&keywords=samek.]
It is possible to do this in an inelegant fashion by adding specific code for the purpose in various places, but I'm pretty sure the only elegant solution for this (i.e., within the framework) requires reflection (not yet available in LabVIEW).
Comments?