Package ptolemy.moml

Class ConvertToLazy

  • All Implemented Interfaces:
    ChangeListener

    public class ConvertToLazy
    extends java.lang.Object
    implements ChangeListener
    Read a specified MoML file and convert all instances of TypedCompositeActor that contain more than a specified number of entities to LazyTypedCompositeActor. The converted model's MoML is produced on standard out. To use this on the command line, invoke as follows:
         $PTII/bin/convertToLazy inputMoML.xml numberOfEntities > outputMoML.xml
      
    or
         java -classpath $PTII ptolemy.moml.ConvertToLazy inputMoML.xml numberOfEntities > outputMoML.xml
      
    If the numberOfEntities argument is not supplied, then it defaults to 100.
    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    Edward A. Lee
    Pt.AcceptedRating:
    Red (eal)
    Pt.ProposedRating:
    Red (cxh)
    • Constructor Summary

      Constructors 
      Constructor Description
      ConvertToLazy​(java.lang.String xmlFileName, int threshold)
      Parse the xml file and convert it.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void changeExecuted​(ChangeRequest change)
      React to a change request has been successfully executed by doing nothing.
      void changeFailed​(ChangeRequest change, java.lang.Exception exception)
      React to a change request that has resulted in an exception.
      void convert​(TypedCompositeActor actor, int threshold)
      Convert the model.
      int count​(TypedCompositeActor actor)
      Count the number of contained entities that have not already been made lazy.
      static void main​(java.lang.String[] args)
      Create an instance of a model and convert it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConvertToLazy

        public ConvertToLazy​(java.lang.String xmlFileName,
                             int threshold)
                      throws java.lang.Throwable
        Parse the xml file and convert it.
        Parameters:
        xmlFileName - A string that refers to an MoML file that contains a Ptolemy II model. The string should be a relative pathname.
        threshold - The number of contained entities that a composite should have to be converted to a lazy composite.
        Throws:
        java.lang.Throwable - If there was a problem parsing or running the model.
    • Method Detail

      • changeExecuted

        public void changeExecuted​(ChangeRequest change)
        React to a change request has been successfully executed by doing nothing. This method is called after a change request has been executed successfully. In this class, we do nothing.
        Specified by:
        changeExecuted in interface ChangeListener
        Parameters:
        change - The change that has been executed, or null if the change was not done via a ChangeRequest.
      • changeFailed

        public void changeFailed​(ChangeRequest change,
                                 java.lang.Exception exception)
        React to a change request that has resulted in an exception. This method is called after a change request was executed, but during the execution in an exception was thrown. This method throws a runtime exception with a description of the original exception.
        Specified by:
        changeFailed in interface ChangeListener
        Parameters:
        change - The change that was attempted or null if the change was not done via a ChangeRequest.
        exception - The exception that resulted.
      • convert

        public void convert​(TypedCompositeActor actor,
                            int threshold)
        Convert the model.
        Parameters:
        actor - The model to convert.
        threshold - The threshold to use.
      • count

        public int count​(TypedCompositeActor actor)
        Count the number of contained entities that have not already been made lazy.
        Parameters:
        actor - The actor to count.
        Returns:
        The number of contained entities (deeply) that are not already lazy.
      • main

        public static void main​(java.lang.String[] args)
        Create an instance of a model and convert it.
        Parameters:
        args - The command-line arguments providing the number of entities threshold and naming the .xml file to convert.