1.1 --- a/src/java/isac/bridge/BridgeRMI.java Sat Feb 05 15:04:29 2005 +0100
1.2 +++ b/src/java/isac/bridge/BridgeRMI.java Sat Feb 05 15:46:11 2005 +0100
1.3 @@ -12,8 +12,10 @@
1.4 import isac.util.formulae.CalcHeadCompoundID;
1.5 import isac.util.formulae.CalcHeadSimpleID;
1.6 import isac.util.formulae.CalcFormula;
1.7 +import isac.util.formulae.FormHeadsContainer;
1.8 import isac.util.formulae.Position;
1.9 import isac.util.interfaces.ICalcElement;
1.10 +import isac.util.interfaces.ICalcIterator;
1.11 import isac.util.interfaces.IToCalc;
1.12 import isac.util.parser.XMLParserDigest;
1.13 import isac.util.tactics.Tactic;
1.14 @@ -204,11 +206,11 @@
1.15 java_calcid_to_smlcalcid_.put(new Integer(javaCalcID), new Integer(
1.16 smlCalcID));
1.17 sendToKernel("Iterator " + smlCalcID + ";", restore);//WN041209 no
1.18 - // Iterator from KN
1.19 + // Iterator from KN
1.20 sendToKernel("moveActiveRoot " + smlCalcID + ";", restore);//WN041209
1.21 - // no
1.22 - // Iterator
1.23 - // from KN
1.24 + // no
1.25 + // Iterator
1.26 + // from KN
1.27 if (!restore)
1.28 bufferInput(javaCalcID, instr);
1.29 return smlCalcID;
1.30 @@ -338,7 +340,7 @@
1.31 return -1;
1.32 if (wrapper.getResponse() == null) {
1.33 //WN041126 ---> isac.wsdialog.DialogGuide#notifyUserAction @@@
1.34 - autoCalculate(id, /*scope*/1, /*steps*/1);
1.35 + autoCalculate(id, /* scope */1, /* steps */1);
1.36 return 0; //Everything is ok
1.37 } else {
1.38 return -1; //An Error occcured
1.39 @@ -401,8 +403,8 @@
1.40
1.41 public CalcChanged replaceFormula(int id, CalcFormula f) {
1.42 ResponseWrapper wrapper = null;
1.43 - wrapper = interpretSML(id, "replaceFormula @calcid@ \"" + f.toSMLString()
1.44 - + "\";", false);
1.45 + wrapper = interpretSML(id, "replaceFormula @calcid@ \""
1.46 + + f.toSMLString() + "\";", false);
1.47 if (wrapper == null)
1.48 return null;
1.49 else if (wrapper.getResponse() instanceof Message)
1.50 @@ -413,8 +415,8 @@
1.51
1.52 public CalcChanged appendFormula(int id, CalcFormula f) {
1.53 ResponseWrapper wrapper = null;
1.54 - wrapper = interpretSML(id, "appendFormula @calcid@ \"" + f.toSMLString()
1.55 - + "\";", false);
1.56 + wrapper = interpretSML(id, "appendFormula @calcid@ \""
1.57 + + f.toSMLString() + "\";", false);
1.58 if (wrapper == null)
1.59 return null;
1.60 else if (wrapper.getResponse() instanceof Message)
1.61 @@ -423,6 +425,20 @@
1.62 return (CalcChanged) wrapper.getResponse();
1.63 }
1.64
1.65 + public Vector getElementsFromTo(int id, ICalcIterator iterator_from,
1.66 + ICalcIterator iterator_to, Integer level,
1.67 + boolean result_includes_tactics) {
1.68 + ResponseWrapper wrapper = null;
1.69 + // getElementsFromTo 1 unc gen 1 false;
1.70 + wrapper = interpretSML(id, "getElementsFromTo @calcid@ "
1.71 + + iterator_from.toSMLString() + " " + iterator_to.toSMLString()
1.72 + + " " + level + " " + result_includes_tactics + ";", false);
1.73 + if (wrapper == null)
1.74 + return null;
1.75 + FormHeadsContainer c = (FormHeadsContainer) wrapper.getResponse();
1.76 + return c.getElements();
1.77 + }
1.78 +
1.79 public int iterator(int id) {
1.80 logger_.warn("iterator: id=" + id);
1.81 // ResponseWrapper wrapper = null;
1.82 @@ -443,18 +459,18 @@
1.83 return 4711;//TODO.WN041208 drop CalcIterator.iteratorID_
1.84 }
1.85
1.86 -// private Position moveSuccess(ResponseWrapper wrapper) {
1.87 -// if (wrapper == null)
1.88 -// return null;
1.89 -// else {
1.90 -// if (wrapper.getResponse() instanceof Message)
1.91 -// return null;//TODO.WN041209 handle messages
1.92 -// else {
1.93 -// Position p = (Position) wrapper.getPosition();
1.94 -// return p;
1.95 -// }
1.96 -// }
1.97 -// }
1.98 + // private Position moveSuccess(ResponseWrapper wrapper) {
1.99 + // if (wrapper == null)
1.100 + // return null;
1.101 + // else {
1.102 + // if (wrapper.getResponse() instanceof Message)
1.103 + // return null;//TODO.WN041209 handle messages
1.104 + // else {
1.105 + // Position p = (Position) wrapper.getPosition();
1.106 + // return p;
1.107 + // }
1.108 + // }
1.109 + // }
1.110 private Position moveSuccess(ResponseWrapper wrapper) {
1.111 if (wrapper == null)
1.112 return null;
1.113 @@ -713,9 +729,9 @@
1.114
1.115 ICalcElement ce = (ICalcElement) wrapper.getResponse();
1.116 if (ce instanceof CalcFormula) {
1.117 -// ((CalcFormula) ce).setPosition(wrapper.getPosition());
1.118 + // ((CalcFormula) ce).setPosition(wrapper.getPosition());
1.119 } else if (ce instanceof CalcHead) {
1.120 -// ((CalcHead) ce).setPosition(wrapper.getPosition());
1.121 + // ((CalcHead) ce).setPosition(wrapper.getPosition());
1.122 ((CalcHead) ce).setCalcTreeID(javaCalcID);
1.123 }
1.124 return ce;
1.125 @@ -733,9 +749,9 @@
1.126
1.127 ICalcElement ce = (ICalcElement) wrapper.getResponse();
1.128 if (ce instanceof CalcFormula) {
1.129 -// ((CalcFormula) ce).setPosition(wrapper.getPosition());
1.130 + // ((CalcFormula) ce).setPosition(wrapper.getPosition());
1.131 } else if (ce instanceof CalcHead) {
1.132 -// ((CalcHead) ce).setPosition(wrapper.getPosition());
1.133 + // ((CalcHead) ce).setPosition(wrapper.getPosition());
1.134 ((CalcHead) ce).setCalcTreeID(calcTreeID);
1.135 }
1.136 return ce;
2.1 --- a/src/java/isac/bridge/CalcTree.java Sat Feb 05 15:04:29 2005 +0100
2.2 +++ b/src/java/isac/bridge/CalcTree.java Sat Feb 05 15:46:11 2005 +0100
2.3 @@ -510,22 +510,13 @@
2.4 logger_.fatal(" DG->BR: getElementsFromTo("
2.5 + iterator_from.toSMLString() + ", "
2.6 + iterator_to.toSMLString() + level + ")");
2.7 - // CalcChanged cc;
2.8 - // int transactionID = -1;
2.9 - // try {
2.10 - // cc = mathEngine_.autoCalculate(this.id_, scope, nSteps);
2.11 - // if (!(cc == null)) {
2.12 - // hot_spot_ = new CalcIterator(this, cc.getLastGenerated());
2.13 - // transactionID = generateTransactionID();
2.14 - // informListeners(new CalcIterator(this, cc.getLastUnchanged()),
2.15 - // new CalcIterator(this, cc.getLastDeleted()),
2.16 - // new CalcIterator(this, cc.getLastGenerated()),
2.17 - // transactionID);
2.18 - // }
2.19 - // } catch (RemoteException e) {
2.20 - // e.printStackTrace();
2.21 - // }
2.22 - return null;
2.23 + try {
2.24 + return mathEngine_.getElementsFromTo(this.id_, iterator_from,
2.25 + iterator_to, level,result_includes_tactics);
2.26 + } catch (RemoteException e) {
2.27 + e.printStackTrace();
2.28 + }
2.29 + return null;
2.30 }
2.31
2.32 }
2.33 \ No newline at end of file
3.1 --- a/src/java/isac/bridge/IBridgeRMI.java Sat Feb 05 15:04:29 2005 +0100
3.2 +++ b/src/java/isac/bridge/IBridgeRMI.java Sat Feb 05 15:46:11 2005 +0100
3.3 @@ -11,6 +11,7 @@
3.4 import isac.util.formulae.CalcFormula;
3.5 import isac.util.formulae.Position;
3.6 import isac.util.interfaces.ICalcElement;
3.7 +import isac.util.interfaces.ICalcIterator;
3.8 import isac.util.tactics.Tactic;
3.9
3.10 import java.rmi.Remote;
3.11 @@ -52,7 +53,9 @@
3.12
3.13 public CalcChanged appendFormula(int id, CalcFormula f) throws RemoteException;
3.14
3.15 -// public CalcChanged appendFormula(int id, CalcFormula f) throws RemoteException;
3.16 + public Vector getElementsFromTo(int id, ICalcIterator iterator_from,
3.17 + ICalcIterator iterator_to, Integer level,
3.18 + boolean result_includes_tactics) throws RemoteException;
3.19
3.20 public int iterator(int calcTreeID) throws RemoteException;
3.21
4.1 --- a/src/java/isac/bridge/MathEngine.java Sat Feb 05 15:04:29 2005 +0100
4.2 +++ b/src/java/isac/bridge/MathEngine.java Sat Feb 05 15:46:11 2005 +0100
4.3 @@ -24,329 +24,342 @@
4.4 import org.apache.log4j.Logger;
4.5
4.6 /**
4.7 - * Class MathEngine: This class is called by the Dialog
4.8 - * and communicates with the Bridge via RMI.
4.9 - * It also delegates the methods of the CalcTree and the
4.10 - * CalcIterator to the Bridge.
4.11 + * Class MathEngine: This class is called by the Dialog and communicates with
4.12 + * the Bridge via RMI. It also delegates the methods of the CalcTree and the
4.13 + * CalcIterator to the Bridge.
4.14 + *
4.15 * @author rgradisc
4.16 */
4.17 public class MathEngine implements Serializable {
4.18
4.19 - private static MathEngine singleton;
4.20 + private static MathEngine singleton;
4.21
4.22 - private IBridgeRMI bridgeRMI;
4.23 + private IBridgeRMI bridgeRMI;
4.24
4.25 - // Stores the calcTrees after call of startSpecifying //WN00827 startCalculation
4.26 - // and hands them out to the dialog after startSolving//WN00827 ???
4.27 - private Map calcTrees;
4.28 + // Stores the calcTrees after call of startSpecifying //WN00827
4.29 + // startCalculation
4.30 + // and hands them out to the dialog after startSolving//WN00827 ???
4.31 + private Map calcTrees;
4.32
4.33 - static Logger logger = Logger.getLogger(MathEngine.class.getName());
4.34 + static Logger logger = Logger.getLogger(MathEngine.class.getName());
4.35
4.36 - // This is a Singleton Class: A private constructor is needed
4.37 - private MathEngine(String hostName) {
4.38 - logger.debug("MathEngine("+hostName+")");
4.39 - try {
4.40 - //connect to bridge
4.41 - bridgeRMI = (IBridgeRMI) Naming.lookup("//" + hostName + "/BridgeRMI");
4.42 - System.out.println(
4.43 - "MathEngine Constr: connected to Bridge: " + bridgeRMI.toString());
4.44 - if (bridgeRMI == null)
4.45 - System.out.println("Error occured: The Bridge could not be found!");
4.46 - } catch (Exception e) {
4.47 - System.out.println(
4.48 - "Could not connect to Bridge via RMI\n"
4.49 - + "Please make sure that the Bridge is running and connected");
4.50 - e.printStackTrace();
4.51 - }
4.52 - calcTrees = new HashMap();
4.53 - }
4.54 + // This is a Singleton Class: A private constructor is needed
4.55 + private MathEngine(String hostName) {
4.56 + logger.debug("MathEngine(" + hostName + ")");
4.57 + try {
4.58 + //connect to bridge
4.59 + bridgeRMI = (IBridgeRMI) Naming.lookup("//" + hostName
4.60 + + "/BridgeRMI");
4.61 + System.out.println("MathEngine Constr: connected to Bridge: "
4.62 + + bridgeRMI.toString());
4.63 + if (bridgeRMI == null)
4.64 + System.out
4.65 + .println("Error occured: The Bridge could not be found!");
4.66 + } catch (Exception e) {
4.67 + System.out
4.68 + .println("Could not connect to Bridge via RMI\n"
4.69 + + "Please make sure that the Bridge is running and connected");
4.70 + e.printStackTrace();
4.71 + }
4.72 + calcTrees = new HashMap();
4.73 + }
4.74
4.75 - /*
4.76 - * FIXME.WN040924 just to make the old bridge continue work
4.77 - **/
4.78 - protected IBridgeRMI getBridgeRMI() {
4.79 - return bridgeRMI;
4.80 - }
4.81 - /**
4.82 - * Initialize the MathEngine
4.83 - * @param hostName: Host name on which the Bridge is running
4.84 - */
4.85 - public static void init(String hostName) {
4.86 - logger.fatal(" DG->BR: init("+hostName+")");
4.87 - if (singleton == null) {
4.88 - singleton = new MathEngine(hostName);
4.89 - }
4.90 - }
4.91 + /*
4.92 + * FIXME.WN040924 just to make the old bridge continue work
4.93 + */
4.94 + protected IBridgeRMI getBridgeRMI() {
4.95 + return bridgeRMI;
4.96 + }
4.97
4.98 - public static MathEngine getMathEngine() {
4.99 - logger.fatal(" DG<>BR: getMathEngine()");
4.100 - return singleton;
4.101 - }
4.102 + /**
4.103 + * Initialize the MathEngine
4.104 + *
4.105 + * @param hostName:
4.106 + * Host name on which the Bridge is running
4.107 + */
4.108 + public static void init(String hostName) {
4.109 + logger.fatal(" DG->BR: init(" + hostName + ")");
4.110 + if (singleton == null) {
4.111 + singleton = new MathEngine(hostName);
4.112 + }
4.113 + }
4.114
4.115 - /**
4.116 - * Start a new calculation
4.117 - * @param f Formalization of the new calculation, from expl
4.118 - * @return CalcHead: empty for startSpecifying
4.119 - * @throws RemoteException WN040924 ???
4.120 - *
4.121 - * int id = calcHead.getCalcTreeID();//WN040922 TODO simplify CalcHead
4.122 - * CalcTree calcTree = (CalcTree) calcTrees.get(new Integer(id));//WN040922 TODO simplify
4.123 - */
4.124 - public CalcTree startCalculation(Formalization f) {
4.125 - logger.fatal(" DG->BR: startCalculation("+f.toSMLString()+")");
4.126 - CalcTree calcTree = null;//WN
4.127 - try {
4.128 - int id = bridgeRMI.startCalculation(f);
4.129 - calcTree = new CalcTree(this, id);
4.130 - calcTrees.put(new Integer(id), calcTree);
4.131 + public static MathEngine getMathEngine() {
4.132 + logger.fatal(" DG<>BR: getMathEngine()");
4.133 + return singleton;
4.134 + }
4.135
4.136 - ICalcIterator hotSpot = calcTree.iterator();
4.137 - calcTree.setHotSpot(hotSpot); //first iterator marks the hotSpot
4.138 - //hotSpot.moveRoot();
4.139 - int i = 111;
4.140 - } catch (RemoteException e) {
4.141 - e.printStackTrace();
4.142 - }
4.143 - logger.fatal(" DG<-BR: startCalculation <- calcTree="+ calcTree);
4.144 - return calcTree;
4.145 - }
4.146 + /**
4.147 + * Start a new calculation
4.148 + *
4.149 + * @param f
4.150 + * Formalization of the new calculation, from expl
4.151 + * @return CalcHead: empty for startSpecifying
4.152 + * @throws RemoteException
4.153 + * WN040924 ???
4.154 + *
4.155 + * int id = calcHead.getCalcTreeID();//WN040922 TODO simplify CalcHead
4.156 + * CalcTree calcTree = (CalcTree) calcTrees.get(new Integer(id));//WN040922
4.157 + * TODO simplify
4.158 + */
4.159 + public CalcTree startCalculation(Formalization f) {
4.160 + logger.fatal(" DG->BR: startCalculation(" + f.toSMLString() + ")");
4.161 + CalcTree calcTree = null;//WN
4.162 + try {
4.163 + int id = bridgeRMI.startCalculation(f);
4.164 + calcTree = new CalcTree(this, id);
4.165 + calcTrees.put(new Integer(id), calcTree);
4.166
4.167 -/*
4.168 - boolean autoCalculate(int id, int scope, int nSteps) throws RemoteException {
4.169 - logger.debug("autoCalculate: id="+id+", scope="+scope+", nSteps="+nSteps);
4.170 - return bridgeRMI.autoCalculate(id, scope, nSteps);
4.171 - }
4.172 -*/
4.173 -
4.174 - /**
4.175 - * @see IToCalc#startSolving(), copied to CalcTree
4.176 - *
4.177 - public void startSolving(CalcHead calcHead) throws Exception {
4.178 - logger.debug("startSolving: calcHead="+calcHead);
4.179 - int id = calcHead.getCalcTreeID();//WN040922 TODO simplify CalcHead
4.180 - CalcTree calcTree = (CalcTree) calcTrees.get(new Integer(id));//WN040922 TODO simplify
4.181 + ICalcIterator hotSpot = calcTree.iterator();
4.182 + calcTree.setHotSpot(hotSpot); //first iterator marks the hotSpot
4.183 + //hotSpot.moveRoot();
4.184 + int i = 111;
4.185 + } catch (RemoteException e) {
4.186 + e.printStackTrace();
4.187 + }
4.188 + logger.fatal(" DG<-BR: startCalculation <- calcTree=" + calcTree);
4.189 + return calcTree;
4.190 + }
4.191
4.192 - if (calcHead.getCalcHeadStatus() != CalcHead.CALCHEAD_CORRECT) {
4.193 - throw new Exception("Startsolving with incorrect CalcHead");
4.194 - }
4.195 - Tactic t = calcTree.fetchProposedTactic();
4.196 - if (t.getName().compareTo("Apply_Method") != 0) {
4.197 - throw new Exception("Startsolving fetches " + t.getName());
4.198 - }
4.199 - //Next Tactic must always be Apply_Method
4.200 - calcTree.setNextTactic(t);
4.201 - //return calcTree;
4.202 - }
4.203 - **/
4.204 -
4.205 - /**
4.206 - * @see IToCalc
4.207 - public void modifyCalcHead(CalcHead calcHead) {
4.208 - logger.debug("modifyCalcHead: calcHead="+calcHead);
4.209 - CalcHead newCalcHead = null;
4.210 - try {
4.211 - newCalcHead = bridgeRMI.modifyCalcHead(calcHead);
4.212 - calcHead.fillValuesfrom(newCalcHead);
4.213 - } catch (RemoteException e) {
4.214 - e.printStackTrace();
4.215 - }
4.216 - }
4.217 - */
4.218 -
4.219 - /*
4.220 - * @see IToCalc
4.221 - public void completeCalcHead(CalcHead calcHead) {
4.222 - logger.debug("completeCalcHead: calcHead="+calcHead);
4.223 - CalcHead newCalcHead = null;
4.224 - try {
4.225 - //WN040924 newCalcHead = bridgeRMI.completeCalcHead(calcHead);
4.226 - bridgeRMI.completeCalcHead(calcHead);
4.227 - //WN040924 calcHead.fillValuesfrom(newCalcHead);
4.228 - } catch (RemoteException e) {
4.229 - e.printStackTrace();
4.230 - }
4.231 - }
4.232 - */
4.233 -
4.234 - /*
4.235 - * @see IToCalc
4.236 - public void completeCalcHead(CalcHead calcHead, int completeItem) {
4.237 - CalcHead newCalcHead;
4.238 - try {
4.239 - //WN040924 newCalcHead = bridgeRMI.completeCalcHead(calcHead, completeItem);
4.240 - bridgeRMI.completeCalcHead(calcHead, completeItem);
4.241 - //WN040924 calcHead.fillValuesfrom(newCalcHead);
4.242 - //TODO: Remove the following line!!
4.243 - calcHead.setCalcHeadStatus(CalcHead.CALCHEAD_CORRECT);
4.244 + /*
4.245 + * boolean autoCalculate(int id, int scope, int nSteps) throws
4.246 + * RemoteException { logger.debug("autoCalculate: id="+id+",
4.247 + * scope="+scope+", nSteps="+nSteps); return bridgeRMI.autoCalculate(id,
4.248 + * scope, nSteps); }
4.249 + */
4.250
4.251 - } catch (RemoteException e) {
4.252 - e.printStackTrace();
4.253 - }
4.254 - }
4.255 - */
4.256 + /**
4.257 + * @see IToCalc#startSolving(), copied to CalcTree
4.258 + *
4.259 + * public void startSolving(CalcHead calcHead) throws Exception {
4.260 + * logger.debug("startSolving: calcHead="+calcHead); int id =
4.261 + * calcHead.getCalcTreeID();//WN040922 TODO simplify CalcHead CalcTree
4.262 + * calcTree = (CalcTree) calcTrees.get(new Integer(id));//WN040922 TODO
4.263 + * simplify
4.264 + *
4.265 + * if (calcHead.getCalcHeadStatus() != CalcHead.CALCHEAD_CORRECT) { throw
4.266 + * new Exception("Startsolving with incorrect CalcHead"); } Tactic t =
4.267 + * calcTree.fetchProposedTactic(); if (t.getName().compareTo("Apply_Method") !=
4.268 + * 0) { throw new Exception("Startsolving fetches " + t.getName()); } //Next
4.269 + * Tactic must always be Apply_Method calcTree.setNextTactic(t); //return
4.270 + * calcTree; }
4.271 + */
4.272
4.273 - /**
4.274 - * Refine a given problem for this CalcTree
4.275 - * @param problemID
4.276 - * @return CalcHead, if the operation was successful, else null
4.277 - */
4.278 - public void tryRefine(CalcHead calcHead, CalcHeadCompoundID problemID)
4.279 - throws NotInSpecificationPhaseException {
4.280 - CalcHead newCalcHead = null;
4.281 - try {
4.282 - //WN040924 newCalcHead = bridgeRMI.tryRefine(calcHead.getCalcTreeID(), problemID);
4.283 - bridgeRMI.tryRefine(calcHead.getCalcTreeID(), problemID);
4.284 - if (newCalcHead == null) {
4.285 - throw new NotInSpecificationPhaseException();
4.286 - }
4.287 - calcHead.fillValuesfrom(newCalcHead);
4.288 - } catch (RemoteException e) {
4.289 - // TODO Auto-generated catch block
4.290 - e.printStackTrace();
4.291 - }
4.292 - }
4.293 + /**
4.294 + * @see IToCalc public void modifyCalcHead(CalcHead calcHead) {
4.295 + * logger.debug("modifyCalcHead: calcHead="+calcHead); CalcHead
4.296 + * newCalcHead = null; try { newCalcHead =
4.297 + * bridgeRMI.modifyCalcHead(calcHead);
4.298 + * calcHead.fillValuesfrom(newCalcHead); } catch (RemoteException e) {
4.299 + * e.printStackTrace(); } }
4.300 + */
4.301
4.302 - /**
4.303 - * Match a given problem for this CalcTree
4.304 - * @param problemID
4.305 - * @return CalcHead, if the operation was successful, else null
4.306 - */
4.307 - public void tryMatch(CalcHead calcHead, CalcHeadCompoundID problemID)
4.308 - throws NotInSpecificationPhaseException {
4.309 - CalcHead newCalcHead = null;
4.310 - try {
4.311 - //WN040924 newCalcHead = bridgeRMI.tryMatch(calcHead.getCalcTreeID(), problemID);
4.312 - bridgeRMI.tryMatch(calcHead.getCalcTreeID(), problemID);
4.313 - if (newCalcHead == null) {
4.314 - throw new NotInSpecificationPhaseException();
4.315 - }
4.316 - calcHead.fillValuesfrom(newCalcHead);
4.317 - } catch (RemoteException e) {
4.318 - // TODO Auto-generated catch block
4.319 - e.printStackTrace();
4.320 - }
4.321 - }
4.322 + /*
4.323 + * @see IToCalc public void completeCalcHead(CalcHead calcHead) {
4.324 + * logger.debug("completeCalcHead: calcHead="+calcHead); CalcHead
4.325 + * newCalcHead = null; try { //WN040924 newCalcHead =
4.326 + * bridgeRMI.completeCalcHead(calcHead);
4.327 + * bridgeRMI.completeCalcHead(calcHead); //WN040924
4.328 + * calcHead.fillValuesfrom(newCalcHead); } catch (RemoteException e) {
4.329 + * e.printStackTrace(); } }
4.330 + */
4.331
4.332 - // Delegated methods from CalcTree/Iterator
4.333 - int setNextTactic(int id, Tactic tactic) throws RemoteException {
4.334 - return bridgeRMI.setNextTactic(id, tactic);
4.335 - }
4.336 + /*
4.337 + * @see IToCalc public void completeCalcHead(CalcHead calcHead, int
4.338 + * completeItem) { CalcHead newCalcHead; try { //WN040924 newCalcHead =
4.339 + * bridgeRMI.completeCalcHead(calcHead, completeItem);
4.340 + * bridgeRMI.completeCalcHead(calcHead, completeItem); //WN040924
4.341 + * calcHead.fillValuesfrom(newCalcHead); //TODO: Remove the following
4.342 + * line!! calcHead.setCalcHeadStatus(CalcHead.CALCHEAD_CORRECT); }
4.343 + * catch (RemoteException e) { e.printStackTrace(); } }
4.344 + */
4.345
4.346 - Tactic fetchProposedTactic(int id) throws RemoteException {
4.347 - return bridgeRMI.fetchProposedTactic(id);
4.348 - }
4.349 + /**
4.350 + * Refine a given problem for this CalcTree
4.351 + *
4.352 + * @param problemID
4.353 + * @return CalcHead, if the operation was successful, else null
4.354 + */
4.355 + public void tryRefine(CalcHead calcHead, CalcHeadCompoundID problemID)
4.356 + throws NotInSpecificationPhaseException {
4.357 + CalcHead newCalcHead = null;
4.358 + try {
4.359 + //WN040924 newCalcHead =
4.360 + // bridgeRMI.tryRefine(calcHead.getCalcTreeID(), problemID);
4.361 + bridgeRMI.tryRefine(calcHead.getCalcTreeID(), problemID);
4.362 + if (newCalcHead == null) {
4.363 + throw new NotInSpecificationPhaseException();
4.364 + }
4.365 + calcHead.fillValuesfrom(newCalcHead);
4.366 + } catch (RemoteException e) {
4.367 + // TODO Auto-generated catch block
4.368 + e.printStackTrace();
4.369 + }
4.370 + }
4.371
4.372 - Tactic[] fetchAppliableTactics(int id, int scope) throws RemoteException {
4.373 - return bridgeRMI.fetchAppliableTactics(id, scope);
4.374 - }
4.375 + /**
4.376 + * Match a given problem for this CalcTree
4.377 + *
4.378 + * @param problemID
4.379 + * @return CalcHead, if the operation was successful, else null
4.380 + */
4.381 + public void tryMatch(CalcHead calcHead, CalcHeadCompoundID problemID)
4.382 + throws NotInSpecificationPhaseException {
4.383 + CalcHead newCalcHead = null;
4.384 + try {
4.385 + //WN040924 newCalcHead =
4.386 + // bridgeRMI.tryMatch(calcHead.getCalcTreeID(), problemID);
4.387 + bridgeRMI.tryMatch(calcHead.getCalcTreeID(), problemID);
4.388 + if (newCalcHead == null) {
4.389 + throw new NotInSpecificationPhaseException();
4.390 + }
4.391 + calcHead.fillValuesfrom(newCalcHead);
4.392 + } catch (RemoteException e) {
4.393 + // TODO Auto-generated catch block
4.394 + e.printStackTrace();
4.395 + }
4.396 + }
4.397
4.398 - CalcChanged autoCalculate(int id, int scope, int nSteps) throws RemoteException {
4.399 - logger.debug("autoCalculate: id="+id+", scope="+scope+", nSteps="+nSteps);
4.400 - return bridgeRMI.autoCalculate(id, scope, nSteps);
4.401 - }
4.402 + // Delegated methods from CalcTree/Iterator
4.403 + int setNextTactic(int id, Tactic tactic) throws RemoteException {
4.404 + return bridgeRMI.setNextTactic(id, tactic);
4.405 + }
4.406
4.407 - CalcChanged replaceFormula(int id, CalcFormula f) throws RemoteException {
4.408 - return bridgeRMI.replaceFormula(id, f);
4.409 - }
4.410 + Tactic fetchProposedTactic(int id) throws RemoteException {
4.411 + return bridgeRMI.fetchProposedTactic(id);
4.412 + }
4.413
4.414 - CalcChanged appendFormula(int id, CalcFormula f) throws RemoteException {
4.415 - return bridgeRMI.appendFormula(id, f);
4.416 - }
4.417 + Tactic[] fetchAppliableTactics(int id, int scope) throws RemoteException {
4.418 + return bridgeRMI.fetchAppliableTactics(id, scope);
4.419 + }
4.420
4.421 - Position moveActiveFormula(int calcTreeID, Position p) throws RemoteException {
4.422 - return bridgeRMI.moveActiveFormula(calcTreeID, p);
4.423 - }
4.424 + CalcChanged autoCalculate(int id, int scope, int nSteps)
4.425 + throws RemoteException {
4.426 + logger.debug("autoCalculate: id=" + id + ", scope=" + scope
4.427 + + ", nSteps=" + nSteps);
4.428 + return bridgeRMI.autoCalculate(id, scope, nSteps);
4.429 + }
4.430
4.431 - int iterator(int id) throws RemoteException {
4.432 - logger.debug("iterator: id="+id);
4.433 - return bridgeRMI.iterator(id);
4.434 - }
4.435 + CalcChanged replaceFormula(int id, CalcFormula f) throws RemoteException {
4.436 + return bridgeRMI.replaceFormula(id, f);
4.437 + }
4.438
4.439 - Position moveRoot(int calcTreeID, int iteratorID) throws RemoteException {
4.440 - logger.debug("moveRoot: calcTreeID="+calcTreeID+", iteratorID="+iteratorID);
4.441 - return bridgeRMI.moveRoot(calcTreeID, iteratorID);
4.442 - }
4.443 + CalcChanged appendFormula(int id, CalcFormula f) throws RemoteException {
4.444 + return bridgeRMI.appendFormula(id, f);
4.445 + }
4.446
4.447 - Position moveUp(int calcTreeID, int iteratorID, Position p) throws RemoteException {
4.448 - return bridgeRMI.moveUp(calcTreeID, iteratorID, p);
4.449 - }
4.450 + Vector getElementsFromTo(int id, ICalcIterator iterator_from,
4.451 + ICalcIterator iterator_to, Integer level,
4.452 + boolean result_includes_tactics) throws RemoteException {
4.453 + return bridgeRMI.getElementsFromTo(id, iterator_from, iterator_to,
4.454 + level, result_includes_tactics);
4.455 + }
4.456
4.457 - Position moveDown(int calcTreeID, int iteratorID, Position p) throws RemoteException {
4.458 - logger.debug("moveDown: calcTreeID="+calcTreeID+", sml_pos_="+p);
4.459 - return bridgeRMI.moveDown(calcTreeID, iteratorID, p);
4.460 - }
4.461 + Position moveActiveFormula(int calcTreeID, Position p)
4.462 + throws RemoteException {
4.463 + return bridgeRMI.moveActiveFormula(calcTreeID, p);
4.464 + }
4.465
4.466 - Position moveLevelUp(int calcTreeID, int iteratorID, Position p) throws RemoteException {
4.467 - return bridgeRMI.moveLevelUp(calcTreeID, iteratorID, p);
4.468 - }
4.469 + int iterator(int id) throws RemoteException {
4.470 + logger.debug("iterator: id=" + id);
4.471 + return bridgeRMI.iterator(id);
4.472 + }
4.473
4.474 - Position moveLevelDown(int calcTreeID, int iteratorID, Position p)
4.475 - throws RemoteException {
4.476 - return bridgeRMI.moveLevelDown(calcTreeID, iteratorID, p);
4.477 -}
4.478 + Position moveRoot(int calcTreeID, int iteratorID) throws RemoteException {
4.479 + logger.debug("moveRoot: calcTreeID=" + calcTreeID + ", iteratorID="
4.480 + + iteratorID);
4.481 + return bridgeRMI.moveRoot(calcTreeID, iteratorID);
4.482 + }
4.483
4.484 - Position moveCalcHead(int calcTreeID, int iteratorID, Position p)
4.485 - throws RemoteException {
4.486 - return bridgeRMI.moveCalcHead(calcTreeID, iteratorID, p);
4.487 -}
4.488 + Position moveUp(int calcTreeID, int iteratorID, Position p)
4.489 + throws RemoteException {
4.490 + return bridgeRMI.moveUp(calcTreeID, iteratorID, p);
4.491 + }
4.492
4.493 -
4.494 - boolean moveTactic(int calcTreeID, int iteratorID) throws RemoteException {
4.495 - return bridgeRMI.moveTactic(calcTreeID, iteratorID);
4.496 - }
4.497 + Position moveDown(int calcTreeID, int iteratorID, Position p)
4.498 + throws RemoteException {
4.499 + logger.debug("moveDown: calcTreeID=" + calcTreeID + ", sml_pos_=" + p);
4.500 + return bridgeRMI.moveDown(calcTreeID, iteratorID, p);
4.501 + }
4.502
4.503 - boolean moveFormula(int calcTreeID, int iteratorID) throws RemoteException {
4.504 - return bridgeRMI.moveFormula(calcTreeID, iteratorID);
4.505 - }
4.506 + Position moveLevelUp(int calcTreeID, int iteratorID, Position p)
4.507 + throws RemoteException {
4.508 + return bridgeRMI.moveLevelUp(calcTreeID, iteratorID, p);
4.509 + }
4.510
4.511 - ICalcElement getElement(int calcTreeID, Position p)
4.512 - throws RemoteException {
4.513 - return bridgeRMI.getElement(calcTreeID, p);
4.514 - }
4.515 + Position moveLevelDown(int calcTreeID, int iteratorID, Position p)
4.516 + throws RemoteException {
4.517 + return bridgeRMI.moveLevelDown(calcTreeID, iteratorID, p);
4.518 + }
4.519
4.520 - /**
4.521 - * Destruct a calcTree: Gives the memory occupied by this calcTree free again.
4.522 - * Call this method when the calcTree is no longer needed. This method is irreversible.
4.523 - * @param calcTreeID id of the calcTree to be destructed
4.524 - */
4.525 - public boolean destruct(int calcTreeID) throws RemoteException {
4.526 - return bridgeRMI.destruct(calcTreeID);
4.527 - }
4.528 + Position moveCalcHead(int calcTreeID, int iteratorID, Position p)
4.529 + throws RemoteException {
4.530 + return bridgeRMI.moveCalcHead(calcTreeID, iteratorID, p);
4.531 + }
4.532
4.533 - /**
4.534 - * Save a calcTree
4.535 - * @param calcTreeID id of the calcTree to be saved
4.536 - * @return a vector containing strings, representing the status of the calcTree
4.537 - */
4.538 - public Vector saveCalcTree(int calcTreeID) {
4.539 - try {
4.540 - return bridgeRMI.saveCalcTree(calcTreeID);
4.541 - } catch (RemoteException e) {
4.542 - e.printStackTrace();
4.543 - }
4.544 - return null;
4.545 - }
4.546 + boolean moveTactic(int calcTreeID, int iteratorID) throws RemoteException {
4.547 + return bridgeRMI.moveTactic(calcTreeID, iteratorID);
4.548 + }
4.549
4.550 - /**
4.551 - * Load a previously stored calcTree
4.552 - * @param v Vector: the return value of saveCalcTree
4.553 - * @return a calcTree reference
4.554 - */
4.555 - public CalcTree loadCalcTree(Vector v) {
4.556 - try {
4.557 - int id = bridgeRMI.loadCalcTree(v);
4.558 - CalcTree calcTree = new CalcTree(this, id);
4.559 - calcTrees.put(new Integer(id), calcTree);
4.560 - ICalcIterator hotSpot = calcTree.iterator();
4.561 - // may be not first iterator (not hotspot)
4.562 - ((CalcIterator) hotSpot).makeHotSpot();
4.563 - // make sure it is a hotspot iterator
4.564 - calcTree.setHotSpot(hotSpot);
4.565 - hotSpot.moveRoot();
4.566 - return calcTree;
4.567 - } catch (RemoteException e) {
4.568 - e.printStackTrace();
4.569 - }
4.570 - return null;
4.571 - }
4.572 -}
4.573 + boolean moveFormula(int calcTreeID, int iteratorID) throws RemoteException {
4.574 + return bridgeRMI.moveFormula(calcTreeID, iteratorID);
4.575 + }
4.576 +
4.577 + ICalcElement getElement(int calcTreeID, Position p) throws RemoteException {
4.578 + return bridgeRMI.getElement(calcTreeID, p);
4.579 + }
4.580 +
4.581 + /**
4.582 + * Destruct a calcTree: Gives the memory occupied by this calcTree free
4.583 + * again. Call this method when the calcTree is no longer needed. This
4.584 + * method is irreversible.
4.585 + *
4.586 + * @param calcTreeID
4.587 + * id of the calcTree to be destructed
4.588 + */
4.589 + public boolean destruct(int calcTreeID) throws RemoteException {
4.590 + return bridgeRMI.destruct(calcTreeID);
4.591 + }
4.592 +
4.593 + /**
4.594 + * Save a calcTree
4.595 + *
4.596 + * @param calcTreeID
4.597 + * id of the calcTree to be saved
4.598 + * @return a vector containing strings, representing the status of the
4.599 + * calcTree
4.600 + */
4.601 + public Vector saveCalcTree(int calcTreeID) {
4.602 + try {
4.603 + return bridgeRMI.saveCalcTree(calcTreeID);
4.604 + } catch (RemoteException e) {
4.605 + e.printStackTrace();
4.606 + }
4.607 + return null;
4.608 + }
4.609 +
4.610 + /**
4.611 + * Load a previously stored calcTree
4.612 + *
4.613 + * @param v
4.614 + * Vector: the return value of saveCalcTree
4.615 + * @return a calcTree reference
4.616 + */
4.617 + public CalcTree loadCalcTree(Vector v) {
4.618 + try {
4.619 + int id = bridgeRMI.loadCalcTree(v);
4.620 + CalcTree calcTree = new CalcTree(this, id);
4.621 + calcTrees.put(new Integer(id), calcTree);
4.622 + ICalcIterator hotSpot = calcTree.iterator();
4.623 + // may be not first iterator (not hotspot)
4.624 + ((CalcIterator) hotSpot).makeHotSpot();
4.625 + // make sure it is a hotspot iterator
4.626 + calcTree.setHotSpot(hotSpot);
4.627 + hotSpot.moveRoot();
4.628 + return calcTree;
4.629 + } catch (RemoteException e) {
4.630 + e.printStackTrace();
4.631 + }
4.632 + return null;
4.633 + }
4.634 +}
4.635 \ No newline at end of file
5.1 --- a/src/java/isac/util/interfaces/IToCalc.java Sat Feb 05 15:04:29 2005 +0100
5.2 +++ b/src/java/isac/util/interfaces/IToCalc.java Sat Feb 05 15:46:11 2005 +0100
5.3 @@ -120,7 +120,7 @@
5.4 /**
5.5 * requests the intermediate steps leading to the activeFormula
5.6 *
5.7 - * @return int + calcChangedEvent 05.01. or Vector on success, ?? on error
5.8 + * @return Vector of Formulae and CalcHeads
5.9 */
5.10 public int intermediateSteps() throws RemoteException;
5.11
5.12 @@ -245,8 +245,8 @@
5.13 public int autoCalculate(int scope, int nSteps) throws RemoteException;
5.14
5.15 /**
5.16 - * get the elements of the calcTree between the two iterators (including the
5.17 - * elements the two iterators a pointing to)
5.18 + * get the Formulae and CalcHeads of the calcTree between the two iterators
5.19 + * (including the elements the two iterators a pointing to)
5.20 *
5.21 * @param iterator_from
5.22 * The iterator pointing to the element immediately before of the
5.23 @@ -262,7 +262,7 @@
5.24 * @param result_includes_tactics
5.25 * true if the result should include the tactics, false otherwise
5.26 *
5.27 - * @return an Vector containing the elements of the clacTree
5.28 + * @return an Vector containing the Formulae and CalcHeads of the calcTree
5.29 * @author Alois Kirchsteiger 12.01.2005 16:51:43
5.30 */
5.31 public Vector getElementsFromTo(ICalcIterator iterator_from,