XPRDMosel
- java.lang.Object
-
- com.dashoptimization.XPRDMosel
-
public class XPRDMosel extends java.lang.ObjectA Mosel remote instance.
-
-
Field Summary
Modifier and Type Field and Description java.lang.StringencodingCharacter encoding used by this Mosel instance.static intF_APPENDCode for opening the file in append mode (output stream).static intF_BINARYCode for opening file in binary mode.static intF_ERRORCode for error stream.static intF_INPUTCode for input stream.static intF_LINBUFCode for enabling line buffering (output stream).static intF_OUTPUTCode for output stream.static intSYS_ARCHProcessor architecture of the host running the instance.static intSYS_NAMEName of the operating system running the instance.static intSYS_NODEName of host running the instance.static intSYS_PROCProcessor type of the host running the instance.static intSYS_RAMTotal amount of memory in megabytes of the host running the instance.static intSYS_RELRelease number of the operating system running the instance.static intSYS_VERVersion name of the operating system running the instance.
-
Method Summary
Modifier and Type Method and Description voidcompile(java.lang.String options, java.lang.String src, java.lang.String dest)Compile a model source file.voidcompile(java.lang.String options, java.lang.String src, java.lang.String dest, java.lang.String ucom, java.lang.String pass, java.lang.String privkey, java.lang.String pubkeys)Compile a model source file.intdisconnect()Disconnect the instance.java.lang.StringgetBanner()Get the connection bannerintgetId()Get the ID of the instancejava.lang.StringgetSystemInformation()Retrieve information about the system running the instance.java.lang.StringgetSystemInformation(int what)Retrieve information about the system running the instance.XPRDgetXPRD()Get the XPRD object managing this instance.booleanisConnected()Check whether this instance is connected.XPRDModelloadModel(java.lang.String name)Load a compiled model into memory.XPRDModelloadModel(java.lang.String name, java.lang.String options, java.lang.String pass, java.lang.String privkey, java.lang.String pubkeys)Load a compiled model into memory.java.io.InputStreamopenForReading(java.lang.String fname, int mode)Open a file for reading operations on the instance.java.io.InputStreamopenForReading(java.lang.String fname, int mode, int bufsize)Open a file for reading operations on the instance with buffer size.java.io.BufferedOutputStreamopenForWriting(java.lang.String fname, int mode)Open a file for writing operations on the instance.java.io.BufferedOutputStreamopenForWriting(java.lang.String fname, int mode, int bufsize)Open a file for writing operations on the instance with buffer size.voidsetControl(java.lang.String name, java.lang.String val)Set a Mosel instance control parameter for the instance.voidsetDefaultStream(int wmd, java.lang.String fileName)Set default input/output streams.voidunloadModel(XPRDModel mod)Unload a previously loaded model.
-
-
-
Field Detail
-
encoding
public final java.lang.String encoding
Character encoding used by this Mosel instance.
-
F_INPUT
public static final int F_INPUT
Code for input stream.
-
F_OUTPUT
public static final int F_OUTPUT
Code for output stream.
-
F_ERROR
public static final int F_ERROR
Code for error stream.
-
F_LINBUF
public static final int F_LINBUF
Code for enabling line buffering (output stream).
-
F_BINARY
public static final int F_BINARY
Code for opening file in binary mode.
-
F_APPEND
public static final int F_APPEND
Code for opening the file in append mode (output stream).
-
SYS_NAME
public static final int SYS_NAME
Name of the operating system running the instance.- See Also:
-
getSystemInformation(int), Constant Field Values
-
SYS_REL
public static final int SYS_REL
Release number of the operating system running the instance.- See Also:
-
getSystemInformation(int), Constant Field Values
-
SYS_VER
public static final int SYS_VER
Version name of the operating system running the instance.- See Also:
-
getSystemInformation(int), Constant Field Values
-
SYS_PROC
public static final int SYS_PROC
Processor type of the host running the instance.- See Also:
-
getSystemInformation(int), Constant Field Values
-
SYS_ARCH
public static final int SYS_ARCH
Processor architecture of the host running the instance.- See Also:
-
getSystemInformation(int), Constant Field Values
-
SYS_NODE
public static final int SYS_NODE
Name of host running the instance.- See Also:
-
getSystemInformation(int), Constant Field Values
-
SYS_RAM
public static final int SYS_RAM
Total amount of memory in megabytes of the host running the instance.- See Also:
-
getSystemInformation(int), Constant Field Values
-
-
Method Detail
-
disconnect
public int disconnect()
Disconnect the instance.- Returns:
- exit status of the instance or -1 if the instance is not connected
-
isConnected
public boolean isConnected()
Check whether this instance is connected.- Returns:
-
trueif the instance is connected
-
getXPRD
public XPRD getXPRD()
Get the XPRD object managing this instance.- Returns:
-
the associated XPRD or
nullif the instance is not connected
-
getSystemInformation
public java.lang.String getSystemInformation(int what)
Retrieve information about the system running the instance.
-
getSystemInformation
public java.lang.String getSystemInformation()
Retrieve information about the system running the instance.- Returns:
- Text string reporting the requested information
-
compile
public void compile(java.lang.String options, java.lang.String src, java.lang.String dest) throws XPRDCompileException, java.io.IOExceptionCompile a model source file. This method compiles a given model source file into a binary model file (bim file) that is required as input to methodloadModel(java.lang.String)for loading the model.- Parameters:
-
options- compilation options (may benull):"g"include debugging information: in the case of a run time error during the execution of the model the location of the error in the source file may be indicated"s"strip symbols: secure the bim file by removing all private symbol names used in the source model"p"parse only: stop after the syntax analysis of the source file, do not compile (no file generated)
-
src- name of the source file -
dest- name of the output (bim) file (may benull) - Throws:
-
XPRDCompileException- If compilation fails. -
java.io.IOException- In case of communication error with the remote instance
-
compile
public void compile(java.lang.String options, java.lang.String src, java.lang.String dest, java.lang.String ucom, java.lang.String pass, java.lang.String privkey, java.lang.String pubkeys) throws XPRDCompileException, java.io.IOExceptionCompile a model source file. This method compiles a given model source file into a binary model file (bim file) that is required as input to methodloadModel(java.lang.String)for loading the model.- Parameters:
-
options- compilation options (may benull):"g"include debugging information: in the case of a run time error during the execution of the model the location of the error in the source file may be indicated"s"strip symbols: secure the bim file by removing all private symbol names used in the source model"p"parse only: stop after the syntax analysis of the source file, do not compile (no file generated)
-
src- name of the source file -
dest- name of the output (bim) file (may benull) -
ucom- user comment (may benull) -
pass- password file (may benull) -
privkey- private key file (may benull) -
pubkeys- file of public keys (may benull) - Throws:
-
XPRDCompileException- If compilation fails. -
java.io.IOException- In case of communication error with the remote instance
-
setDefaultStream
public void setDefaultStream(int wmd, java.lang.String fileName) throws java.io.IOExceptionSet default input/output streams. This method defines the default global streams: they are used as the default when a model is loaded and whenever no model information is available (e.g. compilation errors, error on modules, etc). The method can be used only if no model is currently loaded in memory.
Using an empty string as the file name implies resetting to the corresponding original default stream.- Parameters:
-
wmd- stream to be set: -
fileName- extended file name to be used for the stream. The default values are"null:"for input"rmt:[0]sysfd:1"for output"rmt:[0]sysfd:2"for error
- Throws:
-
java.io.IOException- If the stream cannot be set.
-
setControl
public void setControl(java.lang.String name, java.lang.String val) throws java.io.IOExceptionSet a Mosel instance control parameter for the instance.- Parameters:
-
name- name of the parameter. -
val- value. - Throws:
-
java.io.IOException- If the control cannot be set (invalid name or value).
-
loadModel
public XPRDModel loadModel(java.lang.String name) throws java.io.IOException
Load a compiled model into memory. This method loads a compiled model (Binary Model file) into memory. While loading a model from a file, Mosel also automatically opens any additional modules that are required by this model.- Parameters:
-
name- name of a binary model file - Returns:
-
A new model instance of type
XPRDModelcreated from a binary model file. - Throws:
-
java.io.IOException- If the binary model file cannot be found or instance is not connected.
-
loadModel
public XPRDModel loadModel(java.lang.String name, java.lang.String options, java.lang.String pass, java.lang.String privkey, java.lang.String pubkeys) throws java.io.IOException
Load a compiled model into memory. This method loads a compiled model (Binary Model file) into memory. While loading a model from a file, Mosel also automatically opens any additional modules that are required by this model.- Parameters:
-
name- name of a binary model file -
options- loader options (may benull): -
pass- password file (may benull) -
privkey- private key file (may benull) -
pubkeys- file of public keys (may benull) - Returns:
-
A new model instance of type
XPRDModelcreated from a binary model file. - Throws:
-
java.io.IOException- If the binary model file cannot be found or instance is not connected.
-
getBanner
public java.lang.String getBanner()
Get the connection banner- Returns:
- message displayed by the instance upon connection
-
getId
public int getId()
Get the ID of the instance- Returns:
- node number associated to the instance
-
unloadModel
public void unloadModel(XPRDModel mod) throws java.io.IOException
Unload a previously loaded model. After this method has been called, the corresponding model can no longer be used.- Parameters:
-
mod- model to be unloaded - Throws:
-
java.io.IOException- If the model is running.
-
openForWriting
public java.io.BufferedOutputStream openForWriting(java.lang.String fname, int mode) throws java.io.IOExceptionOpen a file for writing operations on the instance.- Parameters:
-
fname- file name -
mode- open mode - Returns:
- an OutputStream
- Throws:
-
java.io.IOException- if the file cannot be open
-
openForWriting
public java.io.BufferedOutputStream openForWriting(java.lang.String fname, int mode, int bufsize) throws java.io.IOExceptionOpen a file for writing operations on the instance with buffer size.- Parameters:
-
fname- file name -
mode- open mode -
bufsize- buffer size in kilobytes (from 2 to 64) - Returns:
- an OutputStream
- Throws:
-
java.io.IOException- if the file cannot be open
-
openForReading
public java.io.InputStream openForReading(java.lang.String fname, int mode) throws java.io.IOExceptionOpen a file for reading operations on the instance.- Parameters:
-
fname- file name -
mode- open mode - Returns:
- an InputStream
- Throws:
-
java.io.IOException- if the file cannot be open
-
openForReading
public java.io.InputStream openForReading(java.lang.String fname, int mode, int bufsize) throws java.io.IOExceptionOpen a file for reading operations on the instance with buffer size.- Parameters:
-
fname- file name -
mode- open mode -
bufsize- buffer size in kilobytes (from 2 to 64) - Returns:
- an InputStream
- Throws:
-
java.io.IOException- if the file cannot be open
-
-
