Hi Colin,
(test) CEs get evaluated only when the immediately preceding pattern
is matched. So in the rule below, the test is evaluated only when the
generateBill fact is first asserted. The only conceivable alternative
is to have Jess sit in a loop calling isCompleted over and over again
-- clearly not a sensible implementation.
What you need to to is have Jess be notified when the generateBill
Bean is done with its computation. I don't know anything about your
bean's architecture, but either there's an execute() method that some
method calls, in which case that code could turn around and notify
Jess, or perhaps the Bean sends an event when it completes, in which
can an event handler could do the job. In any case, the notification
would be the assertion of a billCompleted fact, so that maybe your
rule looks like:
(defrule discountBill
(generateBill ?id ?generateBill)
(billCompleted ?id)
=>
(printout t \"discountBill ready\" crlf))
If there's absolutely, positively no other way, then you need to
create a Thread which polls ?generateBill.isCompleted() and asserts
the fact when it returns true. The thread should sleep for some period
of time between calls.
I think colin harris wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi,
>
> I am using Jess6.0a2 embedded in an enterprise java bean application. I have
> a number of EntityBeans, that when they are created, i store their reference
> in the Rete object like this:
>
> rete.store(name + "INSTANCE", entityBean);
> rete.executeCommand("(assert (" + name + " " + id + "(fetch " + name +
> "INSTANCE)))");
>
> so an example fact asserted would be (generateBill 23 <reference to
> generateBill EntityBean> )
>
> I have several rules set in the engine as below.
>
> (defrule discountBill (generateBill ?id ?generateBill) (test (call
> ?generateBill isCompleted)) => (printout t
> \"discountBill ready\" crlf))
>
> What i am trying to do is activate the discountBill rule, when the
> generateBill Entity Bean isCompleted.
>
> My problem is that it appears the (test (call ?generateBill isCompleted))
> is evaluated only once at the start, when it returns FALSE, and not again
> later on when (call ?generateBill isCompleted) returns TRUE. So the
> discountBill rule never fires even though the test should be returning TRUE,
> at the later stage.
>
> Is this assumption true that the test only gets evaluated once, or do tests
> get evaluated every time run() is called and am i missing something???
>
> any help/ advice would be much appreciated.
>
> regards
>
> colin...............
>
>
>
>
> ---------------------------------------------------------------------
> 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
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
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]
---------------------------------------------------------------------