Title: Modifying JavaBeans

Sorry to bother everyone. I am trying to play around with JESS embedded in Java to get an understanding of JESS. I created a simple Java bean which contains two properties: range and qualRng. I create the fact within Jess utilizing defclass and definstance. Executing engine.facts() shows that the fact has been created in Jess's memory with the appropriate slots. I created a simple rule to check to see if range is below 20, if true, modify the qualRng slot to TRUE. I added code to main() decrement the initial value of range in order to fire the rule. Watching the results shows that the range slot decrements properly and the rule fires, but the qualRng field never gets updated to show TRUE. I am sure it is something simple, but I just don't see the problem. I've modified the RHS of the rule with all the different iterations I could think of but to no avail. The code is listed below (minus the java bean class). Thanks for your assistance.

import jess.*;

public class testFacts
{
        public static void main(String[] args)
        {
                Value fact;
                try
                {
                        Rete engine = new Rete();
                        engine.watchAll();

                        engine.defclass("testTrkClass", "testTrack", null);
                        testTrack trkOne = new testTrack(30, 45, 5);
                        fact = engine.definstance("testTrkClass", trkOne, true);
                       
                        // Load rules clip file
                        engine.executeCommand("(batch testTrk.clp)");
                        engine.run();
                       
                        // change range until it triggers a dummy doct rule

                        int i;
                        for(i = trkOne.getRange(); i > 5; i--)
                        {
                                trkOne.setRange(i);
                                try
                                {
                                        Thread.sleep(500);
                                }
                                catch (InterruptedException ie){}
                        }
                }
                catch (JessException je)
                {
                        System.out.print("An error occurred at line " + je.getLineNumber());
                        System.out.println(" which looks like " + je.getProgramText());
                        System.out.println("Message: " + je.getMessage());
                }
        }

}

The clp file:

(defrule dummy-range-doctrine
    ;; set qualRng to true if trk is in range
    ?fact <- (testTrkClass (range ?x&:(<= ?x 20)))
    =>
    (modify ?fact (qualRng TRUE)))



Scott L. Krasnigor
Principal Engineer/Scientist
Atlantic Science & Technology
Lockheed Martin - MS2
' 856-359-3094
* [EMAIL PROTECTED]
* 770-2

Reply via email to