1
826220679@qq.com
2023-07-22 734291355c39914629aafb6ae1b0b925b0e88538
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package baowen;
 
import java.math.BigInteger;
 
import DataBase.DatabaseManagement;
import frame.Index1;
import publicclass.GetNowTime;
import publicclass.JugeNumber;
import publicclass.ShowMessage;
 
public class Dell_55aa0c {
    
    static String tagid=null;
    static int  power=-1;
    static int  baoxu;
    static int stationary_flag;
    static int tag_hz;
    static int shijianpian;
    static int anchornum;
    static int heart;//ÐÄÂÊ
    static String nowzhendong;//Õð¶¯×´Ì¬
    static int taggao ;//±êǩʵʱ¸ß¶È
    static String ancgasid;//Èýά²Î¿¼»ùÕ¾ID
    static int angas;
    static int gascha;
    static int gasancgao;
    static String qiya;//ÆøÑ¹¼ÆÖµ
    static int qiyaji;
    static StringBuffer data=new StringBuffer();
    static StringBuffer anchids=new StringBuffer();
    static StringBuffer distances=new StringBuffer();
    static String[] hex;
 
    public static void dell55aa0c_start(String message,String ip,int port) {
        if(!message.startsWith("55AA0C")) {
            return;
        }
        message=message.replaceAll("\r\n|\r|\n", "");//È¡³öËùÓГQÐкͻسµ
        String[] aa0=message.split("55AA");
        int size=aa0.length;
        for(int i=0;i<size;i++) {
            String info="55AA"+aa0[i];
            dell_55aa0c(info,ip,port);
        }
    }
 
    //´¦Àí55AAOC¿ªÍ·µÄ±¨ÎÄ
    public static void dell_55aa0c(String message,String ip,int port) {
 
        int lenth=message.length();
        int timestamp=GetNowTime.timestamp();
        String intime=GetNowTime.timestamp2();
        if(lenth>10) {
            hex=hex(message);
            String type= hex[2] ;//Ö¸ÁîÀàÐÍ
            if(!type.equals("0C")) {
                return;
            }
            int datalenth1=decodeHEX(hex[3]) ;//Êý¾Ý³¤¶È
            datalenth1=datalenth1*2+8;
            if(lenth==datalenth1) {                        
                tagid=hex[5]+hex[4];//±êÇ©ID
                power=decodeHEX(hex[8]);//µçÁ¿
                baoxu=decodeHEX(hex[7]+hex[6]);//°üÐò
                tag_hz=decodeHEX(hex[12]);//±êǩƵÂÊ
                anchornum=decodeHEX(hex[16]);//»ùÕ¾ÊýÁ¿
//                String ancrid0=hex[18]+hex[17];//µ±Ç°²â¾àµÄÖ÷»ùÕ¾
                String[] anchorid=new String[anchornum];//»ùÕ¾ID¼¯ºÏ            
                int[] distance=new int[anchornum];//»ùÕ¾¾àÀ뼯ºÏ
                int dis1=anchornum*2+17;
                int dis2=dis1+1;
                int dis3=dis1+2;
                int dis4=dis1+3;
                for(int i=0;i<anchornum;i++) {                
                    anchorid[i]=hex[18+i*2]+hex[17+i*2];
                    distance[i]=decodeHEX(hex[dis4+i*4]+hex[dis3+i*4]+hex[dis2+i*4]+hex[dis1+i*4]);
                    addbuf(anchids,i,anchorid[i]);
                    addbuf(distances,i,String.valueOf(distance[i]));
                }                
                showdata();
            }else {//Èç¹û±¨Îij¤¶È²»µÈÓÚÐèÒªµÄ³¤¶È¿ÉÄÜÁ¬°üÁË
                Dell_uanshi_byt.intsert(ip,message,intime, timestamp,port);
            }
        }else {//Èç¹û±¨Îij¤¶È²»×ã10
            Dell_uanshi_byt.intsert(ip,message,intime, timestamp,port);
        }
 
    }
 
    
 
    //½«Êý¾Ý²åÈëÊý¾Ý¿â
    public static void indatabase(String anchorid,String distance, String power) {
        if (power.equals("0")) {
            power="1";
        }
        String[]  ziduan= {"tagid","anchorid","distance","power","addtime"};
        String[] zhi= {tagid,anchorid,distance ,power,GetNowTime.now()};
        DatabaseManagement.insertfast("tb_door", ziduan, zhi);
    }
    public static String[] hex(String message) {
        int size=message.length()/2;        
        String[] hex=new String[size];
        for(int i=0;i<size;i++) {
            hex[i]=message.substring(i*2, 2+i*2);
        }
 
        return hex;
    }
 
    /**16½øÖÆ×ªÎª10½øÖÆ*/
    public static int decodeHEX(String hexs){
        String hex=hexs.trim();
        boolean a=JugeNumber.isLetterDigit(hex);
        int numb=0;
        if(a) {
            BigInteger bigint=new BigInteger(hex,16);
            numb=bigint.intValue();
        }else {
            ShowMessage.zidingyi_24("16½øÖÆ×ª10½øÖƳö´í,ÊÕµ½£º"+hex);
        }
        return numb;
 
    }
 
    /**±¨ÎÄÏÔʾµ÷ÓÃ*/
    public static void showdata() {
        if(Index1.getTagid().equals("ԭʼÊý¾Ý")) {
            return;
        }
        if(Index1.isShoware()) {
            data.append("ID:"+tagid+",");
            data.append("°üÐò:"+baoxu+",");
            data.append("µçÁ¿:"+power+",");
            data.append("»ùÕ¾Êý:"+anchornum+",");
            data.append("±àºÅ:"+anchids+",");
            data.append("¾àÀë:"+distances+",");            
            String as=data.toString();    
            if(Index1.getTagid().equals("0")) {
                Index1.ara_show(as);
            }else {
                if(Index1.getTagid().equals(tagid)) {
                    Index1.ara_show(as);
                }
            }            
            data.setLength(0);
            anchids.setLength(0);
            distances.setLength(0);
        }
 
    }
 
    /**Ìí¼Ó»ùÕ¾½øÈ뱨ÎÄ*/
    public static void addbuf(StringBuffer buf,int i,String anchorid) {
        if(Index1.isShoware()) {
            if(anchornum==1) {
                buf.append("["+anchorid+"]");
            }else {
                if(i==0) {
                    buf.append("["+anchorid+",");
                }else if(i==(anchornum-1)) {
                    buf.append(anchorid+"]");
                }else {
                    buf.append(anchorid+",");
                }
            }
        }
    }
    
    
}