isac-java/src/java/isac/bridge/BridgeRMI.java
author Walther Neuper <wneuper@ist.tugraz.at>
Tue, 18 Aug 2015 14:04:32 +0200
changeset 4787 7eecd797ed85
parent 4785 59515e5b7fa0
child 4790 044ed538a999
permissions -rw-r--r--
PIDE-phase 2c: CONTINUED with 3 IsaToJava + repair xml_.._Formula

Note: this changeset should have separated adding to IsaToJava
from (partial?) repair of Formula.
wneuper@2707
     1
/**
rgradisc@988
     2
 * Created on Oct 13, 2003
wneuper@2707
     3
 * @author Richard Gradischnegg RG
rgradisc@988
     4
 */
rgradisc@988
     5
package isac.bridge;
rgradisc@988
     6
wneuper@4753
     7
import isac.bridge.xml.IntCChanged;
wneuper@4751
     8
import isac.bridge.xml.IntFormHead;
wneuper@4750
     9
import isac.bridge.xml.IntFormulas;
wneuper@4750
    10
import isac.bridge.xml.IntIntCompound;
wneuper@4750
    11
import isac.bridge.xml.IntPosition;
wneuper@4769
    12
import isac.bridge.xml.DataTypes;
wneuper@4750
    13
import isac.bridge.xml.IsaToJava;
wneuper@4750
    14
import isac.bridge.xml.JavaToIsa;
wneuper@2750
    15
import isac.interfaces.ICalcElement;
wneuper@2750
    16
import isac.interfaces.ICalcIterator;
wneuper@2750
    17
import isac.interfaces.IToCalc;
rgradisc@1088
    18
import isac.util.Formalization;
rgradisc@1134
    19
import isac.util.ResponseWrapper;
wneuper@2100
    20
import isac.util.formulae.Assumptions;
rgradisc@1311
    21
import isac.util.formulae.CalcHead;
nsimic@3490
    22
import isac.util.formulae.Context;
rkoenig@3592
    23
import isac.util.formulae.ContextMethod;
rkoenig@3592
    24
import isac.util.formulae.ContextProblem;
nsimic@3490
    25
import isac.util.formulae.ContextTheory;
wneuper@3114
    26
import isac.util.formulae.HierarchyKey;
rgradisc@1311
    27
import isac.util.formulae.CalcHeadSimpleID;
wneuper@2051
    28
import isac.util.formulae.CalcFormula;
wneuper@2065
    29
import isac.util.formulae.FormHeadsContainer;
wneuper@2523
    30
import isac.util.formulae.Match;
wneuper@2838
    31
import isac.util.formulae.MethodID;
wneuper@1861
    32
import isac.util.formulae.Position;
wneuper@2524
    33
import isac.util.formulae.ProblemID;
rgradisc@1306
    34
import isac.util.parser.XMLParserDigest;
wneuper@4773
    35
import isac.util.tactics.SimpleTactic;
rgradisc@1311
    36
import isac.util.tactics.Tactic;
rgradisc@1428
    37
import isac.util.tactics.TacticsContainer;
nsimic@3490
    38
import isac.wsdialog.IContextProvider.ContextType;
wneuper@4750
    39
import edu.tum.cs.isabelle.japi.JSystem;
wneuper@4750
    40
import edu.tum.cs.isabelle.japi.Operations;
wneuper@4750
    41
import isabelle.XML;
wneuper@4750
    42
import isabelle.XML.Tree;
wneuper@4750
    43
rgradisc@989
    44
import java.io.BufferedReader;
rgradisc@989
    45
import java.io.IOException;
rgradisc@989
    46
import java.io.InputStreamReader;
rgradisc@989
    47
import java.io.PrintWriter;
wneuper@4750
    48
import java.math.BigInteger;
rgradisc@989
    49
import java.net.MalformedURLException;
rgradisc@1019
    50
import java.net.Socket;
rgradisc@989
    51
import java.net.UnknownHostException;
rgradisc@988
    52
import java.rmi.Naming;
rgradisc@988
    53
import java.rmi.RMISecurityManager;
rgradisc@988
    54
import java.rmi.RemoteException;
rgradisc@989
    55
import java.rmi.registry.LocateRegistry;
rgradisc@988
    56
import java.rmi.server.UnicastRemoteObject;
rgradisc@1196
    57
import java.util.HashMap;
rgradisc@1191
    58
import java.util.Iterator;
rgradisc@1196
    59
import java.util.Map;
rgradisc@1198
    60
import java.util.Set;
rgradisc@1191
    61
import java.util.Vector;
wneuper@4770
    62
wneuper@4767
    63
import scala.math.BigInt;
rgradisc@988
    64
wneuper@3881
    65
import org.apache.log4j.Logger;
wneuper@3881
    66
rgradisc@988
    67
/**
wneuper@2736
    68
 * @author Richard Gradischnegg RG
wneuper@1976
    69
 * 
wneuper@1989
    70
 * WN0422 here seems to be the key for simplifying the whole bridge.* drawbacks
wneuper@1989
    71
 * of the present implementation: # more complicated than necessary #
wneuper@1989
    72
 * JUnitTestCases require BridgeMain running # BridgeLogger cannot be made
wneuper@1989
    73
 * serializable, thus not accessible for writing by JUnitTestCases #
rgradisc@988
    74
 */
rgradisc@988
    75
