There is a mechanism called truth maintenance ensuring for example
A -> B
B -> C
that C becomes false when it's premise (B) becomes false as well.
What it basically does it track the LHS side of the rule and undoes
asserted facts when there are no more "facts" to support it (activate
the rules in question).
Look at the documentation for logicals / truth mainteance. It's pretty
cool.
For your case:
rule "light2on"
when
LIght(name=="0/0/2", actualvalue=="1")
then
insertLogical( new LightIsOn(2))
end
the fact "LightIsOn" will only be true (in the working memory) as long
as the LHS of the rule above is still true. For example if acutalvalue
becomes 0, that fact would vanish automagically.
That implies that you use facts to make statements about your system
(not using behind the scene callbacks) - but from my very little
experience I would say this is a good practice anyway. Fiddeling with
activations make me suspicious ;-) - But then it all depends on your
particular problem at hand.
--I
rule "light 2 on"
dialect "java"
when
Light (name=="0/0/2", actualvalue=="1");
then
System.out.println("luce 2 on");
end
Am 29.07.2008 um 14:42 schrieb Claudio Rainoldi:
i'm sorry i'm a new drools user.. Can you try to be a little more
clear?
thanks..
2008/7/29, Ingomar Otter <[EMAIL PROTECTED]>:
Use logicals.
Am 29.07.2008 um 11:20 schrieb Claudio Rainoldi:
Hi everyone,
isn'it there a way to find when a rule isn't more active.
For example if i have this rule:
rule "light 2 on"
dialect "java"
when
Light (name=="0/0/2", actualvalue=="1");
then
System.out.println("luce 2 on");
end
when someone turn on the light 2 i discover that the rule is fired
using
an
Agenda Event Listener and the method afterActivationFired;
But when someone turn off the ligth isn't there a similar way to
discover
that the rule "light 2 on" isn't more active.
My only solution is to use the dual rule:
rule "light 2 on_dual"
dialect "java"
when
not (Light (name=="0/0/2", actualvalue=="1"));
then
System.out.println("luce 2 off");
end
Isn't there a more sample way to do this?
Thanks in advance.
Cla
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users