I have an application that needs to do things periodically.

I created a Java object containing the current time. It is updated every minute by a separate thread. When I need an action to be executed repeatedly, say every 5 minutes, I record the time the action has been executed last. The rule computes the time difference between the last execution and the current time and tests that the difference is >= 5 minutes.

I don't know how your application works, but maybe you could implement a generic timer that the users can refer to?

Note that every time you update the timer, JESS will review its agenda, so it might not be a reasonable to update the timer every second. I don't know how much times that takes.


Mrinal Khanvilkar wrote:
Thank you Ernest..but in my application i am just allowing the user to enter rules and facts into the engine. I cannot provide him the functionality of adding deffunction(since it would be inconsistant with the application) .

My question is , whether the engine process rules even if there are no facts being inserted into the engine which may fire the rules. If yes, then we can write predicates in such a way that they will be true after some time and the rule fires without any facts being inserted.
but if no, then i will have to add and retract facts on a periodic basis.


Any suggestions?

Regards,
Mrinal


On 5/29/07, *Ernest Friedman-Hill * <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:


    On May 29, 2007, at 12:48 PM, Mrinal Khanvilkar wrote:

    > Hi,
    >
    > Is there a way to generate a rule and firing it periodically?
    > for e.g.
    >

    There's a discussion of something like this in the FAQ, under "How do
    I make Jess run forever?":

    http://herzberg.ca.sandia.gov/jess/FAQ.shtml#Q9

    But I think what I'd recommend is to use the "implement" function to
    create a Runnable that calls a deffunction, and then use the Runnable
    with a java.util.Timer to have it called periodically.


    > (defrule rule1
    >
    > fire after every time t
    >
    > =>
    >
    > someactions)
    >
    > the predicates in this case is only going to be the time interval
    > for which the rule is being fired.
    >
    > thanks,
    > Mrinal

    ---------------------------------------------------------
    Ernest Friedman-Hill
    Advanced Software Research          Phone: (925) 294-2154
    Sandia National Labs                FAX:   (925) 294-2234
    PO Box 969, MS 9012                 [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>
    Livermore, CA 94550                 http://www.jessrules.com

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



--
Florian Fischer
Service d'Informatique Médicale
Hôpitaux Universitaires de Genève
Tél: 022 37 28861
[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]
--------------------------------------------------------------------

Reply via email to