com.jstatcom.engine.gauss
Class GaussEngine
- java.lang.Object
-
- com.jstatcom.engine.gauss.GaussEngine
-
- All Implemented Interfaces:
- Engine
public final class GaussEngine extends java.lang.Object implements Engine
Links to an instance of the software package Gauss (www.aptech.com). This object performs the whole communication with Gauss and has control over it, i.e. it starts, commands, and ends Gauss.This class enforces the Singleton property by a static initializer. Currently it runs only on the Windows OS.
-
-
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)Executes a procedure with input and return parameters specified.java.lang.StringcompileGCG()Compiles the source files defined in the XML file for compilation.java.lang.StringcreateLibs()Creates the GAUSS libraries defined in the respective XML filevoidexecute(java.lang.String command)Executes a GAUSS command.static GaussEnginegetInstance()Returns an instance of theGaussEnginethat is a Singleton.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.voidread(JSCData[] rtArray)Reads all variables defined invarNamesfrom GAUSS.voidshutdown()Terminates this engine and does clean up tasks.voidstart(boolean compileIfNecessary)Starts an instance of GAUSS.voidstop()Stops a running execution.voidwrite(JSCData[] engineData)Write a data array to GAUSS.
-
-
-
Method Detail
-
compileGCG
public java.lang.String compileGCG()
Compiles the source files defined in the XML file for compilation.- Returns:
nullif ok, error string otherwise
-
createLibs
public java.lang.String createLibs()
Creates the GAUSS libraries defined in the respective XML file- Returns:
nullif ok, error string otherwise
-
execute
public void execute(java.lang.String command)
Executes a GAUSS command. If this engine is in debug mode, the command is also printed toSystem.out.- Parameters:
command- string with GAUSS code, for example "y=rndn(100,1)"- Throws:
java.lang.IllegalArgumentException-if (command == null)java.lang.RuntimeException- if execution ofcommandfailed, usegetMessageto retrieve the error string
-
call
public void call(java.lang.String procName, JSCData[] args, JSCData[] retData)Executes a procedure with input and return parameters specified. The results are set to the data objects specified inretData. Listeners registered to these data objects receive notifications if something changed.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 name to be executed by this engineargs- the data to be used as input, can benullor emtpy if no arguments neededretData- the data array to store results can benullor emtpy if no returns needed- Throws:
java.lang.IllegalArgumentException- ifargsorretDatacontain elements that arenulljava.lang.RuntimeException- if return types are not compatible with returns
-
getInstance
public static GaussEngine getInstance()
Returns an instance of theGaussEnginethat is a Singleton. Whenever this method is called, the respective system library is loaded.- Returns:
- initialized GAUSS instance, not yet started
- Throws:
java.lang.RuntimeException- if operating system is not supported or if something went wrong during the init processjava.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 GAUSS engine. Theargsargument is ignored.- Specified by:
loadin interfaceEngine- Parameters:
loadName- the name of the module to loadloadType- the type of module to loadargs- (optional) module load arguments if needed- Throws:
java.lang.IllegalArgumentException-if (loadName == null || loadType == null)orif (loadName.length() == 0)or ifloadNameis not valid- See Also:
Engine
-
read
public void read(JSCData[] rtArray)
Reads all variables defined invarNamesfrom GAUSS. ThevarTypesare necessary to enforce type savety.- Parameters:
rtArray- the data to be read- Throws:
java.lang.IllegalArgumentException-if (rtArray == nul)or ifrtArraycontainsnullelementsjava.lang.RuntimeException- if the variable could not be read or if an invalid type was specified or if the read variable does not match with the respective type
-
start
public void start(boolean compileIfNecessary)
Starts an instance of GAUSS. If in DEBUG mode, then it uses the library system, otherwise the specified .gcg file is loaded. If the load of the .gcg file fails then a compilation of the source files is carried out.Nothing happens if GAUSS is already running.
- Parameters:
compileIfNecessary- compiles gcg file if it cannot be loaded- Throws:
java.lang.RuntimeException- if start fails
-
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()
Description copied from interface:EngineTerminates this engine and does clean up tasks. Whenever aloadorexecuteis called afterwards this engine should be reinitialized.
-
write
public void write(JSCData[] engineData)
Write a data array to GAUSS. If GAUSS is not yet running, thestartmethod is called.- Parameters:
engineData- the data array to be written to GAUSS- Throws:
java.lang.IllegalArgumentException- if one of the data types cannot be handled by the GAUSS engine orif (engineData == null)or if one element ofengineDataisnulljava.lang.RuntimeException- if write failed of if GAUSS could not be started if it was not running before- See Also:
Engine
-
-
DMelt 3.0 © DataMelt by jWork.ORG