public class MoMLCommandLineApplication extends MoMLSimpleApplication
MoMLApplication sets the look and feel, which starts up Swing, so we can't use MoMLApplication for non-graphical simulations.
The parent class, @{link ptolemy.moml.MoMLSimpleApplication} does not handle command line parameters that set parameters For example to use this class, try:
java -classpath $PTII ptolemy.moml.MoMLCommandLineApplication -myParameter '"Hello, World."' test/MoMLCommandLineApplicationTest.xmlor
$PTII/bin/ptinvoke ptolemy.moml.MoMLCommandLineApplication -myParameter '""Hellow, World.""' test/MoMLCommandLineApplicationTest.xml
If a Ptolemy model is instantiated on the command line, either by giving a MoML file or a -class argument, then parameters of that model can be set on the command line. The syntax is:
$PTII/bin/ptinvoke ptolemy.moml.MoMLCommandLineApplication -parameterName value modelFile.xmlwhere parameterName is the name of a parameter relative to the top level of a model or the director of a model. For instance, if foo.xml defines a toplevel entity named
x and
x contains an entity named y and a
parameter named a, and y contains a
parameter named b, then:
$PTII/bin/ptinvoke ptolemy.moml.MoMLCommandLineApplication -a 5 -y.b 10 foo.xmlwould set the values of the two parameters.
Note that strings need to be carefully backslashed, so to set a
parameter named c to the string "bar" it
might be necessary to do something like:
$PTII/bin/ptinvoke ptolemy.moml.MoMLCommandLineApplication -a 5 -y.b 10 -c '""bar"" foo.xmlThe reason the single quotes and double quotes are necessary is because
ptinvoke
is a shell script which tends to strip off the double quotes.| Red (eal) |
| Red (cxh) |
_activeCount, _executionFinishedOrError, _manager, _parser, _sawThrowable, _toplevel, _workspace| Constructor and Description |
|---|
MoMLCommandLineApplication(java.lang.String[] args)
Parse a MoML file that contains a model, update the parameters
and run the model.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
main(java.lang.String[] args)
Create an instance of a single model and run it.
|
changeExecuted, changeFailed, cleanup, executionError, executionFinished, managerStateChanged, rerun, waitForFinishpublic MoMLCommandLineApplication(java.lang.String[] args)
throws java.lang.Throwable
args - An array of strings, where the last element names
a MoML file that contains a Ptolemy II model. The string should be
a relative pathname. Other elements may name model parameters
and values for the parameters. Parameter names should begin
with a "-" and be followed by the value for the parameter.java.lang.Throwable - If there was a problem parsing
or running the model.