com.jstatcom.engine.matlab
Class MatlabEngine
- java.lang.Object
-
- com.jstatcom.engine.matlab.MatlabEngine
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidcall(java.lang.String procName, JSCData[] args, JSCData[] retData)Makes a call toprocNamein the native library that was loaded before.java.lang.StringgetCurrentSysLib()Gets the system library that is currently used by this engine.static MatlabEnginegetInstance()Returns an instance of theMLabEnginethat is a Singleton.booleanisValid(JSCTypes type)Gets whethertypecan be handled by this engine.voidload(java.lang.String module, LoadTypes loadType, JSCData... args)Sets the name of the native library to be used or loads an executable.voidsetOutErrHandler(OutErrHandler outErrHandler)Sets a new output error handler.voidshutdown()Empty method, no termination code.voidstop()Stops a running execution.
-
-
-
Method Detail
-
getInstance
public static MatlabEngine getInstance()
Returns an instance of theMLabEnginethat is a Singleton.- Returns:
- an engine instance
- Throws:
java.lang.RuntimeException- if the native support library cannot be found
-
call
public void call(java.lang.String procName, JSCData[] args, JSCData[] retData)Makes a call toprocNamein the native library that was loaded before. It is assumed that the library was created with the MatLab compiler from an .m file. This call uses themlxinterface function. It also takes care of initialization and termination tasks.Usage Note
The name of the procedure and the input/return parameters must conform to the specification in the MatLab .m file. All input and return parameters will first be transformed to amxArray. Afterwards the return values are read back and set to the specified data objects. The datatypes must be correctly specified.- Specified by:
callin interfaceEngine- Parameters:
procName- name of the procedure to call, must be defined in the currently loaded library, must correspond to the name in the .m file (lowercase)args- arguments for the procedureretData- return types- Throws:
java.lang.IllegalArgumentException-- if
argsorretDatacontainnullelements or unsupported types - if
retDatacontains more than 1 element -
if (procName == null || procName.length() == 0)or - if an element of
argsrepresentsSARRAYand containsnullstrings
- if
java.lang.RuntimeException- ifprocNameadress could not be found in the loaded libraryjava.lang.UnsatisfiedLinkError- if native support routines cannot be foundjava.lang.IllegalStateException- if no system library was loaded before
-
isValid
public boolean isValid(JSCTypes type)
Description copied from interface:EngineGets whethertypecan be handled by this engine.- Specified by:
isValidin interfaceEngine- Parameters:
type- the data type to be checked- Returns:
trueif ok,falseiftypecannot be handled by this engine- See Also:
Engine.isValid(com.jstatcom.model.JSCTypes)
-
load
public void load(java.lang.String module, LoadTypes loadType, JSCData... args)Sets the name of the native library to be used or loads an executable. The library is then used in the next call to a function.if (loadType == MLabLoadTypes.USERLIB)then the library is searched in thejmlabsubdirectory.- Specified by:
loadin interfaceEngine- Parameters:
module- the name of the system library to load without the system specific extensionloadType- the load typeargs- ignored- Throws:
java.lang.IllegalArgumentException-if (loadName == null || loadType == null)orif (module.length() == 0)or- if no user library/exectuable with that name exists in
the
jmlabsubdir or - if
EXEis specified andargscontains other types thanJSCTypes.STRINGor - if
argscontainsnullelements
java.lang.RuntimeException- if operating system is not supported or if the system library/exectuable with the given name cannot be found or if execution returned other value than 0- See Also:
Engine.load(String, com.jstatcom.engine.LoadTypes, com.jstatcom.model.JSCData[])
-
getCurrentSysLib
public java.lang.String getCurrentSysLib()
Gets the system library that is currently used by this engine. It can be changed via theloadmethod.- Returns:
- the absolute path of the current system library or null if
nonehas been loaded so far
-
stop
public void stop()
Description copied from interface:EngineStops a running execution. If there is nothing to do for this engine, this method must throw anUnsupportedOperationException.
-
shutdown
public void shutdown()
Empty method, no termination code.- Specified by:
shutdownin interfaceEngine- See Also:
Engine.shutdown()
-
setOutErrHandler
public void setOutErrHandler(OutErrHandler outErrHandler)
Sets a new output error handler.- Parameters:
outErrHandler- new implementation for dealing with output and errors- Throws:
java.lang.IllegalArgumentException- ifnullargument
-
-
DMelt 3.0 © DataMelt by jWork.ORG