[protege-owl] JessTab, adding Commands to Jess, Protege 3.2 b 318

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[protege-owl] JessTab, adding Commands to Jess, Protege 3.2 b 318

ulrich thye
Hi,

I am trying to use maple http://www.maplesoft.com from
Jess in the JessTab plugin.
I create a simple beta-code for testing but if I execute:

jess> (load-function CallMaple)
or
jess> (load-package ExCallMaple)

the JessTab seems to hang.

If I run this from Jess-Shell it works.


My configuration (for Jess-Shell):
----------------------------------
>MYCLASS=/develop/AA_MY/Jess2Maple/CallMaple
>MAPLE=/opt/maple95
>export MAPLE
>CLASSPATH=$MYCLASS:$MAPLE/java/externalcall.jar:$MAPLE/java/jopenmaple.jar
>export CLASSPATH

>LD_LIBRARY_PATH=$MAPLE/bin.IBM_INTEL_LINUX
>export LD_LIBRARY_PATH

(It's necassary, that LD_LIBRARY_PATH is set correct!)

This works:

jess>(load-package ExCallMaple)
TRUE
jess>(callmaple "sin(2.0);")
.9092974268


For Protege 3.2b318 I have changed the run_protege.sh and added the above
ENV-Variables and installed CallMaple.class and ExCallMaple.class
in plugins/Jess

The Source-Code of CallMaple and ExCallMaple is listed below.



Thanks,
with best regards

Ulrich


==================================
The code:
(BTW: I have not much experience in java ;-( )

>cat ExCallMaple.java:
-------------------------------
import jess.*;

public class ExCallMaple implements Userpackage {
    public void add(Rete engine) {
        engine.addUserfunction(new CallMaple());
    }
}
-------------------------------


>cat CallMaple.java
-------------------------------
import jess.*;
import com.maplesoft.openmaple.*;
import com.maplesoft.externalcall.MapleException;

public class CallMaple implements Userfunction {

 String aj[];
 String result;
 static Engine t = null;
 Algebraic ergalg;
 String Val1;

 public String getName() { return "callmaple";}
       
 public Value call(ValueVector vv, Context context) throws JessException {
   
  Val1 = vv.get(1).stringValue(context);
     
  try
  {
    try
    {
     if (t == null) {
        aj = new String[1];
        aj[0]="java";
        // CREATE NEW maple-engine
        t = new Engine(aj, new EngineCallBacksDefault(),null,null);
     }
    }
    catch (MapleException me)
    {
      System.out.println("<!-- ....Konstruktor Engine faild: " +me.getMessage() +" -->");
      return null;
    }

    // EVALUATE THE EXPRESSION BY MAPLE:
    ergalg = t.evaluate(Val1);
    result = ergalg.toString();
  }
  catch (MapleException e)
  {
     System.out.println("<!-- ...calling faild: " +e.getMessage() +" -->");
     return null;
  }
  return new Value(result, RU.STRING);
 }
}
-------------------------------------------------------------------
-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

[protege-owl] Re: JessTab, adding Commands to Jess, Protege 3.2 b 318

ulrich thye


Sorry,

forget this. I have found the failure.
I have to put the Class-Files in plugins/JessTab

Regards

Ulrich
-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html