statemachine icon indicating copy to clipboard operation
statemachine copied to clipboard

Process event in new state

Open RockWood66 opened this issue 4 years ago • 1 comments

How do I handle an event in one state, transition to another state and handle the same instance of the event in the new state?

        builder.In(States.NoReadHeader)
            .On(TAEvents.TriggerCamera)
                .If(HeaderNRComplete).Goto(States.GoodHeader)
                .Otherwise().Execute(SendHeaderNR_SM);

        builder.In(States.GoodHeader)
            .On(TAEvents.TriggerCamera)
                .If(HeaderComplete).Goto(States.Labels)
                .Otherwise().Execute(SendHeaderSM);

If I fire trigger camera on state NoReadHeader and the guard transitions to GoodHeader I need to run the guard/otherwise when the GoodHeader transtions, so in the above if HeaderNRComplete is true and HeaderComplete is false it executes SendHeaderSM

RockWood66 avatar Aug 20 '21 16:08 RockWood66

A single event can only trigger a single transition and is then considered to be processed. You would need a second event to trigger another transition. Maybe you should define a transition from NoReadHeader to Labels/SendHeaderSM directly.

ursenzler avatar Aug 23 '21 07:08 ursenzler