Hi, 

I am pretty new to jess and I would be very happy if
someone could explain: what I am trying to do is
syntactically wrong or jess is not design to do the
following.
I have used the example of the book 
DimmerSwitchDynamic.
I defined a new method getBrightness in the java bean
DimmerSwitchDynamic. What I am try to do is to fire
the rule if the returning value of the method of the
java bean getBrightness is equal to the slot value pv
of template previous-value.  
Does jess allow executing functions or methods on the
left hand side of a rule? And if that is the case,
how?
Thank you in advance for your help 


Best regards,
Giovanni


**************
CODE*****************************************
(clear)
(watch all)
;Defining the class and link it to the 
DimmerSwitchDynamic java bean
(defclass dimmer DimmerSwitchDynamic)
(bind ?ds (new DimmerSwitchDynamic))
(definstance dimmer ?ds )


;Test the methods of the DimmerSwitchDynamic java bean

(call ?ds setBrightness 20)
(bind ?x (call ?ds getBrightness))
(printout t "The getBrightness: " ?x crlf)
;(printout t "The getBrightness---- " (bind ?x (call
?ds getBrightness))crlf)

; Define a template previous-value in order to compare
with Brigthtness value of the java bean 
(deftemplate previous-value     
        (slot pv)) 

(assert (previous-value  (pv 20)))

(facts)

;This rule should only be triggered if the value of
the java bean DimmerSwitchDynamic is equal to the 
;value of the slot pv defined in the previous-value
template 
(defrule check-brightness
        "it triggers if the brightness is = 20"
        (previous-value (pv ?n&:( eq (call ?ds getBrightness)
?n)))
        =>
(printout t "The new value is equal to the previous
one "  crlf))

(run)

********** ERROR MESSAGE
******************************************


Jess, the Rule Engine for the Java Platform
Copyright (C) 2004 Sandia Corporation
Jess Version 7.0a1 9/17/2004

This copy of Jess will expire in 11 day(s).
 ==> f-0 (MAIN::dimmer (brightness 0) (class
<External-Address:java.lang.Class>) (OBJECT
<External-Address:DimmerSwitchDynamic>))
 <=> f-0 (MAIN::dimmer (brightness 20) (class
<External-Address:java.lang.Class>) (OBJECT
<External-Address:DimmerSwitchDynamic>))
The getBrightness: 20
 ==> f-1 (MAIN::previous-value (pv 20))
f-0   (MAIN::dimmer (brightness 20) (class
<External-Address:java.lang.Class>) (OBJECT
<External-Address:DimmerSwitchDynamic>))
f-1   (MAIN::previous-value (pv 20))
For a total of 2 facts.
Jess reported an error in routine HasLHS.addPattern.
  Message: Variable used before definition: ds.
  Program text: ( defrule check-brightness "it
triggers if the brightness is = 20" ( previous-value (
pv ?n & : ( eq ( call ?ds getBrightness ) ?n ) ) ) = >
( printout t "The new value is equal to the previous
one " crlf ) )  at line 29.




                
___________________________________ 
Nuovo Yahoo! Messenger: E' molto piy divertente: Audibles, Avatar, Webcam, Giochi, 
Rubrica Scaricalo ora! 
http://it.messenger.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]
--------------------------------------------------------------------

Reply via email to