All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ools-benchmark.6.0.0.Beta2.source-code.fireAlarmJava.drl Maven / Gradle / Ivy

There is a newer version: 7.36.1.Final
Show newest version
dialect "java"

import java.util.*
import org.drools.benchmark.model.*

rule "When there is a fire turn on the sprinkler"
when
    $fire: Fire($roomA_ : room)
    $sprinklerA_ : Sprinkler( room == $roomA_, on == false )
then
    modify( $sprinklerA_ ) { setOn( true ) };
//    System.out.println( "Turn on the sprinkler for room " + $roomA_.getName() );
//    System.out.println( $fire );
end

rule "When the fire is gone turn off the sprinkler"
when
    $roomB_ : Room( )
    $sprinklerB_ : Sprinkler( room == $roomB_, on == true )
    not Fire( room == $roomB_ )
then
    modify( $sprinklerB_ ) { setOn( false ) };
//    System.out.println( "Turn off the sprinkler for room " + $roomB_.getName() );
end

rule "Raise the alarm when we have one or more fires"
when
    exists Fire()
then
    insert( new Alarm() );
//    System.out.println( "Raise the alarm" );
end

rule "Cancel the alarm when all the fires have gone"
when
    not Fire()
    $alarm_ : Alarm()
then
    retract( $alarm_ );
//    System.out.println( "Cancel the alarm" );
end

rule "Status output when things are ok"
when
    not Alarm()
    not Sprinkler( on == true )
then
//    System.out.println( "Everything is ok" );
end




© 2015 - 2025 Weber Informatics LLC | Privacy Policy