I have a Java object ct_device. ct_object has a Source and Id properties. I want
a rule to fire when I upgrade the objects Id property.

The following is my rule:
   (defclass device ct_device)
   (defrule rule-4
      (device (id ?i) (source ?s))
      (test (neq ?i -1))
       =>
      (printout t "(test.clp rule-4) Source= " ?s ", Id= " ?i crlf)

The following is my Java Code where I set values for Id and Source. Note that I
have a one second delay between the two sets.
        ct_device[] d= new ct_device[n];
        for (int i= 1; i <= n-1; i++){
            d[i].setId(i);
            try { Thread.sleep(1000); } catch (InterruptedException ie) { break;
 }
            d[i].setSource("Device" + i);
        }

The above rule fires twice for each object. Once when I set the Id value, and
once when setting the Source property value.
 Below is a sample output.
   SetId: 1
   (test.clp rule-4) Source= default, Id= 1
   SetSource: Device1
   (test.clp rule-4) Source= Device1, Id= 1
   SetId: 2
   (test.clp rule-4) Source= default, Id= 2
   SetSource: Device2
   (test.clp rule-4) Source= Device2, Id= 2

Now, when I remove the one second wait between the two set property values,
i.e.,
        ct_device[] d= new ct_device[n];
        for (int i= 1; i <= n-1; i++){
            d[i].setId(i);
            d[i].setSource("Device" + i);
        }the rule only fires once for the combined sets. Below is a sample of
the output.

   SetId: 1
   SetSource: Device1
   (test.clp rule-4) Source= Device1, Id= 1
   SetId: 2
   SetSource: Device2
   (test.clp rule-4) Source= Device2, Id= 2
   SetId: 3
   SetSource: Device3

Can any one explain the observed behavior.
In case 1, why is the rule firing when I do a set on the Source property? It
seems that the rule is firing when I do a set on any of the ct_device object's
property as long as Id neq -1 !!
If the output from case 1 is a normal behavior, then, why is it that in case 2
when both Id and Source properties are set with no delays between them, I only
get one firing of the rule?

By the way, I am using Jess 60a5 with JDK1.3

Thanks in advance,

Regards,
___________________________
Vicken Kasparian
A C T E R N A
Voice: 941.756.6000 x3550
mailto: [EMAIL PROTECTED]
http://www.acterna.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