Package ptolemy.moml
Class MoMLCommandLineApplication
- java.lang.Object
-
- ptolemy.moml.MoMLSimpleApplication
-
- ptolemy.moml.MoMLCommandLineApplication
-
- All Implemented Interfaces:
ExecutionListener
,ChangeListener
public class MoMLCommandLineApplication extends MoMLSimpleApplication
A application that reads command line arguments that set parameters and a .xml file naming a model, sets the parameters and runs the model.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.xml
or$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.xml
where 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 namedx
andx
contains an entity namedy
and a parameter nameda
, andy
contains a parameter namedb
, then:$PTII/bin/ptinvoke ptolemy.moml.MoMLCommandLineApplication -a 5 -y.b 10 foo.xml
would 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.xml
The reason the single quotes and double quotes are necessary is becauseptinvoke
is a shell script which tends to strip off the double quotes.- Since:
- Ptolemy II 8.0
- Version:
- $Id$
- Author:
- Christopher Brooks
- Pt.AcceptedRating:
- Red (eal)
- Pt.ProposedRating:
- Red (cxh)
-
-
Field Summary
-
Fields inherited from class ptolemy.moml.MoMLSimpleApplication
_activeCount, _executionFinishedOrError, _manager, _parser, _sawThrowable, _toplevel, _workspace
-
-
Constructor Summary
Constructors Constructor Description MoMLCommandLineApplication(java.lang.String[] args)
Parse a MoML file that contains a model, update the parameters and run the model.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
main(java.lang.String[] args)
Create an instance of a single model and run it.-
Methods inherited from class ptolemy.moml.MoMLSimpleApplication
changeExecuted, changeFailed, cleanup, closeVertx, executionError, executionFinished, managerStateChanged, rerun, toplevel, waitForFinish
-
-
-
-
Constructor Detail
-
MoMLCommandLineApplication
public MoMLCommandLineApplication(java.lang.String[] args) throws java.lang.Throwable
Parse a MoML file that contains a model, update the parameters and run the model.- Parameters:
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.- Throws:
java.lang.Throwable
- If there was a problem parsing or running the model.
-
-