comparison src/pathfinder/mergetest/EditorSimulator.java @ 126:b56b5950cb18

ns.writelog(str, int);
author kent
date Tue, 25 Dec 2007 20:52:18 +0900
parents 34b15dfcb83e
children 0d49e1116336
comparison
equal deleted inserted replaced
125:34b15dfcb83e 126:b56b5950cb18
33 synchronized public void finish(){ 33 synchronized public void finish(){
34 running = false; 34 running = false;
35 } 35 }
36 36
37 public void run(){ 37 public void run(){
38 System.out.println("Editor"+eid+" start."); 38 ns.writeLog("Editor"+eid+" start.", 1);
39 39
40 // Send All Command that is included CmdList. 40 // Send All Command that is included CmdList.
41 //sendAllCommand(); 41 //sendAllCommand();
42 42
43 // MainLoop, 43 // MainLoop,
44 while(running){ 44 while(running){
45 REPCommand cmd = cs.read(); 45 REPCommand cmd = cs.read();
46 REPCommand[] cmds; 46 REPCommand[] cmds;
47 47
48 //System.out.println("\tEditor"+eid+" catch command from "+cmd.eid+" NO."+cmd.seq); 48 ns.writeLog("\tEditor"+eid+" catch command from "+cmd.eid+" NO."+cmd.seq, 3);
49 49
50 if (cmd.eid==eid){ 50 if (cmd.eid==eid){
51 cmds = translater.catchOwnCommand(cmd); 51 cmds = translater.catchOwnCommand(cmd);
52 for (int i=0; i<cmds.length; i++){ 52 for (int i=0; i<cmds.length; i++){
53 REPCommand tmp = cmds[i]; 53 REPCommand tmp = cmds[i];
54 //System.out.println("\t\tEditor"+eid+" edit text. "); 54 ns.writeLog("\t\tEditor"+eid+" edit text. ", 4);
55 text.edit(tmp); 55 text.edit(tmp);
56 } 56 }
57 /* 終了条件 */ 57 /* 終了条件 */
58 if (cmd.cmd==REP.SMCMD_QUIT){ 58 if (cmd.cmd==REP.SMCMD_QUIT){
59 //System.out.println("\tEditor"+eid+" catch QUIT command emited by itself."); 59 ns.writeLog("\tEditor"+eid+" catch QUIT command emited by itself.", 2);
60 running=false; break; 60 running=false; break;
61 } 61 }
62 } else if (cmd.eid==-1){ 62 } else if (cmd.eid==-1){
63 /* 制御プロセスからの指令 */ 63 /* 制御プロセスからの指令 */
64 System.out.println("\tEditor"+eid+" send command."); 64 ns.writeLog("\tEditor"+eid+" send command.", 2);
65 if (cmd.cmd==REP.SMCMD_QUIT)
66 synchronized(ns){ ns.writeLog("send Quit cmd.", 1); }
65 sendOneCommand(cmd); 67 sendOneCommand(cmd);
66 } else { 68 } else {
67 cmds = translater.transReceiveCmd(cmd); 69 cmds = translater.transReceiveCmd(cmd);
68 for (int i=0; i<cmds.length; i++){ 70 for (int i=0; i<cmds.length; i++){
69 cmd = cmds[i]; 71 cmd = cmds[i];
70 //System.out.println("\t\tEditor"+eid+" edit text and pass Cmd. "); 72 ns.writeLog("\t\tEditor"+eid+" edit text and pass Cmd. ", 4);
71 text.edit(cmd); 73 text.edit(cmd);
72 cs.write(new REPCommand(cmd)); 74 cs.write(new REPCommand(cmd));
73 } 75 }
74 } 76 }
75 } 77 }
76 78
77 System.out.println("Editor"+eid+" finish."); 79 ns.writeLog("Editor"+eid+" finish.", 1);
78 } 80 }
79 81
80 private void sendOneCommand(REPCommand cmd) { 82 private void sendOneCommand(REPCommand cmd) {
81 REPCommand[] cmds; 83 REPCommand[] cmds;
82 if (cmd==null) cmd = CmdList.poll(); 84 if (cmd==null) cmd = CmdList.poll();