public class BridgeRMI extends UnicastRemoteObject implements IBridgeRMI {
rgradisc@988
    76
nsimic@3781
    77
    static final long serialVersionUID = -3047706038036289437L;
wneuper@3881
    78
    private static final Logger logger = Logger.getLogger(BridgeRMI.class.getName());
nsimic@3781
    79
nsimic@3781
    80
	private BridgeMain bridge_;
rgradisc@1178
    81
mlang@2448
    82
    private XMLParserDigest xml_parser_digest_;
rgradisc@1178
    83
mlang@2448
    84
    // Socket used to communicate with bridge
mlang@2448
    85
    private Socket socket_ = null;
rgradisc@1178
    86
mlang@2448
    87
    // Writer to write sml requests to the kernel
wneuper@4700
    88
    private PrintWriter out_ = null;
rgradisc@989
    89
mlang@2448
    90
    // Reader to read sml response from kernel
wneuper@4700
    91
    private BufferedReader in_ = null;
rgradisc@1191
    92
mlang@2448
    93
    private String host_;
rgradisc@1196
    94
mlang@2448
    95
    private int rmiid_;
rgradisc@1191
    96
mlang@2448
    97
    /**
mlang@2448
    98
     * Maps the Java calc(Tree)rmiID to the sml calc(Tree)rmiID. A mapping is
mlang@2448
    99
     * nescessary because these ids are not (nescessary) the same: For example
mlang@2448
   100
     * when restoring the kernel, the calcTree rmiID can change because of
mlang@2448
   101
     * already finished CalcTrees no longer existing and their CalcId assigned
mlang@2448
   102
     * to another CalcTree. key: Integer (javaCalcID) value: Integer (smlCalcID)
mlang@2448
   103
     */
mlang@2448
   104
    private Map java_calcid_to_smlcalcid_;
rgradisc@1252
   105
mlang@2448
   106
    /**
mlang@2448
   107
     * This map stores user inputs which have already been answered by the
mlang@2448
   108
     * kernel and the response being sent back to the user. These inputs are
mlang@2448
   109
     * resent to the kernel in the case of a newstart of the kernel. key:
mlang@2448
   110
     * Integer (javaCalcID) value: Vector (containing input strings)
mlang@2448
   111
     */
mlang@2448
   112
    private Map inputs_;
wneuper@4750
   113
	private JSystem connection_to_kernel_;
rgradisc@1252
   114
mlang@2448
   115
    public BridgeRMI(BridgeMain bridge, String host, int port, String dtdPath)
mlang@2448
   116
            throws RemoteException {
wneuper@3881
   117
        if (logger.isDebugEnabled())
wneuper@3881
   118
            logger.debug("BridgeRMI obj.init: bridge=" + bridge + ", host=" + host
wneuper@3881
   119
                + ", port=" + port + ", dtdPath=" + dtdPath);
mlang@2448
   120
        this.host_ = host;
mlang@2448
   121
        this.bridge_ = bridge;
wneuper@4750
   122
        this.connection_to_kernel_ = bridge.getConnectionToKernel();
mlang@2448
   123
        /*
mlang@2448
   124
         * out = bridge.getSmlWriter(); in = bridge.getSmlReader();
mlang@2448
   125
         */
mlang@2448
   126
        in_ = bridge.getSmlReader();
mlang@2448
   127
        try {
mlang@2448
   128
            socket_ = new Socket(host, port);
wneuper@4700
   129
            out_ = new PrintWriter(socket_.getOutputStream(), true);
wneuper@4700
   130
            in_ = new BufferedReader(new InputStreamReader(socket_
mlang@2448
   131
                    .getInputStream()));
mlang@2448
   132
        } catch (UnknownHostException e) {
mlang@2448
   133
            System.out.println("Unknown host: " + host + "\n");
mlang@2448
   134
        } catch (IOException e) {
mlang@2448
   135
            System.out.println("No I/O\n");
mlang@2448
   136
        }
mlang@2448
   137
        rmiBind();
mlang@2448
   138
        xml_parser_digest_ = new XMLParserDigest(dtdPath);
mlang@2448
   139
        //xml_parser_digest_.setValidating(true);
mlang@2448
   140
        //...all XML-data should be tested in
mlang@2448
   141
        //javatest.isac.util.parser.TestXMLParserDigest
mlang@2448
   142
        inputs_ = new HashMap();
mlang@2448
   143
        java_calcid_to_smlcalcid_ = new HashMap();
mlang@2448
   144
    }
rgradisc@1215
   145
mlang@2448
   146
    /**
mlang@2448
   147
     * Buffers input sent to the sml-Kernel (for later possible restart)
mlang@2448
   148
     * 
mlang@2448
   149
     * @param javaCalcID
mlang@2448
   150
     *            calcTree this input belongs to
mlang@2448
   151
     * @param input
mlang@2448
   152
     *            to be buffered
mlang@2448
   153
     */
mlang@2448
   154
    public void bufferInput(int javaCalcID, String input) {
mlang@2448
   155
        Vector v = (Vector) inputs_.get(new Integer(javaCalcID));
mlang@2448
   156
        if (v == null) {
mlang@2448
   157
            v = new Vector();
mlang@2448
   158
            inputs_.put(new Integer(javaCalcID), v);
mlang@2448
   159
        }
mlang@2448
   160
        v.add(input);
mlang@2448
   161
    }
rgradisc@988
   162
mlang@2448
   163
    // '@calcid@' is a placeholder for the CalcID
mlang@2448
   164
    // this method replaces it with a real CalcID
mlang@2448
   165
    private String insertCalcID(int id, String s) {
mlang@2448
   166
        return s.replaceAll("@calcid@", String.valueOf(id));
mlang@2448
   167
    }
rgradisc@988
   168
mlang@2448
   169
    // return smallest integer which is not yet
mlang@2448
   170
    // used as a (java)CalcID
mlang@2448
   171
    private int smallestFreeCalcID() {
mlang@2448
   172
        Set set = java_calcid_to_smlcalcid_.keySet();
mlang@2448
   173
        for (int i = 0; i < set.size(); i++) {
wneuper@2523
   174
            if (!set.contains(new Integer(i))) {
wneuper@2523
   175
                return i;
wneuper@2523
   176
            }
mlang@2448
   177
        }
mlang@2448
   178
        return set.size();
mlang@2448
   179
    }
rgradisc@988
   180
mlang@2448
   181
    /*
mlang@2448
   182
     * Send a sml instruction to the kernel. restore == true, if the instruction
mlang@2448
   183
     * is resent after the kernel crashed
mlang@2448
   184
     */
mlang@2448
   185
    private ResponseWrapper sendToKernel(String smlInstr, boolean restore) {
wneuper@3881
   186
        if (logger.isDebugEnabled())
wneuper@3881
   187
            logger.debug("   BR->KN: sendToKernel(" + smlInstr + ")");
mlang@2448
   188
        ResponseWrapper wrapper = null;
mlang@2448
   189
        //bridge.log(1,"---sendToKernel |
mlang@2448
   190
        //bridge.isRestoring=="+bridge.isRestoring());
mlang@2448
   191
        //bridge.log(1,"---sendToKernel | restoring=="+restore);
mlang@2448
   192
        if (!bridge_.isRestoring() || restore) {
mlang@2448
   193
            String xmlString = "";
rgradisc@1107
   194
mlang@2448
   195
            out_.println(smlInstr);// send the sml Instruction to the sml Kernel
mlang@2448
   196
            try {
mlang@2448
   197
                xmlString = in_.readLine();//read the response from the kernel
wneuper@3881
   198
                if (logger.isInfoEnabled())
wneuper@3881
   199
                    logger.info("   BR<-KN: sendToKernel <- xml= " + xmlString);
mlang@2448
   200
            } catch (IOException e) {
mlang@2448
   201
                bridge_.log(1, "BridgeRMI.interpretSKN: IOException");
mlang@2448
   202
                e.printStackTrace();
mlang@2448
   203
            }
mlang@2448
   204
            //if (!(restore) && bridge.isRestoring()) {
mlang@2448
   205
            //	this.restoreExistingCalcTrees();
mlang@2448
   206
            //}
nsimic@3606
   207
            
nsimic@3606
   208
            bridge_.log( 1, xmlString );
mlang@2448
   209
            wrapper = xml_parser_digest_.parse(xmlString);
mlang@2448
   210
        }
mlang@2448
   211
        return wrapper;
mlang@2448
   212
    }
rgradisc@1016
   213
mlang@2448
   214
    /**
mlang@2448
   215
     * Send an instruction to the SML-Kernel and return the response
mlang@2448
   216
     * 
mlang@2448
   217
     * @param smlInstr
mlang@2448
   218
     *            Instruction
mlang@2448
   219
     * @return response from SML-Kernel
mlang@2448
   220
     */
mlang@2448
   221
    private synchronized ResponseWrapper interpretSML(int javaCalcID,
mlang@2448
   222
            String instr, boolean restore) {
mlang@2448
   223
        int smlCalcID;
nsimic@3236
   224
        
wneuper@4770
   225
        Integer smlCalcInteger = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
nsimic@3236
   226
        if( smlCalcInteger == null ) {
nsimic@3236
   227
        	bridge_.log(1, "smlCalcInteger is null for javaCalcID : " + javaCalcID );
nsimic@3236
   228
        	return null;
nsimic@3236
   229
        }
nsimic@3236
   230
        
nsimic@3236
   231
        smlCalcID = smlCalcInteger.intValue();
mlang@2448
   232
        String smlInstr = insertCalcID(smlCalcID, instr);
mlang@2448
   233
        bridge_.log(1, "JavaCalcID " + javaCalcID + " == SmlCalcID "
mlang@2448
   234
                + smlCalcID);
mlang@2448
   235
        bridge_.log(1, "sent to bridge: " + smlInstr);
kober@4047
   236
        ResponseWrapper wrapper = this.sendToKernel(smlInstr, restore); 
wneuper@2523
   237
        if (!restore)
wneuper@2523
   238
            bufferInput(javaCalcID, smlInstr);
mlang@2448
   239
        return wrapper;
mlang@2448
   240
    }
rgradisc@1586
   241
mlang@2448
   242
    private void rmiBind() {
wneuper@3881
   243
        if (logger.isDebugEnabled())
wneuper@3881
   244
            logger.debug("rmiBind");
mlang@2448
   245
        if (System.getSecurityManager() == null) {
mlang@2448
   246
            System.setSecurityManager(new RMISecurityManager());
mlang@2448
   247
        }
nsimic@3783
   248
        
mlang@2448
   249
        String name = "//" + host_ + "/BridgeRMI";
mlang@2448
   250
        try {
mlang@2448
   251
            System.out.println("try to bind as " + name);
mlang@2448
   252
            Naming.rebind(name, this);
mlang@2448
   253
            System.out.println("Bridge RMI bound to " + name);
mlang@2448
   254
        } catch (java.rmi.ConnectException e) {
nsimic@3782
   255
            System.err.println("failed to contact as " + name + " (creating RMI-Server on localhost: 1099)");
nsimic@3782
   256
            try {
nsimic@3782
   257
                LocateRegistry.createRegistry(1099);
nsimic@3782
   258
            } catch (java.rmi.RemoteException exc2) {
nsimic@3782
   259
                System.err.println("can not create registry: " + exc2.getMessage());
nsimic@3782
   260
                System.exit(1);
nsimic@3782
   261
            }
nsimic@3794
   262
            rmiBind();
mlang@2448
   263
        } catch (RemoteException e) {
nsimic@3783
   264
        	System.err.println("RemoteException");
nsimic@3782
   265
        	System.err.println(e.getMessage());
nsimic@3783
   266
        	System.err.println(e.getCause().getMessage());
nsimic@3783
   267
        	System.err.println(e.getCause().getClass());
nsimic@3782
   268
        	e.printStackTrace();
nsimic@3782
   269
        	System.exit(1);
nsimic@3782
   270
mlang@2448
   271
        } catch (MalformedURLException e) {
nsimic@3782
   272
        	System.err.println(e.getMessage());
nsimic@3782
   273
        	e.printStackTrace();
nsimic@3782
   274
        	System.exit(1);
nsimic@3782
   275
nsimic@3782
   276
        } catch (Exception e) {
nsimic@3783
   277
        	System.err.println("----------- Exception");
nsimic@3783
   278
        	System.err.println(e.getClass().getName());
nsimic@3782
   279
        	System.err.println(e.getMessage());
nsimic@3782
   280
        	e.printStackTrace();
nsimic@3782
   281
        	System.exit(1);
nsimic@3782
   282
        	
mlang@2448
   283
        }
mlang@2448
   284
    }
rgradisc@1016
   285
wneuper@4762
   286
    /**
wneuper@4762
   287
     * Restore a saved calcTree.
wneuper@4762
   288
     * 
wneuper@4762
   289
     * @param v
wneuper@4762
   290
     *            Vector containing strings
wneuper@4762
   291
     * @return Java CalcTreeID (not SML-ID)
wneuper@4762
   292
     */
wneuper@4762
   293
    public int loadCalcTree(Vector v) {
wneuper@4762
   294
        this.bridge_.log(1, "----------------begin loading------------");
wneuper@4762
   295
        int javaCalcID = smallestFreeCalcID();
wneuper@4762
   296
        this.bridge_.log(1, "-----smallest free  = " + javaCalcID);
wneuper@4762
   297
        restoreToSML(javaCalcID, v);
wneuper@4762
   298
        this.bridge_.log(1, "----------------done loading-------------");
wneuper@4762
   299
        return javaCalcID;
wneuper@4762
   300
    }
rgradisc@1133
   301
wneuper@4762
   302
    public int smlCalcIDtoJavaCalcID(int smlID) {
wneuper@4762
   303
        Iterator it = java_calcid_to_smlcalcid_.keySet().iterator();
wneuper@4762
   304
        while (it.hasNext()) {
wneuper@4762
   305
            Object key = it.next();
wneuper@4762
   306
            Integer value = (Integer) java_calcid_to_smlcalcid_.get(key);
wneuper@4762
   307
            if (value.intValue() == smlID) {
wneuper@4762
   308
                return ((Integer) key).intValue();
wneuper@4762
   309
            }
wneuper@4762
   310
        }
wneuper@4762
   311
        return -1;
wneuper@4762
   312
    }
wneuper@4762
   313
wneuper@4762
   314
    public Map getInputs() {
wneuper@4762
   315
        return inputs_;
wneuper@4762
   316
    }
wneuper@4762
   317
wneuper@4762
   318
    public int getRmiID() {
wneuper@4762
   319
        return rmiid_;
wneuper@4762
   320
    }
wneuper@4762
   321
wneuper@4762
   322
    public void setRmiID(int i) {
wneuper@4762
   323
        if (logger.isDebugEnabled())
wneuper@4762
   324
            logger.debug("setRmiID: i=" + i);
wneuper@4762
   325
        rmiid_ = i;
mlang@2448
   326
    }
rgradisc@1586
   327
wneuper@2736
   328
    /**
wneuper@2736
   329
     * causes a CalcChanged event for the first line on the Worksheet
wneuper@2736
   330
     * 
wneuper@2736
   331
     * @param id
wneuper@2736
   332
     *            for the CalcTree (unused)
wneuper@2736
   333
     * @return CalcChanged with Iterators pointing at the root of the CalcTree
wneuper@2736
   334
     */
wneuper@3881
   335
    public CChanged startCalculate(int id) {
wneuper@2736
   336
        Position p = new Position();
wneuper@2736
   337
        p.setKind("Pbl");// toSMLString --> ([],"Pbl")
wneuper@3881
   338
        CChanged cc = new CChanged();
wneuper@2736
   339
        cc.setLastUnchanged(p);
wneuper@2736
   340
        cc.setLastDeleted(p);
wneuper@2736
   341
        cc.setLastGenerated(p);
wneuper@2736
   342
        return cc;
wneuper@2736
   343
    }
wneuper@2736
   344
wneuper@4783
   345
    /**
wneuper@4783
   346
     * Starts the specifying phase: fill the calcTree with the appropriate
wneuper@4783
   347
     * information. Once the calc_head_ is fully specified, the user can begin
wneuper@4783
   348
     * with the actual calculation.
wneuper@4783
   349
     * 
wneuper@4783
   350
     * @param f
wneuper@4783
   351
     *            Formalization for this calculation (empty if user starts a
wneuper@4783
   352
     *            complete new calculation)
wneuper@4783
   353
     * @return javaCalcID
wneuper@4783
   354
     */
wneuper@4783
   355
    public int getCalcTree(Formalization formalization) {
wneuper@4783
   356
    	int return_val;
wneuper@4783
   357
    	int javaCalcID = smallestFreeCalcID();
wneuper@4783
   358
    	this.bridge_.log(1, "-----smallest free javaCalcID = " + javaCalcID);
wneuper@4783
   359
    	int smlCalcID = newCalculation(javaCalcID, 
wneuper@4783
   360
    	  "CalcTree " + formalization.toSMLString() + ";", formalization, false);
wneuper@4783
   361
    	return_val = javaCalcID;
wneuper@4783
   362
        return return_val;
wneuper@4783
   363
    }
wneuper@4783
   364
wneuper@4762
   365
    /***********************************************************************
wneuper@4762
   366
     * Below are all the methods in structure Math_Engine : MATH_ENGINE
wneuper@4762
   367
     * listed in the same order as in the signature.
wneuper@4762
   368
     * The previous order still reflected original development;
wneuper@4762
   369
     * method names reflect the original struggle at the 
wneuper@4762
   370
     * interface Java <--> Isabelle/Isac: different names are made explicit.
wneuper@4762
   371
     */
wneuper@4762
   372
    
wneuper@4762
   373
    /** MATH_ENGINE: val appendFormula : calcID -> cterm' -> XML.tree */
wneuper@4762
   374
    public CEvent appendFormula(int id, CalcFormula f) {
wneuper@4763
   375
    	CEvent return_val = null;
wneuper@4770
   376
    	int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
wneuper@4768
   377
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "appendFormula " + sml_id + " \"" + f.toSMLString() + "\";");
wneuper@4767
   378
wneuper@4769
   379
    	/*PIDE*/XML.Tree TODO = JavaToIsa.append_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), f.getFormula());    	
wneuper@4768
   380
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4764
   381
    	
wneuper@4784
   382
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.APPEND_FORM, TODO);
wneuper@4784
   383
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4764
   384
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4784
   385
        /*---------------------------------------------------------------------------*/
wneuper@4784
   386
        /*---------------------------------------------------------------------------*/
wneuper@4763
   387
    	/*TTY*/ResponseWrapper wrapper = null;
wneuper@4763
   388
    	/*TTY*/wrapper = interpretSML(id, "appendFormula @calcid@ \"" + f.toSMLString() + "\";", false);
wneuper@4763
   389
    	/*TTY*/if (wrapper == null) return null;
wneuper@4763
   390
    	/*TTY*/return_val = (CEvent) wrapper.getResponse();
wneuper@4763
   391
        return return_val;   
wneuper@4762
   392
    }
wneuper@4762
   393
wneuper@4762
   394
    /** MATH_ENGINE: val autoCalculate : calcID -> auto -> XML.tree */
wneuper@4762
   395
    public CEvent autoCalculate(int id, int scope, int steps) {
wneuper@4762
   396
        if (logger.isDebugEnabled())
wneuper@4762
   397
            logger.debug("BridgeRMI#autoCalculate: id=" + id + ", scope" + scope + ", steps" + steps);
wneuper@4762
   398
        ResponseWrapper wrapper = null;
wneuper@4762
   399
    	CEvent return_val = null;
wneuper@4770
   400
    	int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
wneuper@4762
   401
    	String log_str;
wneuper@4762
   402
        //-----------------------------------------------------------------------------
wneuper@4769
   403
    	/*PIDE*/String scope_str;
wneuper@4769
   404
    	/*PIDE*/if ((scope == 3) && (steps == 0)) { //scope ==3 means IToCalc.SCOPE_CALCHEAD:
wneuper@4769
   405
    	/*PIDE*/	scope_str = "CompleteCalcHead"; //FIXXXME.WN040624 steps == 0 hides mismatch in specifications
wneuper@4769
   406
    	/*PIDE*/} else if ((scope == IToCalc.SCOPE_CALCULATION) && (steps == 0)) {
wneuper@4769
   407
    	/*PIDE*/	scope_str = "CompleteCalc";
wneuper@4769
   408
    	/*PIDE*/} else if ((scope == IToCalc.SCOPE_MODEL) && (steps == 0)) {
wneuper@4769
   409
    	/*PIDE*/	scope_str = "CompleteModel";
wneuper@4769
   410
    	/*PIDE*/} else if ((scope == IToCalc.SCOPE_SUBCALCULATION) && (steps == 0)) {
wneuper@4769
   411
    	/*PIDE*/	scope_str = "CompleteToSubpbl";
wneuper@4769
   412
    	/*PIDE*/} else if ((scope == IToCalc.SCOPE_SUBPROBLEM) && (steps == 0)) {
wneuper@4769
   413
    	/*PIDE*/	scope_str = "CompleteSubpbl";
wneuper@4769
   414
    	/*PIDE*/} else { //FIXXXME040624: steps do not regard the scope
wneuper@4769
   415
    	/*PIDE*/	scope_str = "Step"; // steps > 0 according to impl.in "isabelle tty"
wneuper@4769
   416
    	/*PIDE*/}
wneuper@4769
   417
    	/*PIDE*/if (steps == 0) log_str = scope_str; else log_str = "(Step " + steps + ")";
wneuper@4769
   418
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "autoCalculate " + sml_id + " " + log_str + ";");
wneuper@4769
   419
    	
wneuper@4773
   420
    	/*PIDE*/XML.Tree TODO = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
wneuper@4781
   421
    	/*PIDE*/  scope_str, new scala.math.BigInt(BigInteger.valueOf(steps)));
wneuper@4769
   422
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   423
wneuper@4784
   424
wneuper@4784
   425
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.AUTO_CALC, TODO);
wneuper@4784
   426
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);    	
wneuper@4769
   427
    	
wneuper@4784
   428
    	//THIS RUN ON TestBridge:
wneuper@4762
   429
    	//*PIDE*/XML.Tree AUTO_CALC_out = connection_to_kernel_.invoke(Operations.AUTO_CALC,
wneuper@4762
   430
    	//*PIDE*/  JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
wneuper@4762
   431
	    //*PIDE*/	scope_str, new scala.math.BigInt(BigInteger.valueOf(steps))));
wneuper@4762
   432
    	//*PIDE*/bridge_.log(1, "<--ISA: " + AUTO_CALC_out);
wneuper@4762
   433
    	//*PIDE*/IntCChanged calcid_cc = IsaToJava.auto_calc_out(AUTO_CALC_out);
wneuper@4762
   434
    	//*PIDE*/int calcid = calcid_cc.getCalcId();
