Title: Rules firing in an endless loop...

If OrmedContext is a bound bean, then when you execute the function (call ?c setSelectedScript ?s) it will fire a property change, and so the shadow fact will be updated.

This makes the rule eligible to fire again, thus causing an infinite loop.

It looks like you have the slot (readyToRun <bool>) specifically to toggle eligibility of the fact to trigger a rule.Therefore, you should add another line to the RHS:

(call ?c setReadyToRun FALSE)

 

Richard Long�������� "Imagination is more important than knowledge."

Senior Developer

Gestalt LLC

12605 Challenger, Suite 160, Orlando, FL 32826

321.235.8254 - Office

407.491.8628 - Cell
407.380.2456 - Fax

 

http://www.gestalt-llc.com

Value beyond the sum of the parts!

-----Original Message-----
From: Alexander Lamb [mailto:[EMAIL PROTECTED]]
Sent
: Thursday, October 10, 2002 6:19 AM
To: [EMAIL PROTECTED]
Subject: JESS: Rules firing in an endless loop...

 

Although I only have 5 rules, I get into a strange loop.

Here is the rule that fires continuously:

(defrule ASP1
    (OrmedContext
        (readyToRun TRUE)
        (task "script")
        (OBJECT ?c)
    )
    (CompleterResponseElement
        (ormedContext ?c)
        (key "ASP")
    )
    =>
    (bind ?s (new OrmedScript "ASP"))
    (call ?c setSelectedScript ?s)
    (call ?s addInstruction (new OrmedScriptInstruction "Aspirine Cardio (100mg)" FALSE TRUE TRUE TRUE))
    (call ?s addInstruction (new OrmedScriptInstruction "Aspirine 500mg" FALSE TRUE TRUE TRUE))
    (call ?s addInstruction (new OrmedScriptInstruction "Aspirine 1000mg" FALSE TRUE TRUE TRUE))
)

My understanding is that ?c is the same. It is the way I found to avoid the problem of bean properties which can’t be null.
Here OrmedContext has a completerResponseElement, but it can be null. Therefore, I do things the other way round:
When I set a completerResponseElement to my OrmedContext, I set the ormedContext in CompleterResponseElement and
The latter is definstanced.

My rule means:

When a OrmedContext is readyToRun and task is “script” and has a CompleterResponseElement with key is “ASP”
Then create a new OrmedScript, set it to OrmedContext then add three instructions.

OrmedContext, CompleterResponseElement, OrmedScript are definstanced (in the Java code). Only OrmedContext is dynamic.
When I add the new OrmedScript to OrmedContext I do:

         undefinstance the previous one if it is not null

         assign the ormedContext property to it

         definstance the new selectedScript

         fire property change for the selectedScript in OrmedContext


I am really puzzled because it seems so simple!

Thanks,

Alex
--
Alexander Lamb
Groupe Serveurs Applicatifs
Division d'Informatique M�dicale
H�pitaux Universitaires de Gen�ve
21 rue Micheli-du-Crest
CH-1211 Gen�ve 4 / Switzerland
Tel: +41-22 372.48.46 Fax: +41-22 382.86.80
[EMAIL PROTECTED] / http://www.hcuge.ch

Reply via email to