1 24 25 26 30 31 package org.objectweb.clif.analyser; 32 33 import java.io.*; 34 import java.util.*; 35 import java.lang.Math ; 36 import org.objectweb.clif.analyser.lib.gui.GuiPanelAutomaticAnalyser; 37 38 39 40 44 public class Rule 45 { 46 private String name; 47 protected Hypothesis[] hyp; 48 private Thread thisThread; 49 private volatile Thread [] monitor= new Thread [100]; 50 51 52 53 public Rule(String name, String hypo, String test, String machine, String thread, int X, int Y, String interval, int fonction, String fresult) 56 { 57 this.name = name; 58 this.hyp = new Hypothesis[100]; 59 hyp[0] = new Hypothesis(hypo,test,machine,thread,X,Y,interval,fonction,fresult); 60 } 61 62 63 public String getName() { return name; } 64 65 66 67 70 public void updateRule(String hypo,String test,String machine,String thread,int X,int Y,String interval,int fonction,String fresult) 71 { 72 int i; 73 for(i=0; hyp[i] != null; i++) 74 if(hyp[i].getName().equals(hypo)) 75 { 76 hyp[i].updateHyp(test,machine,thread,X,Y,interval,fonction,fresult); 77 break; 78 } 79 if(hyp[i] == null) hyp[i] = new Hypothesis(hypo,test,machine,thread,X,Y,interval,fonction,fresult); 80 } 81 82 83 84 87 public void eraseHyp(String name,String hypo) 88 { 89 int i,j; 90 int etat =0; 91 for(i=0; hyp[i] != null; i++) 92 if(hyp[i].getName().equals(hypo)) 93 { 94 for(j=i; hyp[j] != null; j++) hyp[j] = hyp[j+1]; 95 etat = 1; 96 } 97 if(etat==0) System.out.println("l'hypothese "+hypo+" n'existe pas ! impossible de l'effacer..."); 98 AutomaticAnalyser aa = new AutomaticAnalyser(); 99 if(i==1) aa.eraseRule(name); 100 } 101 102 103 107 public void start() 108 { 109 System.out.println("rule "+getName() +" started"); 110 for(int i=0;hyp[i]!=null;i++) 111 { 112 hyp[i].start(); 113 } 114 } 115 116 117 121 public void stop() 122 { 123 System.out.println("rule "+getName() +" stopped"); 124 for(int i=0;hyp[i]!=null;i++) 125 { 126 hyp[i].stop(); 127 } 128 } 129 130 } 131 | Popular Tags |