If the problem is something subtle, then we're not going to be able to help you unless you show us the real code, because most likely the problem is in something you're not showing here. As far as this goes, it looks more or less OK, but as they say, "the devil is in the details."

On Jul 1, 2010, at 12:28 PM, [email protected] wrote:

BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; } Please help, my *very simple* rule in JEss is not fired. I follow the HVAC example, chapter 14 of the book Jess in Action. But my simple rule never fired.

Example rule: if a person with age < 24 months then it is a toddler.

The exercise is written in Java with the rule in Jess

IDE environement: Eclipse

Java class

      public class Person {

             private String m_name;

            private int         m_age;

           // set and get funciton

// in order to test out the different rules, a method is writen to increase the age of an object.

         public void increaseAge() {

         }

   }

// same code from the Jess Action book, chater 14. The class is to add / remove property change listener and

public abstract class BeanSupport {

}

// class PersonStageReasoner. This class will start a thread with a forever-loop to change a person age

public class PersonStageReasoner extends BeanSupport implements Runnable {

// constructor that will instantiage a person object and start a thread

    public PersonStageReasoner  (Person p) {

           m_person = new Person(p);

          new Thread(this).start();

    }

    public int getAge() {return m_person.getAge()); }

    public void run() {

          while (true) {

                      prev_age := m_person.getAge();

                     m_person.increaseAge();

                     int age_now = m_person.getAge()

                    m_pcs.firedPropertyChange("age", prev_age, age);

                     try { Thread.sleep (1000); }

                     catch (InterruptedException ie) { return; }

          } // end while true

   }


}


Jess:

!! Add rules



(bind?p(new person.Person"firstname lastname" 0))




(


defclassPersonStageReasoner person.PersonStageReasoner)


(definstancePersonStageReasoner



(new person.PersonStageReasoner?p))




(defruleperson-stage-todler




(PersonStageReasoner(age?a&:(< ?a 12)))




=>

(printout t "toddler" crlf)

(halt))





(run-until-halt)

(exit)



I know that defclass, definstance are fine, because the Java code, espeically the PersonStageReasoner thread is spawn in is in the forever loop (while true), the person age is changing. But the rule in defrule was never fired.


I thank you for any and all help.






My Coyne
[email protected]
(cel): 301-399-6351


---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences, Sandia National Laboratories
PO Box 969, MS 9012, Livermore, CA 94550
http://www.jessrules.com







--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [email protected]'
in the BODY of a message to [email protected], NOT to the list
(use your own address!) List problems? Notify [email protected].
--------------------------------------------------------------------

Reply via email to