|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.symcomp.scscp.CASClient
org.symcomp.scscp.SCSCPClient
public class SCSCPClient
A class to encapsulate the access to an SCSCP-Server.
To use an SCSCP server to compute mathematical expressions that are given in OpenMath form,
the SCSCP-protocol needs to be implemented. This class takes care of all the protocol stuff.
To connect to an SCSCP-server running on machine www.somewhere.org on port 12345 just create
an instance of SCSCPClient:
SCSCPClient client = new SCSCPClient("www.somewhere.org", 12345)
Then, you can communicate with the client in a non-blocking way by use of
compute,resultAvailable andgetResultcomputeBlocking.
A typical scenario would be:
SCSCPClient client = new SCSCPClient("127.0.0.1", 12345);
String token = client.compute("<OMOBJ>...</OMOBJ>");
while (!client.resultAvailable(token))
// do something reasonable with your time
String result = client.getResult(token);
// Now, use that result.
Or, in the blocking case:
SCSCPClient client = new SCSCPClient("127.0.0.1", 12345);
String result = client.computeBlocking("<OMOBJ>...</OMOBJ>");
// Now, use that result.
| Field Summary | |
|---|---|
protected OpenMathBase.ENCODINGS |
activeEncoding
|
protected OpenMathBase.ENCODINGS |
defaultEncoding
|
protected java.io.BufferedReader |
inn
|
protected java.lang.Integer |
loglevel
|
protected java.io.PrintWriter |
out
|
protected java.lang.Integer |
scscpPort
|
protected java.lang.String |
scscpUri
|
protected java.lang.String |
scscpVersion
|
protected java.lang.String |
serviceId
|
protected java.lang.String |
serviceName
|
protected java.lang.String |
serviceVersion
|
protected java.net.Socket |
socket
|
protected java.lang.Integer |
state
|
protected java.util.List<OpenMathBase.ENCODINGS> |
supportedEncodings
|
| Fields inherited from class org.symcomp.scscp.CASClient |
|---|
computations, currentComputation, id, resultThread, waitingComputations |
| Constructor Summary | |
|---|---|
SCSCPClient()
|
|
SCSCPClient(java.lang.String uri,
java.lang.Integer port)
Creates an SCSCP-Client that connects to a server on the machine at uri
port port. |
|
| Method Summary | |
|---|---|
java.lang.String |
compute(OpenMathBase omCommand)
Computes an OpenMath-expression, non-blocking. |
OpenMathBase |
computeBlocking(OpenMathBase omCommand)
Computes an OpenMath-expression, blocking. |
OpenMathBase.ENCODINGS |
getActiveEncoding()
|
java.lang.Integer |
getComputationState(java.lang.String token)
Get the state of a particular computation. |
OpenMathBase |
getResult(java.lang.String token)
Retrieves the result of a computation. |
java.lang.Integer |
getSCSCPPort()
|
java.lang.String |
getSCSCPUri()
|
java.lang.String |
getSCSCPVersion()
|
java.lang.String |
getServiceId()
|
java.lang.String |
getServiceName()
|
java.lang.String |
getServiceVersion()
|
java.lang.Integer |
getState()
|
java.util.List<OpenMathBase.ENCODINGS> |
getSupportedEncodings()
|
protected void |
log(java.lang.Integer l,
java.lang.String msg)
just for logging, quick hack, to be replaced by something better. |
void |
quit()
|
java.lang.Boolean |
resultAvailable(java.lang.String token)
Checks whether a given computation has finished. |
void |
run()
Private method, does the actual background-communication. |
boolean |
setActiveEncoding(OpenMathBase.ENCODINGS enc,
boolean force)
Private method to send data to the SCSCP server |
void |
setLoglevel(java.lang.Integer l)
|
protected void |
setSupportedEncodings(java.lang.String str)
encoding business |
java.lang.String |
startComputation(Computation comp)
Starts a Computation |
| Methods inherited from class org.symcomp.scscp.CASClient |
|---|
getComputation, getComputations, getNumberOfComputations, isIdle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String scscpUri
protected java.lang.Integer scscpPort
protected java.net.Socket socket
protected java.io.BufferedReader inn
protected java.io.PrintWriter out
protected java.lang.String scscpVersion
protected java.lang.Integer loglevel
protected java.lang.String serviceName
protected java.lang.String serviceVersion
protected java.lang.String serviceId
protected java.lang.Integer state
protected java.util.List<OpenMathBase.ENCODINGS> supportedEncodings
protected OpenMathBase.ENCODINGS activeEncoding
protected OpenMathBase.ENCODINGS defaultEncoding
| Constructor Detail |
|---|
public SCSCPClient()
public SCSCPClient(java.lang.String uri,
java.lang.Integer port)
uri
port port.
Directly after the creation of the object, the version-negotiation (phase 1 of the SCSCP-protocol) is done.
uri - The IP-address or the hostname of the machine where the SCSCP-server is runningport - The port on which the SCSCP-Server is listening.| Method Detail |
|---|
public java.lang.String startComputation(Computation comp)
The Computation comp is sent
to the attaced SCSCP-server. The function call returns immediately, returning a token
which can be used to get the result using getResult.
comp - a Computation
public java.lang.String compute(OpenMathBase omCommand)
The OpenMath expression represented by the parameter omCommand is wrapped
in a Computation and sent to the attached SCSCP-server. The function call returns
immediately, returning a token which can be used to get the result using getResult.
compute in class CASClientomCommand - an OpenMath expression
public OpenMathBase computeBlocking(OpenMathBase omCommand)
The OpenMath expression represented by the parameter omCommand is sent
to the attaced SCSCP-server. The function call returns after the computation has finished
returning an xml-string
Note, that this computation may take extremely long, so only use this call if there is really nothing you want to do in the meantime.
omCommand - an OpenMath expression
public OpenMathBase getResult(java.lang.String token)
Using the token returned by compute(), this function is used
to retrieve the actual result. If the result is not yet ready, null is
returned.
If a non-token is given, an Exception is raised.
getResult in class CASClienttoken - A string that was created using compute()
public java.lang.Boolean resultAvailable(java.lang.String token)
Using the token returned by compute(), this function is used
to find out, whether the SCSCP-server has finished its computation.
If a non-token is given, an Exception is raised.
resultAvailable in class CASClienttoken - a string that was created using compute()
true if the computation is ready, false otherwise.public java.lang.Integer getComputationState(java.lang.String token)
Using the token returned by compute(), this function can be
used to find out what state this computation is in.
If a non-token is given, an Exception is raised.
token - A string that was created using compute()
public void quit()
public void run()
run in interface java.lang.Runnablerun in class CASClientpublic java.lang.String getServiceName()
public java.lang.String getServiceVersion()
public java.lang.String getServiceId()
public java.lang.String getSCSCPUri()
public java.lang.Integer getSCSCPPort()
public java.lang.String getSCSCPVersion()
public java.lang.Integer getState()
protected void setSupportedEncodings(java.lang.String str)
public java.util.List<OpenMathBase.ENCODINGS> getSupportedEncodings()
public OpenMathBase.ENCODINGS getActiveEncoding()
public boolean setActiveEncoding(OpenMathBase.ENCODINGS enc,
boolean force)
enc - The requested encodingforce - Whether the encoding should be set even if it was not (known to be) supported.
protected void log(java.lang.Integer l,
java.lang.String msg)
public void setLoglevel(java.lang.Integer l)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||