Class PtExecuteApplication

  • All Implemented Interfaces:
    ExecutionListener

    public class PtExecuteApplication
    extends MoMLApplication
    This application executes Ptolemy II models specified on the command line.

    The exact facilities that are available are determined by an optional command line argument that names a directory in ptolemy/configs that contains a configuration.xml file. For example, if we call vergil -ptiny, then we will use ptolemy/configs/ptiny/configuration.xml and ptolemy/configs/ptiny/intro.htm. The default configuration is ptolemy/configs/runConfiguration.xml, which is loaded before any other command-line arguments are processed.

    This application also takes an optional command line argument pair -conf configurationFile.xml that names a configuration to be read. For example,

     $PTII/bin/ptexecute -conf ptolemy/configs/full/configuration.xml ../../domains/sdf/demo/Butterfly/Butterfly.xml
     
    and
     $PTII/bin/ptexecute -full ../../domains/sdf/demo/Butterfly/Butterfly.xml
     
    are equivalent

    If no configuration is specified on the command line, then the MoML file ptolemy/configs/runConfiguration.xml is loaded before other command line arguments are processed.

    If one of the command-line arguments is -exit, then System.exit() is called when all the models are finished running. System.exit() returns 0 if all the models finished without throwing an exception, otherwise it returns an integer that represents the number of models that threw an exception. The main() method calls System.exit() as well and returns an integer that represents the number of models that threw an exception.

    If there are no command-line arguments at all, then this class does nothing.

    This class will bring up the GUI and usually requires access to a display. The MoMLSimpleApplication class will run models in a non-graphical context.

    Since:
    Ptolemy II 1.0
    Version:
    $Id$
    Author:
    Edward A. Lee, Steve Neuendorffer Christopher Hylands
    See Also:
    ModelFrame, RunTableau
    Pt.AcceptedRating:
    Red (eal)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • _localCommandFlags

        protected static java.lang.String[] _localCommandFlags
        The command-line options that are either present or not.
      • _localCommandOptions

        protected static java.lang.String[][] _localCommandOptions
        The command-line options that take arguments.
    • Constructor Detail

      • PtExecuteApplication

        public PtExecuteApplication​(java.lang.String[] args)
                             throws java.lang.Exception
        Parse the specified command-line arguments, creating models and running them.
        Parameters:
        args - The command-line arguments.
        Throws:
        java.lang.Exception - If command line arguments have problems.
    • Method Detail

      • executionError

        public void executionError​(Manager manager,
                                   java.lang.Throwable throwable)
        Display a stack trace because one of the models has an error. A dialog box with the stack trace is created, the stack trace is printed to stderr and the eventual exiting of the process is delayed so the stack trace can be read.
        Specified by:
        executionError in interface ExecutionListener
        Overrides:
        executionError in class ConfigurationApplication
        Parameters:
        manager - The manager calling this method.
        throwable - The Throwable to be displayed.
      • main

        public static void main​(java.lang.String[] args)
        Create a new instance of this application, passing it the command-line arguments.
        Parameters:
        args - The command-line arguments.
      • _createDefaultConfiguration

        protected Configuration _createDefaultConfiguration()
                                                     throws java.lang.Exception
        Return a default Configuration, which in this case is given by the MoML file ptolemy/configs/runConfiguration.xml. The default configuration supports executing, but not editing, Ptolemy models. If there is an _applicationInitializer parameter, then construct it. The _applicationInitializer parameter contains a string that names a class to be initialized.
        Overrides:
        _createDefaultConfiguration in class ConfigurationApplication
        Returns:
        A default configuration.
        Throws:
        java.lang.Exception - If the configuration cannot be opened.
      • _parseArgs

        protected void _parseArgs​(java.lang.String[] args)
                           throws java.lang.Exception
        Parse the command-line arguments. This overrides the base class only to set the usage information.
        Overrides:
        _parseArgs in class ConfigurationApplication
        Parameters:
        args - The command-line arguments to be parsed.
        Throws:
        java.lang.Exception - If an argument is not understood or triggers an error.
      • _usage

        protected java.lang.String _usage()
        Return a string summarizing the command-line arguments.
        Overrides:
        _usage in class ConfigurationApplication
        Returns:
        A usage string.