Package ptolemy.domains.metroII.kernel
Class ResumableFire
- java.lang.Object
-
- ptolemy.domains.metroII.kernel.FireMachine
-
- ptolemy.domains.metroII.kernel.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:- START: initial state
- BEGIN: prefire() is called and returns true. getfire() will be called.
- PROCESS: getfire() is being called, may be suspended but not terminated yet
- END: getfire() is called and returns properly.
- FINAL: final state
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)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.domains.metroII.kernel.FireMachine
FireMachine.State
-
-
Field Summary
Fields Modifier and Type Field Description protected net.jimblackler.Utils.YieldAdapterIterator<java.lang.Iterable<metroIIcomm.Event.Builder>>
_eventIterator
YieldAdapterIterator that is used to trigger actions of the wrapped actor.
-
Constructor Summary
Constructors Constructor Description ResumableFire(Actor actor)
Constructs a ResumableFire by wrapping the actor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
reset()
Stops and dispose any associated thread.void
startOrResume(java.util.LinkedList<metroIIcomm.Event.Builder> metroIIEventList)
Fires the wrapped actor in a resumable style.-
Methods inherited from class ptolemy.domains.metroII.kernel.FireMachine
actor, getState, getStateEvent, proposeStateEvent, setState, wrapup
-
-
-
-
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:- Propose MetroII event POSTFIRE_END_PREFIRE_BEGIN and wait for the event being notified
- prefire()
- Propose MetroII event PREFIRE_END_FIRE_BEGIN and wait for the event being notified
- Repeated calling getfire(eventList) and proposing events in the returned eventList until getfire(eventList) terminates properly
- Propose MetroII event FIRE_END_POSTFIRE_BEGIN and wait for the the event being notified
- postfire()
- Parameters:
metroIIEventList
- A list of MetroII events.- Throws:
IllegalActionException
- if the associated action (e.g. firing) is not permitted.
-
reset
public void reset()
Stops and dispose any associated thread.- Specified by:
reset
in interfaceStartOrResumable
- Overrides:
reset
in classFireMachine
-
-