wneuper@4762
   435
    	//*PIDE*/return_val = (CEvent) calcid_cc.getCChanged();
wneuper@4762
   436
        /*---------------------------------------------------------------------------*/
wneuper@4762
   437
        /*---------------------------------------------------------------------------*/
wneuper@4762
   438
    	/*TTY*/if ((scope == 3) && (steps == 0)) { //scope ==3 means IToCalc.SCOPE_CALCHEAD:
wneuper@4762
   439
    	/*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteCalcHead;", false);
wneuper@4762
   440
    	/*TTY*/} else if ((scope == IToCalc.SCOPE_CALCULATION) && (steps == 0)) {
wneuper@4762
   441
    	/*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteCalc;", false);
wneuper@4762
   442
        /*TTY*/} else if ((scope == IToCalc.SCOPE_MODEL) && (steps == 0)) {
wneuper@4762
   443
        /*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteModel;", false);
wneuper@4762
   444
        /*TTY*/} else if ((scope == IToCalc.SCOPE_SUBCALCULATION) && (steps == 0)) {
wneuper@4762
   445
        /*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteToSubpbl;", false);
wneuper@4762
   446
        /*TTY*/} else if ((scope == IToCalc.SCOPE_SUBPROBLEM) && (steps == 0)) {
wneuper@4762
   447
        /*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ CompleteSubpbl;", false);
wneuper@4762
   448
        /*TTY*/} else { //FIXXXME040624: steps do not regard the scope
wneuper@4762
   449
        /*TTY*/    wrapper = interpretSML(id, "autoCalculate @calcid@ (Step " + steps + ");", false);
wneuper@4762
   450
        /*TTY*/}
wneuper@4762
   451
        /*TTY*/if (wrapper == null) return_val =  null;
wneuper@4762
   452
        /*TTY*/return_val = (CEvent) wrapper.getResponse();
wneuper@4762
   453
        /*\-------------------------------------------------------------------------/*/
wneuper@4762
   454
        return return_val;
wneuper@4762
   455
    }
wneuper@4762
   456
wneuper@4762
   457
    /** MATH_ENGINE: val applyTactic : calcID -> pos' -> tac -> XML.tree 
wneuper@4763
   458
     * not implemented in Math_Engine.
wneuper@4763
   459
     * compare setNextTactic. */
wneuper@4762
   460
    
wneuper@2838
   461
    /**
wneuper@4762
   462
     * Starts a new calculation in the sml-Kernel: i.e. a new CalcTree with the
wneuper@4762
   463
     * initial hot_spot_
wneuper@4762
   464
     * 
wneuper@4762
   465
     * @param instr
wneuper@4762
   466
     *            "CalcTree" + Formalization in string Representation
wneuper@4762
   467
     * @param fmz 
wneuper@4762
   468
     * @return sml_calcid //WN150817 why return SML(?!) calcid to Java(?!)
wneuper@4762
   469
     * 
wneuper@4762
   470
     * MATH_ENGINE: val CalcTree : fmz list -> XML.tree
mlang@2448
   471
     */
wneuper@4762
   472
    private synchronized int newCalculation(int javaCalcID, String instr,
wneuper@4762
   473
            Formalization fmz, boolean restore) {
wneuper@4762
   474
wneuper@4762
   475
        if (logger.isDebugEnabled())
wneuper@4762
   476
            logger.debug("newCalculation: javaCalcID=" + javaCalcID + ", instr" + instr + ", restore=" + restore);
wneuper@4762
   477
        int sml_calcid;
wneuper@4762
   478
        int return_val;
wneuper@4762
   479
        //----- Mini_Test step 1, 2, 3 -----------------------------------------------\
wneuper@4769
   480
        /*PIDE*/bridge_.log(1, "-->ISA: " + instr);
wneuper@4769
   481
        /*PIDE*/XML.Tree CALC_TREE_out = connection_to_kernel_.invoke(Operations.CALC_TREE,
wneuper@4769
   482
        /*PIDE*/  DataTypes.xml_of_Formalization(fmz));
wneuper@4769
   483
        /*PIDE*/bridge_.log(1, "<--ISA: " + CALC_TREE_out);
wneuper@4769
   484
        /*PIDE*/sml_calcid = (IsaToJava.calc_tree_out(CALC_TREE_out)).intValue();
wneuper@4762
   485
        //----- Mini_Test step 2 WN150808 try to drop this step, see WN041209
wneuper@4769
   486
        /*PIDE*/bridge_.log(1, "-->ISA: " + "Iterator " + sml_calcid + ";");
wneuper@4769
   487
        /*PIDE*/XML.Tree ITERATOR_out = connection_to_kernel_.invoke(Operations.ITERATOR,
wneuper@4769
   488
        /*PIDE*/  new scala.math.BigInt(BigInteger.valueOf(sml_calcid)));
wneuper@4769
   489
        /*PIDE*/IntIntCompound int_int = IsaToJava.iterator_out(ITERATOR_out);
wneuper@4769
   490
        /*PIDE*/sml_calcid = int_int.get_calcid().intValue();
wneuper@4769
   491
        /*PIDE*/int userid = int_int.get_userid().intValue(); //WN150808 ununsed
wneuper@4769
   492
        /*PIDE*/bridge_.log(1, "<--ISA: " + ITERATOR_out);
wneuper@4762
   493
        //----- Mini_Test step 3
wneuper@4769
   494
        /*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveRoot " + sml_calcid + ";");
wneuper@4769
   495
        /*PIDE*/XML.Tree MOVE_ACTIVE_ROOT_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_ROOT,
wneuper@4769
   496
        /*PIDE*/  new scala.math.BigInt(BigInteger.valueOf(sml_calcid)));
wneuper@4769
   497
        /*PIDE*/IntPosition calcid_pos = IsaToJava.move_active_root_out(MOVE_ACTIVE_ROOT_out);
wneuper@4769
   498
        /*PIDE*/return_val = calcid_pos.getCalcId();
wneuper@4769
   499
        /*PIDE*/Position pos = calcid_pos.getPos(); //WN150808 unused
wneuper@4769
   500
        /*PIDE*/bridge_.log(1, "<--ISA: " + MOVE_ACTIVE_ROOT_out);
wneuper@4762
   501
        /*---------------------------------------------------------------------------*/
wneuper@4762
   502
        /*---------------------------------------------------------------------------*/
wneuper@4762
   503
        /*TTY*/bridge_.log(1, "new calculation: " + instr);
wneuper@4762
   504
        /*TTY*/ResponseWrapper wrapper = sendToKernel(instr, restore);
wneuper@4762
   505
        /*TTY*/if (wrapper == null) return -1;
wneuper@4762
   506
        /*TTY*/sml_calcid = wrapper.getCalcID();
wneuper@4762
   507
        /*TTY*/sendToKernel("Iterator " + sml_calcid + ";", restore);//WN041209 no
wneuper@4762
   508
        /*TTY*/sendToKernel("moveActiveRoot " + sml_calcid + ";", restore);//WN041209
wneuper@4762
   509
        /*TTY*/if (!restore) bufferInput(javaCalcID, instr);
wneuper@4762
   510
        /*\-------------------------------------------------------------------------/*/
wneuper@4762
   511
        java_calcid_to_smlcalcid_.put(new Integer(javaCalcID), new Integer(sml_calcid));
wneuper@4762
   512
        return_val = sml_calcid; //WN150808 SML_caldid --> JAVA frontend ?!?
wneuper@4762
   513
        return return_val;
wneuper@4762
   514
    }
wneuper@4762
   515
wneuper@4762
   516
    /** MATH_ENGINE: val checkContext : calcID -> pos' -> guh -> XML.tree */
wneuper@4767
   517
    public Context checkContext(int javaCalcID, Context context, Position pos) throws RemoteException {
wneuper@4763
   518
    	Context return_val = null;
wneuper@4770
   519
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4764
   520
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "checkContext " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
wneuper@4767
   521
wneuper@4769
   522
    	/*PIDE*/XML.Tree TODO = JavaToIsa.check_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
wneuper@4784
   523
    	/*PIDE*/  pos, context.getKEStoreKey().toString() + "\"");
wneuper@4769
   524
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4764
   525
    	
wneuper@4784
   526
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.CHECK_CTXT, TODO);
wneuper@4784
   527
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4764
   528
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   529
    	/*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4763
   530
    	/*TTY*/  "checkContext @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false);
wneuper@4763
   531
    	/*TTY*/if(wrapper == null) return null;
wneuper@4763
   532
    	/*TTY*/return_val = (Context) wrapper.getResponse();
wneuper@4763
   533
        return return_val;
wneuper@4762
   534
    }    
wneuper@4762
   535
    
wneuper@4762
   536
    /** MATH_ENGINE: val DEconstrCalcTree : calcID -> XML.tree */
wneuper@4762
   537
    public boolean destruct(int javaCalcID) {
wneuper@4762
   538
    	boolean return_val;
wneuper@4770
   539
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4769
   540
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "DEconstrCalcTree " + sml_id);
wneuper@4784
   541
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.DEL_CALC,
wneuper@4769
   542
    	/*PIDE*/  new scala.math.BigInt(BigInteger.valueOf(sml_id)));
wneuper@4784
   543
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
   544
    	/*PIDE*/sml_id = IsaToJava.del_calc_out(xml_out).intValue();
wneuper@4769
   545
    	/*PIDE*/return_val = true;
wneuper@4762
   546
    	/*---------------------------------------------------------------------------*/
wneuper@4762
   547
    	/*---------------------------------------------------------------------------*/
wneuper@4762
   548
    	/*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4762
   549
    	/*TTY*/  "DEconstrCalcTree @calcid@;", false);
wneuper@4762
   550
    	/*TTY*/if (wrapper == null) { return_val = false; }
wneuper@4762
   551
    	/*TTY*/inputs_.remove(new Integer(javaCalcID));
wneuper@4762
   552
    	/*TTY*/return_val = true;
wneuper@4762
   553
    	/*\-------------------------------------------------------------------------/*/
wneuper@4762
   554
    	java_calcid_to_smlcalcid_.remove(new Integer(javaCalcID));
wneuper@4762
   555
    	return return_val;
wneuper@4762
   556
    }
wneuper@4762
   557
wneuper@4762
   558
    /** MATH_ENGINE: val fetchApplicableTactics : calcID -> int -> pos' -> XML.tree */
wneuper@4762
   559
    public Vector getAppliableTactics(int id, int scope, Position pos) {
wneuper@4763
   560
    	Vector return_val = null;
wneuper@4770
   561
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
wneuper@4764
   562
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "fetchApplicableTactics " + sml_id + " " + scope + pos.toSMLString() + ";");
wneuper@4764
   563
    	
wneuper@4782
   564
    	/*PIDE*/XML.Tree TODO = JavaToIsa.fetch_applicable_tacs(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
wneuper@4782
   565
    	/*PIDE*/  new scala.math.BigInt(BigInteger.valueOf(scope)), pos);    	
wneuper@4782
   566
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4769
   567
wneuper@4784
   568
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.FETCH_APPL_TACS, TODO);
wneuper@4784
   569
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
   570
wneuper@4764
   571
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   572
    	/*TTY*/ResponseWrapper wrapper = interpretSML(id,
wneuper@4763
   573
        /*TTY*/  "fetchApplicableTactics @calcid@ " + scope + pos.toSMLString() + ";", false);
wneuper@4763
   574
        /*TTY*/if (wrapper == null) return null;
wneuper@4763
   575
        /*TTY*/TacticsContainer tc = (TacticsContainer) wrapper.getResponse();
wneuper@4763
   576
        /*TTY*/if( tc == null ) return null;
wneuper@4763
   577
        /*TTY*/return_val = tc.getTactics();
wneuper@4763
   578
        return return_val;
wneuper@4762
   579
    }
wneuper@4762
   580
wneuper@4762
   581
    /** MATH_ENGINE: val fetchProposedTactic : calcID -> XML.tree */
wneuper@4762
   582
    public Tactic fetchProposedTactic(int id) {
wneuper@4763
   583
    	Tactic return_val = null;
wneuper@4770
   584
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
wneuper@4764
   585
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "fetchProposedTactic " + sml_id + ";");
wneuper@4764
   586
    	
wneuper@4770
   587
    	/*PIDE*/XML.Tree TODO = JavaToIsa.fetch_proposed_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4770
   588
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4770
   589
        //----^^^ delete at end of phase-2a ------------------------------------------------
wneuper@4770
   590
wneuper@4784
   591
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.FETCH_PROP_TAC, TODO);
wneuper@4784
   592
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
   593
wneuper@4764
   594
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   595
    	/*TTY*/ResponseWrapper wrapper = interpretSML(id, "fetchProposedTactic @calcid@;", false);
wneuper@4763
   596
        /*TTY*/if (wrapper == null) { return null; }
wneuper@4763
   597
        /*TTY*/return_val = (Tactic) wrapper.getResponse();
wneuper@4763
   598
        return return_val;
wneuper@4762
   599
    }
wneuper@4762
   600
wneuper@4762
   601
    /** MATH_ENGINE: val findFillpatterns : calcID -> errpatID -> XML.tree 
wneuper@4762
   602
     * only implemented in Math_Engine */
wneuper@4762
   603
    
wneuper@4762
   604
    /**
wneuper@4762
   605
     * @see isac.bridge.IBridgeRMI#getAccumulatedAssumptions(int,
wneuper@4762
   606
     *      isac.util.formulae.Position)
wneuper@4762
   607
     *      
wneuper@4762
   608
     * ** MATH_ENGINE: val getAccumulatedAsms : calcID -> pos' -> XML.tree
wneuper@4762
   609
     */
wneuper@4762
   610
    public Assumptions getAccumulatedAssumptions(int calcTreeID, Position pos) throws RemoteException {
wneuper@4763
   611
    	Assumptions return_val = null;
wneuper@4770
   612
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
wneuper@4764
   613
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "getAccumulatedAsms " + sml_id + " " + pos.toSMLString() + ";");
wneuper@4764
   614
    	
wneuper@4770
   615
    	/*PIDE*/XML.Tree TODO = JavaToIsa.get_accumulated_asms(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);    	
wneuper@4770
   616
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4770
   617
