ptolemy.actor.gui
Class PtExecuteApplication

java.lang.Object
  extended by ptolemy.actor.gui.ConfigurationApplication
      extended by ptolemy.actor.gui.MoMLApplication
          extended by ptolemy.actor.gui.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: PtExecuteApplication.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee, Steve Neuendorffer Christopher Hylands
See Also:
ModelFrame, RunTableau
Accepted Rating:
Red (eal)
Proposed Rating:
Yellow (eal)

Nested Class Summary
 
Nested classes/interfaces inherited from class ptolemy.actor.gui.ConfigurationApplication
ConfigurationApplication.ConfigurationFilenameFilter, ConfigurationApplication.IgnoreErrorHandler
 
Field Summary
private  java.lang.String _configurationSubdirectory
           
private  java.net.URL _configurationURL
           
private static int _exitValue
           
private  boolean _expectingConfiguration
           
protected static java.lang.String[] _localCommandFlags
          The command-line options that are either present or not.
protected static java.lang.String[][] _localCommandOptions
          The command-line options that take arguments.
 
Fields inherited from class ptolemy.actor.gui.ConfigurationApplication
_basePath, _commandFlagsWithDescriptions, _commandOptions, _commandTemplate, _configuration, _exit, _parser, _printPDF, _run, _statistics, _test
 
Constructor Summary
PtExecuteApplication(java.lang.String[] args)
          Parse the specified command-line arguments, creating models and running them.
 
Method Summary
private  boolean _configurationParseArg(java.lang.String arg)
          Parse a command-line argument.
protected  Configuration _createDefaultConfiguration()
          Return a default Configuration, which in this case is given by the MoML file ptolemy/configs/runConfiguration.xml.
protected  Configuration _createEmptyConfiguration()
          Throw an exception.
protected  void _parseArgs(java.lang.String[] args)
          Parse the command-line arguments.
protected  java.lang.String _usage()
          Return a string summarizing the command-line arguments.
 void executionError(Manager manager, java.lang.Throwable throwable)
          Display a stack trace because one of the models has an error.
static void main(java.lang.String[] args)
          Create a new instance of this application, passing it the command-line arguments.
 
Methods inherited from class ptolemy.actor.gui.MoMLApplication
_initializeApplication
 
Methods inherited from class ptolemy.actor.gui.ConfigurationApplication
_configurationUsage, _configurationUsage, _openModel, _openModel, _parseArg, _printPDF, _readConfiguration, executionFinished, managerStateChanged, models, readConfiguration, runModels, specToURL, throwArgsException, waitForFinish
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.


_configurationSubdirectory

private java.lang.String _configurationSubdirectory

_configurationURL

private java.net.URL _configurationURL

_exitValue

private static int _exitValue

_expectingConfiguration

private boolean _expectingConfiguration
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.

_createEmptyConfiguration

protected Configuration _createEmptyConfiguration()
                                           throws java.lang.Exception
Throw an exception.

Overrides:
_createEmptyConfiguration in class ConfigurationApplication
Returns:
Does not return.
Throws:
java.lang.Exception - Always thrown.

_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.

_configurationParseArg

private boolean _configurationParseArg(java.lang.String arg)
                                throws java.lang.Exception
Parse a command-line argument. Usually, we would name this method _parseArg(), but we want to handle any arguments that handle configuration changes before calling the parent class _parseArg() because the parent class depends either having a configuration to work with, or the parent class sets up a configuration.

Returns:
True if the argument is understood, false otherwise.
Throws:
java.lang.Exception - If something goes wrong.