Menu

How to invoke only some methods in Entry are?

Help
Kairat
2006-05-31
2013-05-28
  • Kairat

    Kairat - 2006-05-31

    Hello !

    I've a few objects(duplicate) with same State Machine scenario.
    In Entry area of X_STATE, I want that only some methods will be invoked.
    Scenario :
    One of SM (first listened) handles event from queue, goes to X_STATE, invoke all method and sends to all object event change state to X_STATE (even himself). Now every object must invoke only c(), d() method.

    obj1.SM         obj2.SM          obj3.SM

    X_STATE         X_STATE          X_STATE
    Entry           Entry            Entry
    {               {                {
    a()//first inv.  a()//not         a()//not
    b()//first inv.  b()//not         b()//not
    c()//all inv.    c()//all inv.    c()//all inv.
    d()//all inv.    d()//all inv.    d()//all inv.
    }                }                }

    How can I do it?

    Thanks.

     
    • Charles Rapp

      Charles Rapp - 2006-06-01

      1. Entry actions are only invoked upon entering a state.
      2. There is no way to invoke some Entry actions. All Entry actions are invoked.

      The solution to this problem is to place actions a() and b() in a conditional transition and keep actions c() and d() in the X_STATE entry actions. Example:

      W_STATE
      {
          // First handler - execute a() and b().
          X_TRANSITION(event: QueueEvent)
            [event.firstHandler() == true]
              X_STATE
              {
                  a();
                  b();
              }

          // Not first handler - no actions.
          X_TRANSITION(event: QueueEvent)
              X_STATE
              {}
      }

      X_STATE
          Entry
          {
              c();
              d();
          }
      {
          ...
      }

      Does this solution meet your needs?

      Charles Rapp

       

Log in to post a comment.

MongoDB Logo MongoDB