ptolemy.actor.gui
Class MoMLSimpleApplication

java.lang.Object
  extended byptolemy.actor.gui.MoMLSimpleApplication
All Implemented Interfaces:
ChangeListener
Direct Known Subclasses:
MoMLSimpleStatisticalApplication

public class MoMLSimpleApplication
extends java.lang.Object
implements ChangeListener

A simple application that reads in a .xml file as a command line argument and runs it.

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
    

Since:
Ptolemy II 2.0
Version:
$Id: MoMLSimpleApplication.java,v 1.42 2004/04/13 05:12:05 cxh Exp $
Author:
Christopher Hylands
Accepted Rating:
Red (eal)
Proposed Rating:
Red (cxh)

Constructor Summary
MoMLSimpleApplication()
          A Nullary constructor is necessary so that we can extends this base class with a subclass
MoMLSimpleApplication(java.lang.String xmlFileName)
          Parse the xml file and run it.
 
Method Summary
 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.
static void main(java.lang.String[] args)
          Create an instance of a single model and run it
 void rerun()
          Execute the same model again.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MoMLSimpleApplication

public MoMLSimpleApplication()
                      throws java.lang.Exception
A Nullary constructor is necessary so that we can extends this base class with a subclass

Throws:
java.lang.Exception - Not thrown in this base class

MoMLSimpleApplication

public MoMLSimpleApplication(java.lang.String xmlFileName)
                      throws java.lang.Exception
Parse the xml file and run it.

Parameters:
xmlFileName - A string that refers to an MoML file that contains a Ptolemy II model. The string should be a relative pathname.
Throws:
java.lang.Exception - If there was a problem parsing or running the model.
Method Detail

changeExecuted

public void changeExecuted(ChangeRequest change)
React to a change request has been successfully executed by doing nothing. This method is called after a change request has been executed successfully. In this class, we do nothing.

Specified by:
changeExecuted in interface ChangeListener
Parameters:
change - The change that has been executed, or null if the change was not done via a ChangeRequest.

changeFailed

public void changeFailed(ChangeRequest change,
                         java.lang.Exception exception)
React to a change request that has resulted in an exception. This method is called after a change request was executed, but during the execution in an exception was thrown. This method throws a runtime exception with a description of the original exception.

Specified by:
changeFailed in interface ChangeListener
Parameters:
change - The change that was attempted or null if the change was not done via a ChangeRequest.
exception - The exception that resulted.

main

public static void main(java.lang.String[] args)
Create an instance of a single model and run it

Parameters:
args - The command-line arguments naming the .xml file to run

rerun

public void rerun()
           throws java.lang.Exception
Execute the same model again.

Throws:
java.lang.Exception