I *think* you need to do something like this (?l is just the shadow fact
id):

(defclass Sphere Sphere)
(defclass LightBulb LightBulb)
(definstance LightBulb (new LightBulb "Halogen" 30))
(definstance LightBulb (new LightBulb "Floroscent" 40))
 
(defrule Rule1
    (LightBulb (OBJECT ?bulb) (type "Halogen") (visRep))
     =>
     (bind ?sphere (new Sphere))
     (definstance Sphere ?sphere dynamic)
     (call ?bulb setVisRep ?sphere)
)
(run)


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 27, 2000 7:58 AM
> To: [EMAIL PROTECTED]
> Subject: JESS: Referencing instances of JavaBeans in Jess
> 
> 
> 
> Can somebody help me in determining how to refer the 
> instances of JavaBeans
> in Jess as for following example?
> 
> ON JAVA  SIDE
> Two JavaBeans "Sphere", "LightBulb" are defined as follows
> 
> class LightBulb {
>      private String type;
>      private int watts;
>      private Object visRep;
> 
>      public LightBulb{}
> 
>      public LightBulb(String type, int watts) {
>           ...
>      }
>      get/set methods and propert_change_support_methods...
> }
> 
> class Sphere {
>      private float center;
>      private float radius;
> 
>      get/set methods and propert_change_support_methods...
> }
> 
> 
> ON JESS SIDE
> 
> (defclass Sphere Sphere)
> (defclass LightBulb LightBulb)
> (definstance LightBulb (new LightBulb "Halogen" 30))
> (definstance LightBulb (new LightBulb "Floroscent" 40))
> 
> (defrule Rule1
>     ?l <- (LightBulb (type "Halogen") (visRep))
>      =>
>      (bind ?sphere (new Sphere))
>      (definstance Sphere ?sphere dynamic)
>      (call ?l setVisRep ?sphere)
> )
> (run)
> 
> 
> Here we try to determine if lightbulb is of halogen type then set its
> visual representation as spherical shape.
> BUT ABOVE STMT (call ?l setVisRep ?sphere) fails.
> 
> 1. Since after creation of JavaBeans in Jess, it creates 
> shadow image as
> facts, now problem arises when trying to define rules which 
> work over the
> facts and how to refer instances of JavaBeans corresponding 
> to facts as in
> above case.
> 
> 2. In Jess, the fact created corresponding to first instance 
> of LightBulb
> is as follows
>     (LightBulb (class <External-Address::java.lang.Class>) 
> (type "Halogen")
> (watts 30) (visRep nil) (OBJECT <External-Address::LightBulb>)
> 
>     Does this OBJECT slotv alue refers to same instance of 
> JavaBean?? Is it
> same as if I refered by "lb" variable as follows
> 
> (bind ?lb (new LightBulb "Halogen" 30))
> (definstance LightBulb ?lb dynamic)
> 
> 3. When I try to make any change to the corresponding JavaBean, Jess
> removes the original fact and creates a new fact with 
> modified image of the
> JavaBean.
> 
> 
> Thanks in advance for any comments/help.
> 
> Regards,
> Vikram
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
> 
---------------------------------------------------------------------
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