=================================================================== RCS file: /home/cvs/OpenXM/src/OpenMath/ORG/openxm/tam/OpenXM.java,v retrieving revision 1.2 retrieving revision 1.7 diff -u -p -r1.2 -r1.7 --- OpenXM/src/OpenMath/ORG/openxm/tam/OpenXM.java 2000/09/07 11:07:01 1.2 +++ OpenXM/src/OpenMath/ORG/openxm/tam/OpenXM.java 2001/11/01 08:54:50 1.7 @@ -1,5 +1,5 @@ /** - * $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/OpenXM.java,v 1.1 2000/09/07 10:41:34 tam Exp $ + * $OpenXM: OpenXM/src/OpenMath/ORG/openxm/tam/OpenXM.java,v 1.6 2001/01/28 19:17:24 tam Exp $ */ package ORG.openxm.tam; @@ -7,16 +7,39 @@ import java.io.*; import java.net.*; +/*&ja + OpenXM サーバとの接続を行なうクラス. + クライアント側が使用する. + 接続するサーバ毎に一つの OpenXM クラスが必要. +*/ /** - * OpenXM サーバとの接続を行なう抽象クラス. - * クライアント側が使用する. + * OpenXM is a class to connect to OpenXM RFC100 compliant + * servers. + * There is one-to-one correspondence between the instances + * of the class OpenXM and the OpenXM servers. */ public class OpenXM{ - private OpenXMconnection control = null, stream = null; + private OpenXMstream control = null, stream = null; final protected boolean debug = false; + /*&ja + * OpenXM サーバとの接続を TCP/IP ソケットを用いて行なう. + * マシン名 host のポート番号 CtrlPort にコントロールを, + * ポート番号 StreamPort にデータ用の接続を行なう. + */ + /** + * Connect to an OpenXM server via TCP/IP socket. + * host : machine name of the OpenXM server. + * CtrlPort : control port number of the OpenXM server. + * StreamPort : data port number of the OpenXM server. + * As to details on the notion of control port and data port, see + * Design and Implementation of OpenXM client server model and + * common mathematical object format (OpenXM-RFC 100, + * proposed standard) + * at http://www.openxm.org + */ public OpenXM(String host,int CtrlPort,int StreamPort) throws IOException{ - control = new OpenXMconnection(host,CtrlPort); + control = new OpenXMstream(host,CtrlPort); try{ Thread.sleep(100); // We need a few wait for starting up server. @@ -24,39 +47,66 @@ public class OpenXM{ System.err.println(e.getMessage()); } - stream = new OpenXMconnection(host,StreamPort); + stream = new OpenXMstream(host,StreamPort); control.sendByteOrder(); stream.sendByteOrder(); } /** - * 接続の reset を行なう. 現在は未実装. + * コマンド command を立ち上げ、 + * OpenXM サーバとの接続を TCP/IP ソケットを用いて行なう. + * マシン名 host のポート番号 CtrlPort にコントロールを, + * ポート番号 StreamPort にデータ用の接続を行なう. */ + public OpenXM(String command,String host,int CtrlPort,int StreamPort) + throws IOException{ + Runtime.getRuntime().exec(command); + control = new OpenXMstream(host,CtrlPort); + + try{ + Thread.sleep(100); // We need a few wait for starting up server. + }catch(InterruptedException e){ + System.err.println(e.getMessage()); + } + + stream = new OpenXMstream(host,StreamPort); + + control.sendByteOrder(); + stream.sendByteOrder(); + } + + /** + * 接続の初期化を行なう. 現在は未実装. + */ public synchronized void resetConnection(){ debug("control: stopping computer process..."); debug("control: sending SYNC BALL."); } /** - * OpenXM メッセージを送信する. ただし、このメソッドは - * ボディの部分だけでよい. ヘッダの部分は自動で付加される. + * OpenXM メッセージをデータストリームに送信する. + * このメソッドはメッセージのボディの部分だけでよい. + * ヘッダ部分は自動で付加される. */ public void send(OXbody object) throws IOException,MathcapViolation{ stream.send(object); } /** - * OpenXM メッセージを受け取る. + * データストリームから OpenXM メッセージを受け取る. */ public OXmessage receive() throws IOException{ return stream.receive(); } /** - * MathCap を mathcap に設定する. - * 以後, mathcap に反した CMO を送ると - * MathcapViolation が発生する. + * データストリームの MathCap を mathcap に設定する. + * 以後, 送信するオブジェクトは mathcap に合っているかどうか + * チェックが入る. 実際にチェックが入るかどうかは + * OXbody クラスの派生クラスの実装による. + * mathcap に反したオブジェクトを送ろうとした時には, + * 以後 MathcapViolation が発生することが期待される. */ public void setMathCap(CMO_MATHCAP mathcap){ stream.setMathCap(mathcap); @@ -77,7 +127,7 @@ public class OpenXM{ for(int i=0;i