Class VisualModelReference

  • All Implemented Interfaces:
    java.lang.Cloneable, Actor, Executable, ExecutionListener, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

    public class VisualModelReference
    extends ModelReference
    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)"
      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"
    Since:
    Ptolemy II 4.0
    Version:
    $Id$
    Author:
    Edward A. Lee, Elaine Cheong
    See Also:
    Variable, Parameter, Settable
    Pt.AcceptedRating:
    Red (eal)
    Pt.ProposedRating:
    Yellow (eal)
    • 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:
        • "do not open" (the default)
        • "open in Vergil"
        • "open in Vergil (full screen)"
      • 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"
      • _tableau

        protected Tableau _tableau
        Tableau that has been created (if any).
    • 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
        Clone this actor into the specified workspace. Override the base class to ensure that private variables are reset to null.
        Overrides:
        clone in class ModelReference
        Parameters:
        workspace - The workspace for the cloned object.
        Returns:
        A new instance of VisualModelReference.
        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
        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 - Thrown if a parent class throws it.