package Frame; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; import java.util.Vector; import javax.swing.ButtonGroup; import javax.swing.ImageIcon; import javax.swing.JCheckBox; import javax.swing.JFileChooser; import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JRadioButton; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.event.InternalFrameEvent; import javax.swing.event.InternalFrameListener; import javax.swing.filechooser.FileNameExtensionFilter; import BaoWen.Dell_55AA03; import BaoWen.Udp_Receive; import ColorAndFont.UIColor; import Method.GetDeskPath; import Method.GetNowTime; import Method.JComboBoxModel; import PbuliClass.JButtonModel; import PbuliClass.JlableModel; import PbuliClass.ShowMessage; import PbuliClass.Systems; import PbuliClass.jinternalFrame; import anchor.Anchor; import anchor.Anchor_Dell; import anchor.Write_peizhi; import tbDataModel_Dell.Dell_Ip; import tbDataModel_Dell.Read_Write_Anchor_Message; import tbDataModel_Dell.Tools; import ymodem.Update; /**»ùÕ¾ÉèÖÃÒ³Ãæ*/ public class AnchorSet extends jinternalFrame { /** * */ private static final long serialVersionUID = 1L; JPanel mb=null; JlableModel jl_choose_anchor= new JlableModel("Ñ¡Ôñ»ùÕ¾:"); JlableModel jl_nearanchor= new JlableModel("ͬ²½»ùÕ¾/ÀàÐÍ"); JlableModel jl_nearanchornum= new JlableModel("ÁÙ½ü»ùÕ¾ÊýÁ¿:"); JlableModel jl_anchorid= new JlableModel("É豸±àºÅ:"); JlableModel jl_gonglv= new JlableModel("·¢É书ÂÊ:"); JlableModel jl_wucha= new JlableModel("Îó²îУ׼:"); JlableModel jl_lvbo= new JlableModel("Â˲¨²ÎÊý:"); JlableModel jl_tongxuzu= new JlableModel("ͨѶС×é:"); JlableModel jl_shangxian= new JlableModel("ͨѶÉÏÏÞ:"); JlableModel jl_hz= new JlableModel("ͨѶƵÂÊ:"); JlableModel jl_banben= new JlableModel("¹Ì¼þ°æ±¾:"); JlableModel jl_moshi=new JlableModel("É豸ģʽ:"); JlableModel jl_qiehuan=new JlableModel("Çл»¾àÀë:"); JlableModel jl_gaojiaohzun=new JlableModel("¸ß¶ÈУ׼:"); JlableModel jl_fastdis=new JlableModel("×î´ó²â¾à/cm:"); JlableModel jl_allout=new JlableModel("Êý¾ÝÈ«²¿Êä³ö:"); public static boolean is=false; static boolean readpeizhi=false; static int isok=0; JTextField jtf_ip=null;//»ùÕ¾ipµØÖ· static public JTextField jf_anchorid=null; static public JTextField jf_gonglv=null; static public JTextField jf_wucha=null; static public JTextField jf_lvbo=null; static public JTextField jf_tongxuzu=null; static public JTextField jf_banben=null; static public JTextField jf_shangxian=null; static public JTextField jf_hz=null; static public JTextField jf_nearancnum=new JTextField(); static public JTextField jf_near1=new JTextField(); static public JTextField jf_near2=new JTextField(); static public JTextField jf_near3=new JTextField(); static public JTextField jf_near4=new JTextField(); static public JTextField jf_near5=new JTextField(); static public JTextField jf_near6=new JTextField(); static public JTextField jf_near7=new JTextField(); static public JTextField jf_near8=new JTextField(); static public JTextField jf_near9=new JTextField(); static public JTextField jf_near10=new JTextField(); static public JTextField jf_qiehuan=new JTextField(); static public JTextField jf_allout=new JTextField(); JTextField jt_shengji=new JTextField(); JButtonModel jbt_xunze=null;//Ñ¡ÔñÎļþ static JButtonModel jbt_shengji=null;//Éý¼¶ static JButtonModel jbt_write=null;//дÈë static JButtonModel uwbUp=null;//½øÈëuwbÉý¼¶Ä£Ê½ static JButtonModel exitUwbUp=null;//Í˳öuwbÉý¼¶Ä£Ê½ static public JTextField jf_rootanchor=new JTextField();//ͬ²½»ùÕ¾ //¸ß¶ÈУ׼ static public JTextField jc_gaojiaohzun=new JTextField(); //×îÔ¶²â¾à¾àÀë static public JTextField jf_fastdis=new JTextField(); String cejuip=null;//²â¾à»ùÕ¾IP static String xuhao="0"; JTextField jf_bin=null; ButtonGroup btgroup=null;//ÉêÃ÷°´Å¥×é static public JRadioButton anchor=null; static public JRadioButton tag=null; static public JCheckBox jc_initiative=null;//Ö÷¶¯²â¾à static public JCheckBox jc_heart=null;//ÐÄÌø°ü¹¦ÄÜÄØ JScrollPane gd=null; JButtonModel jbt_read_peizhi=null; JButtonModel jbt_reboot;//ÖØÆô JButtonModel jbt_reset;//»Ö¸´³ö³§ JButtonModel jbt_save;//±£´æÅäÖà JButtonModel jbt_bin;//Ñ¡ÔñbinÎļþ JButtonModel jbt_grade;//Éý¼¶¹Ì¼þ JButtonModel jbt_alertall;//ÐÞ¸ÄËùÓлùÕ¾ JButtonModel jbt_zanting;//ÐÞ¸ÄËùÓлùÕ¾ JButtonModel jbt_clear;//Çå¿Õ static public JTextArea jt_area=new JTextArea(); JComboBoxModel box_anchorid=null;//»ùÕ¾µÄ¼¯ºÏ static JComboBoxModel box_anchortype=null;//»ùÕ¾ÀàÐÍ JProgressBar progressBar; String anchorid=null; String anchorip=null; int x0=30; int y0=20; int height=25; static boolean isopen=false;//µ±Ç°´°¿ÚÊÇ·ñ´¦ÓÚ¿ªÆô״̬ static String ischooseanchor=null;//µ±Ç°Ñ¡ÖеĻùÕ¾ID static String ischooseip="192.168.0.1";//µ±Ç°Ñ¡ÖеĻùÕ¾IP String path; static boolean shengjimoshi=false; static boolean write=false; static boolean zanting=true; public AnchorSet() { String title="»ùÕ¾ÅäÖÃ"; if(Systems.sys().getLanguage().equals("English")) { title="Anchor Site"; } this.setTitle(title); Container rq=getContentPane();//»ñÈ¡ÈÝÆ÷ rq.setLayout(new BorderLayout()); rq.add(getMb(),BorderLayout.CENTER); this.addInternalFrameListener(new InternalFrameListener() { public void internalFrameOpened(InternalFrameEvent e) { } public void internalFrameIconified(InternalFrameEvent e) { isopen=false; } public void internalFrameDeiconified(InternalFrameEvent e) { isopen=true; } public void internalFrameDeactivated(InternalFrameEvent e) { isopen=false; } public void internalFrameClosing(InternalFrameEvent e) { isopen=false; readpeizhi=false; ischooseanchor=null; shengjimoshi=false; write=false; if(is) { byte[] byt=Read_Write_Anchor_Message.WriteData((byte)0x10,(byte)0x2,0); if(Dell_Ip.get_ipanchor(cejuip)!=null) { String a=jf_anchorid.getText().trim(); Anchor anchor=Anchor_Dell.get_anchor(a); if(anchor==null) { ShowMessage.zidingyi(a+"²»´æÔÚ..."); return; } Udp_Receive.out(byt,byt.length,anchor,"»ùÕ¾ÉèÖÃ"); } is=false; } jt_area.setText(""); } public void internalFrameClosed(InternalFrameEvent e) { } public void internalFrameActivated(InternalFrameEvent e) { isopen=true; } }); this.setBounds(175, 0, 980, 585); this.setFrameIcon(new ImageIcon("image/icon/setanchor.png"));//ÉèÖô°Ìåͼ±ê getBtgroup(); } public JPanel getMb() { if(mb==null) { mb=new JPanel(); mb.setLayout(null); mb.setBackground(UIColor.getNorth_color()); mb.add(getJbt_xunze()); mb.add(getJbt_shengji()); mb.add(jt_shengji); mb.add(getJbt_write()); mb.add(getUwbUp()); mb.add(getExitUwbUp()); //Ñ¡Ôñ»ùÕ¾ jl_choose_anchor.setBounds(x0, y0,75, height); mb.add(jl_choose_anchor); //»ùÕ¾idÏÂÀ­¿ò mb.add(getBox_anchorid()); box_anchorid.setBounds(x0+75, y0, 100, height); //»ùÕ¾ipµØÖ· mb.add(getJtf_ip()); jtf_ip.setBounds(x0+185, y0, 130, height); //¶ÁÈ¡ÅäÖð´Å¥ mb.add(getJbt_read_peizhi()); jbt_read_peizhi.setBounds(x0+340, y0,80, height); //É豸ģʽ jl_moshi.setBounds(x0, y0+40,75, height); getAnchor().setBounds(x0+75, y0+40,70, height); getTag().setBounds(x0+160, y0+40,70, height); mb.add(jl_moshi); mb.add(anchor); mb.add(tag); //»ùÕ¾»¥²â¾à getJc_initiative().setBounds(x0+245, y0+40,90, height); mb.add(jc_initiative); //ÐÄÌø°ü getJc_heart().setBounds(x0+350, y0+40,100, height); mb.add(jc_heart); //»ùÕ¾id jl_anchorid.setBounds(x0, y0+80,75, height); getJf_anchorid().setBounds(x0+75, y0+80,100, height); mb.add(jl_anchorid); mb.add(jf_anchorid); //É豸¹¦ÂÊ jl_gonglv.setBounds(x0+240, y0+80,75, height); getJf_gonglv().setBounds(x0+315, y0+80,100, height); mb.add(jl_gonglv); mb.add(jf_gonglv); //Îó²îУ׼ jl_wucha.setBounds(x0, y0+120,75, height); getJf_wucha().setBounds(x0+75, y0+120,100, height); mb.add(jl_wucha); mb.add(jf_wucha); //Â˲¨²ÎÊý jl_lvbo.setBounds(x0+240, y0+120,75, height); getJf_lvbo().setBounds(x0+315, y0+120,100, height); mb.add(jl_lvbo); mb.add(jf_lvbo); //ͨѶ·Ö×é jl_tongxuzu.setBounds(x0, y0+160,75, height); getJf_tongxuzu().setBounds(x0+75, y0+160,100, height); mb.add(jl_tongxuzu); mb.add(jf_tongxuzu); //²â¾àƵÂÊ jl_hz.setBounds(x0+240, y0+160,75, height); getJf_hz().setBounds(x0+315, y0+160,100, height); mb.add(jl_hz); mb.add(jf_hz); //ͨѶÉÏÏÞ jl_shangxian.setBounds(x0, y0+200,75, height); getJf_shangxian().setBounds(x0+75, y0+200,100, height); mb.add(jl_shangxian); mb.add(jf_shangxian); //¹Ì¼þ°æ±¾ jl_banben.setBounds(x0+240, y0+200,75, height); getJf_banben().setBounds(x0+315, y0+200,100, height); mb.add(jl_banben); mb.add(jf_banben); //ÁÙ½ü»ùÕ¾ÊýÁ¿ jl_nearanchornum.setBounds(x0+240, y0+240,110, height); jf_nearancnum.setBounds(x0+350, y0+240,65, height); mb.add(jl_nearanchornum); mb.add(jf_nearancnum); //ͬ²½»ùÕ¾ÀàÐÍ jl_nearanchor.setBounds(x0, y0+240,100, height); jf_rootanchor.setBounds(x0+100, y0+240,50, height); getBox_anchortype().setBounds(x0+155, y0+240,60, height); mb.add(jl_nearanchor); mb.add(jf_rootanchor); mb.add(box_anchortype); //ÁÙ½ü»ùÕ¾1 jf_near1.setBounds(x0, y0+280,80, height); jf_near2.setBounds(x0+90, y0+280,80, height); jf_near3.setBounds(x0+180, y0+280,80, height); jf_near4.setBounds(x0+270, y0+280,80, height); jf_near5.setBounds(x0+360, y0+280,80, height); jf_near6.setBounds(x0, y0+320,80, height); jf_near7.setBounds(x0+90, y0+320,80, height); jf_near8.setBounds(x0+180, y0+320,80, height); jf_near9.setBounds(x0+270, y0+320,80, height); jf_near10.setBounds(x0+360, y0+320,80, height); //Çл»¾àÀë jl_qiehuan.setBounds(x0, y0+360,80, height); jf_qiehuan.setBounds(x0+80, y0+360,95, height); //×îÔ¶²â¾à¾àÀ뵥λÀåÃ× int y11=y0+360+40; jl_fastdis.setBounds(x0, y11,140, height); jf_fastdis.setBounds(x0+95, y11,80, height); mb.add(jl_fastdis); mb.add(jf_fastdis); //ËùÓÃÊý¾ÝÊä³ö mb.add(jl_allout); mb.add(jf_allout); jl_allout.setToolTipText("×÷ΪÖ÷»úÕ¾µÄʱºò¿ªÆô½ÓÊÕËùÓûùÕ¾Êý¾Ýģʽ1¿ªÆô0¹Ø±Õ"); jl_allout.setBounds(x0+240, y11,100, height); jf_allout.setBounds(x0+340, y11,90, height); //¸ß¶ÈУ׼ jl_gaojiaohzun.setBounds(x0+240, y0+360,80, height); jc_gaojiaohzun.setBounds(x0+320, y0+360,110, height); mb.add(jl_gaojiaohzun); mb.add(jc_gaojiaohzun); mb.add(jf_near1); mb.add(jf_near2); mb.add(jf_near3); mb.add(jf_near4); mb.add(jf_near5); mb.add(jf_near6); mb.add(jf_near7); mb.add(jf_near8); mb.add(jf_near9); mb.add(jf_near10); mb.add(jl_qiehuan); mb.add(jf_qiehuan); getUwbUp().setBounds(x0, y0+460,150, height);//½øÈëuwbÉý¼¶Ä£Ê½ getExitUwbUp().setBounds(x0+280, y0+460,150, height);//Í˳öuwbÉý¼¶Ä£Ê½ getJbt_save().setBounds(x0, y0+500,80, height);//±£´æÅäÖà mb.add(jbt_save); getJbt_reboot().setBounds(x0+170, y0+500,80, height);//ÖØÆô mb.add(jbt_reboot); //ÐÞ¸ÄÈ«²¿»ùÕ¾ getJbt_alertall().setBounds(x0+350, y0+500,80, height); mb.add(jbt_alertall); //ÔÝÍ£ getJbt_zanting().setBounds(x0+790, y0,60, height);//ÔÝÍ£ mb.add(jbt_zanting); //Çå¿Õ getJbt_clear().setBounds(x0+870, y0,60, height); mb.add(jbt_clear); //Îı¾ÏÔÊ¾ÇøÓò getGd().setBounds(x0+480, y0+30,450, 450); mb.add(gd); //Éý¼¶ jbt_xunze.setBounds(x0+480, y0+500,90, height); jt_shengji.setBounds(x0+480+92,y0+500,170, 25); jbt_shengji.setBounds(x0+480+92+185,y0+500,80, 25); jbt_write.setBounds(x0+480+92+280,y0+500,80, 25); } return mb; } /**»ñÈ¡»ùÕ¾µÄipµØÖ·Îı¾¿ò*/ public JTextField getJtf_ip() { if( jtf_ip==null) { jtf_ip=new JTextField(); } return jtf_ip; } /**»ñÈ¡»ùÕ¾µÄÅäÖð´Å¥*/ public JButtonModel getJbt_read_peizhi() { if( jbt_read_peizhi==null) { jbt_read_peizhi=new JButtonModel("¶ÁÈ¡ÅäÖÃ"); jbt_read_peizhi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String a=(String) box_anchorid.getSelectedItem(); if(a.equals("Ñ¡Ôñ»ùÕ¾") || a.equals("ËùÓлùÕ¾") ) { ShowMessage.zidingyi("ÇëÑ¡ÔñÐèÒª¶ÁÈ¡ÅäÖõĻùÕ¾"); return; } Anchor anchor=Anchor_Dell.get_anchor(a); String ip=getip(); int port=getport(); readpeizhi=true; byte[] byt=Read_Write_Anchor_Message.ReadData((byte)0x2,(byte)0x50); if(byt==null) { return; } if(Systems.isAncshengjimoshi()) { Update.chushihua(); Update.fasongdata(byt,ip,port); }else { if(port !=0) { Udp_Receive.out(byt,byt.length,anchor,"»ùÕ¾ÉèÖÃ"); addmesg(ip+":"+port+"¶ÁÈ¡ÐÅÏ¢ÒÑ·¢ËÍ..."); } } } }); } return jbt_read_peizhi; } /**»ñÈ¡»ùÕ¾µÄÅäÖð´Å¥*/ public JButtonModel getJbt_() { if( jbt_read_peizhi==null) { jbt_read_peizhi=new JButtonModel("¶ÁÈ¡ÅäÖÃ"); jbt_read_peizhi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String a=(String) box_anchorid.getSelectedItem(); if(a.equals("Ñ¡Ôñ»ùÕ¾") || a.equals("ËùÓлùÕ¾") ) { ShowMessage.zidingyi("ÇëÑ¡ÔñÐèÒª¶ÁÈ¡ÅäÖõĻùÕ¾"); return; } Anchor anchor=Anchor_Dell.get_anchor(a); String ip=getip(); int port=getport(); readpeizhi=true; byte[] byt=Read_Write_Anchor_Message.ReadData((byte)0x2,(byte)0x50); if(byt==null) { return; } if(Systems.isAncshengjimoshi()) { Update.chushihua(); Update.fasongdata(byt,ip,port); }else { if(port !=0) { Udp_Receive.out(byt,byt.length,anchor,"»ùÕ¾ÉèÖÃ"); addmesg(ip+":"+port+"¶ÁÈ¡ÐÅÏ¢ÒÑ·¢ËÍ..."); } } } }); } return jbt_read_peizhi; } /**»ñÈ¡»ùÕ¾µÄIDÏÂÀ­¿ò*/ public JComboBoxModel getBox_anchorid() { if( box_anchorid==null) { box_anchorid=new JComboBoxModel(Anchor_Dell.get_anchorid()); box_anchorid.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå box_anchorid.setEnabled(true); //ÏÂÀ­¿ò¿ÉÒÔÊäÈë box_anchorid.setEditable(true); box_anchorid.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { anchorid=(String) box_anchorid.getSelectedItem(); ischooseanchor=anchorid; if(anchorid.equals("Ñ¡Ôñ»ùÕ¾")) { jtf_ip.setText(""); isok=0; }else if(anchorid.equals("ËùÓлùÕ¾")){ isok=1; jtf_ip.setText("ËùÓлùÕ¾½«»á±»Ð޸ģ¡"); jf_anchorid.setText("ÎÞЧ"); jf_gonglv.setText("67"); jf_wucha.setText("-60"); jf_lvbo.setText("2"); jf_tongxuzu.setText("0"); jf_hz.setText("1000"); jf_shangxian.setText("10"); box_anchortype.setSelectedIndex(0); jf_rootanchor.setText("FFFF"); }else { isok=2; //2023.07.14 zsh ÅжϻùÕ¾ÊÇ·ñΪ¿Õ Anchor anchor = Anchor_Dell.get_anchor(anchorid); if (anchor==null){ return; } anchorip=anchor.getAnc_ip(); if(anchorip==null) { anchorip=""; } ischooseip=anchorip; int port=Anchor_Dell.get_anchor(anchorid).getPort(); jtf_ip.setText(anchorip+":"+port); if(port==0) { isok=0; } } } }); } return box_anchorid; } public JButtonModel getJbt_save() { if(jbt_save==null) { jbt_save=new JButtonModel("±£´æÅäÖÃ"); jbt_save.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if(Systems.isAncshengjimoshi()) { peimesage(); }else { if(isok==0) { ShowMessage.zidingyi("ûÓÐʶ±ðµ½»ùÕ¾¶Ë¿ÚºÅ£¬¶Áȡʧ°Ü..."); return; }else if(isok==2) { peimesage(); }else if(isok==1){ ShowMessage.zidingyi("±£´æÅäÖÃʧ°Ü£¬ÇëÑ¡ÔñÈ«²¿Ð޸İ´¼ü..."); } } } }); } return jbt_save; } public JButtonModel getJbt_reboot() { if(jbt_reboot==null) { jbt_reboot=new JButtonModel("ÖØÆôÉ豸"); jbt_reboot.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if(Dell_55AA03.readpeizhi_succ) { if(isok==2) { ShowMessage.zidingyi("ûÓÐʶ±ðµ½»ùÕ¾¶Ë¿ÚºÅ£¬¶Áȡʧ°Ü..."); return; } addmesg(" ÖØÆôÉ豸..."); byte[] byt=Read_Write_Anchor_Message.WriteData((byte)0x60,(byte)0x2,1); String a=(String) box_anchorid.getSelectedItem(); Anchor anchor=Anchor_Dell.get_anchor(a); if(anchor==null) { ShowMessage.zidingyi(a+"null..."); return; } Udp_Receive.out(byt,byt.length,anchor,"»ùÕ¾ÉèÖÃ"); String datas=Tools.Bytes2HexString(byt); addmesg(" ÖØÆôÐÅÏ¢ÒÑÏ·¢,"+datas); }else { addmesg(" ÖØÆôÉ豸ÇëÏȶÁÈ¡ÅäÖóɹ¦..."); } } }); } return jbt_reboot; } public JButtonModel getJbt_reset() { if(jbt_reset==null) { jbt_reset=new JButtonModel("»Ö¸´³ö³§"); jbt_reset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if(Dell_55AA03.readpeizhi_succ) { if(isok==2) { ShowMessage.zidingyi("ûÓÐʶ±ðµ½»ùÕ¾¶Ë¿ÚºÅ£¬¶Áȡʧ°Ü..."); return; } addmesg(" »Ö¸´³ö³§ÉèÖÃ..."); byte[] byt=Read_Write_Anchor_Message.WriteData((byte)0x62,(byte)0x2,1); int l=byt.length; String a=(String) box_anchorid.getSelectedItem(); Anchor anchor=Anchor_Dell.get_anchor(a); if(anchor==null) { ShowMessage.zidingyi(a+"null..."); return; } Udp_Receive.out(byt,l,anchor,"»ùÕ¾ÉèÖÃ"); addmesg(" »Ö¸´³ö³§³É¹¦..."); }else { addmesg("»Ö¸´³ö³§ÇëÏȶÁÈ¡ÅäÖóɹ¦..."); } } }); } return jbt_reset; } public JTextField getJf_gonglv() { if(jf_gonglv==null) { jf_gonglv=new JTextField(); } return jf_gonglv; } public JTextField getJf_anchorid() { if(jf_anchorid==null) { jf_anchorid=new JTextField(); } return jf_anchorid; } public JTextField getJf_wucha() { if(jf_wucha==null) { jf_wucha=new JTextField(); } return jf_wucha; } public JTextField getJf_lvbo() { if(jf_lvbo==null) { jf_lvbo=new JTextField(); } return jf_lvbo; } public JTextField getJf_tongxuzu() { if(jf_tongxuzu==null) { jf_tongxuzu=new JTextField(); } return jf_tongxuzu; } public JTextField getJf_banben() { if(jf_banben==null) { jf_banben=new JTextField(); jf_banben.setForeground(Color.red); jf_banben.setEditable(false); } return jf_banben; } public JTextField getJf_bin() { if(jf_bin==null) { jf_bin=new JTextField(); } return jf_bin; } public JButtonModel getJbt_bin() { if(jbt_bin==null) { jbt_bin=new JButtonModel("Ñ¡ÔñBinÎļþ"); } return jbt_bin; } public JButtonModel getJbt_grade() { if(jbt_grade==null) { jbt_grade=new JButtonModel("Éý¼¶¹Ì¼þ"); } return jbt_grade; } public JProgressBar getProgressBar() { if(progressBar==null) { progressBar=new JProgressBar (); progressBar.setStringPainted(true); progressBar.setPreferredSize(new Dimension(300, 30)); progressBar.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 16)); } return progressBar; } public JScrollPane getGd() { if(gd==null) { jt_area.setBackground(UIColor.getNorth_color()); jt_area.setForeground(UIColor.getGrenn()); gd=new JScrollPane(jt_area); } return gd; } public static JTextField getJf_shangxian() { if(jf_shangxian==null) { jf_shangxian=new JTextField(); } return jf_shangxian; } public static JTextField getJf_hz() { if(jf_hz==null) { jf_hz=new JTextField(); } return jf_hz; } public ButtonGroup getBtgroup() { if(btgroup==null) { btgroup=new ButtonGroup(); btgroup.add(getAnchor()); btgroup.add(getTag()); } return btgroup; } public JRadioButton getTag() { if(tag==null) { tag=new JRadioButton("±êÇ©"); tag.setBackground(null); tag.setFont(new Font("΢ÈíÑźÚ",Font.PLAIN,15)); } return tag; } public JRadioButton getAnchor() { if(anchor==null) { anchor=new JRadioButton("»ùÕ¾"); anchor.setBackground(null); anchor.setFont(new Font("΢ÈíÑźÚ",Font.PLAIN,15)); anchor.setSelected(true); } return anchor; } /**ÐÞ¸ÄËùÓлùÕ¾*/ public JButtonModel getJbt_alertall() { if(jbt_alertall==null) { jbt_alertall=new JButtonModel("È«²¿ÐÞ¸Ä"); jbt_alertall.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if(isok==1) { String gonglv=jf_gonglv.getText().trim(); String wucha=jf_wucha.getText().trim(); String lvbo=jf_lvbo.getText().trim(); String zu=jf_tongxuzu.getText().trim(); String hz=jf_hz.getText().trim(); String shangxian=jf_shangxian.getText().trim(); String rootanc=jf_rootanchor.getText().trim(); if(rootanc.equals("FFFF")) { rootanc="0"; } String heart="0"; if(jc_heart.isSelected()) { heart="1"; } int[] value= new int[35]; value[0]=Integer.parseInt(hz);//±êǩͨѶ¼ä¸ô 0x6 value[1]=Integer.parseInt(shangxian);//µ¥´ÎͨѶ»ùÕ¾ÊýÁ¿ÉÏÏÞ value[2]=Integer.parseInt(zu);//0xA ͨѶ×éID£¨2Byte£© value[3]=Integer.parseInt(wucha);//0xC ¾àÀëУ׼ֵ£¨2Byte£© value[4]=0;//0xE Ä£¿éÀàÐÍ£¨2Byte£© value[5]=0;//0x10 »ùÕ¾Ö÷¶¯²â¾à£¨2Byte£© value[6]=0;//0x12 ±¨¾¯É豸£¨2Byte£© value[7]=0;//0x14 ±¨¾¯¾àÀë1£¨2Byte£© value[8]=0;//0x16 ±¨¾¯¾àÀë2£¨2Byte£© value[9]=0;//0x18 ±¨¾¯¾àÀë3£¨2Byte£© value[10]=0;//0x1A Åä¶ÔIDÎÞ×÷Óã¨2Byte£© value[11]=Integer.parseInt(heart);//0x1C ÐÄÌø°ü£¨2Byte£© value[12]=0;//0x1E Modbusģʽ£¨2Byte£© value[13]=0; value[14]=0; value[15]=0; value[16]=0; value[17]=0; value[18]=0; value[19]=0; value[20]=0; value[21]=0; value[22]=0; value[23]=0; value[24]=Integer.parseInt(gonglv);//·¢É书ÂÊ value[25]=2;//¼ÓËÙ¶ÈÁéÃô¶È value[26]=120;//ÐÝÃßʱ¼ä value[27]=0;//Õñ¶¯Ê¹ÄÜ value[28]=0;//¼ÓËÙ¶ÈʹÄÜ value[29]=Integer.parseInt(lvbo);//±êǩϷ¢ÅäÖÃ״̬ value[30]=0;//±êǩϷ¢ÅäÖÃID 0x42 value[31]=Integer.parseInt(rootanc);//ͬ²½»ùÕ¾µØÖ· 0x44 value[32]=Integer.parseInt(xuhao);//ͬ²½ÀàÐÍ0/1/2(0ÆÕͨ»ùÕ¾£¬1Ö÷»úÕ¾£¬2ÊÇ´Ó»ùÕ¾)46 value[33]=0;//µØÖ·48 value[34]=0;//µØÖ·50,ÆøÑ¹¼Æ¸ß¶ÈУ׼ֵ byte[] byt=Write_peizhi.write((byte)0x6,(byte)0x46, value); Dell_Ip.alert_all_ip(byt,"AnchorSet"); }else { jt_area.setText(GetNowTime.now2()+" ÇëÏÈÑ¡ÔñËùÓлùÕ¾..."); } } }); } return jbt_alertall; } public static JCheckBox getJc_initiative() { if(jc_initiative==null) { jc_initiative=new JCheckBox("Ö÷¶¯²â¾à"); jc_initiative.setFont(new Font("΢ÈíÑźÚ",Font.PLAIN,15)); jc_initiative.setBackground(null); } return jc_initiative; } public static JCheckBox getJc_heart() { if(jc_heart==null) { jc_heart=new JCheckBox("¿ªÆôÐÄÌø"); jc_heart.setFont(new Font("΢ÈíÑźÚ",Font.PLAIN,15)); jc_heart.setBackground(null); } return jc_heart; } public static boolean isReadpeizhi() { return readpeizhi; } public static JComboBoxModel getBox_anchortype() { if(box_anchortype==null) { String[] type={"ÎÞ","Ö÷","´Ó"}; box_anchortype=new JComboBoxModel(type); box_anchortype.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int xu=box_anchortype.getSelectedIndex(); if(xu==1) { xuhao="1"; jf_rootanchor.setText("0"); }else if(xu==2) { xuhao="2"; }else { xuhao="0"; } } }); } return box_anchortype; } public static boolean isIsopen() { return isopen; } public static void setIsopen(boolean isopen) { AnchorSet.isopen = isopen; } public static String getIschooseanchor() { return ischooseanchor; } public static void setIschooseanchor(String ischooseanchor) { AnchorSet.ischooseanchor = ischooseanchor; } public JButtonModel getJbt_xunze() { if(jbt_xunze==null) { jbt_xunze=new JButtonModel("Ñ¡Ôñ¹Ì¼þ:"); jbt_xunze.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(!Systems.isAncshengjimoshi()) { ShowMessage.zidingyi("ÇëÏÈÔÚϵͳ¹ÜÀí´¦ÉèÖÃΪÉý¼¶Ä£Ê½"); return; } JFileChooser fileChooser=new JFileChooser(GetDeskPath.path());//ÎļþÑ¡ÔñÆ÷ FileNameExtensionFilter filter=new FileNameExtensionFilter("bin", "bin");//Îļþ¹ýÂËÆ÷ fileChooser.setFileFilter(filter);//Ìí¼ÓÎļþ¹ýÂËÆ÷ int i=fileChooser.showOpenDialog(mb);//ÏÔʾѡÔñÎļþ¶Ô»°¿ò if(i==JFileChooser.APPROVE_OPTION) {//Èç¹ûÓû§Ñ¡ÔñµÄÊÇ¡°´ò¿ª¡±°´Å¥ File file=fileChooser.getSelectedFile();//»ñȡѡÖеÄÎļþ path=file.getPath();//ÎļþÃû³Æ jt_shengji.setText(path); } else { return; } } }); } return jbt_xunze; } public JButtonModel getJbt_shengji() { if(jbt_shengji==null) { jbt_shengji=new JButtonModel("µã»÷Éý¼¶"); jbt_shengji.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(!shengjimoshi) { if(path==null ||path.length()<10) { ShowMessage.zidingyi("¹Ì¼þ²»¶ÔÇëÑ¡ÔñÕýÈ·µÄ¹Ì¼þ"); return; } shengjimoshi=true; shengjizhiling(anchorid);//·¢ËÍÉý¼¶Ö¸Áî jbt_shengji.setText("Éý¼¶ÖÐ..."); }else { shengjimoshi=false; jbt_shengji.setText("µã»÷Éý¼¶"); } } }); } return jbt_shengji; } public JButtonModel getJbt_write() { if(jbt_write==null) { jbt_write=new JButtonModel("дÈëÎļþ"); jbt_write.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(!write) { if(path==null ||path.length()<10) { ShowMessage.zidingyi("¹Ì¼þ²»¶ÔÇëÑ¡ÔñÕýÈ·µÄ¹Ì¼þ"); return; } write=true; writeCode(anchorid);//·¢ËÍдÈëÎļþÖ¸Áî jbt_write.setText("дÈëÖÐ..."); }else { write=false; jbt_write.setText("µã»÷дÈë"); } } }); } return jbt_write; } public JButtonModel getUwbUp() { if(uwbUp==null) { uwbUp=new JButtonModel("½øÈëuwbÉý¼¶Ä£Ê½"); uwbUp.addActionListener(e -> { if(Dell_55AA03.readpeizhi_succ) { if (isok == 2) { ShowMessage.zidingyi("ûÓÐʶ±ðµ½»ùÕ¾¶Ë¿ÚºÅ,·¢ËÍʧ°Ü..."); return; } addmesg(" ½øÈë'ÓÃuwb¸ø±êÇ©Éý¼¶Ä£Ê½'..."); byte[] byt = Read_Write_Anchor_Message.toAnchor((byte)0x3); String datas = Tools.Bytes2HexString(byt); System.out.println(datas); String a = (String) box_anchorid.getSelectedItem(); Anchor anchor = Anchor_Dell.get_anchor(a); if (anchor == null) { ShowMessage.zidingyi(a + "null..."); return; } Udp_Receive.out(byt, byt.length, anchor, "»ùÕ¾ÉèÖÃ"); addmesg(" ÐÅÏ¢ÒÑÏ·¢," + datas); } }); } return uwbUp; } public JButtonModel getExitUwbUp() { if(exitUwbUp==null) { exitUwbUp=new JButtonModel("Í˳öuwbÉý¼¶Ä£Ê½"); exitUwbUp.addActionListener(e -> { if(Dell_55AA03.readpeizhi_succ) { if (isok == 2) { ShowMessage.zidingyi("ûÓÐʶ±ðµ½»ùÕ¾¶Ë¿ÚºÅ,·¢ËÍʧ°Ü..."); return; } addmesg(" Í˳ö'ÓÃuwb¸ø±êÇ©Éý¼¶Ä£Ê½'..."); byte[] byt = Read_Write_Anchor_Message.toAnchor((byte)0x4); String a = (String) box_anchorid.getSelectedItem(); Anchor anchor = Anchor_Dell.get_anchor(a); if (anchor == null) { ShowMessage.zidingyi(a + "null..."); return; } Udp_Receive.out(byt, byt.length, anchor, "»ùÕ¾ÉèÖÃ"); String datas = Tools.Bytes2HexString(byt); addmesg(" ÐÅÏ¢ÒÑÏ·¢," + datas); } }); } return exitUwbUp; } /**·¢ËÍÉý¼¶Ö¸Áî*/ public void shengjizhiling(String anchorid) { byte[] byt=Read_Write_Anchor_Message.WriteData((byte)0x64,(byte)0x2,1); String ip=getip(); int port=getport(); if (ip.equals("127.0.0.1")||port==0){ return; } try { Update.shengji(ip, port, path,byt); } catch (IOException e) { e.printStackTrace(); } } /**·¢ËÍдÈëÎļþÖ¸Áî*/ public void writeCode(String anchorid) { byte[] byt = Read_Write_Anchor_Message.toAnchor((byte)0x2); String ip=getip(); int port=getport(); if (ip.equals("127.0.0.1")||port==0){ return; } try { Update.shengji(ip, port, path,byt); } catch (IOException e) { e.printStackTrace(); } } /**Ìí¼ÓÎı¾*/ public static void addmesg(String message) { if(zanting) { jt_area.append(GetNowTime.HH_MM_SS()+":"+message+"\n"); jt_area.setCaretPosition(jt_area.getText().length()); } } public static String getIschooseip() { return ischooseip; } public static void setIschooseip(String ischooseip) { AnchorSet.ischooseip = ischooseip; } public static boolean isShengjimoshi() { return shengjimoshi; } public static void setShengjimoshi(boolean shengjimoshi) { if(!shengjimoshi) { jbt_shengji.setText("µã»÷Éý¼¶"); } AnchorSet.shengjimoshi = shengjimoshi; } public JButtonModel getJbt_zanting() { if(jbt_zanting==null) { jbt_zanting=new JButtonModel("ÔÝÍ£"); jbt_zanting.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(zanting) { zanting=false; jbt_zanting.setText("ÔÝÍ£"); }else { zanting=true; jbt_zanting.setText("¿ªÊ¼"); } } }); } return jbt_zanting; } public static boolean isZanting() { return zanting; } public static void setZanting(boolean zanting) { AnchorSet.zanting = zanting; } public JButtonModel getJbt_clear() { if(jbt_clear==null) { jbt_clear=new JButtonModel("Çå¿Õ"); jbt_clear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jt_area.setText(""); } }); } return jbt_clear; } /**ÅäÖÃÐÅÏ¢*/ public void peimesage() { Vector vc=new Vector(); String anchorid=jf_anchorid.getText().trim(); String gonglv=jf_gonglv.getText().trim(); String wucha=jf_wucha.getText().trim(); String lvbo=jf_lvbo.getText().trim(); String zu=jf_tongxuzu.getText().trim(); String hz=jf_hz.getText().trim(); String shangxian=jf_shangxian.getText().trim(); String type="0"; String nearnum=jf_nearancnum.getText().trim(); //»ùÕ¾Ö÷¶¯²â¾à String initiative="0"; if(jc_initiative.isSelected()) { initiative="1"; } String heart="0"; if(jc_heart.isSelected()) { heart="1"; } String near1=jf_near1.getText().trim(); if(near1.length()==4) { vc.add(near1); }else { near1="0000"; } String near2=jf_near2.getText().trim(); if(near2.length()==4) { vc.add(near2); }else { near2="0000"; } String near3=jf_near3.getText().trim(); if(near3.length()==4) { vc.add(near3); }else { near3="0000"; } String near4=jf_near4.getText().trim(); if(near4.length()==4) { vc.add(near4); }else { near4="0000"; } String near5=jf_near5.getText().trim(); if(near5.length()==4) { vc.add(near5); }else { near5="0000"; } String near6=jf_near6.getText().trim(); if(near6.length()==4) { vc.add(near6); }else { near6="0000"; } String near7=jf_near7.getText().trim(); if(near7.length()==4) { vc.add(near7); }else { near7="0000"; } String near8=jf_near8.getText().trim(); if(near8.length()==4) { vc.add(near8); }else { near8="0000"; } String near9=jf_near9.getText().trim(); if(near9.length()==4) { vc.add(near9); }else { near9="0000"; } String near10=jf_near10.getText().trim(); if(near10.length()==4) { vc.add(near10); }else { near10="0000"; } int nearnumint=Integer.parseInt(nearnum); if(nearnumint !=vc.size()) { ShowMessage.zidingyi_24(nearnumint+"ÁÙ½ü»ùÕ¾Êý×ÖºÍÁÙ½ü»ùÕ¾¸öÊý²»Æ¥Åä..."); return; } String qiehuan=jf_qiehuan.getText().trim();//Çл»¾àÀë String fasdis=jf_fastdis.getText().trim();//×îÔ¶²â¾à¾àÀë String allout=jf_allout.getText().trim();//Êä³öËùÓÐÊý¾Ý String rootanchor=jf_rootanchor.getText().trim();//ͬ²½»ùÕ¾ String gaodujiaozhun=jc_gaojiaohzun.getText().trim();//¸ß¶ÈУ׼ֵ if(!anchor.isSelected()) { type="1"; } int[] value= new int[36]; value[0]=Write_peizhi.covert(anchorid);//É豸id 0x4 value[1]=Integer.parseInt(hz);//±êǩͨѶ¼ä¸ô 0x6 value[2]=Integer.parseInt(shangxian);//µ¥´ÎͨѶ»ùÕ¾ÊýÁ¿ÉÏÏÞ value[3]=Integer.parseInt(zu);//0xA ͨѶ×éID£¨2Byte£© value[4]=Integer.parseInt(wucha);//0xC ¾àÀëУ׼ֵ£¨2Byte£© value[5]=1;//0xE Ä£¿éÀàÐÍ£¨2Byte£© if(type.equals("0")) { value[5]=0; } value[6]=0;//0x10 »ùÕ¾Ö÷¶¯²â¾à£¨2Byte£© if(initiative.equals("1")) { value[6]=1; } value[7]=0;//0x12 ±¨¾¯É豸£¨2Byte£© value[8]=Integer.parseInt(qiehuan);//0x14 Çл»¾àÀ루2Byte£© value[9]=Integer.parseInt(fasdis);//0x16 ×îÔ¶²â¾à¾àÀ루2Byte£© value[10]=Integer.parseInt(allout);//0x18 Êä³öËùÓÐÊý¾Ý×öÖ÷»úվʱºò£¨2Byte£© value[11]=0;//0x1A Åä¶ÔIDÎÞ×÷Óã¨2Byte£© value[12]=0;//0x1C ÐÄÌø°ü£¨2Byte£© if(heart.equals("1")) { value[12]=1; } value[13]=0;//0x1E Modbusģʽ£¨2Byte£© value[14]=Integer.parseInt(nearnum); value[15]=Write_peizhi.covert(near1); value[16]=Write_peizhi.covert(near2); value[17]=Write_peizhi.covert(near3); value[18]=Write_peizhi.covert(near4); value[19]=Write_peizhi.covert(near5); value[20]=Write_peizhi.covert(near6); value[21]=Write_peizhi.covert(near7); value[22]=Write_peizhi.covert(near8); value[23]=Write_peizhi.covert(near9); value[24]=Write_peizhi.covert(near10); value[25]=Integer.parseInt(gonglv);//·¢É书ÂÊ value[26]=2;//¼ÓËÙ¶ÈÁéÃô¶È value[27]=120;//ÐÝÃßʱ¼ä value[28]=0;//Õñ¶¯Ê¹ÄÜ value[29]=0;//¼ÓËÙ¶ÈʹÄÜ value[30]=Integer.parseInt(lvbo);//±êǩϷ¢ÅäÖÃ״̬ value[31]=0;//±êǩϷ¢ÅäÖÃID 0x42 value[32]=Write_peizhi.covert(rootanchor);//ͬ²½»ùÕ¾µØÖ· 0x44 value[33]=Integer.parseInt(xuhao);//ͬ²½ÀàÐÍ0/1/2(0ÆÕͨ»ùÕ¾£¬1Ö÷»úÕ¾£¬2ÊÇ´Ó»ùÕ¾)46 value[34]=0;//µØÖ·48 value[35]=Integer.parseInt(gaodujiaozhun);//µØÖ·50,ÆøÑ¹¼Æ¸ß¶ÈУ׼ֵ byte[] data=Write_peizhi.write((byte)0x4,(byte)0x48, value); String datas=Tools.Bytes2HexString(data); if(data !=null) { String a=(String) box_anchorid.getSelectedItem(); if(!Systems.isAncshengjimoshi()) { Anchor anchor=Anchor_Dell.get_anchor(a); if(anchor==null) { ShowMessage.zidingyi(a+"±£´æÅäÖûùÕ¾²»´æÔÚ..."); return; } Udp_Receive.out(data,data.length,anchor,"»ùÕ¾ÉèÖÃ"); }else{ String ip=getip(); int port=getport(); Update.fasongdata(data, ip, port); } addmesg("·¢£º"+datas+","+GetNowTime.now2()); ShowMessage.zidingyi(a+"±£´æÅäÖÃÐÅÏ¢ÒÑÏ·¢..."); } } public String getip() { String b=jtf_ip.getText().trim(); String[] as=b.split(":"); String ip=as[0]; if(ip.length()<10) { ShowMessage.zidingyi("É豸IPµØÖ·²»ÕýÈ·"+ip); ip="127.0.0.1"; } return ip; } public int getport() { int port=8233; String b=jtf_ip.getText().trim(); String[] as=b.split(":"); if(as.length>1) { port = Integer.parseInt(as[1]); if (port < 10) { port = 8233; } } return port; } }