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); ////»ùÕ¾µçÁ¿×´Ì¬ÎªÕý³£ } } }