Package ptolemy.domains.ptera.kernel
Class PteraController
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable,Actor,Executable,Initializable,TypedActor,ExplicitChangeContext,RefinementActor,Changeable,Debuggable,DebugListener,Derivable,DropTargetHandler,Instantiable,ModelErrorHandler,MoMLExportable,Moveable,Nameable
public class PteraController extends ModalController
This controller is used in every Ptera modal model. It contains anPteraDirectorto execute the events in it.Each Ptera modal model has one or more Ptera controllers. One of those controllers is the top level controller, which can be obtained with
ModalModel.getController(). The other controllers are refinements of events.- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Thomas Huining Feng
- Pt.AcceptedRating:
- Red (tfeng)
- Pt.ProposedRating:
- Yellow (tfeng)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.domains.modal.kernel.FSMActor
FSMActor.PortScope
-
Nested classes/interfaces inherited from class ptolemy.kernel.CompositeEntity
CompositeEntity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description PteraDirectordirectorThe Ptera director contained by this controller.ParameterLIFOA Boolean parameter that decides whether simultaneous events should be placed in the event queue in the last-in-first-out (LIFO) fashion or not.-
Fields inherited from class ptolemy.domains.modal.modal.ModalController
_mirrorDisable
-
Fields inherited from class ptolemy.domains.modal.kernel.FSMActor
_currentState, _disabledRefinements, _initializables, _inputTokenMap, _lastChosenTransition, _lastChosenTransitions, _lastTakenTransitions, _stateRefinementsToPostfire, _stopRequested, errorCause, errorClass, errorMessage, finalStateNames, initialStateName, probability, resetOnEachRun, seed, stateDependentCausality, timeout
-
Fields inherited from class ptolemy.kernel.CompositeEntity
_levelCrossingLinks
-
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 PteraController(CompositeEntity container, java.lang.String name)Construct an Ptera controller with a name and a container.PteraController(Workspace workspace)Construct an Ptera controller in the specified workspace with no container and an empty string as a name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.TreeMap<java.lang.Class<? extends Entity>,java.lang.String>_getRefinementClasses()Return a map from the classes of the entities to be dropped into a state and the class names of the refinements that can be used to contain those entities.protected void_setCurrentEvent(Event event)Set the event currently being executed.voidattributeChanged(Attribute attribute)React to a change in an attribute.java.lang.Objectclone(Workspace workspace)Clone the controller into the specified workspace.voidfire()Invoke the fire() method of the enclosedPteraDirector.CausalityInterfacegetCausalityInterface()Return a causality interface for this actor.DirectorgetDirector()Return the director responsible for the execution of this actor.DirectorgetExecutiveDirector()Return the executive director.StategetInitialState()Return null as the initial state.voidinitialize()Initialize this controller by initializing the director that it contains, which sets the initial events, and initializing all the refinements.booleanisFireFunctional()Return the result of isFireFunctional() from the director.booleanisStrict()Return the result of isStrict() from the director.intiterate(int count)Invoke a specified number of iterations of the actor by calling iterate() of the director.ComponentRelationnewRelation(java.lang.String name)Create a new instance ofSchedulingRelationwith the specified name in this actor, and return it.booleanpostfire()Invoke postfire() of the director.booleanprefire()Invoke prefire() of the director.voidpreinitialize()Preinitialize the controller by invoking preinitialize() of the director and that of the refinements.voidreadInputs()Set the value of the shadow variables for input ports of this actor.voidstop()Stop execution by invoking stop() of the director.voidstopFire()Request that execution of the current iteration stop as soon as possible by invoking stopFire() of the director.booleansynchronizeToRealtime()Return whether the synchronizeToRealtime attribute of this controller is set or not.voidterminate()Invoke terminate() of the director.java.util.Set<Inequality>typeConstraints()Return the type constraints of this actor.voidwrapup()Wrap up the controller by invoking wrapup() of the director and that of the refinements.-
Methods inherited from class ptolemy.domains.modal.modal.ModalController
_addPort, _checkContainer, addRefinement, dropObject, getRefinedState, newPort, setMirrorDisable
-
Methods inherited from class ptolemy.domains.modal.kernel.FSMActor
_addEntity, _addRelation, _areAllImmediateTransitionsDisabled, _chooseTransitions, _destinationState, _getChannelForIdentifier, _getPortForIdentifier, _getStateRefinementsToPostfire, _getTransitionRefinementsToPostfire, _init, _initializeRefinements, _isRefinementOutput, _isSafeToClear, _readInputs, _schedule, _setCurrentConnectionMap, _setTimeForRefinement, addChosenTransition, addInitializable, createReceivers, currentState, enabledTransitions, exportSubmodel, foundUnknown, getContext, getLastChosenTransition, getLastChosenTransitions, getLastTakenTransitions, getManager, getModifiedVariables, getPortScope, handleModelError, hasInput, hasInput, inputPortList, isBackwardTypeInferenceEnabled, isOpaque, newReceiver, outputPortList, readOutputsFromRefinement, removeInitializable, reset, setLastChosenTransition, setNewIteration, setSupportMultirate, wasTransitionTaken
-
Methods inherited from class ptolemy.kernel.CompositeEntity
_adjustDeferrals, _containedDecorators, _deepOpaqueEntityList, _description, _exportMoMLContents, _finishedAddEntity, _removeEntity, _removeRelation, _validateSettables, allAtomicEntityList, allowLevelCrossingConnect, classDefinitionList, connect, connect, containedObjectsIterator, deepCompositeEntityList, deepEntityList, deepGetEntities, deepNamedObjList, deepOpaqueEntityList, deepRelationSet, entityList, entityList, exportLinks, exportMoML, getAttribute, getEntities, getEntity, getPort, getRelation, getRelations, isAtomic, lazyAllAtomicEntityList, lazyAllCompositeEntityList, lazyAllCompositeTransparentAndOpaqueEntityList, lazyClassDefinitionList, lazyDeepEntityList, lazyEntityList, lazyRelationList, numberOfEntities, numberOfRelations, numEntities, numRelations, relationList, removeAllEntities, removeAllRelations, setClassDefinition, setContainer, statistics, uniqueName
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_removePort, connectedPortList, connectedPorts, connectionsChanged, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, attributeTypeChanged, clone, decorators, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
Methods inherited from interface ptolemy.actor.TypedActor
isBackwardTypeInferenceEnabled
-
-
-
-
Field Detail
-
LIFO
public Parameter LIFO
A Boolean parameter that decides whether simultaneous events should be placed in the event queue in the last-in-first-out (LIFO) fashion or not.
-
director
public PteraDirector director
The Ptera director contained by this controller.
-
-
Constructor Detail
-
PteraController
public PteraController(CompositeEntity container, java.lang.String name) throws IllegalActionException, NameDuplicationException
Construct an Ptera controller with a name and a container.- Parameters:
container- The container, which must be anPteraModalModel.name- The name.- Throws:
IllegalActionException- If the container is incompatible with this actor.NameDuplicationException- If the name coincides with an actor already in the container.
-
PteraController
public PteraController(Workspace workspace) throws IllegalActionException, NameDuplicationException
Construct an Ptera controller in the specified workspace with no container and an empty string as a name. If the workspace argument is null, then use the default workspace.- Parameters:
workspace- The workspace that will list the controller.- Throws:
IllegalActionException- If the container is incompatible with this actor.NameDuplicationException- If the name coincides with an actor already in the container.
-
-
Method Detail
-
attributeChanged
public void attributeChanged(Attribute attribute) throws IllegalActionException
React to a change in an attribute.- Overrides:
attributeChangedin classFSMActor- Parameters:
attribute- The attribute that changed.- Throws:
IllegalActionException- If thrown by the superclass attributeChanged() method, or if the value of the LIFO parameter cannot be read.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the controller 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:
clonein classFSMActor- Parameters:
workspace- The workspace for the new controller.- Returns:
- A new PteraController.
- 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 IllegalActionExceptionInvoke the fire() method of the enclosedPteraDirector.- Specified by:
firein interfaceExecutable- Overrides:
firein classFSMActor- Throws:
IllegalActionException- If the PteraDirector throws it.- See Also:
PteraDirector.fire()
-
getCausalityInterface
public CausalityInterface getCausalityInterface()
Return a causality interface for this actor. This method returns the causality interface where no output port depends on the input ports. It is an instance ofBreakCausalityInterface. FIXME: A causality interface special for Ptera should be returned instead.- Specified by:
getCausalityInterfacein interfaceActor- Overrides:
getCausalityInterfacein classFSMActor- Returns:
- A representation of the dependencies between input ports and output ports.
-
getDirector
public Director getDirector()
Return the director responsible for the execution of this actor.- Specified by:
getDirectorin interfaceActor- Overrides:
getDirectorin classFSMActor- Returns:
- The director responsible for the execution of this actor.
-
getExecutiveDirector
public Director getExecutiveDirector()
Return the executive director. If the current controller is the top-level controller of an Ptera modal model, then the executive director is its director (returned bygetDirector()). Otherwise, the executive director is the director of the Ptera controller at a higher level in the refinement hierarchy.- Specified by:
getExecutiveDirectorin interfaceActor- Overrides:
getExecutiveDirectorin classFSMActor- Returns:
- The executive director.
-
getInitialState
public State getInitialState()
Return null as the initial state. In Ptera there are multiple initial events. This method is overridden to return null. To get the list of initial events, check the isInitialState parameter of the events contained in this controller.- Overrides:
getInitialStatein classFSMActor- Returns:
- null
-
initialize
public void initialize() throws IllegalActionExceptionInitialize this controller by initializing the director that it contains, which sets the initial events, and initializing all the refinements.- Specified by:
initializein interfaceInitializable- Overrides:
initializein classFSMActor- Throws:
IllegalActionException- If the director or initialize() of the superclass throws it.
-
isFireFunctional
public boolean isFireFunctional()
Return the result of isFireFunctional() from the director.- Specified by:
isFireFunctionalin interfaceExecutable- Overrides:
isFireFunctionalin classFSMActor- Returns:
- The result of isFireFunctional() from the director.
-
isStrict
public boolean isStrict() throws IllegalActionExceptionReturn the result of isStrict() from the director.- Specified by:
isStrictin interfaceExecutable- Overrides:
isStrictin classFSMActor- Returns:
- The result of isStrict() from the director.
- Throws:
IllegalActionException- Thrown if causality interface cannot be computed.
-
iterate
public int iterate(int count) throws IllegalActionExceptionInvoke a specified number of iterations of the actor by calling iterate() of the director. An iteration is equivalent to invoking prefire(), fire(), and postfire(), in that order. In an iteration, if prefire() returns true, then fire() will be called once, followed by postfire(). Otherwise, if prefire() returns false, fire() and postfire() are not invoked, and this method returns NOT_READY. If postfire() returns false, then no more iterations are invoked, and this method returns STOP_ITERATING. Otherwise, it returns COMPLETED. If stop() is called while this is executing, then cease executing and return STOP_ITERATING.- Specified by:
iteratein interfaceExecutable- Overrides:
iteratein classFSMActor- Parameters:
count- The number of iterations to perform.- Returns:
- NOT_READY, STOP_ITERATING, or COMPLETED.
- Throws:
IllegalActionException- If iterating is not permitted, or if prefire(), fire(), or postfire() throw it.
-
newRelation
public ComponentRelation newRelation(java.lang.String name) throws IllegalActionException, NameDuplicationException
Create a new instance ofSchedulingRelationwith the specified name in this actor, and return it. This method is write-synchronized on the workspace.- Overrides:
newRelationin classFSMActor- Parameters:
name- The name of the new scheduling relation.- Returns:
- A scheduling relation with the given name.
- Throws:
IllegalActionException- If the name argument is null.NameDuplicationException- If name collides with that of a scheduling relation already in this actor.
-
postfire
public boolean postfire() throws IllegalActionExceptionInvoke postfire() of the director.- Specified by:
postfirein interfaceExecutable- Overrides:
postfirein classFSMActor- Returns:
- Return value of postfire() of the director.
- Throws:
IllegalActionException- If postfire() of the director throws it.
-
prefire
public boolean prefire() throws IllegalActionExceptionInvoke prefire() of the director.- Specified by:
prefirein interfaceExecutable- Overrides:
prefirein classFSMActor- Returns:
- Return value of prefire() of the director.
- Throws:
IllegalActionException- If prefire() of the director throws it.
-
preinitialize
public void preinitialize() throws IllegalActionExceptionPreinitialize the controller by invoking preinitialize() of the director and that of the refinements.- Specified by:
preinitializein interfaceInitializable- Overrides:
preinitializein classFSMActor- Throws:
IllegalActionException- If preinitialize() of the director or refinements throws it.
-
readInputs
public void readInputs() throws IllegalActionExceptionSet the value of the shadow variables for input ports of this actor. This method skips over ports that connected to outputs of a refinement.- Overrides:
readInputsin classFSMActor- Throws:
IllegalActionException- If a shadow variable cannot take the token read from its corresponding channel (should not occur).
-
stop
public void stop()
Stop execution by invoking stop() of the director.- Specified by:
stopin interfaceExecutable- Overrides:
stopin classFSMActor
-
stopFire
public void stopFire()
Request that execution of the current iteration stop as soon as possible by invoking stopFire() of the director.- Specified by:
stopFirein interfaceExecutable- Overrides:
stopFirein classFSMActor
-
synchronizeToRealtime
public boolean synchronizeToRealtime()
Return whether the synchronizeToRealtime attribute of this controller is set or not.- Returns:
- True if synchronizedToRealtime is set; false otherwise.
-
terminate
public void terminate()
Invoke terminate() of the director.- Specified by:
terminatein interfaceExecutable- Overrides:
terminatein classFSMActor
-
typeConstraints
public java.util.Set<Inequality> typeConstraints()
Return the type constraints of this actor. The constraints have the form of a set of inequalities. This method first creates constraints such that the type of any input port that does not have its type declared must be less than or equal to the type of any output port that does not have its type declared. Type constraints from the contained Typeables (ports, variables, and parameters) are collected. In addition, type constraints from all the transitions are added. These constraints are determined by the guard and trigger expressions of transitions, and actions contained by the transitions. This method is read-synchronized on the workspace.- Specified by:
typeConstraintsin interfaceTypedActor- Overrides:
typeConstraintsin classFSMActor- Returns:
- A list of inequalities.
- See Also:
Inequality
-
wrapup
public void wrapup() throws IllegalActionExceptionWrap up the controller by invoking wrapup() of the director and that of the refinements.- Specified by:
wrapupin interfaceInitializable- Overrides:
wrapupin classFSMActor- Throws:
IllegalActionException- If wrapup() of the director or refinements throws it.
-
_getRefinementClasses
protected java.util.TreeMap<java.lang.Class<? extends Entity>,java.lang.String> _getRefinementClasses()
Return a map from the classes of the entities to be dropped into a state and the class names of the refinements that can be used to contain those entities.- Overrides:
_getRefinementClassesin classModalController- Returns:
- The map.
-
_setCurrentEvent
protected void _setCurrentEvent(Event event)
Set the event currently being executed.- Parameters:
event- The current event.
-
-