Class ModelGenerator

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

    public class ModelGenerator
    extends Source
    An actor to open a window to display the specified model and apply its inputs to the model. If inputs are provided for the moml input port, they are expected to be MoML strings that are to be applied to the model. This can be used, for example, to create animations. If inputs are not provided for the moml input port but for either the trigger port of the modelName port, then empty models are generated with the name specified by the most updated value of the modelName PortParameter.
    Since:
    Ptolemy II 6.0
    Version:
    $Id$
    Author:
    Thomas Huining Feng
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • modelName

        public PortParameter modelName
        The port parameter for the model name.
      • moml

        public TypedIOPort moml
        The port to receive moml strings of the models.
    • Method Detail

      • fire

        public void fire()
                  throws IllegalActionException
        Read the input at the input ports. If the moml port has a token, read it in as a string and parse the string into a model. If not, create an empty model. If the modelName is not an empty string, set the name of the model with the value of modelName. Produce the model to the output port.
        Specified by:
        fire in interface Executable
        Overrides:
        fire in class Source
        Throws:
        IllegalActionException - If the ports cannot be read, or if the model cannot be produced.
      • prefire

        public boolean prefire()
                        throws IllegalActionException
        Return true if the moml port is connected and has a token, or the modelName port is connected and has a token, or neither the modelName port nor the moml port is connected (in which case this actor serves as a source).
        Specified by:
        prefire in interface Executable
        Overrides:
        prefire in class Source
        Returns:
        true if the actor is ready to fire; false otherwise.
        Throws:
        IllegalActionException - If connectivity of the input ports cannot be determined, or availability of the tokens cannot be tested.