ptolemy.vergil.actor.lib
Class VisualModelReference
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.hoc.ModelReference
ptolemy.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.
- openOnFiring:
The value of this string attribute determines what open
happens when the fire() method is invoked. The recognized
values are:
- "do not open" (the default)
- "open in Vergil"
- "open in Vergil (full screen)"
- "open run control panel"
Note that it is dangerous to use the full-screen mode because it
becomes difficult to stop execution of the model that contains this
actor. In full-screen mode, the referenced model will consume
the entire screen. Stopping that execution will only serve to
stop the current iteration, and very likely, another iteration will
begin immediately and again occupy the entire screen.
Use this option with care.
- closeOnPostfire:
The value of this string attribute determines what happens
in the postfire() method. The recognized values are:
- "do nothing" (the default)
- "close Vergil graph"
There are currently a number of serious limitations:
FIXME: Modifying and saving the referenced model, if done through the
Vergil window opened by this actor, results in overwriting the referenced
model with a copy of the model containing this actor!
-
FIXME: Modifying the referenced model in another window and saving
it does not result in this actor re-reading the model.
-
FIXME: Closing the master model doesn't close open referenced models.
-
FIXME: Supporting full-screen operation creates a dependence on vergil.
Without that, this actor could be in the actor package. Need to figure
out how to remove this dependence.
- 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:
- Proposed Rating:
| Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
|
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.AtomicActor |
_createReceivers, connectionsChanged, getDirector, getExecutiveDirector, getFunctionDependency, getManager, initialize, inputPortList, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, removeDependency, setContainer |
| 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.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 |
openOnFiring
public StringParameter openOnFiring
- The value of this string parameter determines what open
happens when the fire() method is invoked. The recognized
values are:
- "do not open" (the default)
- "open in Vergil"
- "open in Vergil (full screen)"
- "open run control panel"
closeOnPostfire
public StringParameter closeOnPostfire
- The value of this string parameter determines what close action
happens in the postfire() method. The recognized values are:
- "do nothing" (the default)
- "close Vergil graph"
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.
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