wneuper@4784
   618
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.GET_ACC_ASMS, TODO);
wneuper@4784
   619
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
   620
    	
wneuper@4764
   621
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   622
    	/*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
wneuper@4763
   623
        /*TTY*/  "getAccumulatedAsms @calcid@ " + pos.toSMLString() + ";", false);
wneuper@4763
   624
        /*TTY*/return_val = (Assumptions) wrapper.getResponse();
wneuper@4763
   625
        return return_val;
wneuper@4762
   626
    }
wneuper@4762
   627
    
wneuper@4762
   628
    /** MATH_ENGINE: val getActiveFormula : calcID -> XML.tree */
wneuper@4762
   629
    public Position getActiveFormula(int javaCalcID) {
wneuper@4763
   630
    	Position return_val = null;
wneuper@4770
   631
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4764
   632
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "getActiveFormula " + sml_id + " ;");
wneuper@4764
   633
    	
wneuper@4773
   634
    	/*PIDE*/XML.Tree TODO = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));
wneuper@4770
   635
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   636
wneuper@4784
   637
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.GET_ACTIVE_FORM, TODO);
wneuper@4784
   638
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
   639
wneuper@4764
   640
    	//*PIDE*/bridge_.log(1, "<--ISA: " + TODOTODOTODOTODO);    	
wneuper@4764
   641
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   642
    	/*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4763
   643
    	/*TTY*/  "getActiveFormula @calcid@ ;", false);
wneuper@4763
   644
    	/*TTY*/return_val = moveSuccess(wrapper);
wneuper@4763
   645
        return return_val;
wneuper@2838
   646
    }
rgradisc@1618
   647
wneuper@2543
   648
    /**
wneuper@4762
   649
     * @see isac.bridge.IBridgeRMI#getAssumption(int, int)
wneuper@4762
   650
     * 
wneuper@4762
   651
     * MATH_ENGINE: val getAssumptions : calcID -> pos' -> XML.tree
wneuper@2838
   652
     */
wneuper@4762
   653
    public Assumptions getAssumptions(int calcTreeID, Position pos) throws RemoteException {
wneuper@4763
   654
    	Assumptions return_val = null;
wneuper@4770
   655
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
wneuper@4764
   656
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "getAssumptions " + sml_id + " " + pos.toSMLString() + ";");
wneuper@4764
   657
    	
wneuper@4770
   658
    	/*PIDE*/XML.Tree TODO = JavaToIsa.get_asms(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);    	
wneuper@4770
   659
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   660
wneuper@4784
   661
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.GET_ASMS, TODO);
wneuper@4784
   662
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
   663
wneuper@4764
   664
    	//*PIDE*/bridge_.log(1, "<--ISA: " + TODOTODOTODOTODO);    	
wneuper@4764
   665
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   666
    	/*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
wneuper@4763
   667
    	/*TTY*/  "getAssumptions @calcid@ " + pos.toSMLString() + ";", false);
wneuper@4763
   668
    	/*TTY*/return_val = (Assumptions) wrapper.getResponse();
wneuper@4763
   669
        return return_val;
wneuper@4762
   670
    }
wneuper@4762
   671
wneuper@4762
   672
    /** MATH_ENGINE: val getFormulaeFromTo : calcID -> pos' -> pos' -> int -> bool -> XML.tree */
wneuper@4762
   673
    public Vector getFormulaeFromTo(int id, ICalcIterator iterator_from,
wneuper@4762
   674
            ICalcIterator iterator_to, Integer level, boolean result_includes_tactics) {
wneuper@4782
   675
        XML.Tree TODO = null;
wneuper@4782
   676
    	ResponseWrapper wrapper = null;
wneuper@4762
   677
        Vector return_val = null;      
wneuper@4762
   678
        //----- Mini_Test step 4 ------------------------------------------------------
wneuper@4770
   679
        /*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
wneuper@4770
   680
        /*PIDE*/try {
wneuper@4770
   681
        /*PIDE*/  bridge_.log(1, "-->ISA: " + "getFormulaeFromTo " + sml_id + " "
wneuper@4770
   682
        /*PIDE*/    + iterator_from.toSMLString() + " " + iterator_to.toSMLString()
wneuper@4770
   683
		/*PIDE*/    + " " + level + " " + result_includes_tactics + ";");
wneuper@4770
   684
		/*PIDE*/} catch (RemoteException e2) { e2.printStackTrace(); }
wneuper@4770
   685
        
wneuper@4781
   686
        /*PIDE*/try {
wneuper@4782
   687
        /*PIDE*/  TODO = JavaToIsa.get_formulae(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
wneuper@4781
   688
		/*PIDE*/    iterator_from.getPosition(), iterator_to.getPosition(), 
wneuper@4781
   689
		/*PIDE*/    new scala.math.BigInt(BigInteger.valueOf(level)), result_includes_tactics);
wneuper@4781
   690
        /*PIDE*/} catch (RemoteException e1) { e1.printStackTrace(); }
wneuper@4782
   691
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4770
   692
wneuper@4784
   693
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.GET_FORMULAE, TODO);
wneuper@4784
   694
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
   695
wneuper@4784
   696
    	//THIS RUN ON TestBridge:
wneuper@4762
   697
        //*PIDE*/XML.Tree GET_FORMULAE_out = null;
wneuper@4762
   698
        //*PIDE*/try { GET_FORMULAE_out = connection_to_kernel_.invoke(Operations.GET_FORMULAE,
wneuper@4762
   699
        //*PIDE*/  JavaToIsa.get_formulae(new scala.math.BigInt(BigInteger.valueOf(sml_id)),
wneuper@4762
   700
        //*PIDE*/  iterator_from.getPosition(), iterator_to.getPosition(), new scala.math.BigInt(BigInteger.valueOf(level)), result_includes_tactics));
wneuper@4762
   701
        //*PIDE*/} catch (RemoteException e1) { e1.printStackTrace(); }
wneuper@4762
   702
        //*PIDE*/bridge_.log(1, "<--ISA: " + GET_FORMULAE_out);
wneuper@4762
   703
        //*PIDE*/IntFormulas calcid_forms = IsaToJava.get_formulae_out(GET_FORMULAE_out);
wneuper@4762
   704
        //*PIDE*/sml_id = calcid_forms.getCalcId();
wneuper@4762
   705
        //*PIDE*/return_val = calcid_forms.getCalcFormulas();
wneuper@4762
   706
        /*---------------------------------------------------------------------------*/
wneuper@4762
   707
        /*---------------------------------------------------------------------------*/
wneuper@4762
   708
        /*TTY*/try { wrapper = interpretSML(id, "getFormulaeFromTo @calcid@ "
wneuper@4762
   709
        /*TTY*/    + iterator_from.toSMLString() + " " + iterator_to.toSMLString()
wneuper@4762
   710
        /*TTY*/    + " " + level + " " + result_includes_tactics + ";", false);
wneuper@4762
   711
        /*TTY*/} catch (RemoteException e) { e.printStackTrace(); }
wneuper@4762
   712
        /*TTY*/if (wrapper == null) return null;
wneuper@4762
   713
        /*TTY*/FormHeadsContainer con = (FormHeadsContainer) wrapper.getResponse();
wneuper@4762
   714
        /*TTY*/if (con != null) return_val = con.getElements();
wneuper@4762
   715
        /*TTY*/else return_val = null;
wneuper@4762
   716
        /*\-------------------------------------------------------------------------/*/
wneuper@4762
   717
        return return_val;
wneuper@4762
   718
    }
wneuper@4762
   719
wneuper@4762
   720
    /*
wneuper@4762
   721
     * @see isac.bridge.IBridgeRMI#getTactic(int, int)
wneuper@4762
   722
     * 
wneuper@4762
   723
     * MATH_ENGINE: val getTactic : calcID -> pos' -> XML.tree
wneuper@4762
   724
     */
wneuper@4762
   725
    public Tactic getTactic(int calcTreeID, Position pos) throws RemoteException {
wneuper@4763
   726
    	Tactic return_val = null;
wneuper@4770
   727
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
wneuper@4764
   728
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "getTactic " + sml_id + " " + pos.toSMLString() + ";");
wneuper@4764
   729
    	
wneuper@4770
   730
    	/*PIDE*/XML.Tree TODO = JavaToIsa.get_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);    	
wneuper@4770
   731
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   732
wneuper@4784
   733
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.GET_TAC, TODO);
wneuper@4784
   734
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
   735
wneuper@4764
   736
    	//*PIDE*/bridge_.log(1, "<--ISA: " + TODOTODOTODOTODO);    	
wneuper@4764
   737
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   738
    	/*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
wneuper@4763
   739
    	/*TTY*/  "getTactic @calcid@ " + pos.toSMLString() + ";", false);
wneuper@4763
   740
    	/*TTY*/return_val = (Tactic) wrapper.getResponse();
wneuper@4763
   741
        return return_val;
wneuper@4762
   742
    }
wneuper@4762
   743
wneuper@4762
   744
    /** MATH_ENGINE: val initContext : calcID -> ketype -> pos' -> XML.tree */
wneuper@4770
   745
    public Context initContext(int javaCalcID, ContextType type, Position pos) throws RemoteException {
wneuper@4763
   746
    	Context return_val = null;
wneuper@4770
   747
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4764
   748
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "initContext " + sml_id + " " + type.toSMLString() + " " + pos.toSMLString() + ";");
wneuper@4764
   749
    	
wneuper@4770
   750
    	/*PIDE*/XML.Tree TODO = JavaToIsa.init_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)), type, pos);    	
wneuper@4770
   751
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4770
   752
wneuper@4784
   753
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.INIT_CTXT, TODO);
wneuper@4784
   754
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
   755
wneuper@4764
   756
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   757
    	/*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4763
   758
    	/*TTY*/  "initContext @calcid@ " + type.toSMLString() + " " + pos.toSMLString() + ";", false);
wneuper@4763
   759
    	/*TTY*/if(wrapper == null) return null;
wneuper@4763
   760
    	/*TTY*/return_val = (Context) wrapper.getResponse();
wneuper@4763
   761
        return return_val;
wneuper@4762
   762
    }
wneuper@4762
   763
wneuper@4762
   764
    /** MATH_ENGINE: val inputFillFormula: calcID -> string -> XML.tree 
wneuper@4762
   765
     * only implemented in Math_Engine */
wneuper@4762
   766
wneuper@4762
   767
    /** MATH_ENGINE: val interSteps : calcID -> pos' -> XML.tree */
wneuper@4762
   768
    public CEvent intermediateSteps(int id, ICalcIterator ci) {
wneuper@4763
   769
    	CEvent return_val = null;
wneuper@4770
   770
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
wneuper@4770
   771
    	/*PIDE*/XML.Tree TODO = null;
wneuper@4765
   772
    	/*PIDE*/try {
wneuper@4765
   773
    	/*PIDE*/	bridge_.log(1, "-->ISA: " + "interSteps " + sml_id + " " + ci.toSMLString() + ";");
wneuper@4765
   774
    	/*PIDE*/} catch (RemoteException e1) { e1.printStackTrace(); }
wneuper@4765
   775
    	
wneuper@4770
   776
    	/*PIDE*/try {
wneuper@4770
   777
    	/*PIDE*/  TODO = JavaToIsa.inter_steps(new scala.math.BigInt(BigInteger.valueOf(sml_id)), ci.getPosition());
wneuper@4770
   778
    	/*PIDE*/} catch (Exception e1) { e1.printStackTrace();}    	
wneuper@4770
   779
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   780
wneuper@4784
   781
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.INTER_STEPS, TODO);
wneuper@4784
   782
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4765
   783
    	
wneuper@4765
   784
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   785
    	/*TTY*/ResponseWrapper wrapper = null;
wneuper@4763
   786
        /*TTY*/try {
wneuper@4763
   787
        /*TTY*/    wrapper = interpretSML(id, "interSteps @calcid@ " + ci.toSMLString() + ";", false);
wneuper@4763
   788
        /*TTY*/} catch (RemoteException e) { e.printStackTrace(); }
wneuper@4763
   789
        /*TTY*/if (wrapper == null) return null;
wneuper@4763
   790
        /*TTY*/return_val = (CEvent) wrapper.getResponse();
wneuper@4763
   791
        return return_val;
wneuper@4762
   792
    }
wneuper@4762
   793
wneuper@4762
   794
    /** MATH_ENGINE: val Iterator : calcID -> XML.tree */
wneuper@4762
   795
    public int iterator(int id) {
wneuper@4762
   796
        if (logger.isDebugEnabled())
wneuper@4762
   797
          logger.debug("iterator: id=" + id);
wneuper@4763
   798
        int return_val;
wneuper@4770
   799
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
wneuper@4764
   800
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "Iterator " + sml_id + ";");
wneuper@4764
   801
    	
wneuper@4770
   802
    	/*PIDE*/BigInt TODO = new scala.math.BigInt(BigInteger.valueOf(sml_id));    	
wneuper@4770
   803
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4770
   804
wneuper@4784
   805
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.ITERATOR, TODO);
wneuper@4784
   806
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
   807
wneuper@4764
   808
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   809
        /*TTY*/if (id == 1) {
wneuper@4763
   810
        /*TTY*/    ResponseWrapper wrapper = interpretSML(id, "Iterator @calcid@;", false);
wneuper@4763
   811
        /*TTY*/    if (wrapper == null) return_val = -1;
wneuper@4763
   812
        /*TTY*/    else return_val = Integer.parseInt(((CalcHeadSimpleID) wrapper .getResponse()).getID());
wneuper@4763
   813
        /*TTY*/} else return_val = 4711;//TODO.WN041208 drop CalcIterator.iteratorID_
wneuper@4763
   814
        return return_val;
wneuper@4762
   815
    }
wneuper@4762
   816
wneuper@4762
   817
    /**
wneuper@4762
   818
     * @see isac.interfaces.IToCalc#modelProblem()
wneuper@4762
   819
     * 
wneuper@4762
   820
     * MATH_ENGINE: val modelProblem : calcID -> XML.tree
wneuper@4762
   821
     */
wneuper@4762
   822
    public CalcHead modelProblem(int calc_tree_id) throws RemoteException {
wneuper@4763
   823
    	CalcHead return_val = null;
wneuper@4770
   824
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
wneuper@4764
   825
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "modelProblem " + sml_id + ";");
wneuper@4764
   826
    	
wneuper@4770
   827
    	/*PIDE*/BigInt TODO = new scala.math.BigInt(BigInteger.valueOf(sml_id));    	
wneuper@4770
   828
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4770
   829
wneuper@4784
   830
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MODEL_PBL, TODO);
wneuper@4784
   831
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
   832
wneuper@4764
   833
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   834
    	/*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id, "modelProblem @calcid@;", false);
wneuper@4763
   835
    	/*TTY*/return_val = (CalcHead) wrapper.getResponse();
wneuper@4763
   836
        return return_val;
wneuper@2838
   837
    }
wneuper@4770
   838
    
wneuper@2838
   839
    /**
wneuper@2838
   840
     * @see isac.interfaces.IToCalc#checkCalcHead(isac.util.formulae.CalcHead)
wneuper@4762
   841
     * 
wneuper@4762
   842
     * MATH_ENGINE: val modifyCalcHead : calcID -> icalhd -> XML.tree
wneuper@2838
   843
     */
wneuper@4762
   844
    public CalcHead checkCalcHead(int calc_tree_id, CalcHead calchead) throws RemoteException {
wneuper@4763
   845
    	CalcHead return_val = null;
wneuper@4770
   846
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
wneuper@4764
   847
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "modelProblem " + sml_id + ";");
wneuper@4764
   848
    	
wneuper@4781
   849
    	/*PIDE*/XML.Tree TODO = JavaToIsa.modify_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)), calchead);    	
wneuper@4781
   850
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4770
   851
wneuper@4784
   852
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MODIFY_CALCHEAD, TODO);
wneuper@4784
   853
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
   854
wneuper@4764
   855
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   856
    	/*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
wneuper@4763
   857
    	/*TTY*/  "modifyCalcHead @calcid@ " + calchead.toSMLString() + ";", false);
wneuper@4763
   858
    	/*TTY*/return_val = (CalcHead) wrapper.getResponse();
wneuper@4763
   859
        return return_val;
wneuper@4762
   860
    }
wneuper@4762
   861
wneuper@4762
   862
    /** MATH_ENGINE: val moveActiveCalcHead : calcID -> XML.tree */
wneuper@4762
   863
    public Position moveCalcHead(int javaCalcID, int iteratorID, Position p) {
wneuper@4763
   864
    	Position return_val = null;
wneuper@4770
   865
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4784
   866
wneuper@4784
   867
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveCalcHead " + sml_id + "" + ";");    	
wneuper@4770
   868
    	/*PIDE*/XML.Tree TODO = JavaToIsa.move_active_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4770
   869
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   870
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_FORM, TODO);
wneuper@4784
   871
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
   872
    	
wneuper@4764
   873
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveCalcHead " + sml_id + " " + " " + p.toSMLString() + ";");
wneuper@4770
   874
    	/*PIDE*/TODO = JavaToIsa.move_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)), null);    	
wneuper@4770
   875
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   876
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_FORM, TODO);
wneuper@4784
   877
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
   878
wneuper@4764
   879
    	//*PIDE*/bridge_.log(1, "<--ISA: " + TODOTODOTODOTODO);    	
wneuper@4764
   880
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   881
    	/*TTY*/ResponseWrapper wrapper = null;
wneuper@4763
   882
    	/*TTY*/if (iteratorID == 1)
wneuper@4763
   883
    	/*TTY*/  wrapper = interpretSML(javaCalcID, "moveActiveCalcHead @calcid@" + ";", false);
wneuper@4763
   884
    	/*TTY*/else
wneuper@4763
   885
    	/*TTY*/  wrapper = interpretSML(javaCalcID, "moveCalcHead @calcid@ " + " " + p.toSMLString() + ";", false);
wneuper@4763
   886
    	/*TTY*/return_val = moveSuccess(wrapper);
wneuper@4763
   887
        return return_val;
wneuper@4762
   888
    }
wneuper@4762
   889
wneuper@4762
   890
    /** MATH_ENGINE: val moveActiveDown : calcID -> XML.tree */
wneuper@4762
   891
    public Position moveDown(int javaCalcID, int iteratorID, Position p) {
wneuper@4762
   892
        if (logger.isDebugEnabled())
wneuper@4762
   893
            logger.debug("moveDown: javaCalcID=" + javaCalcID + ", sml_pos=" + p.toSMLString());
wneuper@4763
   894
    	Position return_val = null;
wneuper@4770
   895
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4764
   896
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveDown " + sml_id + "" + ";");
wneuper@4770
   897
    	/*PIDE*/XML.Tree TODO = JavaToIsa.move_active_down(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4770
   898
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   899
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_DOWN, TODO);
wneuper@4784
   900
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
   901
wneuper@4764
   902
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveDown " + sml_id + " " + p.toSMLString() + ";");
wneuper@4770
   903
    	/*PIDE*/TODO = JavaToIsa.move_down(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);    	
wneuper@4770
   904
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   905
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_DOWN, TODO);
wneuper@4784
   906
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
   907
wneuper@4764
   908
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   909
    	/*TTY*/ResponseWrapper wrapper = null;
wneuper@4763
   910
    	/*TTY*/if (iteratorID == 1)
wneuper@4763
   911
    	/*TTY*/    wrapper = interpretSML(javaCalcID, "moveActiveDown @calcid@" + ";", false);
wneuper@4763
   912
    	/*TTY*/else
wneuper@4763
   913
    	/*TTY*/    wrapper = interpretSML(javaCalcID, "moveDown @calcid@ " + p.toSMLString() + ";", false);
wneuper@4763
   914
    	/*TTY*/return_val = moveSuccess(wrapper);
wneuper@4763
   915
        return return_val;
wneuper@4762
   916
    }
wneuper@4762
   917
wneuper@4762
   918
    /** 
wneuper@4762
   919
     * returns Position for uniformity with move*; not required elsewhere
wneuper@4762
   920
     * 
wneuper@4762
   921
     * MATH_ENGINE: val moveActiveFormula : calcID -> pos' -> XML.tree 
wneuper@4762
   922
     */
wneuper@4762
   923
    public Position moveActiveFormula(int javaCalcID, Position p) {
wneuper@4762
   924
        if (logger.isDebugEnabled())
wneuper@4762
   925
            logger.debug("moveDown: javaCalcID=" + javaCalcID + ", sml_pos=" + p.toSMLString());
wneuper@4763
   926
    	Position return_val = null;
wneuper@4770
   927
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4764
   928
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveFormula " + sml_id + " " + p.toSMLString() + ";");
wneuper@4764
   929
    	
wneuper@4770
   930
    	/*PIDE*/XML.Tree TODO = JavaToIsa.move_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);    	
wneuper@4770
   931
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4770
   932
wneuper@4784
   933
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_FORM, TODO);
wneuper@4784
   934
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
   935
wneuper@4764
   936
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   937
    	/*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4763
   938
    	/*TTY*/  "moveActiveFormula @calcid@ " + p.toSMLString() + ";", false);
wneuper@4763
   939
    	/*TTY*/return_val = moveSuccess(wrapper);
wneuper@4763
   940
        return return_val;
wneuper@4762
   941
    }
wneuper@4762
   942
wneuper@4762
   943
    /** MATH_ENGINE: val moveActiveLevelDown : calcID -> XML.tree */
wneuper@4762
   944
    public Position moveLevelDown(int javaCalcID, int iteratorID, Position p) {
wneuper@4763
   945
    	Position return_val = null;
wneuper@4770
   946
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4784
   947
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveLevelDown " + sml_id + "" + ";");    	
wneuper@4770
   948
    	/*PIDE*/XML.Tree TODO = JavaToIsa.move_active_levdown(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4770
   949
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   950
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_LEVDN, TODO);
wneuper@4784
   951
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
   952
wneuper@4764
   953
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveLevelDown " + sml_id + " " + " " + p.toSMLString() + ";");
wneuper@4770
   954
    	/*PIDE*/TODO = JavaToIsa.move_levdn(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);    	
wneuper@4770
   955
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   956
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_LEVDN, TODO);
wneuper@4784
   957
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4764
   958
    	
wneuper@4764
   959
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   960
    	/*TTY*/ResponseWrapper wrapper = null;
wneuper@4763
   961
    	/*TTY*/if (iteratorID == 1)
wneuper@4763
   962
    	/*TTY*/    wrapper = interpretSML(javaCalcID, "moveActiveLevelDown @calcid@" + ";", false);
wneuper@4763
   963
    	/*TTY*/else
wneuper@4763
   964
    	/*TTY*/    wrapper = interpretSML(javaCalcID, "moveLevelDown @calcid@ " + " " + p.toSMLString() + ";", false);
wneuper@4763
   965
    	/*TTY*/return_val = moveSuccess(wrapper);
wneuper@4763
   966
        return return_val;
wneuper@4762
   967
    }
wneuper@4762
   968
wneuper@4762
   969
    /** MATH_ENGINE: val moveActiveLevelUp : calcID -> XML.tree */
wneuper@4762
   970
    public Position moveLevelUp(int javaCalcID, int iteratorID, Position p) {
wneuper@4763
   971
    	Position return_val = null;
wneuper@4770
   972
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4764
   973
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveLevelUp " + sml_id + "" + ";");
wneuper@4770
   974
    	/*PIDE*/XML.Tree TODO = JavaToIsa.move_active_levup(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4770
   975
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   976
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_LEVUP, TODO);
wneuper@4784
   977
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
   978
wneuper@4764
   979
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveLevelUp " + sml_id + " " + p.toSMLString() + ";");
wneuper@4770
   980
    	/*PIDE*/TODO = JavaToIsa.move_levup(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);    	
wneuper@4770
   981
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
   982
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_LEVUP, TODO);
wneuper@4784
   983
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
   984
wneuper@4764
   985
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
   986
    	/*TTY*/ResponseWrapper wrapper = null;
wneuper@4763
   987
    	/*TTY*/if (iteratorID == 1)
wneuper@4763
   988
    	/*TTY*/    wrapper = interpretSML(javaCalcID, "moveActiveLevelUp @calcid@" + ";", false);
wneuper@4763
   989
    	/*TTY*/else
wneuper@4763
   990
    	/*TTY*/    wrapper = interpretSML(javaCalcID, "moveLevelUp @calcid@ " + p.toSMLString() + ";", false);
wneuper@4763
   991
    	/*TTY*/return_val = moveSuccess(wrapper);
wneuper@4763
   992
        return return_val;
wneuper@4762
   993
    }
wneuper@4762
   994
wneuper@4762
   995
    /** MATH_ENGINE: val moveActiveRoot : calcID -> XML.tree */
wneuper@4762
   996
    public Position moveRoot(int javaCalcID, int iteratorID) {
wneuper@4762
   997
        if (logger.isDebugEnabled())
wneuper@4762
   998
            logger.debug("moveRoot: javaCalcID=" + javaCalcID);
wneuper@4763
   999
    	Position return_val = null;
wneuper@4770
  1000
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4764
  1001
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveActiveRoot " + sml_id + "" + ";");
wneuper@4784
  1002
    	/*PIDE*/scala.math.BigInt TODO = new scala.math.BigInt(BigInteger.valueOf(sml_id));    	
wneuper@4770
  1003
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1004
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_ROOT, TODO);
wneuper@4784
  1005
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
  1006
wneuper@4764
  1007
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveRoot " + sml_id + " " + ";");
wneuper@4784
  1008
    	/*PIDE*/XML.Tree TODO2 = JavaToIsa.move_root(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4784
  1009
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO2);
wneuper@4784
  1010
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_ROOT, TODO2);
wneuper@4784
  1011
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
  1012
wneuper@4764
  1013
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
  1014
    	/*TTY*/ResponseWrapper wrapper = null;
wneuper@4763
  1015
    	/*TTY*/if (iteratorID == 1)
wneuper@4763
  1016
    	/*TTY*/    wrapper = interpretSML(javaCalcID, "moveActiveRoot @calcid@" + ";", false);
wneuper@4763
  1017
    	/*TTY*/else
wneuper@4763
  1018
    	/*TTY*/    wrapper = interpretSML(javaCalcID, "moveRoot @calcid@ " + ";", false);
wneuper@4763
  1019
    	/*TTY*/return_val = moveSuccess(wrapper);
wneuper@4763
  1020
        return return_val;
wneuper@4762
  1021
    }
wneuper@4762
  1022
wneuper@4762
  1023
    /** MATH_ENGINE: val moveActiveRootTEST : calcID -> XML.tree 
wneuper@4762
  1024
     *  used only internally in Math_Engine */
wneuper@4762
  1025
wneuper@4762
  1026
    /** MATH_ENGINE: val moveActiveUp : calcID -> XML.tree */
wneuper@4762
  1027
    public Position moveUp(int javaCalcID, int iteratorID, Position p) {
wneuper@4763
  1028
    	Position return_val = null;
wneuper@4770
  1029
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4770
  1030
    	/*PIDE*/XML.Tree TODO = JavaToIsa.move_active_up(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4770
  1031
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1032
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.MOVE_ACTIVE_UP, TODO);
wneuper@4784
  1033
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
  1034
wneuper@4764
  1035
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "moveUp " + sml_id + " " + p.toSMLString() + ";");
wneuper@4770
  1036
    	/*PIDE*/TODO = JavaToIsa.move_up(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);    	
wneuper@4770
  1037
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1038
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.MOVE_UP, TODO);
wneuper@4784
  1039
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
  1040
wneuper@4764
  1041
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
  1042
    	/*TTY*/ResponseWrapper wrapper = null;
wneuper@4763
  1043
    	/*TTY*/if (iteratorID == 1)
wneuper@4763
  1044
    	/*TTY*/    wrapper = interpretSML(javaCalcID, "moveActiveUp @calcid@" + ";", false);
wneuper@4763
  1045
    	/*TTY*/else
wneuper@4763
  1046
    	/*TTY*/    wrapper = interpretSML(javaCalcID, "moveUp @calcid@ " + p.toSMLString() + ";", false);
