[rules-users] Truth maintenance and RHS variables

Wolfgang Laun wolfgang.laun at gmail.com
Tue Feb 7 11:44:23 EST 2012


It works (5.3.0), but there's other things that can go awry. These are
the settings I use:
   //...
   kBaseConfig.setOption( EventProcessingOption.STREAM );
   //...
   kSessionConfig.setOption( ClockTypeOption.get("pseudo") );
   //...
        clock = kSession.getSessionClock();
        StateEvent se1 = new StateEvent( "door.1" );
        kSession.insert( se1 );
        kSession.fireAllRules();
        clock.advanceTime( 60, TimeUnit.SECONDS );
        kSession.fireAllRules();
        clock.advanceTime( 1, TimeUnit.SECONDS );
        kSession.fireAllRules();
        clock.advanceTime( 1, TimeUnit.SECONDS );
        StateEvent se2 = new StateEvent( "presence.2" );
        kSession.insert( se2 );
        clock.advanceTime( 25, TimeUnit.SECONDS );
        StateEvent se3 = new StateEvent( "presence.2" );
        kSession.insert( se3 );
        clock.advanceTime( 40, TimeUnit.SECONDS );
        kSession.fireAllRules();

And this is the output (according to println's in the three rules):
created Monitor for door.1
not working: door.1
created Monitor for presence.2
stopped Monitor for presence.2
created Monitor for presence.2

A retract of an old StateEvent should be added to "stop monitoring":
rule "stop monitoring"
when
    $se: StateEvent( $in: itemName )
    $m: Monitor( $ose: stateEvent != $se, itemName == $in )
then
    retract( $m );
    retract( $ose );
    System.out.println( "stopped Monitor for " + $in );
end

-W


On 07/02/2012, juankera <juankera at gmail.com> wrote:
> Thanks for your quick reply.
>
> I can't say that your solution works because i'm facing a problem with
> declared facts.
>
> 1. I have declared Monitor inside my drl file
> 2. I can insert monitor facts in "start monitoring" rule without problems.
> And i've checked that it's fired.
>
> But rule "nothing for 1m" is not working, even with the most basic LHS
>
> rule "nothing for 1m"
> when
>     $monitor : Monitor( )
> then
>     System.out.println( ">>>>>>>>>>>>>>>>>>>>>>> not working: " );
> end
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/rules-users-Truth-maintenance-and-RHS-variables-tp3722632p3722952.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



More information about the rules-users mailing list