jmatlink
Class CoreJMatLink

java.lang.Object
  extended byjava.lang.Thread
      extended byjmatlink.CoreJMatLink
All Implemented Interfaces:
java.lang.Runnable

public class CoreJMatLink
extends java.lang.Thread


Field Summary
static int THREAD_DEAD
           
static int THREAD_DYING
           
static int THREAD_RUNNING
           
static int THREAD_STARTING
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CoreJMatLink()
          This is the constructor for the CoreJMatLink library.
 
Method Summary
 void engClose()
          Close the connection to MATLAB.
 void engClose(long epL)
          Close a specified connection to an instance of MATLAB.
 void engCloseAll()
          Close all open handles to MATLAB.
 void engEvalString(long epL, java.lang.String evalS)
          Evaluate an expression in MATLAB's workspace.
 void engEvalString(java.lang.String evalS)
          Evaluate an expression in MATLAB's workspace.
 java.lang.String engGetOutputBuffer()
          Return the outputs of previous commands from MATLAB's workspace.
 java.lang.String engGetOutputBuffer(long epL)
          Return the ouputs of previous commands in MATLAB's workspace.
 double engGetScalar(long epL, java.lang.String arrayS)
          Get a scalar value from a specified workspace.
 double engGetScalar(java.lang.String arrayS)
          Get a scalar value from MATLAB's workspace.
 double[][] engGetVariable(long epL, java.lang.String arrayS)
          Get an array from a specified instance/workspace of MATLAB.
 double[][] engGetVariable(java.lang.String arrayS)
          Get an array from MATLAB's workspace.
 boolean engGetVisible(long epL)
           
 void engOpen(java.lang.String startCmdS)
          Open engine.
 long engOpenSingleUse(java.lang.String startCmdS)
          Open engine for single use.
 int engOutputBuffer()
          Return the outputs of previous commands from MATLAB's workspace.
 int engOutputBuffer(long epL, int buflenI)
          Return the ouputs of previous commands in MATLAB's workspace.
 void engPutVariable(long epL, java.lang.String arrayS, double[][] valuesDD)
          Put an array (2 dimensional) into a specified instance/workspace of MATLAB.
 void engPutVariable(java.lang.String arrayS, double[][] valuesDD)
          Put an array (2 dimensional) into MATLAB's workspace.
 void engSetVisible(long epL, boolean engVisB)
           
 int getNoOfEngines()
          Returns the number of currently opened engines
 int getThreadStatus()
          closing of the engine thread takes some time.
 void kill()
          this kills the engine thread
 void run()
           
 void setDebug(boolean debugB)
          Switch on or disable debug information printed to standard output.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

THREAD_DEAD

public static final int THREAD_DEAD
See Also:
Constant Field Values

THREAD_STARTING

public static final int THREAD_STARTING
See Also:
Constant Field Values

THREAD_RUNNING

public static final int THREAD_RUNNING
See Also:
Constant Field Values

THREAD_DYING

public static final int THREAD_DYING
See Also:
Constant Field Values
Constructor Detail

CoreJMatLink

public CoreJMatLink()
This is the constructor for the CoreJMatLink library.

Method Detail

getThreadStatus

public int getThreadStatus()
closing of the engine thread takes some time. During this time NO call to engOpen() or engOpenSingleUse() MUST be made.

Returns:
status of the CoreJMatLink thread (DEAD, STARTING, DYING, RUNNING)

kill

public void kill()
this kills the engine thread


getNoOfEngines

public int getNoOfEngines()
Returns the number of currently opened engines

Returns:
number of open engines

engOpen

public void engOpen(java.lang.String startCmdS)
Open engine. This command is used to open a single connection to MATLAB.

This command is only useful on unix systems. On windows the optional parameter must be NULL. This method is used in conjunction with engClose()

Parameters:
startCmdS - start command for engine. Does not work on Windows.

engOpenSingleUse

public long engOpenSingleUse(java.lang.String startCmdS)
Open engine for single use. This command is used to open multiple connections to MATLAB. This method is used in conjunction with engClose( enginePointer )

Parameters:
startCmdS - start command for engine. Does not work on Windows.

engClose

public void engClose()
Close the connection to MATLAB. This method is used in conjunction with engOpen()


engClose

public void engClose(long epL)
Close a specified connection to an instance of MATLAB.

Parameters:
epL - close one connection to the engine, with pointer epL

engCloseAll

public void engCloseAll()
Close all open handles to MATLAB. This methods closes all connections, which have been opened using engOpen() and engOpenSingleUse().


engSetVisible

public void engSetVisible(long epL,
                          boolean engVisB)
Parameters:
epL -
engVisB -

engGetVisible

public boolean engGetVisible(long epL)
Parameters:
epL -
Returns:

engEvalString

public void engEvalString(java.lang.String evalS)
Evaluate an expression in MATLAB's workspace. This function is used for the general engine connection. Usage is in conjuction with engOpen(), engClose()

Parameters:
evalS - String which contains MATLAB commands (e.g. "sin(a);b=rand(3,4)")

engEvalString

public void engEvalString(long epL,
                          java.lang.String evalS)
Evaluate an expression in MATLAB's workspace. This function is used for all connections to MATLAB which have been opened by epL=engOpenSingleUse(), engClose(epL)

Parameters:
epL - pointer to individual connection to the engine
evalS - String which contains MATLAB commands (e.g. "sin(a);b=rand(3,4)")

engGetScalar

public double engGetScalar(java.lang.String arrayS)
Get a scalar value from MATLAB's workspace.


engGetScalar

public double engGetScalar(long epL,
                           java.lang.String arrayS)
Get a scalar value from a specified workspace.

Parameters:
epL - pointer to individual connection to the engine
Returns:
scalar value from the workspace

engGetVariable

public double[][] engGetVariable(java.lang.String arrayS)
Get an array from MATLAB's workspace.


engGetVariable

public double[][] engGetVariable(long epL,
                                 java.lang.String arrayS)
Get an array from a specified instance/workspace of MATLAB.


engPutVariable

public void engPutVariable(java.lang.String arrayS,
                           double[][] valuesDD)
Put an array (2 dimensional) into MATLAB's workspace.


engPutVariable

public void engPutVariable(long epL,
                           java.lang.String arrayS,
                           double[][] valuesDD)
Put an array (2 dimensional) into a specified instance/workspace of MATLAB.


engOutputBuffer

public int engOutputBuffer()
Return the outputs of previous commands from MATLAB's workspace.

Returns:

engOutputBuffer

public int engOutputBuffer(long epL,
                           int buflenI)
Return the ouputs of previous commands in MATLAB's workspace.

Returns:

engGetOutputBuffer

public java.lang.String engGetOutputBuffer()
Return the outputs of previous commands from MATLAB's workspace.


engGetOutputBuffer

public java.lang.String engGetOutputBuffer(long epL)
Return the ouputs of previous commands in MATLAB's workspace. Right now the parameter buflen is not supported.

Returns:

setDebug

public void setDebug(boolean debugB)
Switch on or disable debug information printed to standard output.


run

public void run()