ptolemy.copernicus.java
Class CommandLineTemplate

java.lang.Object
  extended by ptolemy.copernicus.java.CommandLineTemplate

public class CommandLineTemplate
extends java.lang.Object

This class is similar to CompositeActorApplication, except that it does not parse command line elements. It is used as a template for generating a command line interface for code generated from a ptolemy model.

In this case, parsing the command line is not necessary because parameter values and the class values are fixed by the code generator.

Since:
Ptolemy II 2.0
Version:
$Id: CommandLineTemplate.java,v 1.61 2007/12/07 06:28:40 cxh Exp $
Author:
Steve Neuendorffer
Accepted Rating:
Red (vogel)
Proposed Rating:
Yellow (cxh)

Field Summary
protected  int _iterationLimit
           
protected  java.util.List _models
          The list of all the models
protected  int _openCount
          The count of currently open windows.
protected static long _parseStartTime
          The time that creating the model started
protected static boolean _test
          Are we testing?
 
Constructor Summary
CommandLineTemplate()
           
 
Method Summary
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 finish() method of the manager.
static java.lang.String timeAndMemory(long startTime)
           
static java.lang.String timeAndMemory(long startTime, long totalMemory, long freeMemory)
           
static void timeAndMemory(long startTime, long totalMemory, long freeMemory, java.lang.StringBuffer buffer)
           
 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

_iterationLimit

protected int _iterationLimit

_models

protected java.util.List _models
The list of all the models


_openCount

protected int _openCount
The count of currently open windows.


_test

protected static boolean _test
Are we testing?


_parseStartTime

protected static long _parseStartTime
The time that creating the model started

Constructor Detail

CommandLineTemplate

public CommandLineTemplate()
Method Detail

main

public static void main(java.lang.String[] args)
Create a new application with the specified command-line arguments.

Parameters:
args - The command-line arguments.

processArgs

public void processArgs(java.lang.String[] args)
                 throws java.lang.Exception
Parse the command-line arguments, creating models as specified.

Parameters:
args - The command-line arguments.
Throws:
java.lang.Exception - If there is a problem processing the arguments.

report

public void report(java.lang.Exception ex)
Report an exception. This prints a message to the standard error stream, followed by the stack trace.

Parameters:
ex - The exception to report.

report

public void report(java.lang.String message)
Report a message to the user. This prints a message to the standard output stream.

Parameters:
message - The message to report.

report

public void report(java.lang.String message,
                   java.lang.Exception ex)
Report an exception with an additional message. This prints a message to standard error, followed by the stack trace.

Parameters:
message - The message.
ex - The exception to report.

startRun

public void startRun(CompositeActor model)
If the specified model has a manager and is not already running, then execute the model in a new thread. Otherwise, do nothing. If the model contains an atomic entity that implements Placeable, we create create an instance of ModelFrame, if nothing implements Placeable, then we do not create an instance of ModelFrame. This allows us to run non-graphical models on systems that do not have a display.

We then start the model running.

Parameters:
model - The model to execute.
See Also:
Manager.startRun()

timeAndMemory

public static java.lang.String timeAndMemory(long startTime)

timeAndMemory

public static java.lang.String timeAndMemory(long startTime,
                                             long totalMemory,
                                             long freeMemory)

timeAndMemory

public static void timeAndMemory(long startTime,
                                 long totalMemory,
                                 long freeMemory,
                                 java.lang.StringBuffer buffer)

stopRun

public void stopRun(CompositeActor model)
If the specified model has a manager and is executing, then stop execution by calling the finish() method of the manager. If there is no manager, do nothing.

Parameters:
model - The model to stop.

waitForFinish

public void waitForFinish()
Wait for all windows to close.