Skip to content

Instantly share code, notes, and snippets.

@eliezerlribeiro
Last active August 29, 2015 14:10
Show Gist options
  • Save eliezerlribeiro/1dfa0ac384a658d19d0c to your computer and use it in GitHub Desktop.
Save eliezerlribeiro/1dfa0ac384a658d19d0c to your computer and use it in GitHub Desktop.
package com.sample
import com.sample.Sensor;
import com.sample.Numero;
import com.sample.SensorReadindg;
declare Sensor
@role( event )
end
rule hello
when
then
System.out.println( "hello" );
end
rule "< 20"
when
Sensor( estadoInterno<20, myMessage : "< 20" )
then
System.out.println( myMessage );
end
rule "> 20"
when
Sensor( estadoInterno>20, myMessage : "> 20" )
then
System.out.println( myMessage );
end
rule "Sensor 1 e sensor 2 > 20"
when
Sensor( estadoInterno>20, nome=="SensorUm" )
Sensor( estadoInterno>20, nome=="SensorDois" )
then
System.out.println( "2 > 20" );
end
rule "Sensor 1 e sensor 2 e sensor 3"
salience 10
when
Sensor( estadoInterno>20, nome=="SensorUm" )
Sensor( estadoInterno>20, nome=="SensorDois" )
Sensor( estadoInterno>20, nome=="SensorTres" )
then
System.out.println( "3 sensores > 20" );
end
rule "Sound the alarm in case temperature rises above threshold"
when
Number( doubleValue > 50 ) from accumulate(
Sensor( $temp : temperatura ) over window:time( 10m ),
average( $temp ) )
then
System.out.println( "explode" );
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment