package BaoWen; import java.util.Vector; import Frame.SystemSet; import Frame.TagReaLocation; import Frame.Tagstate; import Frame.TcpIpManage; import JNADell.DellJAN; import Method.BaoWenShow; import Method.ControTag; import Method.GetNowTime; import Method.JugeHaveZimu; import Method.StringToHex; import PbuliClass.Shi_jian_cha_sss; import PbuliClass.ShowMessage; import PbuliClass.Systems; import ToolBarS.ToolBarModel; import anchor.Anchor; import anchor.Anchor_Dell; import home.ChuShiHua; import person.Person; import person.person_Dell; import tag.Tag; import tag.Tag_Dell; import tbDataModel_Dell.ReadPeizhiMessage; import tbDataModel_Dell.Read_Write_Anchor_Message; /**´¦Àí±êÇ©µÄ×¢²áÐÅÏ¢¼¯ºÏ*/ public class Dell_55AA0A { //±êǩע²á¶ÔÏóµÄ¼¯ºÏ static int zhiding=SystemSet.getZhuceanchor().length(); static boolean busy=false; static int bj=0; static Vector shijianpianvc=new Vector();//ʱ¼äƬµÄ¼¯ºÏ static Person person; static String tagid; static String anchorid; static int hz; static int power;//ÐźÅÇ¿¶È static String tagstate; static String move_open;//¿ªÆôÕñ¶¯01 static String sleep_open;//¿ªÆôÐÝÃß01 static String button;//°´¼ü״̬01±íʾ°´Ï static String version;//±êÇ©°æ±¾ºÅ static int gonglv;//±êÇ©µÄ¹¦ÂÊ static int speed;//±êÇ©µÄ¼ÓËÙ¼ÆãÐÖµ static int sleep_time;//±êÇ©¾²Ö¹ÐÝÃßʱ¼ä static int gas; /**´¦Àí×¢²áÐÅÏ¢ * Ö¸ÁîÀàÐÍ0x0A * Êý¾Ý¶Î³¤¶È20 * »ùÕ¾ID£¨2BYTE£© * ±êÇ©ID£¨2BYTE£©;6,7 * ±êǩ״̬£¨1BYTE£©;8 * µÚһλ£ºÕð¶¯Ê¹ÄÜ; * µÚ¶þλ£ºÐÝÃßʹÄÜ; * µÚÈýλ£º°´¼ü״̬; * ±êÇ©°æ±¾ºÅ£¨2BYTE£©;9,10 * ±êǩƵÂÊ£¨1BYTE£©; 11 * ±êÇ©¹¦ÂÊ£¨1BYTE£©; 12 * ±êÇ©¼ÓËÙ¼ÆãÐÖµ£¨2BYTE£©;13,14 * ±êÇ©¾²Ö¹ÐÝÃßʱ¼ä£¨2BYTE£© ;15,16 * ÐźÅÇ¿¶È£¨1BYTE£©; 17 * ÆøÑ¹²Î¿¼»ùÕ¾ID£¨2BYTE£©;18,19 * */ public static void dellrgs(String infom,String ip,int port) { BaoWenShow.show(infom, "55AA0A",""); String[] hex=StringToHex.hex(infom); anchorid=hex[5]+hex[4]; tagid=hex[7]+hex[6]; hz=get_value(hex[11]);//±êÇ©µÄƵÂÊ tagstate=DellMessage.bytes2BinaryStr(DellMessage.HexStringToBinary(hex[8])); move_open=tagstate.substring(7,8);//¿ªÆôÕñ¶¯01 sleep_open=tagstate.substring(6,7);//¿ªÆôÐÝÃß01 button=tagstate.substring(5,6);//°´¼ü״̬01±íʾ°´Ï version=get_versoin(hex[10],hex[9]);//±êÇ©°æ±¾ºÅ gonglv=get_value(hex[12]);//±êÇ©µÄ¹¦ÂÊ speed=get_value((hex[14]+hex[13]));//±êÇ©µÄ¼ÓËÙ¼ÆãÐÖµ sleep_time=get_value((hex[16]+hex[15]));//±êÇ©¾²Ö¹ÐÝÃßʱ¼ä power=get_value((hex[17]));//±êÇ©ÐźÅÇ¿¶È gas= Integer.valueOf(hex[19]+hex[18], 16).shortValue();//ÆøÑ¹¼ÆÖµ show_baowen(tagstate,move_open,sleep_open,version,gonglv,speed,sleep_time);//ÏÔʾ±¨ÎÄ Tag_Dell.alert_tag(tagid,version, move_open, sleep_open, button,gonglv,speed,sleep_time,power,gas); have_person_do(); have_anchor_do(ip,port); get_dell_hz();//´¦ÀíÆµÂÊ´óÓÚ20HzµÄÎÊÌâ have_tag_do(); } /**ѰÕÒÓÐЧµÄ×¢²áÐÅÏ¢¸øµ½JNA´¦Àí*/ public static void get_ok_regs() { if (Systems.isZidongshijianpian()) {//Èç¹û¿ªÆô×Ô¶¯Ê±¼äƬģʽ return; } Vector needpianvc=person_Dell.needpianvc(); int size=needpianvc.size(); if(size!=0) { for(int i=0;i-1) { getShijianpianvc().add(person); person.setPian(shijianpian); byte[] byt=Read_Write_Anchor_Message.write_timestamp(tagid, tag_freq, shijianpian);//¼ÆËã³öʱ¼äƬºó½«Êý¾Ý¸øµ½»ùÕ¾ if(anchor !=null) {//Èç¹ûÖ¸¶¨Á˸øÄ³¸ö»ùվϷ¢×¢²áÐÅÏ¢ if(zhiding>3) { anchorid=SystemSet.getZhuceanchor(); Anchor acr=Anchor_Dell.get_anchor(anchorid); if(acr !=null) { Udp_Receive.out(byt,byt.length,acr,"´¦Àí×¢²áÐÅÏ¢"); b1=true; } }else { Udp_Receive.out(byt,byt.length,anchor,"´¦Àí×¢²áÐÅÏ¢"); b1=true; } if(TcpIpManage.getStar() && b1) { BaoWenShow.show(a, "×¢²á±¨ÎÄ",tagid); } }else { if(bj==0) { a=anchorid+"·ÖƬʧ°Ü£¡"; BaoWenShow.show(a, "×¢²á±¨ÎÄ",tagid); bj=1; } } }else { person.setPian(-1); a="·ÖƬerr£º"+shijianpian; BaoWenShow.show(a, "×¢²á±¨ÎÄ",tagid); } } }else { ChuShiHua.setPiannedd(50); } } /**Ï·¢Ê±¼äƬ¸øµ½»ùÕ¾*/ public static void fenpian(String tagid,int tag_freq,int shijianpian) { if (Systems.isZidongshijianpian()) {//Èç¹û¿ªÆô×Ô¶¯Ê±¼äƬģʽ return; } Tag tag=Tag_Dell.get_tag(tagid); byte[] byt=Read_Write_Anchor_Message.write_timestamp(tagid, tag_freq, shijianpian); String anchorid=tag.getNowzhuceanchor(); String timez=tag.getZhucetime();//±êÇ©×î½üÏ·¢Ê±¼äƬʱ¼ä if(timez !=null) { int shicha=Shi_jian_cha_sss.get_time_cha_s(GetNowTime.now(), timez); if(shicha<2) {//Èç¹û×îÐÂ×¢²áµÄʱ¼ä²îСÓÚ2Ãë¾Í²»×¢²á return; } } String a=anchorid+"·Ö·¢Æ¬Ê§°Ü£¡"; if(!anchorid.equals("0")) { Anchor anchor=Anchor_Dell.get_anchor(anchorid); if(anchor !=null) { Udp_Receive.out(byt,byt.length,anchor,"´¦Àí×¢²áÐÅÏ¢"); tag.setZhucetime(GetNowTime.now()); if(TcpIpManage.getStar()) { a="·ÖƬ2£º"+tagid+"£¬ÆµÂÊ"+tag_freq+"£¬¸ø»ùÕ¾"+anchorid+",ʱ¼äƬ"+shijianpian; BaoWenShow.show(a, "×¢²á±¨ÎÄ",tagid); } } }else { BaoWenShow.show(a, "×¢²á±¨ÎÄ",tagid); } } /**ÐÞ¸Äijע²á»ùÕ¾¶ÔÏóÐÅÏ¢ *@param tagid±êÇ©id *@param anchor»ùÕ¾ID *@param powerÐźÅÇ¿¶È *@param timestampʱ¼ä´Á*/ public static void alert_xinhaoqiangdu(Tag tag,String anchorid,int newpower) { int oldpower=tag.getXinhaoqingdu(); if(newpower-oldpower<0) { person_Dell.get_Person(tag.getTag_id()).setZhuceanchor(anchorid); tag.setXinhaoqingdu(newpower); } } /**ɾ³ýʱ¼äƬµÄ·½·¨*/ public static void delete_pian(String tagid,int hz,String biaozhi) { Person psrson=person_Dell.get_Person(tagid); int pian=psrson.getPian(); if(hz !=0 ) { if(pian<0 ) { return; } String time=psrson.getXinhaotime(); int tagidint=0; if(JugeHaveZimu.haszimu(tagid)) { tagidint=ReadPeizhiMessage.decodeHEX(tagid); }else { tagidint=Integer.parseInt(tagid,16);//½«str ת»»³É 16½øÖÆÊýÖµ } int succ=DellJAN.delete_tag_from_slotted_aloha(tagid,tagidint, hz); String time1=GetNowTime.timestamp2();//ÏÔʾUDPת·¢µÄÊý¾Ý String a=biaozhi+"ɾ³ýƬ£º"+tagidint+","+tagid+",lastontime:"+time+",return:"+succ+","+time1; BaoWenShow.show(a,"×¢²á±¨ÎÄ",tagid); Person person=person_Dell.get_Person(tagid); person.setPian(-2); getShijianpianvc().removeElement(person); } } /**Ð޸ıêǩƵÂÊ*/ public static void alert_tag_hz(Tag tag,String tagid,int hz) { if(hz>20) { ControTag.set_tag_hz("1",tagid); } if(TagReaLocation.isAlerttaghz()) { String p=tag.getTag_pinglv(); int pinlv=Integer.parseInt(p); if(hz !=pinlv) { ControTag.set_tag_hz(p,tagid); } } } /**δÌí¼Ó±êÇ©·Öʱ¼äƬ*/ public static void noinfenpian(String anchorid,String tagid,int tag_freq) { if (Systems.isZidongshijianpian()) {//Èç¹û¿ªÆô×Ô¶¯Ê±¼äƬģʽ return; } Anchor anchor=Anchor_Dell.get_anchor(anchorid); //¼ÆËã³öʱ¼äƬºó½«Êý¾Ý¸øµ½»ùÕ¾ byte[] byt=Read_Write_Anchor_Message.write_timestamp(tagid, tag_freq, 0); //ÏÔʾע²á±¨ÎÄÐÅÏ¢ if(anchor !=null) { Anchor acr=Anchor_Dell.get_anchor(anchorid); if(acr !=null) { Udp_Receive.out(byt,byt.length,acr,"δÌí¼Ó±êÇ©·ÖÅäʱ¼äƬ"); } } } /**½«Ê±¼äƬÉèÖÃÔÚͬ²½·½·¨ÖÐ*/ public static synchronized Vector getShijianpianvc() { return shijianpianvc; } public static void setShijianpianvc(Vector shijianpianvc) { Dell_55AA0A.shijianpianvc = shijianpianvc; } /**ͨ¹ýʱ¼äƬÕÒµ½Ä³¸ö±êÇ©ID*/ public static Person getpersonpian(String tagid,int pian) { Person pers=null; for(int i=0;i6) { String anchorid=hex[5]+hex[4]; Anchor a=Anchor_Dell.get_anchor(anchorid); if(a !=null) { a.setAnc_ip(ip); a.setPort(port); } } } /**yang20230723 */ public static void have_person_do() { person=person_Dell.get_Person(tagid); if(person !=null) { person.setNow_ceju_anchorid(anchorid); person.setXinhaotime(GetNowTime.now()); person.setHavexinhao(true); person.setHz(hz); } } /**yang20230723 */ public static void have_anchor_do(String ip,int port) { Anchor a2=Anchor_Dell.get_anchor(anchorid); if(a2 !=null) { Anchor_Dell.set_anchor_mode(a2,anchorid,ip,port);//Ð޸ĻùÕ¾µÄÔÚÏß״̬¼°IP } } /**yang20230723 */ public static void have_tag_do() { Tag tag=Tag_Dell.get_tag(tagid); if(tag==null ) { if (ToolBarModel.isAddtagzidong()) {//×Ô¶¯Ìí¼Ó±êÇ© Tag_Dell.add_tag(tagid, "δ°ó¶¨", "150", "500", "1", 0, "", 2); ShowMessage.zidingyi("×Ô¶¯Ìí¼Ó±êÇ©" + tagid); } }else { if (!Systems.isZidongshijianpian()) {//Èç¹ûûÓпªÆô×Ô¶¯Ê±¼äƬģʽ if (Tagstate.isFanjihuo()) { noinfenpian(anchorid, tagid, hz);//ûÓÐÌí¼ÓµÄ±êÇ©¸ø·ÖÅäʱ¼äƬ } if (hz != 0) { if (person == null) { return; } int pian = person.getPian(); alert_xinhaoqiangdu(tag, anchorid, power);//Ð޸ıêÇ©ÐźÅÇ¿¶È if (pian == (-2)) {//Èç¹û±êÇ©²»´¦Óڵȴý×¢²áģʽ£¬Òâ˼¾ÍÊDZêÇ©ÒѾ­·ÖÅäµ½ÁËʱ¼äƬ person.setPian(-1); person.setZhuceanchor(anchorid); person.setAskpiantime(GetNowTime.timestamp()); person.setRealhz(hz); } int lasthz = person.getRealhz(); if (lasthz != hz) { delete_pian(tagid, hz, "×¢²á"); } else { if (pian > (-1)) { fenpian(tagid, hz, pian); } } person.setRealhz(hz); } } alert_tag_hz(tag, tagid, hz);//Èç¹û¿ªÆô×Ô¶¯Ð޸ıêǩƵÂÊ tag.setNowzhuceanchor(anchorid); } } /**yang20230723 */ public static int get_value(String hex) { return Integer.parseInt(hex,16); } /**yang20230723 */ public static void get_dell_hz() { if(hz>20) { hz=1; } } /**yang20230723 */ public static void show_baowen(String tagstate,String move_open,String sleep_open, String version,int gonglv,int speed,int sleep_time) { if(TcpIpManage.getStar()) {//ÏÔʾ±êǩע²áÐÅÏ¢ String tagid0=tagid; Tag tag=Tag_Dell.get_tag(tagid); if(tag==null) { tagid0=tagid+"δÌí¼Ó±êÇ©"; } String a=tagid0+"×¢²á"+ ", À´×Ô:"+anchorid+ ", ״̬:"+tagstate+ ", Õñ¶¯:"+move_open+ ", ÐÝÃß:"+sleep_open+ ", °æ±¾:"+version+ ", ƵÂÊ:"+hz+ ", ¹¦ÂÊ:"+gonglv+ ", IMU:"+speed+ ", ÐÝÃßʱ¼ä:"+sleep_time+ ", Ç¿¶È£º"+power+ ","+GetNowTime.timestamp2(); BaoWenShow.show(a, "×¢²á±¨ÎÄ",tagid); } } /**yang20230723 */ public static String get_versoin(String hex1,String hex2) { String vers="V"+Integer.parseInt(hex1,16)+"."+Integer.parseInt(hex2,16); return vers; } }