equal
deleted
inserted
replaced
40 // Stores the calc_trees_ after call of startSpecifying //WN00827 |
40 // Stores the calc_trees_ after call of startSpecifying //WN00827 |
41 // startCalculation |
41 // startCalculation |
42 // and hands them out to the dialog after startSolving//WN00827 ??? |
42 // and hands them out to the dialog after startSolving//WN00827 ??? |
43 private Map calc_trees_; |
43 private Map calc_trees_; |
44 |
44 |
45 static Logger logger = Logger.getLogger(MathEngine.class.getName()); |
45 static Logger logger_ = Logger.getLogger(MathEngine.class.getName()); |
46 |
46 |
47 // This is a Singleton Class: A private constructor is needed |
47 // This is a Singleton Class: A private constructor is needed |
48 private MathEngine(String hostName) { |
48 private MathEngine(String hostName) { |
49 logger.debug("MathEngine(" + hostName + ")"); |
49 logger_.debug("MathEngine(" + hostName + ")"); |
50 try { |
50 try { |
51 //connect to bridge |
51 //connect to bridge |
52 bridge_rmi_ = (IBridgeRMI) Naming.lookup("//" + hostName |
52 bridge_rmi_ = (IBridgeRMI) Naming.lookup("//" + hostName |
53 + "/BridgeRMI"); |
53 + "/BridgeRMI"); |
54 System.out.println("MathEngine Constr: connected to Bridge: " |
54 System.out.println("MathEngine Constr: connected to Bridge: " |
77 * |
77 * |
78 * @param hostName: |
78 * @param hostName: |
79 * Host name on which the Bridge is running |
79 * Host name on which the Bridge is running |
80 */ |
80 */ |
81 public static void init(String hostName) { |
81 public static void init(String hostName) { |
82 logger.fatal(" DG->BR: init(" + hostName + ")"); |
82 logger_.fatal(" DG->BR: init(" + hostName + ")"); |
83 if (singleton_ == null) { |
83 if (singleton_ == null) { |
84 singleton_ = new MathEngine(hostName); |
84 singleton_ = new MathEngine(hostName); |
85 } |
85 } |
86 } |
86 } |
87 |
87 |
88 public static MathEngine getMathEngine() { |
88 public static MathEngine getMathEngine() { |
89 logger.fatal(" DG<>BR: getMathEngine()"); |
89 logger_.fatal(" DG<>BR: getMathEngine()"); |
90 return singleton_; |
90 return singleton_; |
91 } |
91 } |
92 |
92 |
93 /** |
93 /** |
94 * Start a new calculation |
94 * Start a new calculation |
102 * int id = calc_head_.getCalcTreeID();//WN040922 TODO simplify CalcHead |
102 * int id = calc_head_.getCalcTreeID();//WN040922 TODO simplify CalcHead |
103 * CalcTree calcTree = (CalcTree) calc_trees_.get(new |
103 * CalcTree calcTree = (CalcTree) calc_trees_.get(new |
104 * Integer(id));//WN040922 TODO simplify |
104 * Integer(id));//WN040922 TODO simplify |
105 */ |
105 */ |
106 public CalcTree startCalculation(Formalization f) { |
106 public CalcTree startCalculation(Formalization f) { |
107 logger.fatal(" DG->BR: startCalculation(" + f.toSMLString() + ")"); |
107 logger_.fatal(" DG->BR: startCalculation(" + f.toSMLString() + ")"); |
108 CalcTree calcTree = null;//WN |
108 CalcTree calcTree = null;//WN |
109 try { |
109 try { |
110 int id = bridge_rmi_.startCalculation(f); |
110 int id = bridge_rmi_.startCalculation(f); |
111 calcTree = new CalcTree(this, id); |
111 calcTree = new CalcTree(this, id); |
112 calc_trees_.put(new Integer(id), calcTree); |
112 calc_trees_.put(new Integer(id), calcTree); |
116 //hotSpot.moveRoot(); |
116 //hotSpot.moveRoot(); |
117 int i = 111; |
117 int i = 111; |
118 } catch (RemoteException e) { |
118 } catch (RemoteException e) { |
119 e.printStackTrace(); |
119 e.printStackTrace(); |
120 } |
120 } |
121 logger.fatal(" DG<-BR: startCalculation <- calcTree=" + calcTree); |
121 logger_.fatal(" DG<-BR: startCalculation <- calcTree=" + calcTree); |
122 return calcTree; |
122 return calcTree; |
123 } |
123 } |
124 |
124 |
125 /* |
125 /* |
126 * boolean autoCalculate(int id, int scope, int nSteps) throws |
126 * boolean autoCalculate(int id, int scope, int nSteps) throws |
230 return bridge_rmi_.fetchProposedTactic(id); |
230 return bridge_rmi_.fetchProposedTactic(id); |
231 } |
231 } |
232 |
232 |
233 CalcChanged autoCalculate(int id, int scope, int nSteps) |
233 CalcChanged autoCalculate(int id, int scope, int nSteps) |
234 throws RemoteException { |
234 throws RemoteException { |
235 logger.debug("autoCalculate: id=" + id + ", scope=" + scope |
235 logger_.debug("autoCalculate: id=" + id + ", scope=" + scope |
236 + ", nSteps=" + nSteps); |
236 + ", nSteps=" + nSteps); |
237 return bridge_rmi_.autoCalculate(id, scope, nSteps); |
237 return bridge_rmi_.autoCalculate(id, scope, nSteps); |
238 } |
238 } |
239 |
239 |
240 CalcChanged replaceFormula(int id, CalcFormula f) throws RemoteException { |
240 CalcChanged replaceFormula(int id, CalcFormula f) throws RemoteException { |
261 throws RemoteException { |
261 throws RemoteException { |
262 return bridge_rmi_.moveActiveFormula(calcTreeID, p); |
262 return bridge_rmi_.moveActiveFormula(calcTreeID, p); |
263 } |
263 } |
264 |
264 |
265 int iterator(int id) throws RemoteException { |
265 int iterator(int id) throws RemoteException { |
266 logger.debug("iterator: id=" + id); |
266 logger_.debug("iterator: id=" + id); |
267 return bridge_rmi_.iterator(id); |
267 return bridge_rmi_.iterator(id); |
268 } |
268 } |
269 |
269 |
270 Position moveRoot(int calcTreeID, int iteratorID) throws RemoteException { |
270 Position moveRoot(int calcTreeID, int iteratorID) throws RemoteException { |
271 logger.debug("moveRoot: calcTreeID=" + calcTreeID + ", iteratorID=" |
271 logger_.debug("moveRoot: calcTreeID=" + calcTreeID + ", iteratorID=" |
272 + iteratorID); |
272 + iteratorID); |
273 return bridge_rmi_.moveRoot(calcTreeID, iteratorID); |
273 return bridge_rmi_.moveRoot(calcTreeID, iteratorID); |
274 } |
274 } |
275 |
275 |
276 Position moveUp(int calcTreeID, int iteratorID, Position p) |
276 Position moveUp(int calcTreeID, int iteratorID, Position p) |
278 return bridge_rmi_.moveUp(calcTreeID, iteratorID, p); |
278 return bridge_rmi_.moveUp(calcTreeID, iteratorID, p); |
279 } |
279 } |
280 |
280 |
281 Position moveDown(int calcTreeID, int iteratorID, Position p) |
281 Position moveDown(int calcTreeID, int iteratorID, Position p) |
282 throws RemoteException { |
282 throws RemoteException { |
283 logger.debug("moveDown: calcTreeID=" + calcTreeID + ", sml_pos_=" + p); |
283 logger_.debug("moveDown: calcTreeID=" + calcTreeID + ", sml_pos_=" + p); |
284 return bridge_rmi_.moveDown(calcTreeID, iteratorID, p); |
284 return bridge_rmi_.moveDown(calcTreeID, iteratorID, p); |
285 } |
285 } |
286 |
286 |
287 Position moveLevelUp(int calcTreeID, int iteratorID, Position p) |
287 Position moveLevelUp(int calcTreeID, int iteratorID, Position p) |
288 throws RemoteException { |
288 throws RemoteException { |