public class ClientProcess
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
protected java.util.List<java.lang.String> |
cmdArr
Array containing the command to call and its arguments.
|
protected static int |
dY
Default height of window.
|
protected java.lang.String |
errMes
Error message if
proSta=true or null pointer otherwise. |
static int |
locY
Y location of window that displays the console output.
|
protected java.io.File |
logFil
Log file to which simulation output will be written.
|
protected boolean |
logToSysOut
Flag, if
true , then the output will be written to System.out. |
protected java.lang.String |
modNam
Name of the model.
|
protected lbnl.util.ClientProcess.PrintStderr |
priStdErr
The thread that captures the standard error stream.
|
protected lbnl.util.ClientProcess.PrintOutput |
priStdOut
The thread that captures the standard output stream.
|
protected boolean |
proSta
Flag that is set to
true if the process started without throwing an exception. |
protected boolean |
redErrStr
Flag, if true, redirects the standard error stream to the standard output stream.
|
protected boolean |
showConsoleWindow
Flag, if true, then the console output will be displayed in a JFrame.
|
protected java.lang.Process |
simPro
Process for the simulation.
|
protected javax.swing.JTextArea |
stdAre
Text area that contains the console output of the simulation.
|
protected java.lang.StringBuilder |
stdErr
String that contains the standard error stream.
|
protected javax.swing.JFrame |
stdFra
Frame that contains the console output of the simulation.
|
protected java.lang.StringBuilder |
stdOut
String that contains the standard output stream.
|
protected javax.swing.JScrollPane |
stdScrPan
Scroll pane that contains the text area for the console output.
|
protected java.io.File |
worDir
Working directory of the subprocess, or null if the subprocess
should inherit the working directory of the current process.
|
Constructor and Description |
---|
ClientProcess(java.lang.String modelName)
Create a ClientProcess.
|
Modifier and Type | Method and Description |
---|---|
void |
disposeWindow()
Disposes the window that displays the console output.
|
int |
exitValue()
Get the exit value of the process.
|
java.lang.String |
getErrorMessage()
Return the error message if
proSta=true or a null pointer otherwise. |
java.lang.String |
getStandardError()
Get the standard error of the process.
|
java.lang.String |
getStandardOutput()
Get the standard output of the process.
|
static void |
main(java.lang.String[] args)
Main method for testing.
|
boolean |
processStarted()
Return true if the process started without throwing an exception.
|
void |
redirectErrorStream(boolean flag)
Redirects the standard error stream to the standard output stream.
|
static void |
resetWindowLocation()
Reset the position of the window that shows the console output.
|
void |
run()
Runs the process.
|
void |
setProcessArguments(java.util.List<java.lang.String> cmdarray,
java.lang.String dir)
Set the process arguments.
|
void |
setSimulationLogFile(java.io.File simLogFil)
Sets the simulation log file.
|
void |
showConsoleWindow(boolean showWindow)
Set a flag that determines whether the console window will be displayed.
|
int |
waitFor()
Causes the current thread to wait, if necessary, until the process represented
by this Process object has terminated.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
protected javax.swing.JFrame stdFra
protected javax.swing.JTextArea stdAre
protected javax.swing.JScrollPane stdScrPan
public static int locY
protected static final int dY
protected java.util.List<java.lang.String> cmdArr
protected java.io.File worDir
protected java.io.File logFil
protected boolean logToSysOut
true
, then the output will be written to System.out.protected java.lang.Process simPro
protected java.lang.String modNam
protected boolean showConsoleWindow
protected boolean proSta
true
if the process started without throwing an exception.protected java.lang.String errMes
proSta=true
or null pointer otherwise.protected java.lang.StringBuilder stdOut
protected java.lang.StringBuilder stdErr
protected lbnl.util.ClientProcess.PrintOutput priStdOut
protected lbnl.util.ClientProcess.PrintStderr priStdErr
protected boolean redErrStr
public ClientProcess(java.lang.String modelName)
modelName
- name of the model, used for display onlypublic void showConsoleWindow(boolean showWindow)
showWindow
- Set to false to avoid the console window to be shownpublic void disposeWindow()
public void redirectErrorStream(boolean flag)
flag
- if true, redirects the standard error stream to the standard output streampublic void setSimulationLogFile(java.io.File simLogFil)
simLogFil
- The log file.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public boolean processStarted()
public java.lang.String getErrorMessage()
proSta=true
or a null pointer otherwise.proSta=true
or a null pointer otherwise.public int waitFor() throws java.lang.InterruptedException
java.lang.InterruptedException
- if the current thread is interrupted by another thread
while it is waiting, then the wait is ended and an InterruptedException is thrown.public java.lang.String getStandardOutput()
public java.lang.String getStandardError()
public int exitValue()
public static void resetWindowLocation()
public void setProcessArguments(java.util.List<java.lang.String> cmdarray, java.lang.String dir) throws IllegalActionException
cmdarray
- array containing the command to call and its arguments.dir
- the working directory of the subprocess.IllegalActionException
- if the canonical path name of the program file
cannot be obtained.public static void main(java.lang.String[] args) throws IllegalActionException
args
- Commands to pass to the client process.IllegalActionException
- if the canonical path name
of the program file cannot be obtained.