Hello, I'm a relatively new Jess user and I'm having difficulties with a
rule. I need to create a rule for a context-aware application that
monitors if a user leaves a room. For that a have the following
deftemplate:
(deftemplate user
(slot name)
(slot isInRoom))
The rule should notify me whenever someone leaves an specific room. The
solution I imagined has the following LHS
(defrule ruleCheckLeaveRoom
(user (name ?userName) (isInRoom Office1))
My problem is that the RHS should create (using build) another rule for
each person entering Office1. I tried the following but couldn't have a
variable as part of the second rule's name:
(build "(defrule (checkLeave_?userName
(user (name ?userName) (isInRoom ~Office1))
=>
(printout t User ?userName has left Office1 crlf)
)")
I also need to substitute the variable ?userName for its value so I can
have the generation of the second rule like:
(defrule (checkLeave_John
(user (name John) (isInRoom ~Office1))
=>
(printout t User John has left Office1 crlf)
)
Is it possible? Do you have a suggestion for another solution?
Thanks,
Luiz Olavo Bonino
University of Twente