Menu

multiple FSM

Help
stefano
2005-11-16
2013-05-28
  • stefano

    stefano - 2005-11-16

    Hi,

    I have multiple communicating FSMs.
    I have seen that multiple "map" in the same
    ".sm" have the same "transitions", instead
    i have different transitions in differents fsm.

    How can i do for communications between FSMs?
    (i could make differents applications and use sockets, but i prefer an embedded solution,
    inside one ".sm" file only).

    One FSM action should be able to call a transition of another FSM.

    Bye

     
    • Charles Rapp

      Charles Rapp - 2005-11-16

      Stefano,

      SMC finite state machines can communicate - through the objects that own them. SMC state machines are used to define an object's behavior. These FSMs are not independent, stand-alone agents but passive entities driven by their owning object. So if you want FSMs to communicate, then it is their owning objects that communicate.

      Using Java as the example language, you have two classes: SuperTask and SubTask. Both use an FSM to define their behavior: SuperTask.sm and SubTask.sm. A SuperTask has or more SubTasks and each SubTask works for one SuperTask.

      In SMC, your objects maintain a reference to its FSM. The FSM has a method for each unique transition. When you want to issue a transition, you call the appropriate transition method in your FSM object.

      The SuperTask and SubTask FSMs communicate with each other when the SuperTask and SubTask objects call each others methods. But there is a situation with SMC-generated FSMs: you cannot issue a transition to the same FSM while that FSM is in transition. So you cannot do the following:

      method SuperTask.close()
        transition SuperTask FSM.close()
          calls method SubTask.close()
            transition SubTask FSM.close()
              calls method SuperTask.closed(SubTask task)
                transition SuperTask FSM.subtaskClose(task)
                  ERROR! superTask FSM already in transition.

      When your FSMs communicate, you can't use synchronous communicate (i.e. method calls). One solution is to use event queues. So the method SuperTask.close() does not directly issue the close transition but enqueues a close event and the queue processing then issues the close transition.

      If you haven't read the SMC Programmer's Manual, I suggest you go to http://smc.sourceforge.net and read manual section 1. This provides an overview of what SMC does for you and how it can be used with various programming languages.

      Finally, the multiple maps in a single .sm file do not represent multiple FSMs. Rather, they are all part of the same FSM. SMC allows you to define sub-maps which function similarly to subroutines. Just as you can break your code into ever simpler subroutines, you can break your FSM into even simpler sub-maps.

      I hope this explanation helps.

      Charles Rapp

       
    • stefano

      stefano - 2005-11-18

      thanks a lot

      bye

       

Log in to post a comment.

MongoDB Logo MongoDB