⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_joinnodemodifytuple.drl

📁 jboss规则引擎
💻 DRL
字号:
package TrafficControl

import org.drools.*

rule "Target Retract"
	salience -100
	when
      $tgt1 : Target( $label1 : label, $time : time )
      Target( label == $label1, time > $time )
	then
      retract( $tgt1 );
end

rule "Close Assert"
	when
      Target( $label : label, $time : time, $lat : lat, $lon : lon )
      Target( $label2 : label, time == $time, $lat2 : lat, $lon2 : lon )
      eval( $label.compareTo( $label2 ) < 0 )
	then
      float s1 =  $lat.floatValue() - $lat2.floatValue();
      float s2 =  $lon.floatValue() - $lon2.floatValue();
      double distance = Math.sqrt( s1*s1 + s2*s2 );
      if ( distance < 8.0 )
      {
        Close cl = new Close();
        cl.label = $label;
        cl.label2 = $label2;
        cl.time = $time;
        cl.distance = new Float( distance );
        cl.bearing = new Float( 144.9 );
        assert( cl );
      }
end

rule "Close Retract"
	salience -100
	when
      $cls : Close( $label : label, $label2 : label2, $time : time )
      Close( label == $label, label2 == $label2, time > $time )
	then
      retract( $cls );
end

rule "Approach Begin"
	when
      $cls1 : Close( $label : label, $label2 : label2, $time : time, $distance : distance, $bearing : bearing )
      not Approach( label == $label, label2 == $label2 )
      $cls2 : Close( label == $label, label2 == $label2, $time2 : time > $time, $distance2 : distance < $distance, $bearing2 : bearing )
	then
      Approach a = new Approach();
      a.label = $label;
      a.label2 = $label2;
      a.distance = $distance;
      a.distance2 = $distance2;
      a.time = $time;
      a.time2 = $time2;
      a.bearing = $bearing;
      a.bearing2 = $bearing2;
      assert( a );
      retract( $cls1 );
end

rule "Approach Continue"
	no-loop true
	when
      $app : Approach( $label : label, $label2 : label2, $time2 : time2, $distance2 : distance2 )
      Close( label == $label, label2 == $label2, $time3 : time > $time2, $distance3 : distance <=  $distance2, $bearing3 : bearing )
	then
      $app.distance2 = $distance3;
      $app.bearing2 = $bearing3;
      $app.time2 = $time3;
      modify( $app );
end

rule "Danger Distance Warning"
	when
      Approach( $label : label, $label2 : label2, $distance2 : distance2, $time2 : time2, $bearing2 : bearing2 )
      Target( label == $label, time == $time2, $speed : speed, $course : course )
      eval( $distance2.floatValue() <= 5.2 )
	then
      //System.out.println( "Danger Distance Warning "+$label+" "+$label2+" distance: "+$distance2 );
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -