I suggest that you run (ppdeftemplate CurrentEvent) from within your
EventRules.clp
to see the kind of shadow fact Jess makes from your class.
The code is somewhat incomplete (where is the initialization for
CurrentEvent.bs?)
but I surmise that Jess has a shadow fact with one slot: reading. But the
firePropertyChange method says that the property "cur_eventtype" is changed,
and this field of your class CurrentEvent doesn't have a getter, and so I think
that it doesn't beget a slot in the template for the shadow fact.
Also, I don't like the free running sleeps with the idea that the two
thread sort
themselves out, somehow. I suggest that you let the BeanSimulator
call, periodically, between sleeps, setReading (which saves the field reading
on the stack, updates reading with the argument value, calls
firePropertyChange( "reading",...) on a CurrentEvent object passed to its
constructor periodically. There's no need for run() and sleep() in CurrentEvent.
HTH
Wolfgang
On Mon, Sep 8, 2008 at 12:11 PM, John Chrysakis <[EMAIL PROTECTED]> wrote:
>
> Hello again to all Jess Users,
>
> I am trying to use propertychange listeners in a simple jess application.
> But I am getting: "Jess reported an error in routine
> DefinstanceList.updateMultipleSlots"
>
> The application examines the Type of an event and prints different message
> So the EventRules.clp has the following rules:
>
> (import pack.*)
> (deftemplate CurrentEvent(declare (from-class CurrentEvent )))
>
>
> (defrule check-event-type
> (CurrentEvent {reading == "TypeX" } ) => (printout t "Event TypeX" crlf))
>
> (defrule check-event-type
> (CurrentEvent {reading == "TypeY" } ) => (printout t "Event TypeY" crlf))
>
>
>
> (defrule check-event-type
> (CurrentEvent {reading == "TypeZ" } ) => (printout t "Event TypeX" crlf))
>
>
>
> I hava a BeanSupport Class like the one of page 230 /Jess In Action Book.
> I hava a BeanSimulator which fills some values the class CurrentEvent (My
> Bean Class) and the TestJessBean which includes the main and the required
> function calls to Java API.
>
> Any ideas please, what I'm doing wrong?
>
> Thanks in advance,
>
>
> //////////////////////////////////////////////////////////////////////////////////////////////////
>
> package pack;
>
>
> public class BeanSimulator implements Runnable {
>
> private String theEventType;
>
> public BeanSimulator(){
>
> new Thread (this).start();
> }
>
>
> public String getEventType(){
>
> return theEventType;
> }
>
>
> public void run(){
>
> theEventType = "TypeY";
>
> while (true){
>
>
> try {
>
> for (int i=0; i<3; i++){
> theEventType = "TypeX";
> Thread.sleep(1000);
> theEventType = "TypeY";
> Thread.sleep(1000);
> theEventType = "TypeZ";
> Thread.sleep(1000);
> }
>
>
>
> } catch (InterruptedException e) {
>
> e.printStackTrace();
> return;
> }
>
> }
> }
>
> }
>
> /////////////////////////////////////////////////////////////////////////////////////////
>
>
> package pack;
>
> public class CurrentEvent extends BeanSupport implements Runnable{
>
> private String event_type;
> private String event_type_old;
> private String event_sender;
> private BeanSimulator bs;
>
> public CurrentEvent(String type, String sender){
>
> event_type = type;
> event_sender = sender;
>
> }
>
> public CurrentEvent(){
>
> }
>
> public String getReading(){
>
> return bs.getEventType();
> //return "TypeY";
>
> }
>
>
> public void run() {
> while (true) {
> String cur_eventtype = getReading();
>
> m_pcs.firePropertyChange("cur_eventtype",event_type_old,cur_eventtype);
> event_type_old = cur_eventtype;
> try { Thread.sleep(1000); }
>
> catch (InterruptedException ie) { return; }
> }
>
> }
>
>
> }
>
> //////////////////////////////////////////////////////////////////////////////////////////////////
>
>
> package pack;
>
> import java.io.IOException;
>
> import jess.*;
>
> public class TestJessBean {
>
>
> public static void main (String[] args) throws
> InterruptedException, IOException {
>
> JessHandler jesshand; // Makes run-until-halt and handls
> rete Objects (Engine)
>
>
> CurrentEvent cev = new CurrentEvent();
>
> try {
> jesshand = new JessHandler();
>
>
> jesshand.batch("EventRules.clp");
> BeanSimulator bs = new BeanSimulator();
>
> //jesshand.add(cev);
>
> jesshand.defClass("CurrentEvent","CurrentEvent",null);
> jesshand.defInstance("CurrentEvent",cev, true);
>
>
> } catch (JessException e) {
>
> e.printStackTrace();
> }
>
> }
>
> }
>
>
> -----------------------------------------------------
> John Chrysakis
> R&D Engineer,
> Institute of Computer Science (ICS),
> Foundation for Research and Technology-Hellas (FORTH)
> Heraklion, Crete, Greece.
> -----------------------------------------------------
>
>
>
> --------------------------------------------------------------------
> 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]
--------------------------------------------------------------------