ptolemy.vergil.actor.lib
Class VisualModelReference

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.InstantiableNamedObj
          extended byptolemy.kernel.Entity
              extended byptolemy.kernel.ComponentEntity
                  extended byptolemy.actor.AtomicActor
                      extended byptolemy.actor.TypedAtomicActor
                          extended byptolemy.actor.lib.hoc.ModelReference
                              extended byptolemy.vergil.actor.lib.VisualModelReference
All Implemented Interfaces:
Actor, Changeable, java.lang.Cloneable, Debuggable, DebugListener, Derivable, Executable, ExecutionListener, Instantiable, ModelErrorHandler, MoMLExportable, Nameable, java.io.Serializable, TypedActor

public class VisualModelReference
extends ModelReference
implements ExecutionListener

This is an atomic actor that can execute and/or open a model specified by a file or URL. This can be used to define an actor whose firing behavior is given by a complete execution of another model. It extends the base class with the following attributes and associated capabilities.

There are currently a number of serious limitations:

Since:
Ptolemy II 4.0
Version:
$Id: VisualModelReference.java,v 1.12 2004/04/13 03:49:00 cxh Exp $
Author:
Edward A. Lee
See Also:
Variable, Parameter, Settable, Serialized Form
Accepted Rating:
Red (eal)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
 
Field Summary
 StringParameter closeOnPostfire
          The value of this string parameter determines what close action happens in the postfire() method.
 StringParameter openOnFiring
          The value of this string parameter determines what open happens when the fire() method is invoked.
 
Fields inherited from class ptolemy.actor.lib.hoc.ModelReference
_model, executionOnFiring, lingerTime, modelFileOrURL, postfireAction
 
Fields inherited from class ptolemy.actor.AtomicActor
_stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
VisualModelReference(CompositeEntity container, java.lang.String name)
          Construct a VisualModelReference with a name and a container.
 
Method Summary
 void attributeChanged(Attribute attribute)
          Override the base class to open the model specified if the attribute is modelFileOrURL, or for other parameters, to cache their values.
 java.lang.Object clone(Workspace workspace)
          Override the base class to ensure that private variables are reset to null.
 void fire()
          Run a complete execution of the referenced model.
 boolean postfire()
          Override the base class to perform requested close on postfire actions.
 
Methods inherited from class ptolemy.actor.lib.hoc.ModelReference
executionError, executionFinished, managerStateChanged, stop, stopFire, terminate, wrapup
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList
 
Methods inherited from class ptolemy.actor.AtomicActor
_createReceivers, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, initialize, inputPortList, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, removeDependency, setContainer
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.ExecutionListener
executionError, executionFinished, managerStateChanged
 
Methods inherited from interface ptolemy.actor.Actor
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
initialize, iterate, prefire, preinitialize
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getFullName, getName, getName
 

Field Detail

openOnFiring

public StringParameter openOnFiring
The value of this string parameter determines what open happens when the fire() method is invoked. The recognized values are:


closeOnPostfire

public StringParameter closeOnPostfire
The value of this string parameter determines what close action happens in the postfire() method. The recognized values are:

Constructor Detail

VisualModelReference

public VisualModelReference(CompositeEntity container,
                            java.lang.String name)
                     throws IllegalActionException,
                            NameDuplicationException
Construct a VisualModelReference with a name and a container. The container argument must not be null, or a NullPointerException will be thrown. This actor will use the workspace of the container for synchronization and version counts. If the name argument is null, then the name is set to the empty string. Increment the version of the workspace. This actor will have no local director initially, and its executive director will be simply the director of the container.

Parameters:
container - The container.
name - The name of this actor.
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
Override the base class to open the model specified if the attribute is modelFileOrURL, or for other parameters, to cache their values.

Overrides:
attributeChanged in class ModelReference
Parameters:
attribute - The attribute that changed.
Throws:
IllegalActionException - If the change is not acceptable to this container (not thrown in this base class).

clone

public java.lang.Object clone(Workspace workspace)
                       throws java.lang.CloneNotSupportedException
Override the base class to ensure that private variables are reset to null.

Overrides:
clone in class ModelReference
Returns:
A new instance of VisualModelReference.
Throws:
java.lang.CloneNotSupportedException

fire

public void fire()
          throws IllegalActionException
Run a complete execution of the referenced model. A complete execution consists of invocation of super.initialize(), repeated invocations of super.prefire(), super.fire(), and super.postfire(), followed by super.wrapup(). The invocations of prefire(), fire(), and postfire() are repeated until either the model indicates it is not ready to execute (prefire() returns false), or it requests a stop (postfire() returns false or stop() is called). Before running the complete execution, this method examines input ports, and if they are connected, have data, and if the referenced model has a top-level parameter with the same name, then one token is read from the input port and used to set the value of the parameter in the referenced model. After running the complete execution, if there are any output ports, then this method looks for top-level parameters in the referenced model with the same name as the output ports, and if there are any, reads their values and produces them on the output. If no model has been specified, then this method does nothing.

Specified by:
fire in interface Executable
Overrides:
fire in class ModelReference
Throws:
IllegalActionException - If there is no director, or if the director's action methods throw it.

postfire

public boolean postfire()
                 throws IllegalActionException
Override the base class to perform requested close on postfire actions. Note that if a close is requested, then this method waits until the AWT event thread completes the close. This creates the possibility of a deadlock.

Specified by:
postfire in interface Executable
Overrides:
postfire in class ModelReference
Returns:
Whatever the superclass returns (probably true).
Throws:
IllegalActionException