Ernest,
Thanx first of all for your reply,
I would be more precise in my question.
Let's assume the rule which is appeared in clp file:
(defrule testRule1
"Testing the rule."
(Ontology { reportsLock == TRUE })=> (calling MyFunction)
)
I have a private boolean reportsLock variable and the method:
public boolean isReportsLock(){
return reportsLock;
}
Both appear in my class Ontology. The testRule1 is correct and is fired
when I batch the specific clp file and call add(ont), while
Ontology ont = new Ontology.
BUT, If I want to compare values between strings or integers I don't have
the know how. For example the rule is not correct since string MODE is not
recognized:
(defrule testRule1
"Testing the rule."
(Ontology { MODE == "Something" })=> (calling MyFunction)
)
I have defined in Ontology:
private String Mode = "Something";
and
public String getMode(){
return Mode;
But in Jess Editor an error appears in mode: No such slot Mode in template
MAIN::Ontology at token 'Mode'.
What it is going wrong?
Thanks in advance!
-----------------------------------------------------
John Chrysakis
R&D Engineer,
Institute of Computer Science (ICS),
Foundation for Research and Technology-Hellas (FORTH)
Heraklion, Crete, Greece.
-----------------------------------------------------
On Mon, 5 May 2008, Ernest Friedman-Hill wrote:
> On May 5, 2008, at 5:51 AM, John Chrysakis wrote:
>
> >
> > If (Mode == "string value" && activity == 'int value) call a java
> > userdefined class
> >
> > Can you help me of how I am supposed to write a suitable rule?
> > What Mode needs to be? How?
> > How can I declare the equality of objects (== is true?)
> > How can I declare the equality of int values?
>
> I don't really understand these questions in light of the fact that
> the LHS of your strawman rule, below, looks to be correct.
> >
>
> > The LHS is surely true, but I don't know how to write the RHS
> > of the rule
> >
> > (import owl.*)
> > (deftemplate Ontology (declare (from-class Ontology )))
> >
> > (load-function JessCaller)
> >
> >
> > (defrule testRule
> > "Testing the rule."
> > (Ontology { Mode == "Indoor_MainRoom_AmbientPresentation" &&
> > mode_actice == 0 } )
> > =>
> > (printout t "Reactive Rule ReportsLock: " ?value crlf)
> > (calling MyUserFunction)
> > )
>
> (I reformatted your rule to make it a bit easier to see; I also
> removed an empty set of parentheses from the LHS -- don't know what
> those were for.)
>
> How you call a function depends on what kind of a function it is. This
> section of the manual talks abot calling functions in general:
>
>
http://www.jessrules.com/jess/docs/71/basics.html#functions>
> This section talks about calling the methods of Java objects:
>
>
http://www.jessrules.com/jess/docs/71/java.html#reflection>
> This part shows how to write new Jess functions in Java, how to load
> and call them from Jess:
>
>
http://www.jessrules.com/jess/docs/71/extending.html#extensions>
> Finally, this section describes the OBJECT slot, which you could use
> to get access to your "Ontology" object from the RHS of the rule:
>
>
http://www.jessrules.com/jess/docs/71/memory.html#shadow_instances>
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences Phone: (925) 294-2154
> Sandia National Labs FAX: (925) 294-2234
> PO Box 969, MS 9012
ejfried@...
> Livermore, CA 94550
http://www.jessrules.com>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users
you@...'
> in the BODY of a message to
majordomo@..., NOT to the list
> (use your own address!) List problems? Notify
owner-jess-users@....
> --------------------------------------------------------------------
>
>
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users
you@...'
in the BODY of a message to
majordomo@..., NOT to the list
(use your own address!) List problems? Notify
owner-jess-users@....
--------------------------------------------------------------------