Saturday 15 January 2011

State machine pushing events to its own event queue -


I am currently searching for hierarchical state machines (UML State Machine, Stochat, etc.), and the following is unclear to me :

During the transition and states, the machine is encouraging incidents in the event of its occurrence, and if it is, then whether it is used safely in practice or should it be avoided ?

I will explain the question with two dummy machines:

  1. The following machine state A will be waiting for event A_to_B , after which it will be received in unlimited loop by transmitting events as transit tasks:

      + ----- + + ----- + + - --- + | A. A_to_B / | B B_Toka / | C. | ----- | Sending B_to_C | ----- | Sending C_to_A | ----- | O---- & gt; | + ------------------- & gt; | + ------------------- & gt; | | | | | | | | + ----- + + ----- + + ----- + C_to_A / | | Sending A_to_B | + ------------------------------------------------- ---- +    
  2. The following machine will be immediately received in infinite loop by transmitting events as insertion tasks:

     < Code> + ------------------- + + ------------------- + +----- + | A. | B | C. | ------------------- | A_to_B | ------------------- | B_to_C | ----- | O---- & gt; | On entry: + ---------- & gt; | On entry: + ---------- & gt; | | | Sending A_to_B | | Sending B_to_C | | | | | | Sending C_to_A | | | + ------------------- + + ------------------- + + ----- + ^ | | CITO_A | + -------------------------------------------------  Text "> 

    A state machine can post events to itself, but it has special purpose, such as long-lasting (RTC) steps to complete in small pieces. To do this you would like to enable scheduling to other state machines in the system (or more generally active objects) between your very long RTC phase.

    Especially for your examples, I will try to avoid posting. Generally I see people do this, when they confuse State Churches with a flashchart. A state chunk is required to have events from state to state transition from a processing box to a flowchart transition on completion of the specified count in the box automatically. Obviously, when you post events yourself, you turn the state circle into a flowchart, therefore, you really need a flowchart and do not have state churches, because you do not really wait for anything you are full Keep pace with the process.

    You can see it like this, the purpose of the events is to provide new information to the state machine. This is how a state machine "learns" but when you post events yourself, you do not get new knowledge. Whatever knowledge you want, it has already been given by the original "true" incident. Therefore, instead of spreading you in many "states", there is enough information to move all of these processing into a transition, which is actually the lengthy processing phase.

No comments:

Post a Comment