ptolemy.actor.gui
Class PtExecuteApplication

java.lang.Object
  extended byptolemy.actor.gui.MoMLApplication
      extended byptolemy.actor.gui.PtExecuteApplication
All Implemented Interfaces:
ExecutionListener

public class PtExecuteApplication
extends MoMLApplication
implements ExecutionListener

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. If there are no command-line arguments at all, then this class does nothing.

Since:
Ptolemy II 1.0
Version:
$Id: PtExecuteApplication.java,v 1.40 2004/04/13 03:00:01 cxh Exp $
Author:
Edward A. Lee, Steve Neuendorffer Christopher Hyland
See Also:
ModelFrame, RunTableau
Accepted Rating:
Red (eal)
Proposed Rating:
Yellow (eal)

Field Summary
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.MoMLApplication
_basePath, _commandFlags, _commandOptions, _commandTemplate, _config, _parser, _test
 
Constructor Summary
PtExecuteApplication(java.lang.String[] args)
          Parse the specified command-line arguments, creating models and running them.
 
Method Summary
protected  Configuration _createDefaultConfiguration()
          Return a default Configuration, which in this case is given by the MoML file ptolemy/configuration/runPanelConfiguration.xml.
protected  Configuration _createEmptyConfiguration()
          Throw an exception.
protected  boolean _parseArg(java.lang.String arg)
          Parse a command-line argument.
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)
          Reduce the count of executing models by one.
 void executionFinished(Manager manager)
          Reduce the count of executing models by one.
static void main(java.lang.String[] args)
          Create a new instance of this application, passing it the command-line arguments.
 void managerStateChanged(Manager manager)
          Do nothing.
 java.util.List models()
          Return a list of the Ptolemy II models that were created by processing the command-line arguments.
 void runModels()
          Start the models running, each in a new thread, then return.
 void waitForFinish()
          Wait for all executing runs to finish, then return.
 
Methods inherited from class ptolemy.actor.gui.MoMLApplication
_configurationUsage, _readConfiguration, specToURL
 
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.

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)
Reduce the count of executing models by one. If the number of executing models drops ot zero, then notify threads that might be waiting for this event.

Specified by:
executionError in interface ExecutionListener
Parameters:
manager - The manager calling this method.
throwable - The throwable being reported.

executionFinished

public void executionFinished(Manager manager)
Reduce the count of executing models by one. If the number of executing models drops ot zero, then notify threads that might be waiting for this event.

Specified by:
executionFinished in interface ExecutionListener
Parameters:
manager - The manager calling this method.

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.

managerStateChanged

public void managerStateChanged(Manager manager)
Do nothing.

Specified by:
managerStateChanged in interface ExecutionListener
Parameters:
manager - The manager calling this method.
See Also:
Manager.getState()

models

public java.util.List models()
Return a list of the Ptolemy II models that were created by processing the command-line arguments.

Returns:
A list of instances of NamedObj.

runModels

public void runModels()
               throws IllegalActionException
Start the models running, each in a new thread, then return.

Throws:
IllegalActionException - If the manager throws it.

waitForFinish

public void waitForFinish()
Wait for all executing runs to finish, then return.


_createDefaultConfiguration

protected Configuration _createDefaultConfiguration()
                                             throws java.lang.Exception
Return a default Configuration, which in this case is given by the MoML file ptolemy/configuration/runPanelConfiguration.xml. That configuration supports executing, but not editing, Ptolemy models.

Overrides:
_createDefaultConfiguration in class MoMLApplication
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 MoMLApplication
Returns:
Does not return.
Throws:
java.lang.Exception - Always thrown.

_parseArg

protected boolean _parseArg(java.lang.String arg)
                     throws java.lang.Exception
Parse a command-line argument.

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

_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 MoMLApplication
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 MoMLApplication
Returns:
A usage string.