wneuper@4763
  1047
    	/*TTY*/return_val = moveSuccess(wrapper);
wneuper@4763
  1048
        return return_val;
wneuper@4762
  1049
    }
wneuper@4762
  1050
wneuper@4762
  1051
    /** MATH_ENGINE: val moveCalcHead : calcID -> pos' -> XML.tree 
wneuper@4770
  1052
     *  does not exist in isac-java, see val moveActiveCalcHead */
wneuper@4762
  1053
wneuper@4762
  1054
    /** MATH_ENGINE: val moveDown : calcID -> pos' -> XML.tree 
wneuper@4770
  1055
     *  does not exist in isac-java, see val moveActiveDown */
wneuper@4762
  1056
    
wneuper@4762
  1057
    /** MATH_ENGINE: val val moveLevelDown : calcID -> pos' -> XML.tree 
wneuper@4770
  1058
     *  does not exist in isac-java, see val moveActiveLevelDown */
wneuper@4762
  1059
wneuper@4762
  1060
    /** MATH_ENGINE: val moveLevelUp : calcID -> pos' -> XML.tree 
wneuper@4770
  1061
     *  does not exist in isac-java, see val moveActiveLevelUp */
wneuper@4762
  1062
wneuper@4762
  1063
    /** MATH_ENGINE: val moveRoot : calcID -> XML.tree
wneuper@4770
  1064
     *  does not exist in isac-java, see val moveActiveRoot */
wneuper@4762
  1065
    
wneuper@4762
  1066
    /** MATH_ENGINE: val moveUp : calcID -> pos' -> XML.tree
wneuper@4770
  1067
     *  does not exist in isac-java, see val moveActiveUp */
wneuper@4762
  1068
wneuper@4762
  1069
    /**
wneuper@4762
  1070
     * @see isac.bridge.IBridgeRMI#getElement(int, int)
wneuper@4762
  1071
     * MATH_ENGINE: val refFormula : calcID -> pos' -> XML.tree
wneuper@4762
  1072
     */
wneuper@4762
  1073
    public ICalcElement getElement(int javaCalcID, Position p) {
wneuper@4762
  1074
    	ICalcElement return_val = null;
wneuper@4762
  1075
    	//----- Mini_Test step 6, 10 --------------------------------------------------
wneuper@4770
  1076
    	/*PIDE*/int sml_calcid = ((Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID))).intValue();
wneuper@4770
  1077
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*getElement*)refFormula " + sml_calcid
wneuper@4770
  1078
    	/*PIDE*/  + " " + p.toSMLString() + ";");
wneuper@4770
  1079
wneuper@4770
  1080
    	/*PIDE*/XML.Tree TODO = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_calcid)), p);
wneuper@4770
  1081
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4785
  1082
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, TODO);
wneuper@4784
  1083
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
  1084
    	
wneuper@4784
  1085
    	//THIS ALREADY WORKED WITH TestBridge:
wneuper@4762
  1086
    	//*PIDE*/XML.Tree REF_FORMULA_out = connection_to_kernel_.invoke(Operations.REF_FORMULA,
wneuper@4762
  1087
    	//*PIDE*/  JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_calcid)), p));
wneuper@4762
  1088
    	//*PIDE*/bridge_.log(1, "<--ISA: " + REF_FORMULA_out);
wneuper@4762
  1089
    	//*PIDE*/IntFormHead calcid_formhead = IsaToJava.ref_formula_out(REF_FORMULA_out);
wneuper@4762
  1090
    	//*PIDE*/sml_calcid = calcid_formhead.getCalcId();
wneuper@4762
  1091
    	//*PIDE*/return_val = (ICalcElement) calcid_formhead.getFormHead();
wneuper@4762
  1092
    	/*---------------------------------------------------------------------------*/
wneuper@4762
  1093
    	/*---------------------------------------------------------------------------*/
wneuper@4762
  1094
    	/*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4762
  1095
    	/*TTY*/        "(*getElement*)refFormula @calcid@ " + p.toSMLString() + ";", false);
wneuper@4762
  1096
    	/*TTY*/if (wrapper == null) return_val =  null;
wneuper@4762
  1097
    	/*TTY*/return_val =  (ICalcElement) wrapper.getResponse();
wneuper@4762
  1098
    	/*\-------------------------------------------------------------------------/*/
wneuper@4762
  1099
    	return return_val;
wneuper@4762
  1100
    }
wneuper@4770
  1101
    
wneuper@4763
  1102
    /**
wneuper@4763
  1103
     * @see isac.bridge.IBridgeRMI#getFormula(int, int)
wneuper@4763
  1104
     * @deprecated in favour of getElement.
wneuper@4763
  1105
     * ... WN150812: although it is in IBridgeRMI !!
wneuper@4763
  1106
     * 
wneuper@4763
  1107
     * MATH_ENGINE: val refFormula : calcID -> pos' -> XML.tree
wneuper@4763
  1108
     */
wneuper@4763
  1109
    public ICalcElement getFormula(int calcTreeID, Position p) throws RemoteException {
wneuper@4763
  1110
    	ICalcElement return_val = null;
wneuper@4770
  1111
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calcTreeID));
wneuper@4764
  1112
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*getFormula*)refFormula " + sml_id + " " + p.toSMLString() + ";");
wneuper@4784
  1113
wneuper@4774
  1114
    	/*PIDE*/XML.Tree TODO = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), p);
wneuper@4770
  1115
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1116
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, TODO);
wneuper@4784
  1117
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
  1118
wneuper@4764
  1119
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
  1120
    	/*TTY*/ResponseWrapper wrapper = interpretSML(calcTreeID,
wneuper@4763
  1121
    	/*TTY*/  "(*getFormula*)refFormula @calcid@ " + p.toSMLString() + ";", false);
wneuper@4763
  1122
    	/*TTY*/if (wrapper == null) return_val = null;
wneuper@4763
  1123
    	/*TTY*/else return_val = (ICalcElement) wrapper.getResponse();
wneuper@4763
  1124
        return return_val;
wneuper@4763
  1125
    }
wneuper@4762
  1126
wneuper@4762
  1127
    /** MATH_ENGINE: val refineProblem : calcID -> pos' -> guh -> XML.tree */
wneuper@4770
  1128
    public Context refineProblem(int javaCalcID, Context context, Position pos) throws RemoteException {
wneuper@4763
  1129
    	Context return_val = null;
wneuper@4770
  1130
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4764
  1131
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "refineProblem " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
wneuper@4784
  1132
wneuper@4770
  1133
    	/*PIDE*/XML.Tree TODO = JavaToIsa.refine_pbl(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
wneuper@4779
  1134
    	/*PIDE*/  pos, context.getKEStoreKey().toString() + "\"");
wneuper@4770
  1135
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1136
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.REFINE_PBL, TODO);
wneuper@4784
  1137
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
  1138
wneuper@4764
  1139
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
  1140
    	/*TTY*/ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4763
  1141
    	/*TTY*/  "refineProblem @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false); 
wneuper@4763
  1142
    	/*TTY*/if(wrapper == null) return null;
wneuper@4763
  1143
    	/*TTY*/return_val = (Context) wrapper.getResponse();
wneuper@4763
  1144
        return return_val;
wneuper@4762
  1145
    }
wneuper@4762
  1146
    
wneuper@4762
  1147
    /** MATH_ENGINE: val replaceFormula : calcID -> cterm' -> XML.tree */
wneuper@4762
  1148
    public CEvent replaceFormula(int id, CalcFormula f) {
wneuper@4763
  1149
    	CEvent return_val = null;
wneuper@4770
  1150
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
wneuper@4764
  1151
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "replaceFormula " + sml_id + " \"" + f.toSMLString() + "\";");
wneuper@4764
  1152
    	
wneuper@4770
  1153
    	/*PIDE*/XML.Tree TODO = JavaToIsa.replace_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)), f.getFormula());    	
wneuper@4770
  1154
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1155
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.REPLACE_FORM, TODO);
wneuper@4784
  1156
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
  1157
wneuper@4764
  1158
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
  1159
    	/*TTY*/ResponseWrapper wrapper = null;
wneuper@4763
  1160
    	/*TTY*/wrapper = interpretSML(id, "replaceFormula @calcid@ \"" + f.toSMLString() + "\";", false);
wneuper@4763
  1161
    	/*TTY*/if (wrapper == null) return_val = null;
wneuper@4763
  1162
    	/*TTY*/else return_val = (CEvent) wrapper.getResponse();
wneuper@4763
  1163
        return return_val;
wneuper@4762
  1164
    }
wneuper@4762
  1165
wneuper@4762
  1166
    /** MATH_ENGINE: val requestFillformula : calcID -> errpatID * fillpatID -> XML.tree 
wneuper@4762
  1167
     * only implemented in Math_Engine */
wneuper@4762
  1168
wneuper@4762
  1169
    /** MATH_ENGINE: val resetCalcHead : calcID -> XML.tree */
wneuper@4762
  1170
    /**
wneuper@4762
  1171
     * @see isac.interfaces.IToCalc#resetCalcHead()
wneuper@4762
  1172
     */
wneuper@4762
  1173
    public CalcHead resetCalcHead(int calc_tree_id) throws RemoteException {
wneuper@4763
  1174
    	CalcHead return_val = null;
wneuper@4770
  1175
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
wneuper@4764
  1176
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "resetCalcHead " + sml_id + ";");
wneuper@4764
  1177
    	
wneuper@4770
  1178
    	/*PIDE*/XML.Tree TODO = JavaToIsa.reset_calchead(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4770
  1179
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1180
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.RESET_CALCHEAD, TODO);
wneuper@4784
  1181
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
  1182
wneuper@4764
  1183
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
  1184
    	/*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id, "resetCalcHead @calcid@;", false);
wneuper@4763
  1185
    	/*TTY*/return_val = (CalcHead) wrapper.getResponse();
wneuper@4763
  1186
        return return_val;
wneuper@4762
  1187
    }
wneuper@4762
  1188
wneuper@4762
  1189
    /** MATH_ENGINE: val setContext : calcID -> pos' -> guh -> XML.tree */
wneuper@4762
  1190
    public CalcHead setContext(int javaCalcID, ContextProblem context, Position pos ) throws RemoteException {
wneuper@4763
  1191
    	CalcHead return_val = null;
wneuper@4770
  1192
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(javaCalcID));
wneuper@4764
  1193
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "setContext " + sml_id + " " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";");
wneuper@4764
  1194
    	
wneuper@4770
  1195
    	/*PIDE*/XML.Tree TODO = JavaToIsa.set_ctxt(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
wneuper@4784
  1196
    	/*PIDE*/  pos, context.getKEStoreKey().toString() + "\"");
wneuper@4770
  1197
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1198
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.SET_CTXT, TODO);
wneuper@4784
  1199
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
  1200
wneuper@4764
  1201
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
  1202
    	/*TTY*/ResponseWrapper wrapper =  interpretSML(javaCalcID,
wneuper@4763
  1203
    	/*TTY*/  "setContext @calcid@ " + pos.toSMLString() + " \"" + context.getKEStoreKey().toString() + "\";", false);
wneuper@4763
  1204
    	/*TTY*/if(wrapper == null) return_val = null;
wneuper@4763
  1205
    	/*TTY*/else return_val = (CalcHead) wrapper.getResponse();
wneuper@4763
  1206
        return return_val;
wneuper@4762
  1207
    }   
wneuper@4762
  1208
wneuper@4762
  1209
    /**
wneuper@4762
  1210
     * @see isac.interfaces.IToCalc#setMethod()
wneuper@4762
  1211
     * 
wneuper@4762
  1212
     * MATH_ENGINE: val setMethod : calcID -> metID -> XML.tree
wneuper@4762
  1213
     */
wneuper@4762
  1214
    public CalcHead setMethod(int calc_tree_id, MethodID id) throws RemoteException {
wneuper@4763
  1215
    	CalcHead return_val = null;
wneuper@4770
  1216
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
wneuper@4764
  1217
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "setMethod " + sml_id + " " + id.toSMLString() + ";");
wneuper@4764
  1218
    	
wneuper@4780
  1219
    	/*PIDE*/XML.Tree TODO = JavaToIsa.set_met(new scala.math.BigInt(BigInteger.valueOf(sml_id)), id.getID());    	
wneuper@4780
  1220
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1221
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.SET_MET, TODO);
wneuper@4784
  1222
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4770
  1223
wneuper@4764
  1224
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
  1225
    	/*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1226
    	/*TTY*/  "setMethod @calcid@ " + id.toSMLString() + ";", false);
wneuper@4763
  1227
    	/*TTY*/return_val = (CalcHead) wrapper.getResponse();
wneuper@4763
  1228
        return return_val;
wneuper@4762
  1229
    }
wneuper@4762
  1230
wneuper@4762
  1231
    /** MATH_ENGINE: val setNextTactic : calcID -> tac -> XML.tree */
wneuper@4762
  1232
    public int setNextTactic(int id, Tactic tactic) {
wneuper@4763
  1233
    	int return_val;
wneuper@4770
  1234
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(id));
wneuper@4773
  1235
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "setNextTactic " + sml_id + " (" + tactic.toSMLString() + ");");    	
wneuper@4780
  1236
wneuper@4773
  1237
    	/*PIDE*/XML.Tree TODO = JavaToIsa.set_next_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), tactic);    	
wneuper@4773
  1238
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1239
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.SET_NEXT_TAC, TODO);
wneuper@4784
  1240
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4771
  1241
wneuper@4764
  1242
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
  1243
    	/*TTY*/ResponseWrapper wrapper = interpretSML(id, 
wneuper@4763
  1244
    	/*TTY*/  "setNextTactic @calcid@ (" + tactic.toSMLString() + ");", false);
wneuper@4763
  1245
    	/*TTY*/if (wrapper == null) return_val = -1;//WN050223 response ... MESSAGE not parsed
wneuper@4763
  1246
    	/*TTY*/if (wrapper.getResponse() == null) { return_val = 0; //Everything is ok
wneuper@4763
  1247
    	/*TTY*/} else { return_val = -1; } //An Error occcured
wneuper@4763
  1248
        return return_val;
