Class NonStrictFSMDirector
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.util.Attribute
-
- ptolemy.actor.Director
-
- ptolemy.domains.modal.kernel.FSMDirector
-
- ptolemy.domains.modal.kernel.NonStrictFSMDirector
-
- All Implemented Interfaces:
java.lang.Cloneable
,Executable
,Initializable
,QuasiTransparentDirector
,SuperdenseTimeDirector
,ExplicitChangeContext
,Changeable
,Debuggable
,DebugListener
,Derivable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
public class NonStrictFSMDirector extends FSMDirector
This director extends FSMDirector by consuming only input tokens that are needed in the current state. An input port will consume at most one token if:1. The port is referred by any guard expression of the preemptive transitions leaving the current state, the output actions and/or set actions of the enabled transition.
2. No preemptive transition is enabled and the port is referred by the refinements of the current state, any guard expression of the nonpreemptive transitions leaving the current state, the output actions and/or set actions of the enabled transition.
A port is said to be referred by a guard/output action/set action expression of a transition if the port name appears in that expression. A port is said to be referred by a state refinement if the it is not a dangling port and has a consumption rate greater than zero in the refinement.
FIXME: This is highly preliminary. Missing capabilities: FIXME: Currently this director uses the default receiver of FSMDirector, which is a mailbox, so there is no way to consume more than one token. This director could use a different receiver and support a syntax in the guard expression language to support consumption of more than one token. FIXME: This director does not support immediate transitions.
- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Ye Zhou
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (zhouye)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.domains.modal.kernel.FSMDirector
_currentLocalReceiverMap, _indexOffset, _localReceiverMaps, controllerName
-
Fields inherited from class ptolemy.actor.Director
_actorsFinishedExecution, _aspectForActor, _aspectsPresent, _defaultMicrostep, _executionAspects, _finishRequested, _initializables, _nextScheduleTime, _stopRequested, _tokenSentToCommunicationAspect, _zeroTime, localClock, startTime, stopTime
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description NonStrictFSMDirector(CompositeEntity container, java.lang.String name)
Construct a director in the given container with the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone(Workspace workspace)
Clone the actor into the specified workspace.void
fire()
Fire the modal model.void
getNonpreemptiveTransitionsReferredInputPorts(State state)
Given a state, get a set of input ports referred in the guards of the preemptive transitions leaving that state.void
getOutputActionsReferredInputPorts(Transition transition)
Given a transition, get a set of input ports referred in the outputActions of that transition.void
getPreemptiveTransitionsReferredInputPorts(State state)
Given a state, get a set of input ports referred in the guards of the preemptive transitions leaving that state.void
getReferredInputPorts(java.util.Set portSet, java.util.Set referredInputPorts)
Given a set of ports, get those that are input ports of the container and put them in the indicated referred set.void
getRefinementReferredInputPorts(State state)
Given a state, get a set of input ports referred by the refinements of that state.void
getSetActionsReferredInputPorts(Transition transition)
Given a transition, get a set of input ports referred in the set actions of that transition.java.util.Set
getTransitionReferredInputPorts(java.util.List transitionList)
Given a list of transitions, get a set of referred input ports in the guard expressions of all the transitions leaving this state.void
initialize()
Initialize the director.boolean
postfire()
Call the postfire() method of the super class.boolean
transferInputs(IOPort port)
Override the super class by only transferring inputs for those input ports that are referred by the guard expressions of the preemptive transitions leaving the current state.-
Methods inherited from class ptolemy.domains.modal.kernel.FSMDirector
_buildLocalReceiverMaps, _currentLocalReceivers, _getLastChosenTransition, _getStateRefinementsToPostfire, _getTransitionRefinementsToPostfire, _readInputs, _readOutputsFromRefinement, _setCurrentConnectionMap, _setCurrentState, _transferOutputs, attributeChanged, defaultDependency, fireAt, getContext, getController, getIndex, getModelNextIterationTime, getModifiedVariables, getParseTreeEvaluator, handleModelError, implementsStrictActorSemantics, invalidateSchedule, isStrict, newReceiver, prefire, preinitialize, resetOutputReceivers, setContainer, setIndex
-
Methods inherited from class ptolemy.actor.Director
_actorFinished, _consultTimeRegulators, _description, _isEmbedded, _isTopLevel, _schedule, _transferInputs, addInitializable, createSchedule, delayDependency, elapsedTimeSinceStart, finish, fireAt, fireAt, fireAtCurrentTime, fireContainerAt, fireContainerAt, getCausalityInterface, getCurrentTime, getDeadline, getEnvironmentTime, getExecutionAspect, getGlobalTime, getModelStartTime, getModelStopTime, getModelTime, getNextIterationTime, getStartTime, getStopTime, getTimeResolution, initialize, invalidateResolvedTypes, isEmbedded, isFireFunctional, isStopRequested, iterate, mutexLockObject, notifyTokenSentToCommunicationAspect, preinitialize, removeInitializable, requestInitialization, resume, resumeActor, scheduleContainedActors, setCurrentTime, setEmbedded, setModelTime, setTimeResolution, stop, stopFire, suggestedModalModelDirectors, supportMultirateFiring, suspend, terminate, transferOutputs, transferOutputs, wrapup
-
Methods inherited from class ptolemy.kernel.util.Attribute
_checkContainer, _getContainedObject, _propagateExistence, getContainer, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, setName, updateContent
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _exportMoMLContents, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, containedObjectsIterator, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateExistence, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, uniqueName, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Constructor Detail
-
NonStrictFSMDirector
public NonStrictFSMDirector(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct a director in the given container with the given name. The container argument must not be null, or a NullPointerException will be thrown. If the name argument is null, then the name is set to the empty string. Increment the version number of the workspace.- Parameters:
container
- Container of this director.name
- Name of this director.- Throws:
IllegalActionException
- If the name has a period in it, or the director is not compatible with the specified container.NameDuplicationException
- If the container not a CompositeActor and the name collides with an entity in the container.
-
-
Method Detail
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace. This calls the base class and then sets the attribute public members to refer to the attributes of the new actor.- Overrides:
clone
in classFSMDirector
- Parameters:
workspace
- The workspace for the new actor.- Returns:
- A new FSMActor.
- Throws:
java.lang.CloneNotSupportedException
- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Fire the modal model. The preemptive transitions from the current state are examined. If there is more than one transition enabled, an exception is thrown. If there is exactly one preemptive transition enabled, then it is chosen. Get additional input ports referred by the output actions and set actions of the enabled transition and executed the output actions. The refinements of the current state will not be fired.If no preemptive transition is enabled, get additional input ports referred by the refinements of the current state and transfer at most one token from these input ports. Fire the refinements. After this, get additional input ports referred by the nonpreemptive transitions from the current state and transfer at most one token from these input ports. Then examine the nonpreemptive transitions. If there is more than one transition enabled, an exception is thrown. If there is exactly one nonpreemptive transition enabled, then it is chosen. Get additional input ports referred by the output actions and set actions of the enabled transition and executed the output actions.
- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classFSMDirector
- Throws:
IllegalActionException
- If the super class throws it.
-
getNonpreemptiveTransitionsReferredInputPorts
public void getNonpreemptiveTransitionsReferredInputPorts(State state) throws IllegalActionException
Given a state, get a set of input ports referred in the guards of the preemptive transitions leaving that state.- Parameters:
state
- The given state.- Throws:
IllegalActionException
- If there is no controller or if any guard expression is illegal.
-
getOutputActionsReferredInputPorts
public void getOutputActionsReferredInputPorts(Transition transition) throws IllegalActionException
Given a transition, get a set of input ports referred in the outputActions of that transition.- Parameters:
transition
- The transition.- Throws:
IllegalActionException
- If there is no controller or if the outputActions is illegal.
-
getPreemptiveTransitionsReferredInputPorts
public void getPreemptiveTransitionsReferredInputPorts(State state) throws IllegalActionException
Given a state, get a set of input ports referred in the guards of the preemptive transitions leaving that state.- Parameters:
state
- The given state.- Throws:
IllegalActionException
- If there is no controller or if any guard expression is illegal.
-
getReferredInputPorts
public void getReferredInputPorts(java.util.Set portSet, java.util.Set referredInputPorts)
Given a set of ports, get those that are input ports of the container and put them in the indicated referred set.- Parameters:
portSet
- The given set of portsreferredInputPorts
- The referred set.
-
getRefinementReferredInputPorts
public void getRefinementReferredInputPorts(State state) throws IllegalActionException
Given a state, get a set of input ports referred by the refinements of that state.- Parameters:
state
- The given state.- Throws:
IllegalActionException
- If refinement with given name is not found, or if the port rate does not contain a valid expression.
-
getSetActionsReferredInputPorts
public void getSetActionsReferredInputPorts(Transition transition) throws IllegalActionException
Given a transition, get a set of input ports referred in the set actions of that transition.- Parameters:
transition
- The given transition.- Throws:
IllegalActionException
- If there is no controller or if any set action expression is illegal.
-
getTransitionReferredInputPorts
public java.util.Set getTransitionReferredInputPorts(java.util.List transitionList) throws IllegalActionException
Given a list of transitions, get a set of referred input ports in the guard expressions of all the transitions leaving this state.- Parameters:
transitionList
- The list of Transitions.- Returns:
- A set of input ports referred by the guard expressions of the given transition list.
- Throws:
IllegalActionException
- If there is no controller or if the guard expression is illegal.
-
initialize
public void initialize() throws IllegalActionException
Initialize the director. Get the referred input ports in the guard expressions of all preemptive transitions leaving the initial state.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classFSMDirector
- Throws:
IllegalActionException
- If the super class throws it.
-
postfire
public boolean postfire() throws IllegalActionException
Call the postfire() method of the super class. Get the referred input ports in the guard expressions of all preemptive transitions that go out from the current state.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classFSMDirector
- Returns:
- True if the mode controller wishes to be scheduled for another iteration.
- Throws:
IllegalActionException
- If the super class throws it.
-
transferInputs
public boolean transferInputs(IOPort port) throws IllegalActionException
Override the super class by only transferring inputs for those input ports that are referred by the guard expressions of the preemptive transitions leaving the current state.- Overrides:
transferInputs
in classFSMDirector
- Parameters:
port
- The input port to transfer tokens from.- Returns:
- True if at least one data token is transferred.
- Throws:
IllegalActionException
- If the port is not an opaque input port.
-
-