Package ptolemy.caltrop.actors
Class AbstractCalInterpreter
- java.lang.Object
-
- ptolemy.kernel.util.NamedObj
-
- ptolemy.kernel.InstantiableNamedObj
-
- ptolemy.kernel.Entity<T>
-
- ptolemy.kernel.ComponentEntity<T>
-
- ptolemy.actor.AtomicActor<TypedIOPort>
-
- ptolemy.actor.TypedAtomicActor
-
- ptolemy.caltrop.actors.AbstractCalInterpreter
-
- All Implemented Interfaces:
java.lang.Cloneable
,Actor
,Executable
,FiringsRecordable
,Initializable
,TypedActor
,Changeable
,Debuggable
,DebugListener
,Derivable
,Instantiable
,ModelErrorHandler
,MoMLExportable
,Moveable
,Nameable
- Direct Known Subclasses:
CalInterpreter
public abstract class AbstractCalInterpreter extends TypedAtomicActor
This class is the base class for actors that interpret CAL source inside the Ptolemy II framework. It configures itself according to anActor
data structure (setting up ports, parameters, types etc.) and then proceeds to execute as the actor by interpreting the actions using theDataflowActorInterpreter
infrastructure.The actor interpreter is configured by a context that injects the appropriate Token-based value system into the evaluation of the actions. This is implemented in the class
PtolemyPlatform
.For further documentation on CAL, see the Language Report.
- Since:
- Ptolemy II 4.1
- Version:
- $Id$
- Author:
- Jörn W. Janneck, Christopher Chang, Steve Neuendorffer
- See Also:
DataflowActorInterpreter
,Context
,PtolemyPlatform
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Yellow (neuendor)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
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 AbstractCalInterpreter(CompositeEntity container, java.lang.String name)
Construct an actor with the given container and name.AbstractCalInterpreter(Workspace workspace)
Construct an actor in the given workspace.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_attachActorIcon(java.lang.String name)
Attach the actor icon.protected static Type
_getPtolemyType(caltrop.interpreter.ast.TypeExpr typeExpr)
Get the Ptolemy type that corresponds to the given type expression.protected void
_setupActor(caltrop.interpreter.ast.Actor actor)
Initialize this ptolemy actor using declarations in the given CAL actor.java.lang.Object
clone(Workspace workspace)
Clone the object into the specified workspace.void
fire()
Fire the actor.void
initialize()
Initialize the actor, clearing its input channels.boolean
postfire()
Commit the last state changes.boolean
prefire()
Prefire the actor.void
preinitialize()
Populate the initial actor environment.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup
-
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName
-
Methods inherited from class ptolemy.kernel.Entity
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeChanged, attributeDeleted, attributeList, attributeList, 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, handleModelError, 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, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
isFireFunctional, isStrict, iterate, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, removeInitializable, wrapup
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Constructor Detail
-
AbstractCalInterpreter
public AbstractCalInterpreter(Workspace workspace)
Construct an actor in the given workspace. Increment the version number of the workspace.- Parameters:
workspace
- The workspace that will list the actor.
-
AbstractCalInterpreter
public AbstractCalInterpreter(CompositeEntity container, java.lang.String name) throws NameDuplicationException, IllegalActionException
Construct an actor with the given container and name.- Parameters:
container
- The container.name
- The name of this actor.- Throws:
IllegalActionException
- If the actor cannot be contained by the proposed container.NameDuplicationException
- If the container already has an actor with this name.
-
-
Method Detail
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the object into the specified workspace.- Overrides:
clone
in classTypedAtomicActor
- Parameters:
workspace
- The workspace for the new object.- Returns:
- A new NamedObj.
- Throws:
java.lang.CloneNotSupportedException
- If any of the attributes cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String)
,NamedObj.setDeferringChangeRequests(boolean)
-
fire
public void fire() throws IllegalActionException
Fire the actor.- Specified by:
fire
in interfaceExecutable
- Overrides:
fire
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If thrown by the parent or by the fire() method of the domain-dependent interpreter.
-
initialize
public void initialize() throws IllegalActionException
Initialize the actor, clearing its input channels.- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If the superclass throws it.
-
postfire
public boolean postfire() throws IllegalActionException
Commit the last state changes.- Specified by:
postfire
in interfaceExecutable
- Overrides:
postfire
in classAtomicActor<TypedIOPort>
- Returns:
- Returns whatever super.postfire() returns.
- Throws:
IllegalActionException
- If the superclass throws it.
-
preinitialize
public void preinitialize() throws IllegalActionException
Populate the initial actor environment. This is done by binding the parameters to the user-supplied values and then evaluating the definitions of state variables and creating the corresponding bindings.- Specified by:
preinitialize
in interfaceInitializable
- Overrides:
preinitialize
in classAtomicActor<TypedIOPort>
- Throws:
IllegalActionException
- If an error occurred during the retrieval of parameter values or the evaluation of actor state variable values.
-
prefire
public boolean prefire() throws IllegalActionException
Prefire the actor.- Specified by:
prefire
in interfaceExecutable
- Overrides:
prefire
in classAtomicActor<TypedIOPort>
- Returns:
- true If the actor can be fired.
- Throws:
IllegalActionException
- If thrown by the parent or by the prefire() method of the domain-dependent interpreter.
-
_setupActor
protected void _setupActor(caltrop.interpreter.ast.Actor actor) throws java.lang.Exception
Initialize this ptolemy actor using declarations in the given CAL actor.- Parameters:
actor
- The CAL actor to be used- Throws:
java.lang.Exception
- If there is a problem initializing the actor.
-
_attachActorIcon
protected void _attachActorIcon(java.lang.String name) throws IllegalActionException
Attach the actor icon.- Parameters:
name
- The name of the actor.- Throws:
IllegalActionException
- If thrown while getting the _iconDescription attribute.
-
_getPtolemyType
protected static Type _getPtolemyType(caltrop.interpreter.ast.TypeExpr typeExpr)
Get the Ptolemy type that corresponds to the given type expression.- Parameters:
typeExpr
- The type expression, one of "UINT8", "UINT9", "INT19" or "positive".- Returns:
- the corresponding type, which currently is always ptolemy.data.type.BaseType.int.
-
-