Home > database >  Priority of statemachine transitions with substates
Priority of statemachine transitions with substates

Time:04-05

I am currently writing a generic statemachine in C. But I have a couple of understanding problems.

Say I have a state A. A transitions to B if a condition is met. A also has a substate A1. A1 transitions to state C if a condition is met.

Do I transition to B or C if both conditions are met and the active state is A1? Also do I have to run the repetitive running task of A since A is technically also active?

CodePudding user response:

In order for a state machine to be Deterministic, all the transitions out of a given state (including it's 'substates' which is really just a shorthand for defining states with similar transitions) must be mutually exclusive. If they are not mutually exclusive, you have a Non-Deterministic state machine. Such machines are perfectly reasonable, but harder to evaluate -- at any given time it can be in any set of states (rather than just a single state), and every transition that is possible from any of states in the current set of states is relevant for finding the next set of states. So in your example, you would go from being in states {A1} to states {B,C}

CodePudding user response:

After some more research I found this article that answers my question in chapter 2.10.

Crashcourse UML Statemachines

Shortly it depends which event occurs first, the timeout or the second event.

  • Related