ptolemy.caltrop.actors
Class AbstractCalInterpreter
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.caltrop.actors.AbstractCalInterpreter
- All Implemented Interfaces:
- java.io.Serializable, 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 an
Actor
data structure (setting
up ports, parameters, types etc.) and then proceeds to execute as the
actor by interpreting the actions using the DataflowActorInterpreter
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: AbstractCalInterpreter.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Jörn W. Janneck , Christopher Chang, Steve Neuendorffer
- See Also:
DataflowActorInterpreter
,
Context
,
PtolemyPlatform
,
Serialized Form
- Accepted Rating:
- Proposed Rating:
Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Method Summary |
protected void |
_attachActorIcon(java.lang.String name)
Attach the actor icon. |
private void |
_bindActorParameters(caltrop.interpreter.environment.Environment env)
|
private caltrop.interpreter.environment.Environment |
_extendEnvWithImports(caltrop.interpreter.environment.Environment env,
caltrop.interpreter.ast.Import[] imports)
|
private DDI |
_getDDI(caltrop.interpreter.environment.Environment env)
|
protected static Type |
_getPtolemyType(caltrop.interpreter.ast.TypeExpr typeExpr)
Get the Ptolemy type that corresponds to the given type expression. |
private void |
_initializeStateVariables(caltrop.interpreter.environment.Environment env)
|
private void |
_refreshParameters()
|
private void |
_refreshTypedIOPorts(caltrop.interpreter.ast.PortDecl[] ports,
boolean isInput,
boolean isOutput)
|
protected void |
_setupActor(caltrop.interpreter.ast.Actor actor)
Initialize this ptolemy actor using declarations in the given
CAL actor. |
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.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, 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 |
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, 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, propagateValue, propagateValues, removeChangeListener, removeDebugListener, 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 |
_actor
private caltrop.interpreter.ast.Actor _actor
_ddi
private DDI _ddi
_env
private caltrop.interpreter.environment.Environment _env
_globalEnv
private static final caltrop.interpreter.environment.Environment _globalEnv
_theContext
private static final caltrop.interpreter.Context _theContext
_directorToDDIMap
private static final java.util.Map _directorToDDIMap
importHandlers
private static java.util.List importHandlers
_typeReplacementMap
private static java.util.Map _typeReplacementMap
_lastGeneratedActorName
private java.lang.String _lastGeneratedActorName
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.
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 interface Initializable
- Overrides:
preinitialize
in class AtomicActor
- Throws:
IllegalActionException
- If an error occurred during the
retrieval of parameter values or the evaluation of actor state
variable values.
initialize
public void initialize()
throws IllegalActionException
- Initialize the actor, clearing its input channels.
- Specified by:
initialize
in interface Initializable
- Overrides:
initialize
in class AtomicActor
- Throws:
IllegalActionException
- If the superclass throws it.
prefire
public boolean prefire()
throws IllegalActionException
- Prefire the actor.
- Specified by:
prefire
in interface Executable
- Overrides:
prefire
in class AtomicActor
- Returns:
- true If the actor can be fired.
- Throws:
IllegalActionException
- If thrown by the parent or by the
prefire() meethod of the domain-dependent interpreter.
fire
public void fire()
throws IllegalActionException
- Fire the actor.
- Specified by:
fire
in interface Executable
- Overrides:
fire
in class AtomicActor
- Throws:
IllegalActionException
- If thrown by the parent or by the
fire() meethod of the domain-dependent interpreter.
postfire
public boolean postfire()
throws IllegalActionException
- Commit the last state changes.
- Specified by:
postfire
in interface Executable
- Overrides:
postfire
in class AtomicActor
- Returns:
- Returns whatever super.postfire() returns.
- Throws:
IllegalActionException
- If the superclass throws it.
_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)
- Attach the actor icon.
- Parameters:
name
- The name of the actor.
_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.
_bindActorParameters
private void _bindActorParameters(caltrop.interpreter.environment.Environment env)
throws IllegalActionException
- Throws:
IllegalActionException
_initializeStateVariables
private void _initializeStateVariables(caltrop.interpreter.environment.Environment env)
_getDDI
private DDI _getDDI(caltrop.interpreter.environment.Environment env)
_refreshParameters
private void _refreshParameters()
throws IllegalActionException,
NameDuplicationException
- Throws:
IllegalActionException
NameDuplicationException
_refreshTypedIOPorts
private void _refreshTypedIOPorts(caltrop.interpreter.ast.PortDecl[] ports,
boolean isInput,
boolean isOutput)
throws IllegalActionException,
NameDuplicationException
- Throws:
IllegalActionException
NameDuplicationException
_extendEnvWithImports
private caltrop.interpreter.environment.Environment _extendEnvWithImports(caltrop.interpreter.environment.Environment env,
caltrop.interpreter.ast.Import[] imports)