Class MatlabEngine
- java.lang.Object
-
- org.eclipse.epsilon.emc.simulink.engine.MatlabEngine
-
public class MatlabEngine extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.reflect.Method
closeMethod
protected java.lang.reflect.Method
disconnectMethod
protected java.lang.Object
engine
protected java.lang.reflect.Method
evalAsyncMethod
protected java.lang.StringBuilder
evalCommandQueue
protected java.lang.reflect.Method
evalMethod
protected java.lang.reflect.Method
fevalAsyncMethod
protected java.lang.reflect.Method
fevalMethod
protected java.lang.reflect.Method
fevalWithVariableOutputsMethod
protected java.lang.reflect.Method
getVariableAsyncMethod
protected java.lang.reflect.Method
getVariableMethod
protected java.util.Set<IGenericSimulinkModel>
models
protected java.lang.String
project
protected java.lang.reflect.Method
putVariableAsyncMethod
protected java.lang.reflect.Method
putVariableMethod
protected java.lang.reflect.Method
quitMethod
protected java.lang.StringBuilder
sb
protected Stopwatch
stopWatch
protected java.lang.Boolean
tryCatchEnabled
-
Constructor Summary
Constructors Constructor Description MatlabEngine()
MatlabEngine(java.lang.Object engine)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addModel(IGenericSimulinkModel model)
void
close()
static MatlabEngine
connectMatlab()
static MatlabEngine
connectMatlab(java.lang.String name)
void
disconnect()
void
enableTryCatch(boolean enableTryCatch)
void
eval(java.lang.String cmd)
void
eval(java.lang.String cmd, java.lang.Object... parameters)
This method is now lazily executed.java.util.concurrent.Future<java.lang.Void>
evalAsync(java.lang.String cmd)
java.lang.Object
evalWithResult(java.lang.String cmd)
java.lang.Object
evalWithResult(java.lang.String cmd, java.lang.Object... parameters)
java.lang.Object
evalWithSetupAndResult(java.lang.String setup, java.lang.String cmd, java.lang.Object... parameters)
void
feval(int numberOfOutputs, java.lang.String function, java.lang.Object... handles)
void
feval(java.lang.String function, java.lang.Object... handles)
void
fevalAsync(java.lang.String function, java.lang.Object... handles)
java.lang.Object
fevalWithResult(int numberOfOutputs, java.lang.String function, java.lang.Object... handles)
java.lang.Object
fevalWithResult(java.lang.String function, java.lang.Object... handles)
static java.lang.String[]
findMatlab()
void
flush()
Executes all commands to be executed in the eval method that have been stored in a queue.protected static java.lang.Class<?>
getMatlabClass()
java.lang.String
getProject()
Stopwatch
getStopWatch()
java.lang.StringBuilder
getStream()
java.lang.Object
getVariable(java.lang.String variable)
static boolean
is(java.lang.Object obj)
boolean
isDisconnected()
boolean
isEvalCommandQueueEmpty()
boolean
isReduceExchanges()
java.lang.Boolean
isTryCatchEnabled()
protected java.lang.Object
processInputObject(java.lang.Object o)
protected java.lang.Object[]
processInputObject(java.lang.Object[] objects)
void
putVariable(java.lang.String variableName, java.lang.Object value)
void
quit()
void
release(IGenericSimulinkModel model)
void
resetTimer()
static void
setEngineClass(java.lang.Class<?> matlabEngineClass)
void
setProject(java.lang.String project)
void
setReduceExchanges(boolean reduceExchanges)
static MatlabEngine
startMatlab()
static MatlabEngine
startMatlab(java.lang.String[] options)
void
trackApi(boolean track)
-
-
-
Field Detail
-
engine
protected java.lang.Object engine
-
getVariableMethod
protected java.lang.reflect.Method getVariableMethod
-
getVariableAsyncMethod
protected java.lang.reflect.Method getVariableAsyncMethod
-
putVariableMethod
protected java.lang.reflect.Method putVariableMethod
-
putVariableAsyncMethod
protected java.lang.reflect.Method putVariableAsyncMethod
-
evalMethod
protected java.lang.reflect.Method evalMethod
-
evalAsyncMethod
protected java.lang.reflect.Method evalAsyncMethod
-
fevalMethod
protected java.lang.reflect.Method fevalMethod
-
fevalWithVariableOutputsMethod
protected java.lang.reflect.Method fevalWithVariableOutputsMethod
-
fevalAsyncMethod
protected java.lang.reflect.Method fevalAsyncMethod
-
closeMethod
protected java.lang.reflect.Method closeMethod
-
quitMethod
protected java.lang.reflect.Method quitMethod
-
disconnectMethod
protected java.lang.reflect.Method disconnectMethod
-
project
protected java.lang.String project
-
models
protected java.util.Set<IGenericSimulinkModel> models
-
evalCommandQueue
protected java.lang.StringBuilder evalCommandQueue
-
tryCatchEnabled
protected java.lang.Boolean tryCatchEnabled
-
sb
protected java.lang.StringBuilder sb
-
stopWatch
protected Stopwatch stopWatch
-
-
Method Detail
-
isDisconnected
public boolean isDisconnected() throws java.lang.Exception
- Throws:
java.lang.Exception
-
getStopWatch
public Stopwatch getStopWatch()
- Returns:
- the stopWatch
-
setEngineClass
public static void setEngineClass(java.lang.Class<?> matlabEngineClass)
-
trackApi
public void trackApi(boolean track)
-
getStream
public java.lang.StringBuilder getStream()
-
setProject
public void setProject(java.lang.String project) throws MatlabException
- Throws:
MatlabException
-
addModel
public void addModel(IGenericSimulinkModel model)
-
getProject
public java.lang.String getProject()
-
release
public void release(IGenericSimulinkModel model) throws MatlabRuntimeException
- Throws:
MatlabRuntimeException
-
enableTryCatch
public void enableTryCatch(boolean enableTryCatch)
-
isTryCatchEnabled
public java.lang.Boolean isTryCatchEnabled()
-
evalWithSetupAndResult
public java.lang.Object evalWithSetupAndResult(java.lang.String setup, java.lang.String cmd, java.lang.Object... parameters) throws MatlabException
- Throws:
MatlabException
-
evalWithResult
public java.lang.Object evalWithResult(java.lang.String cmd) throws MatlabException
- Throws:
MatlabException
-
evalWithResult
public java.lang.Object evalWithResult(java.lang.String cmd, java.lang.Object... parameters) throws MatlabException
- Throws:
MatlabException
-
eval
public void eval(java.lang.String cmd, java.lang.Object... parameters) throws MatlabException
This method is now lazily executed. All commands are stored in a queue and are only dispatched when the methodflush()
is invoked.- Parameters:
cmd
-parameters
-- Throws:
MatlabException
-
is
public static boolean is(java.lang.Object obj)
-
getMatlabClass
protected static java.lang.Class<?> getMatlabClass()
-
processInputObject
protected java.lang.Object processInputObject(java.lang.Object o)
-
processInputObject
protected java.lang.Object[] processInputObject(java.lang.Object[] objects)
-
startMatlab
public static MatlabEngine startMatlab() throws MatlabException
- Throws:
MatlabException
-
startMatlab
public static MatlabEngine startMatlab(java.lang.String[] options) throws MatlabException
- Throws:
MatlabException
-
findMatlab
public static java.lang.String[] findMatlab() throws MatlabException
- Throws:
MatlabException
-
connectMatlab
public static MatlabEngine connectMatlab() throws MatlabException
- Throws:
MatlabException
-
connectMatlab
public static MatlabEngine connectMatlab(java.lang.String name) throws MatlabException
- Throws:
MatlabException
-
resetTimer
public void resetTimer()
-
eval
public void eval(java.lang.String cmd) throws MatlabException
- Throws:
MatlabException
-
evalAsync
public java.util.concurrent.Future<java.lang.Void> evalAsync(java.lang.String cmd) throws MatlabException
- Throws:
MatlabException
-
getVariable
public java.lang.Object getVariable(java.lang.String variable) throws MatlabException
- Throws:
MatlabException
-
fevalWithResult
public java.lang.Object fevalWithResult(int numberOfOutputs, java.lang.String function, java.lang.Object... handles) throws MatlabException
- Throws:
MatlabException
-
feval
public void feval(int numberOfOutputs, java.lang.String function, java.lang.Object... handles) throws MatlabException
- Throws:
MatlabException
-
fevalWithResult
public java.lang.Object fevalWithResult(java.lang.String function, java.lang.Object... handles) throws MatlabException
- Throws:
MatlabException
-
feval
public void feval(java.lang.String function, java.lang.Object... handles) throws MatlabException
- Throws:
MatlabException
-
putVariable
public void putVariable(java.lang.String variableName, java.lang.Object value) throws MatlabException
- Throws:
MatlabException
-
fevalAsync
public void fevalAsync(java.lang.String function, java.lang.Object... handles) throws MatlabException
- Throws:
MatlabException
-
close
public void close() throws MatlabException
- Throws:
MatlabException
-
quit
public void quit() throws MatlabException
- Throws:
MatlabException
-
disconnect
public void disconnect() throws MatlabException
- Throws:
MatlabException
-
flush
public void flush() throws MatlabException
Executes all commands to be executed in the eval method that have been stored in a queue.- Throws:
MatlabException
-
isEvalCommandQueueEmpty
public boolean isEvalCommandQueueEmpty()
-
setReduceExchanges
public void setReduceExchanges(boolean reduceExchanges)
- Parameters:
reduceExchanges
-
-
isReduceExchanges
public boolean isReduceExchanges()
-
-