Class FireMachine

  • All Implemented Interfaces:
    StartOrResumable
    Direct Known Subclasses:
    BlockingFire, NonBlockingFire, ResumableFire

    public abstract class FireMachine
    extends java.lang.Object
    implements StartOrResumable
    FireMachine is an abstract wrapper for Ptolemy actors to adapt to MetroII semantics. FireMachine wraps an actor with a set of FSM interfaces so that the actor can be be seen as a FSM from outside. We pre-define the following states and each state represents a state of the wrapped actor:
    1. START: the initial state;
    2. BEGIN: before getfire() is called;
    3. FIRING: getfire() 'yield returns' (@see net.jimblackler.Utils) some internal MetroII events;
    4. END: after getfire() completes;
    5. FINAL: the final state.
    The wrapper explicitly records the current state of the FSM. The state transition is triggered by a function call to startOrResume(events) with MetroII events as the arguments.

    For any concrete subclass of ActMachine, the StartOrResumable() interface has to be implemented, in which how the FSM react to MetroII events (or in other words, the state transitions) should be implemented.

    Since:
    Ptolemy II 11.0
    Version:
    $Id$
    Author:
    Liangpeng Guo
    Pt.AcceptedRating:
    Red (glp)
    Pt.ProposedRating:
    Red (glp)
    • Constructor Detail

      • FireMachine

        public FireMachine​(Actor actor)
        Constructs an FireMachine wrapper and initialize the MetroII events.
        Parameters:
        actor - the actor whose getfire() is to be wrapped.
    • Method Detail

      • getStateEvent

        public metroIIcomm.Event.Builder getStateEvent()
        Returns the MetroII event associated with the current state.
        Returns:
        the MetroII event associated with the current state.
      • reset

        public void reset()
        Resets the state to be PREFIRE_BEGIN.
        Specified by:
        reset in interface StartOrResumable
      • wrapup

        public void wrapup()
        Wraps up the firing by reseting.
      • actor

        protected Actor actor()
        Returns the wrapped actor.
        Returns:
        the wrapped actor.
      • proposeStateEvent

        protected metroIIcomm.Event.Builder proposeStateEvent()
        Returns the MetroII event associated with the current state and set the state of the event to be PROPOSED.
        Returns:
        the MetroII event associated with the current state
      • setState

        protected void setState​(FireMachine.State state)
        Sets the state of the wrapped actor.
        Parameters:
        state - the state to be set.
        See Also:
        getState()