|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.actor.gui.CompositeActorApplication
public class CompositeActorApplication
This application creates one or more Ptolemy II models given a classname on the command line, and then executes those models, each in its own thread. Each specified class should be derived from CompositeActor, and should have a constructor that takes a single argument, an instance of Workspace. If the model does not contain a manager, then one will be created for it. The model is displayed using an instance of ModelFrame, which provides controls for executing the model and setting its top-level and director parameters.
The command-line arguments can also set parameter values for any parameter in the models, with the name given relative to the top-level entity. For example, to specify the iteration count in an SDF model, you can invoke this on the command line as follows:
CLASSPATH=$PTII export CLASSPATH java ptolemy.actor.gui.CompositeActorApplication \ -director.iterations 1000 \ -class ptolemy.domains.sdf.demo.Butterfly.ButterflyThis assumes that the model given by the specified class name has a director named "director" with a parameter named "iterations". If more than one model is given on the command line, then the parameter values will be set for all models that have such a parameter.
This class keeps count the number of open windows. The waitForFinish method can then be used to determine when all of the windows opened by this class have been closed. The main() method exits the application when all windows have been closed.
ModelFrame
Red (vogel) |
Yellow (cxh) |
Field Summary | |
---|---|
protected java.lang.String[] |
_commandFlags
The command-line options that are either present or not. |
protected java.lang.String[][] |
_commandOptions
The command-line options that take arguments. |
protected java.lang.String |
_commandTemplate
The form of the command line. |
private boolean |
_expectingClass
|
protected java.util.List |
_models
The list of all the models. |
protected int |
_openCount
The count of currently open windows. |
private java.util.List |
_parameterNames
|
private java.util.List |
_parameterValues
|
protected static boolean |
_test
If true, then auto exit after a few seconds. |
Constructor Summary | |
---|---|
CompositeActorApplication()
|
Method Summary | |
---|---|
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. |
static void |
main(java.lang.String[] args)
Create a new application with the specified command-line arguments. |
void |
processArgs(java.lang.String[] args)
Parse the command-line arguments, creating models as specified. |
void |
report(java.lang.Exception ex)
Report an exception. |
void |
report(java.lang.String message)
Report a message to the user. |
void |
report(java.lang.String message,
java.lang.Exception ex)
Report an exception with an additional message. |
void |
startRun(CompositeActor model)
If the specified model has a manager and is not already running, then execute the model in a new thread. |
void |
stopRun(CompositeActor model)
If the specified model has a manager and is executing, then stop execution by calling the stop() method of the manager. |
void |
waitForFinish()
Wait for all windows to close. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String[] _commandFlags
protected java.lang.String[][] _commandOptions
protected java.lang.String _commandTemplate
protected java.util.List _models
protected int _openCount
protected static boolean _test
private boolean _expectingClass
private java.util.List _parameterNames
private java.util.List _parameterValues
Constructor Detail |
---|
public CompositeActorApplication()
Method Detail |
---|
public static void main(java.lang.String[] args)
args
- The command-line arguments.public void processArgs(java.lang.String[] args) throws java.lang.Exception
args
- The command-line arguments.
java.lang.Exception
- If something goes wrong.public void report(java.lang.Exception ex)
ex
- The exception to report.public void report(java.lang.String message)
message
- The message to report.public void report(java.lang.String message, java.lang.Exception ex)
message
- The message.ex
- The exception to report.public void startRun(CompositeActor model)
We then start the model running.
model
- The model to execute.Manager.startRun()
public void stopRun(CompositeActor model)
model
- The model to stop.public void waitForFinish()
protected boolean _parseArg(java.lang.String arg) throws java.lang.Exception
arg
- The argument to be parse.
java.lang.Exception
- If something goes wrong.protected void _parseArgs(java.lang.String[] args) throws java.lang.Exception
args
- The arguments to be parsed.
java.lang.Exception
- If an argument is not understood or triggers
an error.protected java.lang.String _usage()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |