zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
package BaoWen;
import Frame.TcpIpManage;
import Judge.JugeNumber;
import Method.*;
import ToolBarS.ToolBarModel;
import anchor.Anchor;
import anchor.Anchor_Dell;
import jiekou.Warnig;
import person.Person;
import person.person_Dell;
import tag.Tag;
import tag.Tag_Dell;
import tbDataModel.Tb_gps;
import tbDataModel_Dell.Dell_tb_suanfa2;
import urt.Dell_gps;
 
 
/*
 * Êý¾Ý¸ñʽ:55AA12+Ö¸ÁîÀàÐÍ+ Êý¾Ý¶Î³¤¶È+±êÇ©ID+±êÇ©°üÐò+µçÁ¿+°´¼ü+±êÇ©Ïà¶Ô¸ß¶È+±£Áô+»ùÕ¾ÊýÁ¿+»ùÕ¾ID+»ùÕ¾¾àÀë+»ùÕ¾µçÁ¿+УÑé
 * 1.°üÍ·£¬55AA,£»¡¾0,1¡¿
 * 2.Ö¸ÁîÀàÐÍ,12£»¡¾2¡¿
 * 3.Êý¾Ý³¤¶È£¬15+5*»ùÕ¾ÊýÁ¿£»¡¾3¡¿
 * 4.±êÇ©ID£¬2£»¡¾4,5¡¿
 * 5.±êÇ©°üÐò£¬2£»¡¾6,7¡¿
 * 6.µçÁ¿£¬1£»¡¾8¡¿
 * 7.°´¼ü£¬1£»¡¾9¡¿
 * 8.±êÇ©Ïà¶Ô¸ß¶È£¬2£»¡¾10,11¡¿
 * 9.±£Áô,4£¬¡¾12,13,14,15¡¿
 * 10.»ùÕ¾ÊýÁ¿£¬1£¬¡¾16¡¿
 * 11.»ùÕ¾ID£¬2*»ùÕ¾ÊýÁ¿¡¾17,17+2*»ùÕ¾ÊýÁ¿¡¿
 * 12.»ùÕ¾¾àÀ룬2*»ùÕ¾ÊýÁ¿¡¾17+2*»ùÕ¾ÊýÁ¿£¬18+2*»ùÕ¾ÊýÁ¿¡¿
 * 13.»ùÕ¾µçÁ¿£¬»ùÕ¾ÊýÁ¿¡¾17+4*»ùÕ¾Êý¾ÝÁ¿£¬18+4*»ùÕ¾Êý¾ÝÁ¿¡¿
 * 14.УÑé
 * 55AA12 19 7218 9400 46 00 0300 00000000 02 3693 4093 5803 7301 1B 1A CBFB
 */
public class Dell_55AA12 {
    static String tagid ;
    static int tagid_int;
    static int baoxu_int;
    static String baoxu;
    static int power = -1;
    static String button;//sos
    static String jingzhi;//¾²Ö¹
    static String xiumian;//ÐÝÃß
    static String tagoff;//±êÇ©±»²ð³ý
    static int tag_height = 0;//ÆøÑ¹¼Æ¸ß¶È
    static int anchornum = 0;
    static StringBuffer data = new StringBuffer();
    static StringBuffer anchids = new StringBuffer();
    static StringBuffer distances = new StringBuffer();
    static StringBuffer acpowers = new StringBuffer();
    static boolean datashow = false;
    static Person person = null;
    static Tag tag = null;
    static int[] anchorid_int ;//»ñÈ¡²â¾à»ùÕ¾µÄ¼¯ºÏintÐÍ»ùÕ¾ID20230708
    static int[] distance ;//»ñÈ¡¾àÀëµÄ¼¯ºÏ20230708yang
    static int[] anchorxinhao;//»ùÕ¾ÐźÅÇ¿¶ÈµÄ¼¯ºÏ120230708yang
    static int[] anchorxinhao2;//»ùÕ¾ÐźÅÇ¿¶ÈµÄ¼¯ºÏ220230708yang
    static String[] anchorid;
    static String[] hex;
    static int[] anchor_power ;//»ùÕ¾µçÁ¿¼¯ºÏ
    static String ip;
    static int port;
    static int zhengdongint;
    static String intime;
    static int timestamp;
 
    public static void dell_12(String ip1, String intime1, String message, int timestamp1, int port1) {        
        ip=ip1;
        port=port1;
        intime=intime1;
        timestamp=timestamp1;
        message = message.replaceAll("\r\n|\r|\n", "");//È¡³öËùÓГQÐкͻسµ
        int lenth = message.length();
        if (lenth < 10) {//³¤¶È²»¶Ô²»´¦Àí
            Dell_uanshi_byt.intsert(ip, message, intime, timestamp, port);
            return;
        }
        isshow();//ÊÇ·ñÐèÒªÏÔʾ±¨ÎÄ        
        hex = StringToHex.hex(message);//ԭʼÊý¾Ý
        int datalenth1 = DellMessage.decodeHEX(hex[3]);//Êý¾Ý³¤¶È
        datalenth1 = datalenth1 * 2 + 8;
        if (lenth == datalenth1) {
            tagid = hex[5] + hex[4];//±êÇ©ID
            tagid_int = Integer.parseInt(tagid, 16);
            baoxu_int = DellMessage.decodeHEX(hex[7]+hex[6]);//°üÐò
            baoxu = String.valueOf(baoxu_int);
            power = DellMessage.decodeHEX(hex[8]);//µçÁ¿            
            String nowzhendong =get_anjian_value(hex[9],2); //Õð¶¯×´Ì¬
            zhengdongint = Integer.parseInt(nowzhendong);
            tagoff =get_anjian_value(hex[9],4);//±êÇ©·À²ð
            xiumian =get_anjian_value(hex[9],5);//±êÇ©ÐÝÃß
            jingzhi =get_anjian_value(hex[9],6);//±êÇ©¾²Ö¹
            button =get_anjian_value(hex[9],7);
            tag_height = DellMessage.decodeHEX(hex[11] + hex[10]);//±êÇ©Ïà¶Ô¸ß¶È
            anchornum = DellMessage.decodeHEX(hex[16]);//»ùÕ¾ÊýÁ¿
            anchorid = new String[anchornum];//»ùÕ¾ID¼¯ºÏ
            anchorid_int = get_anchorids_int();//´¦Àí»ùÕ¾µÄID¼¯ºÏ
            distance =get_distance_int();//»ùÕ¾¾àÀ뼯ºÏ
            anchor_power = get_anchor_power();//»ùÕ¾µçÁ¿¼¯ºÏ
            anchorxinhao=new int[anchornum]; //ûÓÐÐźÅÇ¿¶ÈĬÈÏΪ0
            anchorxinhao2=new int[anchornum];//ûÓеڶþ·ÐźÅÇ¿¶ÈΪĬÈÏÖµ
            jie_xi_ok();
            showdata(ip, port);//±¨ÎÄÏÔʾ
        } else {
            Dell_uanshi_byt.intsert(ip, message, intime, timestamp, port);
        }
        if(Dell_tb_suanfa2.isJnalog_open()){
            SaveFIleInTxt.save_jiexibaowen(message, Dell_baowen_55AA0C.getFile());
        }
    }
 
    /**
     * ±¨ÎÄÊÇ·ñÒªÏÔʾ
     */
    public static void isshow() {
        boolean baowen = TcpIpManage.getDatatypeis().equals("±¨ÎÄÊý¾Ý");
        if (TcpIpManage.getStar() && baowen) {
            datashow = true;
        } else {
            datashow = false;
        }
    }
 
 
    /**20230807»ñÈ¡²â¾à»ùÕ¾µÄ¼¯ºÏ*/
    public static int[] get_anchorids_int() {
        int[] anchorid_int = new int[anchornum];
        for (int i = 0; i < anchornum; i++) {
            anchorid[i] = hex[18 + i * 2] + hex[17 + i * 2];
            anchorid_int[i] = Integer.parseInt(anchorid[i], 16);
            addbuf(anchids, i, anchorid[i]);
        }
        return anchorid_int;
    }
 
