Class GRTEngine
- java.lang.Object
-
- com.jstatcom.engine.grte.GRTEngine
-
- All Implemented Interfaces:
- Engine
public final class GRTEngine extends java.lang.Object implements Engine
Provides communication to the Gauss Runtime Engine and conforms to theEngineinterface. This class serves as an adapter to theGaussWorkspaceclass of the GaussApi. Currently only realy numbers and arrays are recognized, the complex part of returns is ignored.Usage Note:
The engine can be configured via the respective XML config file. On initialization the given GCG file is loaded and the procedureinitJGRTEdefined injgrte.srcis called. Onshutdownthe methodshutdownGRTEis called. It is assumed that these method are compiled into the loaded GCG file before. Change the respective GAUSS code according to your needs. The default functionality depends on the system libraryjgrte.dll(Windows) to manage the display of graphics, which would otherwise not work properly.By default this communication class assumes that the GRT type engine version 5.0 is loaded. This can be changed via setting the system library in the XML config file.
All resources must be placed in the subdirectory
jgrte.
-
-
Constructor Summary
Constructors Constructor and Description GRTEngine()Creates an instance ofGRTEngine.
-
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)Calls a procedure with input and return parameters specified.com.aptech.gaussApi5_0.GaussWorkspacegetGaussWorkSpace()Gets the workspace that is encapsulated by this engine.static GRTEnginegetInstance()Returns an initialized instance of theGRTEnginethat is a Singleton.com.aptech.gaussApi5_0.GaussWorkspacegetWk()Gets the gauss workspace that this engine uses.booleanisValid(JSCTypes type)Gets whethertypecan be handled by this engine.voidload(java.lang.String loadName, LoadTypes loadType, JSCData... args)Loads a module according to the load type.voidshutdown()Deletes graphics directory and shuts down all workspaces by callingGauss.shutdown().voidstop()Throws an Exception, because the task cannot be stopped.
-
-
-
Constructor Detail
-
GRTEngine
public GRTEngine()
Creates an instance ofGRTEngine. This should only be invoked if more than one workspace is needed. Otherwise the static initializer should be preferred. This attachesSystem.outto the output and error writer of the createdGaussWorkspace.- Throws:
java.lang.RuntimeException- if something went wrong during the init processcom.aptech.gaussApi5_0.GaussException- if the workspace initialization failedjava.lang.UnsatisfiedLinkError- if system libraries cannot be found
-
-
Method Detail
-
call
public void call(java.lang.String procName, JSCData[] args, JSCData[] retData)Calls a procedure with input and return parameters specified. If this method is called aftershutdownthen the initialization is done again. IfJSCConstants.DEBUG == true, then initialization is done for every call. This allows to take changes in the compiled GCG file into account without restarting.IMPORTANT:
AnyGaussMatrixthat is returned from a GRTE call that contains only a singleNaNelement is treated as an empty matrix and is transformed to an emptyJSCDataobject of the specified type. This convention is choosen, because otherwise not initialized objects could not be returned.Please note:
If a data object of typeJSCTypes.INTis specified as return, then any double scalar will silently be cast to an int. It may happen that information is lost during that operation.- Specified by:
callin interfaceEngine- Parameters:
procName- procedure to be calledargs- the data to be used as input, can benullor emtpyretData- the data objects to store the return parameters, can benullor emtpy- Throws:
java.lang.IllegalArgumentException- ifargsorretDatacontain elements that arenullorif (procName == null || procName.length() == 0)or ifprocNameis not a loaded procedurejava.lang.RuntimeException- if return types are not compatible with returnscom.aptech.gaussApi5_0.GaussException- if there were any GAUSS errors during the execution of the procedure
-
getInstance
public static GRTEngine getInstance()
Returns an initialized instance of theGRTEnginethat is a Singleton.- Returns:
- initialized GRTE instance
- Throws:
java.lang.RuntimeException- if something went wrong during the init processcom.aptech.gaussApi5_0.GaussException- if the workspace initialization failedjava.lang.UnsatisfiedLinkError- if system libraries cannot be found
-
isValid
public boolean isValid(JSCTypes type)
Description copied from interface:EngineGets whethertypecan be handled by this engine.
-
load
public void load(java.lang.String loadName, LoadTypes loadType, JSCData... args)Loads a module according to the load type. All filenames must be specified relative to the resource directory for the GRT engine. Theargsargument is ignored. If this command is called aftershutdownthen the initialization is done again.- Specified by:
loadin interfaceEngine- Parameters:
loadName- the name of the module to loadloadType- the type of the load operation to invokeargs- always ignored- Throws:
java.lang.IllegalArgumentException-if (loadName == null || loadType == null)orif (loadName.length() == 0)or ifloadNameis not valid- See Also:
Engine
-
stop
public void stop()
Throws an Exception, because the task cannot be stopped.- Specified by:
stopin interfaceEngine- Throws:
java.lang.UnsupportedOperationException- See Also:
Engine.stop()
-
shutdown
public void shutdown()
Deletes graphics directory and shuts down all workspaces by callingGauss.shutdown().
-
getGaussWorkSpace
public com.aptech.gaussApi5_0.GaussWorkspace getGaussWorkSpace()
Gets the workspace that is encapsulated by this engine.- Returns:
- the current workspace used for this engine
-
getWk
public com.aptech.gaussApi5_0.GaussWorkspace getWk()
Gets the gauss workspace that this engine uses.- Returns:
- gauss workspace
-
-
DMelt 3.0 © DataMelt by jWork.ORG