Without seeing the code, I can only guess. First, I am suspicous of the ordering of
your steps. I would perform the defrule before making instances. Second, it is not
clear to me that the (definstance mbox (get-member ?*AGENT* mailbox)) is doing what
you want since your ?*AGENT* global is set from the "JAVA" thread instead of the
"JESS" thread. The definstance command will likely use whatever was in ?*AGENT* at
compile time. You probably want to create definstances of mbox using rules that
detect ?*AGENT* changes. In general, rules based solely on detecting changes to
globals do not fire (in JESS nor in CLIPS - write a rule that just has (test (neq
?*agent* nil)) on the LHS and see if you can make it fire using binds and runs). I
suggest you call the mbox definstance from the "JAVA" thread. The code is similar
to what you wrote to call (bind) from the JAVA thread.
I suggest the following order:
JESS thread:
1) Perform defclasses
2) Perform defrules.
3) Reset
After the JESS thread is initialized, in the JAVA Thread:
1) Create the Agent object
2) Create Mailbox object (probably part of 1)
3) Call definstance function for the mbox.
--Jack
Juan Luis Mulas Platero wrote:
> Hello jess-users.
>
> I am trying to put JESS into an existing agent platform an have
> the next problem: there is a communications thread listening to a port
> whose mission is store each message it receives into the mailbox
> of the agent. What I want to do is create a definstance of this mailbox
> inside JESS (that runs in another thread) in order to detect (using a rule
> with the mailbox in th LHS ofa rule) the arriving of each message.
> The idea is that the Jess inference engine can access to each message
> that arrives at the agent so as to make a plan or do some prefix task.
>
> I have put into the JESS inference engine (using a defglobal)
> a reference to the agent to owns the mailbox object and using the function
> get-member, I have accessed to the mailbox object of the agent. The next
> task is to create a definstance with the reference to the mailbox. Since
> the MailBox object supports PropertyChangeListeners( supports
> addPropertyChangeSuppport(.), ...), each time a message is written to the
> mailbox I call the firePropertyChange(.) method in order to tell JESS that
> the object mailbox has changed and that the rule with the mailbox as a
> pattern in the LHS must be fired. The problem is that such a rule is never fired.
>
> That's more or less what I have done.
>
> 1. Put into Jess a reference to the agent who owns the mailbox from JAVA
> using the Funcall object. I store this reference in a defglobal
> variable named ?*AGENT* (this goes well).
>
> 2. Obtain a reference to the MailBox object of the agent (from JESS) and
> create a definstance of this object:
>
> (defclass mbox MSM.agent.MailBox)
> (definstance mbox (get-member ?*AGENT* mailbox))
>
> where mailbox is the name of the MailBox object owned by the agent.
> (It doesn't throw any exception. Seems to go well)
>
> 3. Create a defrule that must be fired when a changed is reported in the
> mailbox.
>
> (defrule read-message-from-mailbox
> (mbox (OBJECT ?mbox))
> =>
> (do-some-tasks)
> )
>
> BUT this rule is never fired in spite of having used the method
> pcs.firePropertyChange inside the MailBox object when a message is
> written to the mailbox. (pcs is a PropertyChangeSupport object
> defined inside the MailBox object).
>
> 4. What I exactly do inside the MailBox object is called the next method
> each time a message is written to the mailbox. Each time a message
> arrives, this method is called but nothing happens:
>
> pcs.firePropertyChange("number_msg", new Integer(number_msg), new
> Integer(number_msg+1));
>
> where number_msg is a variable of the mailbox that counts the number
> of messages stored at the Mailbox.
>
>
> Could someone help me?
> Could the problem be related with the fact that I haven't created
> the mailbox object inside JESS?(It is impossible to create it inside
> JESS because it must be created by the agent)
>
>
> Thanks in advanced.
>
> Juan Luis Mulas Platero.
> ETSIT Valladolid
> Spain.
>
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. 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. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------