    /**
     * Ìí¼Ó»ùÕ¾½øÈ뱨ÎÄ
     */
    public static void addbuf(StringBuffer buf, int i, String anchorid) {
 
        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 + ",");
            }
 
        }
    }
 
 
    /**20230708»ñÈ¡²â¾à»ùÕ¾¾àÀëµÄ¼¯ºÏ*/
    public static int[] get_distance_int() {
        int[] distance = new int[anchornum];
        int dis1 = anchornum *2 + 17;
        int dis2 = dis1 + 1;
        for (int j = 0; j < anchornum; j++) {
            distance[j]=DellMessage.decodeHEX(hex[dis2+j*2]+hex[dis1+j*2]);            
            addbuf(distances, j, String.valueOf(distance[j]));
        }
        return distance;
    }
 
    /**
     * ´¦Àí»ùÕ¾µçÁ¿
     */
    public static int[] get_anchor_power() {
        int[] anchor_power = new int[anchornum];
        if (anchornum != 0) {
            for (int i = 0; i < anchornum; i++) {
                anchor_power[i] = DellMessage.decodeHEX(hex[17 + 4 * anchornum + i]);
                Anchor acr = Anchor_Dell.get_anchor(anchorid[i]);
                Anchor_Dell.set_anchor_mode(acr,anchorid[i], ip, port);//Ð޸ĻùÕ¾ÔÚÏß״̬
                if (acr != null) {
                    acr.setBaoliu8(anchor_power[i]+"%");//ÉèÖûùÕ¾µçÁ¿
                    dell_anchorpower_err(acr ,anchor_power[i]);
                }                
                addbuf(acpowers, i, String.valueOf(anchor_power[i]));
            }
        }
        return anchor_power;
    }
 
 
    /**
     * ×Ô¶¯Ìí¼Ó±êÇ©
     */
    public static void add_tag_auto() {
        if (ToolBarModel.isAddtagzidong()) {    //Èç¹ûÆô¶¯×Ô¶¯Ìí¼Ó±êÇ©,×Ô¶¯Ìí¼Ó±êÇ©
            AddTagZidong.auto_addtag(tagid, String.valueOf(power));
        }
    }
 
    /**
     * ±¨ÎÄÏÔʾµ÷ÓÃ
     */
    public static void showdata(String ip, int port) {
        if (!TcpIpManage.isShowfrom()) {//Èç¹ûÏÔʾÊý¾ÝÀ´Ô´
            data.append(GetNowTime.timestamp2() + ",from:" + ip + ":" + port + ",");
        }
        if (datashow) {
            data.append("±êÇ©:" + tagid + ",");
            data.append("¾²Ö¹:" + jingzhi + ",");
            data.append("°´¼ü:" + button + ",");
            data.append("°üÐò:" + baoxu_int + ",");
            data.append("µçÁ¿:" + power + ",");
            data.append("²ð³ý:" + tagoff + ",");
            data.append("ÐÝÃß:" + xiumian + ",");
            data.append("Ïà¶Ô¸ß:" + tag_height + ",");
            data.append("»ùÕ¾Êý:" + anchornum + ",");
            data.append("»ùÕ¾ID:" + anchids + ",");
            data.append("¾àÀë:" + distances + ",");
            data.append("µçÁ¿:" + acpowers);
            String as = data.toString() + "\n ";
            BaoWenShow.showbaowen4("±¨ÎÄÊý¾Ý", as, tagid);
            data.setLength(0);
            anchids.setLength(0);
            distances.setLength(0);
            acpowers.setLength(0);
        }
    }
 
    /**
     * ¸Ä±äÈËÔ±µÄÏà¹ØÊý¾Ý
     */
    public static void change_person(String tagid, Person person, String ip, int port) {
        if (person != null) {
            String portr = String.valueOf(port);
            person.setBaoliu8(ip);
            person.setBaoliu9(portr);
            Tb_gps gps = Dell_gps.get_tb_gps(tagid);
            if (gps != null) {
                gps.setIp(ip);
                gps.setPort(portr);
                gps.setAddtime(GetNowTime.HH_MM_SS());
            }
        }
    }
 
 
 
    /**»ñÈ¡°´¼üµÄÖµ*/
    public static String  get_anjian_value(String hex,int wei) {
        byte[] byt = DellMessage.HexStringToBinary(hex);
        String ac = DellMessage.bytes2BinaryStr(byt);//°´¼ü
        String value= String.valueOf(ac.charAt(wei));
        return value;
    }
    
    /**
     * Í¨¹ý¾àÀëÅжϱêÇ©ÊÇ·ñÔÚÊÒÄÚ
     */
    public static void distance_juge_indoor() {
        if (Dell_tb_suanfa2.isJuli_juge_in()) {//Èç¹ûͨ¹ý¾àÀëÅжÏÊÒÄÚÍ⹦ÄÜ¿ªÆô
            for (int j = 0; j < anchornum; j++) {
                if (distance[j] != 131071 && distance[j] != 0) {
                    distance[j] = distance[j] - tag.getBaoliu3();
                }            
                if (distance[j] > 900000 || distance[j] < -10000) {
                    continue; //Ìø³öµ±Ç°µÄÑ­»·£¬¼ÌÐøÖ´ÐÐforÑ­»·µÄÏÂÒ»¸öÑ­»·Ìå
                }
            }
            Dell_55AA0C.juli_juge_indoor(anchorid, distance, person);//ͨ¹ý¾àÀëÅжÏÊÇ·ñÔÚÊÒÄÚ
        }
    }
 
 
 
    /**½âÎöºÏ·¨µÄÊý¾Ý*/
    public static void jie_xi_ok() {
        tag = Tag_Dell.get_tag(tagid);
        if (tag == null) {//Èç¹û±êÇ©²»´æÔÚÔò·µ»Ø
            add_tag_auto();//×Ô¶¯Ìí¼Ó±êÇ©
            return;
        }
 
        if (anchornum == 0) {//ûÓлùÕ¾²â¾à
            return;
        }
        if (BaoxuID.get_bxid(tagid_int) != null) {
            int lastbaoxu = BaoxuID.get_bxid(tagid_int).getLastbaoxu();
            if (baoxu_int > lastbaoxu || baoxu_int < (lastbaoxu - 10)) {
                BaoxuID.add_idbaoxu(tagid_int, baoxu_int, lastbaoxu);
            } else {
                data.append("°üÐòerro: ");
                return;
            }
        } else {
            BaoxuID.add_idbaoxu(tagid_int, baoxu_int, baoxu_int);
        }
 
        have_person_do();//´¦ÀíÈËÔ±Êý¾Ý            
        distance_juge_indoor();//ͨ¹ý¾àÀëÅжÏÊÇ·ñÔÚÊÒÄÚ
        Warnig.sos(tag, tagoff, button, jingzhi, xiumian, tagid, intime, baoxu, person);//SOS¸æ¾¯        
        Have_ceju_message_do.dosometing(tagid, String.valueOf(power), ip, button, anchorid,
                tagoff, distance, xiumian, jingzhi, person);
 
        AA0CToJNA.ToJNA(//Êý¾Ý¸øµ½JNA,dimension[] Ë㷨ѡÔñ1ÊÇ1ά2ÊǶþά
                person,
                tagid,
                intime,//²åÈëʱ¼ä
                baoxu,//°üÐò
                baoxu_int,//°üÐòÕûÊý
                String.valueOf(power),//µç³ØµçÁ¿
                String.valueOf(button),//SOS¸æ¾¯
                timestamp,// Ê±¼ä´Á
                Anchor_Dell.anchor_xyz(anchorid, "x"),// »ùÕ¾x×ø±ê¼¯ºÏ
                Anchor_Dell.anchor_xyz(anchorid, "y"),
                Anchor_Dell.anchor_xyz(anchorid, "z"),
                distance,// ¾àÀëµÄ¼¯ºÏ
                anchornum,// »ùÕ¾ÊýÁ¿
                anchorid_int,//»ùÕ¾id
                tagid_int,// ±êÇ©ID
                get_tag_heigh(),// ±êÇ©¸ß¶È
                get_tag_hz(),//±êǩƵÂÊ
                get_tagspeed_limit(),// ±êÇ©ËÙ¶ÈÏÞÖÆ
                distance, //»ùÕ¾¾àÀë
                Integer.parseInt(jingzhi),//±êǩֹ״̬
                anchorxinhao,//µÚ1·ÐźÅÇ¿¶È
                anchorxinhao2,//µÚ2·ÐźÅÇ¿¶È
                Anchor_Dell.anchor_floor(anchorid),//»ùÕ¾ËùÔڵIJã
                tag_height,//ÆøÑ¹¼ÆÖµ
                anchorid//»ùÕ¾ID¼¯ºÏ
                );
    }
 
    /**´¦ÀíÈËÔ±Êý¾Ý*/
    public static void have_person_do() {
        person = person_Dell.get_Person(tagid);
        if(person !=null) {
            person.setXinhaotime(GetNowTime.now());
            person.setNowzhendong(zhengdongint);
            person.setUwbopen(1);
            change_person(tagid, person, ip, port);//¸Ä±äÈËÔ±Êý¾Ý    
        }
    }
 
    public static int get_tag_heigh() {
        int tag_heigh = 150;//±êÇ©Åå´÷¸ß¶È
        if (JugeNumber.isDigit(tag.getTag_pos_z())) {
            tag_heigh = Integer.parseInt(tag.getTag_pos_z());
        }
        return tag_heigh;
    }
 
    public static int get_tag_hz() {
        int tag_hz = person.getRealhz();
        if (tag_hz == -1) {
            tag_hz = Integer.parseInt(tag.getTag_pinglv());
        }
        return tag_hz;
    }
 
    public static int get_tagspeed_limit() {
        int tagspeed_limit = 100000;//±êÇ©µÄËÙ¶ÈÏÞÖÆÖµ
        String sulv = tag.getTag_sulv();
        if (JugeNumber.isDigit(sulv)) {
            tagspeed_limit = Integer.parseInt(sulv);
        }
        return tagspeed_limit;
    }
 
    /**´¦Àí»ùÕ¾²â¾à¾àÀëÒì³£Çé¿öyang20230910*/
    public static void dell_anchordistance_err(String anchorid ,int dis) {
        Anchor anchor=Anchor_Dell.get_anchor(anchorid);
        if(dis==0) {//Èç¹û²â¾à¾àÀëΪ0
            int a1=anchor.getDis_err_num()+1;
            anchor.setDis_err_num(a1);
            if(anchor.getAnchor_distance_state() !=1) {//Èç¹û»ùվ֮ǰµÄ²â¾à״̬Õý³£
                anchor.setAnchor_distance_state(1);//»ùÕ¾²â¾à״̬Òì³£
                String zuobiao=anchor.getAnc_x()+","+anchor.getAnc_y()+","+anchor.getAnc_z();
                InsertData.sosInsertTbWarning(anchorid,"²â¾àÒì³£", "δ´¦Àí",zuobiao);//½«¸æ¾¯¼Ç¼³öÈëµ½Êý¾Ý¿â
                Anchor_Dell.set_anchor_image(4,anchorid);
            }
        }else {
            if(anchor.getAnchor_distance_state() ==1) {
                anchor.setAnchor_distance_state(0);    //»ùÕ¾²â¾à״̬ΪÕý³£
                //            Anchor_Dell.set_anchor_image(1,anchorid);
            }
        }
    }
 
    /**´¦Àí»ùÕ¾µçÁ¿Òì³£Çé¿öyang20230910*/
    public static void dell_anchorpower_err(Anchor anchor,int power) {
        if(power<5) {//Èç¹ûµçÁ¿Ð¡ÓÚ5            
            if(anchor.getAnchor_power_state()==0) {//Èç¹û»ùվ֮ǰµÄµçÁ¿×´Ì¬Õý³£
                anchor.setAnchor_power_state(1);//»ùÕ¾µçÁ¿×´Ì¬Òì³£
            }
        }else {
            anchor.setAnchor_power_state(0);    ////»ùÕ¾µçÁ¿×´Ì¬ÎªÕý³£
        }
    }
 
 
}