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 anPteraDirector
to 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 PteraDirector
director
The Ptera director contained by this controller.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.-
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.void
attributeChanged(Attribute attribute)
React to a change in an attribute.java.lang.Object
clone(Workspace workspace)
Clone the controller into the specified workspace.void
fire()
Invoke the fire() method of the enclosedPteraDirector
.CausalityInterface
getCausalityInterface()
Return a causality interface for this actor.Director
getDirector()
Return the director responsible for the execution of this actor.Director
getExecutiveDirector()
Return the executive director.State
getInitialState()
Return null as the initial state.void
initialize()
Initialize this controller by initializing the director that it contains, which sets the initial events, and initializing all the refinements.boolean
isFireFunctional()
Return the result of isFireFunctional() from the director.boolean
isStrict()
Return the result of isStrict() from the director.int
iterate(int count)
Invoke a specified number of iterations of the actor by calling iterate() of the director.ComponentRelation
newRelation(java.lang.String name)
Create a new instance ofSchedulingRelation
with the specified name in this actor, and return it.boolean
postfire()
Invoke postfire() of the director.boolean
prefire()
Invoke prefire() of the director.void
preinitialize()
Preinitialize the controller by invoking preinitialize() of the director and that of the refinements.void
readInputs()
Set the value of the shadow variables for input ports of this actor.void
stop()
Stop execution by invoking stop() of the director.void
stopFire()
Request that execution of the current iteration stop as soon as possible by invoking stopFire() of the director.boolean
synchronizeToRealtime()
Return whether the synchronizeToRealtime attribute of this controller is set or not.void
terminate()
Invoke terminate() of the director.java.util.Set<Inequality>
typeConstraints()
Return the type constraints of this actor.void
wrapup()
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:
attributeChanged
in 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:
clone
in 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 IllegalActionException
Invoke the fire() method of the enclosedPteraDirector
.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in 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:
getCausalityInterface
in interfaceActor
- Overrides:
getCausalityInterface
in 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:
getDirector
in interfaceActor
- Overrides:
getDirector
in 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:
getExecutiveDirector
in interfaceActor
- Overrides:
getExecutiveDirector
in 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:
getInitialState
in classFSMActor
- Returns:
- null
-
initialize
public void initialize() throws IllegalActionException
Initialize this controller by initializing the director that it contains, which sets the initial events, and initializing all the refinements.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in 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:
isFireFunctional
in interfaceExecutable
- Overrides:
isFireFunctional
in classFSMActor
- Returns:
- The result of isFireFunctional() from the director.
-
isStrict
public boolean isStrict() throws IllegalActionException
Return the result of isStrict() from the director.- Specified by:
isStrict
in interfaceExecutable
- Overrides:
isStrict
in 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 IllegalActionException
Invoke 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:
iterate
in interfaceExecutable
- Overrides:
iterate
in 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 ofSchedulingRelation
with the specified name in this actor, and return it. This method is write-synchronized on the workspace.- Overrides:
newRelation
in 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 IllegalActionException
Invoke postfire() of the director.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classFSMActor
- Returns:
- Return value of postfire() of the director.
- Throws:
IllegalActionException
- If postfire() of the director throws it.
-
prefire
public boolean prefire() throws IllegalActionException
Invoke prefire() of the director.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classFSMActor
- Returns:
- Return value of prefire() of the director.
- Throws:
IllegalActionException
- If prefire() of the director throws it.
-
preinitialize
public void preinitialize() throws IllegalActionException
Preinitialize the controller by invoking preinitialize() of the director and that of the refinements.- Specified by:
preinitialize
in interfaceInitializable
- Overrides:
preinitialize
in classFSMActor
- Throws:
IllegalActionException
- If preinitialize() of the director or refinements throws it.
-
readInputs
public void readInputs() throws IllegalActionException
Set 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:
readInputs
in 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:
stop
in interfaceExecutable
- Overrides:
stop
in 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:
stopFire
in interfaceExecutable
- Overrides:
stopFire
in 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:
terminate
in interfaceExecutable
- Overrides:
terminate
in 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:
typeConstraints
in interfaceTypedActor
- Overrides:
typeConstraints
in classFSMActor
- Returns:
- A list of inequalities.
- See Also:
Inequality
-
wrapup
public void wrapup() throws IllegalActionException
Wrap up the controller by invoking wrapup() of the director and that of the refinements.- Specified by:
wrapup
in interfaceInitializable
- Overrides:
wrapup
in 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:
_getRefinementClasses
in classModalController
- Returns:
- The map.
-
_setCurrentEvent
protected void _setCurrentEvent(Event event)
Set the event currently being executed.- Parameters:
event
- The current event.
-
-