public class MoMLSimpleApplication extends java.lang.Object implements ChangeListener, ExecutionListener
MoMLApplication sets the look and feel, which starts up Swing, so we can't use MoMLApplication for non-graphical simulations.
We implement the ChangeListener interface so that this class will get exceptions thrown by failed change requests. For example to use this class, try:
java -classpath $PTII ptolemy.actor.gui.MoMLSimpleApplication ../../../ptolemy/domains/sdf/demo/OrthogonalCom/OrthogonalCom.xml
Modifier and Type | Field and Description |
---|---|
protected int |
_activeCount
The count of currently executing runs.
|
protected boolean |
_executionFinishedOrError
A flag that indicates if the execution has finished or thrown
an error.
|
protected Manager |
_manager
The manager of this model.
|
protected MoMLParser |
_parser
The MoMLParser used to parse the model.
|
protected java.lang.Throwable |
_sawThrowable
The exception seen by executionError().
|
protected CompositeActor |
_toplevel
The toplevel model that is created and then destroyed.
|
protected Workspace |
_workspace
The workspace in which the model and Manager are created.
|
Constructor and Description |
---|
MoMLSimpleApplication()
Instantiate a MoMLSimpleApplication.
|
MoMLSimpleApplication(java.lang.String xmlFileName)
Parse the xml file and run it.
|
Modifier and Type | Method and Description |
---|---|
void |
changeExecuted(ChangeRequest change)
React to a change request has been successfully executed by
doing nothing.
|
void |
changeFailed(ChangeRequest change,
java.lang.Exception exception)
React to a change request that has resulted in an exception.
|
void |
cleanup()
Clean up by freeing memory.
|
static void |
closeVertx()
If the VertxHelperBase class is present, then invoke the
closeVertx() method so that this process does not wait around
for the Vert.x threads.
|
void |
executionError(Manager manager,
java.lang.Throwable throwable)
Report an execution failure.
|
void |
executionFinished(Manager manager)
Report that the current execution has finished and
the wrapup sequence has completed normally.
|
static void |
main(java.lang.String[] args)
Create an instance of each model file named in the arguments
and run it.
|
void |
managerStateChanged(Manager manager)
Report that the manager has changed state.
|
void |
rerun()
Execute the same model again.
|
CompositeActor |
toplevel()
Return the toplevel.
|
void |
waitForFinish()
Wait for all executing runs to finish, then return.
|
protected volatile int _activeCount
protected volatile boolean _executionFinishedOrError
protected Manager _manager
protected volatile MoMLParser _parser
protected volatile java.lang.Throwable _sawThrowable
protected volatile CompositeActor _toplevel
protected volatile Workspace _workspace
public MoMLSimpleApplication() throws java.lang.Exception
The HandSimDroid work in $PTII/ptserver uses dependency injection to determine which implementation actors such as Const and Display to use. This method reads the ptolemy/actor/ActorModule.properties file.
java.lang.Exception
- Not thrown in this base classpublic MoMLSimpleApplication(java.lang.String xmlFileName) throws java.lang.Throwable
xmlFileName
- A string that refers to an MoML file that
contains a Ptolemy II model. The string should be
a relative pathname.java.lang.Throwable
- If there was a problem parsing
or running the model.public void changeExecuted(ChangeRequest change)
changeExecuted
in interface ChangeListener
change
- The change that has been executed, or null if
the change was not done via a ChangeRequest.public void changeFailed(ChangeRequest change, java.lang.Exception exception)
changeFailed
in interface ChangeListener
change
- The change that was attempted or null if
the change was not done via a ChangeRequest.exception
- The exception that resulted.public void cleanup()
public static void closeVertx()
public void executionError(Manager manager, java.lang.Throwable throwable)
executionError
in interface ExecutionListener
manager
- The manager controlling the execution.throwable
- The throwable to report.public void executionFinished(Manager manager)
executionFinished
in interface ExecutionListener
manager
- The manager controlling the execution.public void managerStateChanged(Manager manager)
managerStateChanged
in interface ExecutionListener
manager
- The manager controlling the execution.Manager.getState()
public static void main(java.lang.String[] args)
args
- The command-line arguments naming the Ptolemy II
model files (typically .xml files) to be invoked.public void rerun() throws java.lang.Exception
java.lang.Exception
- if there was a problem rerunning the model.public CompositeActor toplevel()
public void waitForFinish()