Class ResumableFire

  • All Implemented Interfaces:
    StartOrResumable

    public class ResumableFire
    extends FireMachine
    ResumableFire is a wrapper for Ptolemy actor. It provides an implementation of FireMachine. More specifically, the wrapper implements a startOrResume() function that associates the state of FireMachine with the state of fire() of the wrapped actor as follows:
    1. START: initial state
    2. BEGIN: prefire() is called and returns true. getfire() will be called.
    3. PROCESS: getfire() is being called, may be suspended but not terminated yet
    4. END: getfire() is called and returns properly.
    5. FINAL: final state
    When startOrResume() is called, the wrapper checks if the Metro event associated with the current state is notified. If the event is notified, call related function of the wrapped actor, transition to the next state, and propose the Metro event associated with the next state. For example,
           action: propose FIRE_BEGIN
     START ---------------------------------------> BEGIN
    
           guard: FIRE_BEGIN is notified
           action: call fire(), propose FIRE_END
     BEGIN ---------------------------------------> FIRE_END
    
           guard: FIRE_BEGIN is not notified
           action: propose FIRE_BEGIN
     BEGIN ---------------------------------------> BEGIN
     
    Since:
    Ptolemy II 11.0
    Version:
    $Id$
    Author:
    Liangpeng Guo
    Pt.AcceptedRating:
    Red (glp)
    Pt.ProposedRating:
    Red (glp)
    • Field Detail

      • _eventIterator

        protected net.jimblackler.Utils.YieldAdapterIterator<java.lang.Iterable<metroIIcomm.Event.Builder>> _eventIterator
        YieldAdapterIterator that is used to trigger actions of the wrapped actor.
    • Constructor Detail

      • ResumableFire

        public ResumableFire​(Actor actor)
        Constructs a ResumableFire by wrapping the actor.
        Parameters:
        actor - Actor to be wrapped
    • Method Detail

      • startOrResume

        public void startOrResume​(java.util.LinkedList<metroIIcomm.Event.Builder> metroIIEventList)
                           throws IllegalActionException
        Fires the wrapped actor in a resumable style. The function getfire() of the wrapped actor is called in startOrResume() as follows:
        1. Propose MetroII event POSTFIRE_END_PREFIRE_BEGIN and wait for the event being notified
        2. prefire()
        3. Propose MetroII event PREFIRE_END_FIRE_BEGIN and wait for the event being notified
        4. Repeated calling getfire(eventList) and proposing events in the returned eventList until getfire(eventList) terminates properly
        5. Propose MetroII event FIRE_END_POSTFIRE_BEGIN and wait for the the event being notified
        6. postfire()
        where 'wait' means checking the status of MetroII event. If notified, continue execution, otherwise proposing the same event again.
        Parameters:
        metroIIEventList - A list of MetroII events.
        Throws:
        IllegalActionException - if the associated action (e.g. firing) is not permitted.