Jess reacting to a PropertyChangeEvent isn't any different from calling (modify) on a regular fact; the value of one or more slots changes. You don't think in any special way about writing rules to fire when properties change, or anything like that; you just write rules to match slot or values of slot, and when the slots change, the rules are reevaluated.


On Sep 8, 2008, at 8:35 AM, John Chrysakis wrote:


To follow my question could you provide me a simple example of changing
one property which in terms fires different rules?
I'm a little bit confused of how I should use the property change
listeners and how should I test them?

Many thanks in advance!

-----------------------------------------------------
John Chrysakis
R&D Engineer,
Institute of Computer Science (ICS),
Foundation for Research and Technology-Hellas (FORTH)
Heraklion, Crete, Greece.
-----------------------------------------------------


On Mon, 8 Sep 2008, John Chrysakis wrote:


Hello again to all Jess Users,

I am trying to use propertychange listeners in a simple jess application.
But I am getting: "Jess reported an error in routine
DefinstanceList.updateMultipleSlots"

The application examines the Type of an event and prints different message
So the EventRules.clp has the following rules:

(import pack.*)
(deftemplate CurrentEvent(declare (from-class CurrentEvent )))


(defrule check-event-type
(CurrentEvent {reading == "TypeX" } ) => (printout t "Event TypeX" crlf))

(defrule check-event-type
(CurrentEvent {reading == "TypeY" } ) => (printout t "Event TypeY" crlf))



(defrule check-event-type
(CurrentEvent {reading == "TypeZ" } ) => (printout t "Event TypeX" crlf))



I hava a BeanSupport Class like the one of page 230 /Jess In Action Book. I hava a BeanSimulator which fills some values the class CurrentEvent (My Bean Class) and the TestJessBean which includes the main and the required
function calls to Java API.

Any ideas please, what I'm doing wrong?

Thanks in advance,


//////////////////////////////////////////////////////////////////////////////////////////////////

package pack;


public class BeanSimulator implements Runnable {

       private String theEventType;

       public BeanSimulator(){

               new Thread (this).start();
       }


       public String getEventType(){

               return theEventType;
       }


       public void run(){

               theEventType = "TypeY";

               while (true){


               try {

                       for (int i=0; i<3; i++){
                               theEventType = "TypeX";
                               Thread.sleep(1000);
                               theEventType = "TypeY";
                               Thread.sleep(1000);
                               theEventType = "TypeZ";
                               Thread.sleep(1000);
                       }



               } catch (InterruptedException e) {

                       e.printStackTrace();
                       return;
               }

               }
       }

}

/////////////////////////////////////////////////////////////////////////////////////////


package pack;

public class CurrentEvent extends BeanSupport implements Runnable{

       private String event_type;
       private String event_type_old;
       private String event_sender;
       private BeanSimulator bs;

       public CurrentEvent(String type, String sender){

               event_type = type;
               event_sender = sender;

       }

       public CurrentEvent(){

       }

       public String getReading(){

               return bs.getEventType();
               //return "TypeY";

       }


       public void run() {
               while (true) {
                       String cur_eventtype = getReading();

m_pcs .firePropertyChange("cur_eventtype",event_type_old,cur_eventtype);
                       event_type_old = cur_eventtype;
                       try { Thread.sleep(1000); }

                       catch (InterruptedException ie) { return; }
               }

       }


}

//////////////////////////////////////////////////////////////////////////////////////////////////


package pack;

import java.io.IOException;

import jess.*;

public class TestJessBean {


       public static void main (String[] args) throws
InterruptedException, IOException {

JessHandler jesshand; // Makes run-until-halt and handls
rete Objects (Engine)


               CurrentEvent cev = new CurrentEvent();

               try {
                       jesshand = new JessHandler();


                       jesshand.batch("EventRules.clp");
                       BeanSimulator bs = new BeanSimulator();

                       //jesshand.add(cev);

jesshand.defClass("CurrentEvent","CurrentEvent",null);
jesshand.defInstance("CurrentEvent",cev, true);


               } catch (JessException e) {

                       e.printStackTrace();
               }

       }

}


-----------------------------------------------------
John Chrysakis
R&D Engineer,
Institute of Computer Science (ICS),
Foundation for Research and Technology-Hellas (FORTH)
Heraklion, Crete, Greece.
-----------------------------------------------------



--------------------------------------------------------------------
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] .
--------------------------------------------------------------------




--------------------------------------------------------------------
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] .
--------------------------------------------------------------------

---------------------------------------------------------
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