I'm attempting to use your nice framework but may be missing something
when it comes to how to handle actions associated with triggers/
transitions between states.
I do know its possible to assign actions to a state's entry or exit
with your framework. But I want to know if its possible to also
assign actions to the firing of a trigger/transition?
I have a state machine design where I need to not always perform an
action on entry of a state. So I'd like to control this via actions
attached to a trigger/transition. Example below:
StateA------GotFill / SendOrder(Order)-----> StateB
StateC------GotFill [mySize == yourSize]------> StateB
In this case, I have the trigger/transition from StateA to StateB
being fired when GotFill event is detected from within StateA. When
that trigger gets fired, I'd also like to invoke the SendOrder
function that I assign to this trigger (i.e., a trigger with guard and
action). And StateC can get to StateB via the GotFill event with a
guard condition but it should not invoke such a function (i.e., just a
plain trigger + guard).
Regards,
JD
ps: Awesome state machine framework!! Great job :)
That is possible. Just inject some side effect (like SendOrder) into a
conditional Permit. If you only have one Permit, then just have the
trigger evaluate true at the end of the side effect.
However, it doesn't seem like the best way to use Permit. Seems like you
can get more of what you want with a combination of states, actions and
conditional Permits. SendOrder would be a state all of its own with a
conditional Permit of (mysize != yourSize). The action associated with
SendOrder would start sending the order. Presumably, when the order
sending action completed, mySize == yourSize, the trigger would fire
again, and a transition to StateB would occur.
I hope I answered your question, I try not to over answer, so please ask
for more detail if you need it.
-g
Thanks for the reply. I actually also was thinking that perhaps using
OnEntryFrom may be what I'm looking for as well (assigning actions to
specific triggers/transitions).
Either way, it seems I have couple of options to try now to get this
to work. Looking forward to using this framework for real :)
JD