I think Giovanni Crudele wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi,
> 
> I wrote this function in order to track which rule
> fired during the execution. I also add a counter in
> order to know the order of firing. I save this
> information in a template rule-fired and I assert this
> fact in a different module called
> COMPANYREGISTRATIONREPORT. When I look the fact
> rule-fired in the module COMPANYREGISTRATIONREPORT it
> seems that all rules fires more then once. I am not
> sure why.
> Jess version 70b3
> 
> Can you please help me?
> 


First, let me point out that explicit use of the function "call" is
unnecessary -- leaving it out makes your code much clearer. You don't
even need it for static functions any more because of Jess "static
imports" feature. Instead of writing

(call (call (call ?evt getObject) getRule) getModule))

you can just write

(((?evt getObject) getRule) getModule)

Now, as to your question: many perfectly correct programs feature
rules that fire more than once, so that by itself isn't bad. I don't
see anything wrong with your code.  Does the list of facts created by
this code disagree with the output of "(watch rules)", which does
something similar?

If they agree, then your question isn't about this code at all, but
rather about your rules, and why they fire as they do. That's a whole
separate problem. My advice to you in that case is to test it one rule
at a time using the "watch all" function, making sure you understand
what's happening at every point. If you have a *specific* question
about what you observe, you can certainly bring it back here.



> 
> Best regards,
> Giovanni 
> 
> ********************** JESS
> LISTENER***************************
> (import jess.JessEvent)
> (import jess.JessEventAdapter)
> (defglobal ?*count-event* = 0)
> 
>  (deffunction set-current-rule-name (?evt)
>       (if (eq (get-member JessEvent DEFRULE_FIRED) (get
> ?evt type)) then  
>           (bind ?tmpM
>               (call (call (call ?evt getObject) getRule)
> getModule));Get the module name where the rule just
> fired
>               (bind ?tmpR 
>               (call (call (call ?evt getObject) getRule)
> getName));Get the rule name that just fired
>               (bind ?date (new Date))     
>               (bind ?ISO (new String yyyy-mm-dd.hh.mm.ss))
>         (bind  ?df (new SimpleDateFormat ?ISO))
>         (bind ?*count-event* (+  ?*count-event* 1))     
>     
>         (assert (COMPANYREGISTRATIONREPORT::rule-fired
> (order ?*count-event* )(name ?tmpR)(time (call ?df
> format ?date))(module ?tmpM)))
> )     
> )
> 
> ; We add the function using JessEventAdapter
> (call (engine) addJessListener 
>       (new JessEventAdapter set-current-rule-name
> (engine)))
> 
> ; We make sure that DEFRULE_FIRED events will be
> produced by setting that
> ; bit in Rete.eventMask
> (set (engine) eventMask 
>      (bit-or (get (engine) eventMask) 
>            (get-member JessEvent DEFRULE_FIRED)))
> 
> *************** THESE ARE THE REPORT OF THE RULE
> FIRED********
> 
>  (COMPANYREGISTRATIONREPORT::rule-fired (order 7)
> (name "COMPANYREGISTRATIONFAIL::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 8) (name
> "COMPANYREGISTRATIONFAIL::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 9) (name
> "COMPANYREGISTRATIONFAIL::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 10)
> (name "COMPANYREGISTRATIONFAIL::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 11)
> (name "COMPANYREGISTRATIONFAIL::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 12)
> (name "COMPANYREGISTRATIONFAIL::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 13)
> (name "COMPANYREGISTRATIONPASS::role-name") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 14)
> (name "COMPANYREGISTRATIONPASS::role-name") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 15)
> (name "COMPANYREGISTRATIONPASS::role-name") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 16)
> (name "COMPANYREGISTRATIONPASS::role-name") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 17)
> (name "COMPANYREGISTRATIONPASS::role-name") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 18)
> (name "COMPANYREGISTRATIONPASS::role-name") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::report (result PASS)
> (rulename "COMPANYREGISTRATIONPASS::role-name")
> (templatename "MAIN::Director") (message "The role has
> this name: {3}") (data 1 2006-09-15 DirectorA nil))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 19)
> (name "COMPANYREGISTRATIONPASS::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 20)
> (name "COMPANYREGISTRATIONPASS::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 21)
> (name "COMPANYREGISTRATIONPASS::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 22)
> (name "COMPANYREGISTRATIONPASS::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 23)
> (name "COMPANYREGISTRATIONPASS::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 24)
> (name "COMPANYREGISTRATIONPASS::switch-focus") (time
> "2006-35-13.12.35.27") (module "a rule was fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 25)
> (name "COMPANYREGISTRATIONREPORT::save-facts-to-file")
> (time "2006-35-13.12.35.27") (module "a rule was
> fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 26)
> (name "COMPANYREGISTRATIONREPORT::save-facts-to-file")
> (time "2006-35-13.12.35.27") (module "a rule was
> fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 27)
> (name "COMPANYREGISTRATIONREPORT::save-facts-to-file")
> (time "2006-35-13.12.35.27") (module "a rule was
> fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 28)
> (name "COMPANYREGISTRATIONREPORT::save-facts-to-file")
> (time "2006-35-13.12.35.27") (module "a rule was
> fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 29)
> (name "COMPANYREGISTRATIONREPORT::save-facts-to-file")
> (time "2006-35-13.12.35.27") (module "a rule was
> fired"))
> (COMPANYREGISTRATIONREPORT::rule-fired (order 30)
> (name "COMPANYREGISTRATIONREPORT::save-facts-to-file")
> (time "2006-35-13.12.35.27") (module "a rule was
> fired"))
> 
> 
> 
>       
> 
>       
>               
> ___________________________________ 
> Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
> http://mail.yahoo.it
> 
> --------------------------------------------------------------------
> 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  
Advanced Software Research          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

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