wneuper@4762
  1249
    }
wneuper@4762
  1250
    
wneuper@4762
  1251
    /**
wneuper@4762
  1252
     * @see isac.interfaces.IToCalc#setProblem()
wneuper@4762
  1253
     * 
wneuper@4762
  1254
     * MATH_ENGINE: val setProblem : calcID -> pblID -> XML.tree
wneuper@4762
  1255
     */
wneuper@4762
  1256
    public CalcHead setProblem(int calc_tree_id, ProblemID id) throws RemoteException {
wneuper@4763
  1257
    	CalcHead return_val = null;
wneuper@4770
  1258
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
wneuper@4764
  1259
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "setProblem " + sml_id + " " + id.toSMLString() + ";");
wneuper@4764
  1260
    	
wneuper@4780
  1261
    	/*PIDE*/XML.Tree TODO = JavaToIsa.set_met(new scala.math.BigInt(BigInteger.valueOf(sml_id)), id.getID());    	
wneuper@4780
  1262
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1263
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.SET_PBL, TODO);
wneuper@4784
  1264
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4784
  1265
wneuper@4764
  1266
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4763
  1267
    	/*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1268
    	/*TTY*/  "setProblem @calcid@ " + id.toSMLString() + ";", false);
wneuper@4763
  1269
    	/*TTY*/return_val = (CalcHead) wrapper.getResponse();
wneuper@4763
  1270
        return return_val;
wneuper@2838
  1271
    }
wneuper@2838
  1272
wneuper@2838
  1273
    /**
wneuper@2838
  1274
     * @see isac.interfaces.IToCalc#setTheory()
wneuper@4762
  1275
     * 
wneuper@4762
  1276
     * TODO/WN150812: use implementation in Math_Engine.
wneuper@4762
  1277
     * MATH_ENGINE: val setTheory : calcID -> thyID -> XML.tree
wneuper@2838
  1278
     */
wneuper@2838
  1279
    public CalcHead setTheory(int calc_tree_id, String thy_id)
wneuper@2838
  1280
            throws RemoteException {
wneuper@4763
  1281
    	CalcHead return_val = null;
wneuper@4774
  1282
    	Position pos = null;
wneuper@4763
  1283
        //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
wneuper@4770
  1284
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
wneuper@4784
  1285
wneuper@4774
  1286
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)setNextTactic " + sml_id + " (Specify_Theory \"" + thy_id + "\");");    	
wneuper@4774
  1287
    	/*PIDE*/SimpleTactic tac = new SimpleTactic("Specify_Theory", thy_id + "\"");
wneuper@4774
  1288
    	/*PIDE*/XML.Tree TODO = JavaToIsa.set_next_tac(new scala.math.BigInt(BigInteger.valueOf(sml_id)), tac);    	
wneuper@4774
  1289
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1290
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.SET_NEXT_TAC, TODO);
wneuper@4784
  1291
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4771
  1292
wneuper@4774
  1293
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)autoCalculate " + sml_id + " (Step 1);");   	
wneuper@4771
  1294
        //----vvv delete at end of phase-2a ------------------------------------------------
wneuper@4774
  1295
    	/*PIDE*/TODO = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
wneuper@4774
  1296
    	/*PIDE*/  "Step", new scala.math.BigInt(BigInteger.valueOf(1)));
wneuper@4774
  1297
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1298
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.AUTO_CALC, TODO);
wneuper@4787
  1299
//GOON    	pos = (Position)xml_out;
wneuper@4784
  1300
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4771
  1301
wneuper@4776
  1302
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)getActiveFormula " + sml_id + ";");   	
wneuper@4776
  1303
    	/*PIDE*/TODO = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4776
  1304
    	/*PIDE*/pos = new Position(); //TODO get from get_active_form_out !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
wneuper@4776
  1305
    	/*PIDE*/pos.setKind("DUMMY"); //TODO get from get_active_form_out !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
wneuper@4784
  1306
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.GET_ACTIVE_FORM, TODO);
wneuper@4784
  1307
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4776
  1308
    	
wneuper@4774
  1309
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*setTheory*)refFormula " + sml_id + " " + pos.toSMLString() + ";");
wneuper@4774
  1310
    	/*PIDE*/TODO = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);//^^pos.setKind("DUMMY")
wneuper@4774
  1311
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1312
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, TODO);
wneuper@4784
  1313
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4771
  1314
wneuper@4766
  1315
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4766
  1316
       	/*PIDE*///\---End hack
wneuper@4766
  1317
       	/*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
wneuper@4763
  1318
    	/*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1319
    	/*TTY*/  "(*setTheory*)setNextTactic @calcid@ (Specify_Theory \"" + thy_id + "\");", false);
wneuper@4763
  1320
    	/*TTY*/wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1321
    	/*TTY*/  "(*setTheory*)autoCalculate @calcid@ (Step 1);", false);
wneuper@4763
  1322
    	/*TTY*///drop the CalcChanged returned by autoCalculate
wneuper@4763
  1323
    	/*TTY*/wrapper = interpretSML(calc_tree_id, 
wneuper@4763
  1324
    	/*TTY*/  "(*setTheory*)getActiveFormula @calcid@ ;", false);
wneuper@4774
  1325
    	/*TTY*/pos = moveSuccess(wrapper);
wneuper@4763
  1326
    	/*TTY*/wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1327
    	/*TTY*/  "(*setTheory*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
wneuper@4763
  1328
    	/*TTY*/return_val = (CalcHead) wrapper.getResponse();
wneuper@4763
  1329
        //\---End hack
wneuper@4763
  1330
        return return_val;
wneuper@2838
  1331
    }
wneuper@2838
  1332
wneuper@4762
  1333
    /***********************************************************************
wneuper@4762
  1334
     * Below are methods not contained in MATH_ENGINE, rather
wneuper@4762
  1335
     * they composed from other methods in Math_Engine. 
wneuper@2838
  1336
     */
wneuper@2838
  1337
wneuper@2838
  1338
    /**
wneuper@2838
  1339
     * @see isac.interfaces.IToCalc#completeCalcHead()
wneuper@2838
  1340
     */
wneuper@2838
  1341
    public CalcHead completeCalcHead(int calc_tree_id) {
wneuper@4763
  1342
    	CalcHead return_val = null;
wneuper@4775
  1343
    	Position pos = null;
wneuper@4770
  1344
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
wneuper@4763
  1345
        //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
wneuper@4784
  1346
wneuper@4765
  1347
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)autoCalculate " + sml_id + "CompleteCalcHead;");
wneuper@4775
  1348
    	/*PIDE*/XML.Tree TODO = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
wneuper@4775
  1349
    	/*PIDE*/  "CompleteCalcHead", new scala.math.BigInt(BigInteger.valueOf(0)));
wneuper@4775
  1350
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1351
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.AUTO_CALC, TODO);
wneuper@4784
  1352
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4763
  1353
    	
wneuper@4766
  1354
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)getActiveFormula " + sml_id + ";");
wneuper@4775
  1355
    	/*PIDE*/TODO = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4775
  1356
    	/*PIDE*/pos = new Position(); //TODO get from auto_calculate_out !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
wneuper@4775
  1357
    	/*PIDE*/pos.setKind("DUMMY"); //TODO get from auto_calculate_out !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
wneuper@4775
  1358
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1359
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.GET_ACTIVE_FORM, TODO);
wneuper@4784
  1360
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4766
  1361
    	
wneuper@4775
  1362
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeCalcHead*)refFormula " + sml_id + pos.toSMLString() + ";");
wneuper@4775
  1363
    	/*PIDE*/TODO = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);    	
wneuper@4775
  1364
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1365
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, TODO);
wneuper@4784
  1366
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4766
  1367
    	
wneuper@4766
  1368
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4766
  1369
       	/*PIDE*///\---End hack
wneuper@4766
  1370
       	/*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
wneuper@4763
  1371
    	/*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1372
    	/*TTY*/  "(*completeCalcHead*)autoCalculate @calcid@ CompleteCalcHead;", false);
wneuper@4763
  1373
    	/*TTY*///drop the CalcChanged returned by autoCalculate
wneuper@4763
  1374
    	/*TTY*/wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1375
    	/*TTY*/  "(*completeCalcHead*)getActiveFormula @calcid@ ;", false);
wneuper@4775
  1376
    	/*TTY*/pos = moveSuccess(wrapper);
wneuper@4763
  1377
    	/*TTY*/wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1378
    	/*TTY*/  "(*completeCalcHead*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
wneuper@4763
  1379
    	/*TTY*/return_val = (CalcHead) wrapper.getResponse();
wneuper@4763
  1380
        //\---End hack
wneuper@4763
  1381
        return return_val;
wneuper@2838
  1382
    }
wneuper@2838
  1383
wneuper@2838
  1384
    /**
wneuper@4762
  1385
     * @see isac.interfaces.IToCalc#completeModel() WN050809 push this method
wneuper@4762
  1386
     *      through to the SML-kernel
wneuper@2543
  1387
     */
wneuper@4762
  1388
    public CalcHead completeModel(int calc_tree_id) throws RemoteException {
wneuper@4763
  1389
       	CalcHead return_val = null;
wneuper@4778
  1390
    	Position pos = null;
wneuper@4770
  1391
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
wneuper@4763
  1392
        //---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
wneuper@4784
  1393
wneuper@4765
  1394
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)autoCalculate " + sml_id + " CompleteModel;");
wneuper@4777
  1395
    	/*PIDE*/XML.Tree TODO = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
wneuper@4777
  1396
    	/*PIDE*/  "CompleteModel", new scala.math.BigInt(BigInteger.valueOf(0)));
wneuper@4777
  1397
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1398
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.AUTO_CALC, TODO);
wneuper@4784
  1399
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4763
  1400
    	
wneuper@4766
  1401
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)getActiveFormula " + sml_id + ";");
wneuper@4777
  1402
    	/*PIDE*/TODO = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4777
  1403
    	/*PIDE*/pos = new Position(); //TODO get from auto_calculate_out !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
wneuper@4777
  1404
    	/*PIDE*/pos.setKind("DUMMY"); //TODO get from auto_calculate_out !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
wneuper@4777
  1405
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1406
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.GET_ACTIVE_FORM, TODO);
wneuper@4784
  1407
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4766
  1408
    	
wneuper@4777
  1409
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*completeModel*)refFormula " + sml_id + " " + pos.toSMLString() + ";");
wneuper@4777
  1410
    	/*PIDE*/TODO = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);    	
wneuper@4777
  1411
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1412
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, TODO);
wneuper@4784
  1413
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4766
  1414
    	
wneuper@4766
  1415
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4766
  1416
       	/*PIDE*///\---End hack
wneuper@4766
  1417
       	/*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
wneuper@4763
  1418
       	/*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1419
       	/*TTY*/  "(*completeModel*)autoCalculate @calcid@ CompleteModel;", false);
wneuper@4763
  1420
       	/*TTY*///drop the CalcChanged returned by autoCalculate
wneuper@4763
  1421
       	/*TTY*/wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1422
       	/*TTY*/  "(*completeModel*)getActiveFormula @calcid@ ;", false);
wneuper@4778
  1423
       	/*TTY*/pos = moveSuccess(wrapper);
wneuper@4763
  1424
       	/*TTY*/wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1425
       	/*TTY*/  "(*completeModel*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
wneuper@4763
  1426
    	/*TTY*/return_val = (CalcHead) wrapper.getResponse();
wneuper@4763
  1427
        //\---End hack
wneuper@4763
  1428
        return return_val;
wneuper@4762
  1429
    }
wneuper@4762
  1430
wneuper@4762
  1431
    /**
wneuper@4762
  1432
     * @see isac.interfaces.IToCalc#nextSpecify() WN050809 push this method
wneuper@4762
  1433
     *      through to the SML-kernel.
wneuper@4762
  1434
     */
wneuper@4762
  1435
    public CalcHead nextSpecify(int calc_tree_id) throws RemoteException {
wneuper@4763
  1436
       	CalcHead return_val = null;
wneuper@4778
  1437
    	Position pos = null;
wneuper@4770
  1438
    	/*PIDE*/int sml_id = (Integer) java_calcid_to_smlcalcid_.get(new Integer(calc_tree_id));
wneuper@4766
  1439
       	/*PIDE*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
wneuper@4784
  1440
wneuper@4766
  1441
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)autoCalculate " + sml_id + " (Step 1);");
wneuper@4778
  1442
    	/*PIDE*/XML.Tree TODO = JavaToIsa.auto_calculate(new scala.math.BigInt(BigInteger.valueOf(sml_id)), 
wneuper@4778
  1443
    	/*PIDE*/  "Step", new scala.math.BigInt(BigInteger.valueOf(1)));
wneuper@4778
  1444
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1445
    	/*PIDE*/XML.Tree xml_out = connection_to_kernel_.invoke(Operations.AUTO_CALC, TODO);
wneuper@4784
  1446
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4766
  1447
    	
wneuper@4766
  1448
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)getActiveFormula " + sml_id + ";");
wneuper@4778
  1449
    	/*PIDE*/TODO = JavaToIsa.get_active_form(new scala.math.BigInt(BigInteger.valueOf(sml_id)));    	
wneuper@4778
  1450
    	/*PIDE*/pos = new Position(); //TODO get from get_active_form_out !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
wneuper@4778
  1451
    	/*PIDE*/pos.setKind("DUMMY"); //TODO get from get_active_form_out !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
wneuper@4784
  1452
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.GET_ACTIVE_FORM, TODO);
wneuper@4784
  1453
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4766
  1454
    	
wneuper@4778
  1455
    	/*PIDE*/bridge_.log(1, "-->ISA: " + "(*nextSpecify*)refFormula " + sml_id + pos.toSMLString() + ";");
wneuper@4778
  1456
    	/*PIDE*/TODO = JavaToIsa.ref_formula(new scala.math.BigInt(BigInteger.valueOf(sml_id)), pos);//^^pos.setKind("DUMMY")
wneuper@4778
  1457
    	/*PIDE*/bridge_.log(1, "-->ISA: " + TODO);
