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