method_update.java
来自「RFID复杂事件处理系统的研究实验」· Java 代码 · 共 206 行
JAVA
206 行
package test2;
import java.util.LinkedList;
public class Method_update {
private static double k;
public static void manage(P_Event pe,LinkedList<C_Event> cell)
{
int i;
for(i=0;i<Detection.getAtree().getLeafnodes().size();i++)
{
if(Detection.getAtree().getLeafnodes().get(i).gettype()==pe.gettype())
break;
}
if(i!=Detection.getAtree().getLeafnodes().size())
{
int ii=Detection.getAtree().getLeafnodes().get(i).insert0(pe);//定位插入位置
int nn=Detection.getAtree().getLeafnodes().get(i).getevents().size();
if(ii==nn-1)
{
if(Detection.getAtree().getLeafnodes().get(i).getmode()==0){
for(int j=0;j<Detection.getAtree().getLeafnodes().get(i).getparent().size();j++)
{
active(Detection.getAtree().getLeafnodes().get(i).getparent().get(j),Detection.getAtree().getLeafnodes().get(i),Detection.getAtree(),cell);
}
}
}else{
//解决乱序:
active(ii,Detection.getAtree().getLeafnodes().get(i).getparent().get(0),Detection.getAtree().getLeafnodes().get(i),Detection.getAtree(),cell);
}
}
}
public static void active(int ii,NonLeaf n,Node n2,Tree atree,LinkedList<C_Event> cell)
{
LinkedList<C_Event> cel=new LinkedList<C_Event>();
if(n.getoperator().equals(";"))
{
Sequence nn=(Sequence)n;
cel=nn.work0(ii,n, n2);
}
if(cel.size()!=0){
if(atree.getRoot()==n)
{
for(int j=0;j<cel.size();j++){
C_Event ce=cel.get(j);
cell.addLast(ce);
long t =System.nanoTime()/1000000;
Detection.increaseDelay(t-ce.gett_end());
ce.setDelay(t-ce.gett_end());
int m=n.checkeffect(ce);
if(m==Integer.MAX_VALUE)
{
System.out.println("此刻延迟="+Detection.getDelay());
n.add_mr(ce);
Detection.increaseResultnum();
LinkedList<P_Event> pel=ce.getel();
//System.out.println("<<<<<<<<<<<<<<<<");
System.out.println();
System.out.println("产生新的匹配结果:");
for(int k=0;k<pel.size();k++)
{
System.out.print(pel.get(k).gettype());
System.out.print(pel.get(k).gettimestamp()+" ");
}
System.out.println();
//System.out.println(">>>>>>>>>>>>>>>>");
}
else{
C_Event ce1=new C_Event();
ce1=n.getmid_result().get(m);
int kk;
for(kk=0;kk<cell.size();kk++)
{
if(cell.get(kk).equal(ce1)) break;
}
cell.remove(kk);
Detection.increaseDelay(-ce1.getDelay());
System.out.println("此刻延迟="+Detection.getDelay());
LinkedList<P_Event> pel=ce1.getel();
//System.out.println("<<<<<<<<<<<<<<<<");
System.out.println();
System.out.println("错误的匹配结果:");
for(int k=0;k<pel.size();k++)
{
System.out.print(pel.get(k).gettype());
System.out.print(pel.get(k).gettimestamp()+" ");
}
System.out.println();
//System.out.println(">>>>>>>>>>>>>>>>");
n.getmid_result().set(m, ce);
LinkedList<P_Event> pel1=ce.getel();
//System.out.println("<<<<<<<<<<<<<<<<");
System.out.println();
System.out.println("修改后的匹配结果:");
for(int k=0;k<pel1.size();k++)
{
System.out.print(pel1.get(k).gettype());
System.out.print(pel1.get(k).gettimestamp()+" ");
}
System.out.println();
//System.out.println(">>>>>>>>>>>>>>>>");
}
}
}else{
//
int jj=-1;
for(int j=0;j<cel.size();j++){
C_Event ce=cel.get(j);
int m=n.checkeffect(ce);
if(m==Integer.MAX_VALUE)
{
if(jj==-1)
jj=n.add_mr(ce);
else n.add_mr(ce);
}
else{
n.getmid_result().set(m, ce);
if(jj==-1)
jj=m;
}
}
active(jj,n.getparent().get(0),n,atree,cell);
/*if(Detection.getMaxsize()<Detection.getsize())
Detection.setMaxsize(Detection.getsize());
System.out.println("此刻内存中存储的最大基本事件个数="+Detection.getMaxsize()); */
}
}else{
/*if(Detection.getMaxsize()<Detection.getsize()) Detection.setMaxsize(Detection.getsize());
System.out.println("此刻内存中存储的最大基本事件个数="+Detection.getMaxsize());*/
}
}
public static void active(NonLeaf n,Node n2,Tree atree,LinkedList<C_Event> cell)
{
C_Event ce=null;
if(n.getoperator().equals(";"))
{
Sequence nn=(Sequence)n;
ce=nn.work(n, n2);
}
if(ce!=null){
n.getmid_result().addLast(ce);
if(atree.getRoot()==n)
{
long t =System.nanoTime()/1000000;
Detection.increaseDelay(t-ce.gett_end());
System.out.println("此刻延迟="+Detection.getDelay());
cell.addLast(ce);
Detection.increaseResultnum();
//LinkedList<P_Event> pel=ce.getel();
//System.out.println("<<<<<<<<<<<<<<<<");
//System.out.println();
//System.out.println("产生匹配结果:");
//for(int j=0;j<pel.size();j++)
//{
// System.out.print(pel.get(j).gettype());
// System.out.print(pel.get(j).gettimestamp()+" ");
//}
//System.out.println();
//System.out.println();
//System.out.println(">>>>>>>>>>>>>>>>");
}else{
if(n.getmode()==0){
for(int i=0;i<n.getparent().size();i++)
{
active(n.getparent().get(i),n,atree,cell);
}}//else{
// if(Detection.getMaxsize()<Detection.getsize()) Detection.setMaxsize(Detection.getsize());
// System.out.println("此刻内存中存储的最大基本事件个数="+Detection.getMaxsize());
//}
}
}//else{
// if(Detection.getMaxsize()<Detection.getsize()) Detection.setMaxsize(Detection.getsize());
//System.out.println("此刻内存中存储的最大基本事件个数="+Detection.getMaxsize());
//}
}
public static double getK() {
return k;
}
public static void setK(double k) {
Method_update.k = k;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?