wneuper@4784
  1458
    	/*PIDE*/xml_out = connection_to_kernel_.invoke(Operations.REF_FORMULA, TODO);
wneuper@4784
  1459
    	/*PIDE*/bridge_.log(1, "<--ISA: " + xml_out);
wneuper@4766
  1460
    	
wneuper@4766
  1461
    	//*PIDE*/return_val = TODOTODOTODOTODO;
wneuper@4766
  1462
       	/*PIDE*///\---End hack
wneuper@4766
  1463
       	/*TTY*///---FIXXXME.WN050809 hack until setTheory pushed into SML-kernel
wneuper@4763
  1464
       	/*TTY*/ResponseWrapper wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1465
       	/*TTY*/  "(*nextSpecify*)autoCalculate @calcid@ (Step 1);", false);
wneuper@4763
  1466
       	/*TTY*///drop the CalcChanged returned by autoCalculate
wneuper@4763
  1467
       	/*TTY*/wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1468
       	/*TTY*/  "(*nextSpecify*)getActiveFormula @calcid@ ;", false);
wneuper@4778
  1469
       	/*TTY*/pos = moveSuccess(wrapper);
wneuper@4763
  1470
       	/*TTY*/wrapper = interpretSML(calc_tree_id,
wneuper@4763
  1471
       	/*TTY*/  "(*nextSpecify*)refFormula @calcid@ " + pos.toSMLString() + ";", false);
wneuper@4763
  1472
       	/*TTY*/return_val = (CalcHead) wrapper.getResponse();
wneuper@4766
  1473
       	/*TTY*///\---End hack
wneuper@4763
  1474
        return return_val;
mlang@2448
  1475
    }
rgradisc@1065
  1476
wneuper@4762
  1477
    /***********************************************************************
wneuper@4762
  1478
     * Below are methods not implemented in MATH_ENGINE at all,
wneuper@4762
  1479
     * or only very fragmentarily.
wneuper@4762
  1480
     * WN150812 here are also methods, where the status is not clarified. 
wneuper@4762
  1481
     * Some methods seem to be replaced by similar ones.
wneuper@4762
  1482
     * TODO: review IBridgeRMI, MathEngine, etc.
wneuper@4762
  1483
     */
wneuper@4762
  1484
wneuper@4762
  1485
    /**
wneuper@4762
  1486
     * @see isac.interfaces.ICalcIterator#tryMatchMethod(MethodID)
wneuper@4762
  1487
     * @deprecated WN150812: not impl. in Math_Engine.
wneuper@4762
  1488
     */
wneuper@4762
  1489
    public Match initMatchMethod(int javaCalcID) throws RemoteException {
wneuper@4762
  1490
        ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4762
  1491
          "initMatchMethod @calcid@ ;", false);
wneuper@4762
  1492
        Object response = wrapper.getResponse();
wneuper@4762
  1493
        CalcHead ch = (CalcHead) response;
wneuper@4762
  1494
        Match m = new Match(ch.getSpecification().getProblem(), ch
wneuper@4762
  1495
                .getStatusString(), ch.getHeadLine(), ch.getModel());
wneuper@4762
  1496
        return m;
wneuper@4762
  1497
    }
wneuper@4762
  1498
    
wneuper@4762
  1499
    /**
wneuper@4762
  1500
     * @see isac.interfaces.ICalcIterator#tryMatchProblem(HierarchyKey)
wneuper@4762
  1501
     * @deprecated WN150812: not impl. in Math_Engine.
wneuper@4762
  1502
     */
wneuper@4762
  1503
    public Match initMatchProblem(int javaCalcID) {
wneuper@4762
  1504
        ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4762
  1505
          "initMatchProblem @calcid@ ;", false);
wneuper@4762
  1506
        Object response = wrapper.getResponse();
wneuper@4762
  1507
        CalcHead ch = (CalcHead) response;
wneuper@4762
  1508
        Match m = new Match(ch.getSpecification().getProblem(), ch
wneuper@4762
  1509
                .getStatusString(), ch.getHeadLine(), ch.getModel());
wneuper@4762
  1510
        return m;
wneuper@4762
  1511
    }
rgradisc@1252
  1512
wneuper@4762
  1513
    /**
wneuper@4762
  1514
     * @deprecated in favour of getFormula
wneuper@4762
  1515
     * WN150812: but used frequently ?!
wneuper@4762
  1516
     */
wneuper@4762
  1517
    public boolean moveFormula(int javaCalcID, int iteratorID) {
wneuper@4762
  1518
        ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4763
  1519
          "moveFormula @calcid@ " + iteratorID + ";", false);
wneuper@4762
  1520
        return true;//WN041208 moveSuccess(wrapper);
wneuper@4762
  1521
    }
wneuper@4762
  1522
wneuper@4762
  1523
    /** WN150812 unused ? */
mlang@2448
  1524
    private Position moveSuccess(ResponseWrapper wrapper) {
mlang@2448
  1525
        if (wrapper == null)
mlang@2448
  1526
            return null;
mlang@2448
  1527
        else {
mlang@2448
  1528
            Object r = wrapper.getResponse();
wneuper@3881
  1529
            if (r instanceof CMessage)
mlang@2448
  1530
                return null;//TODO.WN041209 handle messages
mlang@2448
  1531
            else {
mlang@2448
  1532
                Position p = (Position) wrapper.getResponse();
mlang@2448
  1533
                return p;
mlang@2448
  1534
            }
mlang@2448
  1535
        }
mlang@2448
  1536
    }
rgradisc@1252
  1537
mlang@2448
  1538
    /**
mlang@2448
  1539
     * @deprecated in favour of getTactic
wneuper@4762
  1540
     * WN150812: but used frequently ?!
mlang@2448
  1541
     */
mlang@2448
  1542
    public boolean moveTactic(int javaCalcID, int iteratorID) {
mlang@2448
  1543
        ResponseWrapper wrapper = interpretSML(javaCalcID,
mlang@2448
  1544
                "moveTactic @calcid@ " + iteratorID + ";", false);
mlang@2448
  1545
        return true;//WN041208 moveSuccess(wrapper);
mlang@2448
  1546
    }
rgradisc@1191
  1547
mlang@2448
  1548
    /**
wneuper@4762
  1549
     * @see isac.interfaces.ICalcIterator#tryMatchMethod(MethodID)
wneuper@4762
  1550
     * @deprecated is not impl. in math-engine !!!
mlang@2448
  1551
     */
wneuper@4762
  1552
    public Match tryMatchMethod(int javaCalcID, MethodID keStoreID)
wneuper@4762
  1553
            throws RemoteException {
mlang@2448
  1554
        ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4762
  1555
                "tryMatchMethod @calcid@ " + keStoreID.toSMLString() + ";",
wneuper@4762
  1556
                false);
wneuper@4762
  1557
        Object response = wrapper.getResponse();
wneuper@4762
  1558
        CalcHead ch = (CalcHead) response;
wneuper@4762
  1559
        Match m = new Match(ch.getSpecification().getProblem(), ch
wneuper@4762
  1560
                .getStatusString(), ch.getHeadLine(), ch.getModel());
wneuper@4762
  1561
        return m;
mlang@2448
  1562
    }
rgradisc@1191
  1563
wneuper@4763
  1564
    /** enforced by IBridgeRMI, WN150812: exp-, met-, pbl-, thy-contexts all work --
wneuper@4763
  1565
     * -- so ContextProblem seems to do ContextMethod and ContextTheory, too */
wneuper@4762
  1566
	@Override
wneuper@4762
  1567
	public CalcHead setContext(int javaCalcID, ContextMethod context, Position pos) throws RemoteException {
wneuper@4762
  1568
		return null;
wneuper@4762
  1569
	}
rgradisc@1196
  1570
wneuper@4763
  1571
    /** enforced by IBridgeRMI, WN150812: exp-, met-, pbl-, thy-contexts all work --
wneuper@4763
  1572
     * -- so ContextProblem seems to do ContextMethod and ContextTheory, too */
wneuper@4762
  1573
	@Override
wneuper@4762
  1574
	public CChanged setContext(int javaCalcID, ContextTheory context, Position pos) throws RemoteException {
wneuper@4762
  1575
		return null;
wneuper@4762
  1576
	}
wneuper@4762
  1577
    
wneuper@4762
  1578
    /**
wneuper@4762
  1579
     * @see isac.interfaces.ICalcIterator#tryMatchProblem(HierarchyKey)
wneuper@4762
  1580
     * 
wneuper@4762
  1581
     * WN150812: tryMatchProblem, trymatch only partially implemented in Math_Engine
wneuper@4762
  1582
     */
wneuper@4762
  1583
    public Match tryMatchProblem(int javaCalcID, ProblemID problemID) {
wneuper@4762
  1584
        ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4762
  1585
                "tryMatchProblem @calcid@ " + problemID.toSMLString() + ";",
wneuper@4762
  1586
                false);
wneuper@4762
  1587
        Object response = wrapper.getResponse();
wneuper@4762
  1588
        CalcHead ch = (CalcHead) response;
wneuper@4762
  1589
        Match m = new Match(ch.getSpecification().getProblem(), ch
wneuper@4762
  1590
                .getStatusString(), ch.getHeadLine(), ch.getModel());
wneuper@4762
  1591
        return m;
mlang@2448
  1592
    }
wneuper@1875
  1593
mlang@2448
  1594
    /**
wneuper@4762
  1595
     * @see isac.interfaces.ICalcIterator#tryRefineProblem(HierarchyKey)
wneuper@4762
  1596
     * @deprecated in favour of refineProblem.
mlang@2448
  1597
     */
wneuper@4762
  1598
    public Match tryRefineProblem(int javaCalcID, ProblemID problemID) {
wneuper@4762
  1599
        ResponseWrapper wrapper = interpretSML(javaCalcID,
wneuper@4762
  1600
                "tryRefineProblem @calcid@ " + problemID.toSMLString() + ";",
wneuper@4762
  1601
                false);
wneuper@4762
  1602
        Object response = wrapper.getResponse();
wneuper@4762
  1603
        CalcHead ch = (CalcHead) response;
wneuper@4762
  1604
        Match m = new Match(ch.getSpecification().getProblem(), ch
wneuper@4762
  1605
                .getStatusString(), ch.getHeadLine(), ch.getModel());
wneuper@4762
  1606
        return m;
mlang@2448
  1607
    }
wneuper@1976
  1608
wneuper@4762
  1609
    /***********************************************************************
wneuper@4762
  1610
     * Below are methods for restoring Isabelle/Isac after a crash.
wneuper@4762
  1611
     * This never worked, is to be deleted and 
wneuper@4762
  1612
     * to be reconsidered with introduction of libisabelle.
mlang@2448
  1613
     */
wneuper@1976
  1614
mlang@2448
  1615
    /**
mlang@2448
  1616
     * This method is used when the kernel crashes and the CalcTrees need to be
mlang@2448
  1617
     * entered again to the kernel to restore the previous state. The
mlang@2448
  1618
     * Java-CalcIDs stay the same
mlang@2448
  1619
     */
mlang@2448
  1620
    public void restoreExistingCalcTrees() {
mlang@2448
  1621
        bridge_.log(1, "---- entering restoreExistingCalcTrees");
mlang@2448
  1622
        Iterator it = java_calcid_to_smlcalcid_.keySet().iterator();
mlang@2448
  1623
        // keySet = javaCalcIDs
mlang@2448
  1624
        int javaCalcID, newSmlCalcID;
mlang@2448
  1625
        Vector v;
mlang@2448
  1626
        while (it.hasNext()) {
mlang@2448
  1627
            //bridge.log(1, "1");
mlang@2448
  1628
            //int i = ((Integer)it.next()).intValue();
mlang@2448
  1629
            javaCalcID = ((Integer) it.next()).intValue();
mlang@2448
  1630
            //bridge.log(1, "2");
mlang@2448
  1631
            v = saveCalcTree(javaCalcID);
mlang@2448
  1632
            //bridge.log(1, "3");
mlang@2448
  1633
            this.restoreToSML(javaCalcID, v);
mlang@2448
  1634
        }
mlang@2448
  1635
        bridge_.log(1, "---- done restoreExistingCalcTrees");
mlang@2448
  1636
    }
wneuper@1976
  1637
wneuper@4762
  1638
    private void restoreToSML(int javaCalcID, Vector v) {
wneuper@4762
  1639
        Iterator it = ((Vector) v.clone()).iterator();
wneuper@4762
  1640
        CalcTree result = null;
wneuper@4762
  1641
        String s = (String) it.next();
wneuper@4762
  1642
        int smlCalcID = newCalculation(javaCalcID, s, null/*never worked*/, true);
wneuper@4762
  1643
        //javaCalcIDtoSmlCalcID.put(new Integer(javaCalcID), new
wneuper@4762
  1644
        // Integer(smlCalcID));
wneuper@4762
  1645
        //int smlID = ((Integer)javaCalcIDtoSmlCalcID.get(new
wneuper@4762
  1646
        // Integer(calcID))).intValue();
wneuper@4762
  1647
        while (it.hasNext()) {
wneuper@4762
  1648
            s = (String) it.next();
wneuper@4762
  1649
            interpretSML(javaCalcID, s, true);
wneuper@4762
  1650
        }
mlang@2448
  1651
    }
wneuper@1976
  1652
mlang@2448
  1653
    /**
wneuper@4762
  1654
     * Save a calcTree for later restoring (probably to another SML Kernel)
wneuper@4762
  1655
     * 
wneuper@4762
  1656
     * @param calcTreeID
wneuper@4762
  1657
     *            the ID of the calcTree
wneuper@4762
  1658
     * @return a vector containing strings. This is representatation of the
wneuper@4762
  1659
     *         status of the calcTree
mlang@2448
  1660
     */
wneuper@4762
  1661
    public Vector saveCalcTree(int calcTreeID) {
wneuper@4762
  1662
        this.bridge_.log(1, "----------------begin saving calcTree "
wneuper@4762
  1663
                + calcTreeID + "------------");
wneuper@4762
  1664
        return (Vector) inputs_.get(new Integer(calcTreeID));
mlang@2448
  1665
    }
wneuper@1976
  1666
nsimic@3490
  1667
    
wneuper@1976
  1668
}