package main;
|
import java.awt.EventQueue;
|
|
import javax.swing.JFrame;
|
|
import java.awt.Panel;
|
import java.awt.BorderLayout;
|
|
import javax.swing.JComboBox;
|
import javax.swing.JPanel;
|
import javax.swing.border.TitledBorder;
|
import javax.swing.JButton;
|
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.JOptionPane;
|
import javax.swing.Timer;
|
|
import java.awt.event.ActionListener;
|
import java.awt.event.ActionEvent;
|
import java.awt.Toolkit;
|
|
import javax.swing.JTextField;
|
import javax.swing.UIManager;
|
|
import java.awt.Color;
|
import java.nio.ByteBuffer;
|
import java.util.Date;
|
|
import javax.swing.JTabbedPane;
|
|
import java.awt.Font;
|
import java.awt.event.FocusAdapter;
|
import java.awt.event.FocusEvent;
|
import java.net.InetAddress;
|
import java.net.UnknownHostException;
|
|
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeEvent;
|
|
import sp_comm.CommSerialPort;
|
|
import com.Com;
|
import com.LimitedDocument;
|
import com.dev.btsm.bts_page_base;
|
import com.dev.bybb.bybb_page_base;
|
import com.dev.fbs9600_curr.module_curr_page;
|
import com.dev.fbs9600_groupvol.FCF651_groupvol_page;
|
import com.dev.fbs9600_groupvol.module_vol_page;
|
import com.dev.fbs9600_mon.SPCommMon;
|
import com.dev.fbs9600_mon.module_mon_page;
|
import com.dev.fbs9600_zdhj.zdhj_page_base;
|
import com.dev.nrf_lora_tester.loratester_page_base;
|
import com.dev.ntm.ntm_page_base;
|
|
import javax.swing.BoxLayout;
|
|
import java.awt.Dimension;
|
import java.awt.FlowLayout;
|
|
import javax.swing.JLabel;
|
import javax.swing.ImageIcon;
|
|
import java.awt.GridLayout;
|
|
import javax.swing.SwingConstants;
|
|
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.Logger;
|
|
public class main_window {
|
public static final int CommDevType_MON = 0;
|
public static final int CommDevType_CURR = 1;
|
public static final int CommDevType_GROUPVOL = 2;
|
public static final int CommDevType_FCF651VOL = 3;
|
public static final int CommDevType_ZDHJ = 4;
|
public static final int CommDevType_FBS9100 = 5;
|
public static final int CommDevType_NTM = 6;
|
public static final int CommDevType_LoraTest = 7;
|
public static final int CommDevType_BYBB = 8;
|
|
public static final int CommDevType_FBO4830 = 9;
|
|
|
|
public static int LANG_TYPE_CN = 0;
|
public static int LANG_TYPE_EN = 1;
|
|
//public String mTitle = "MSP&SAM&SWM&Curr_V1.523_220424G";
|
public String mTitle = "»ã¼¯Ä£¿éµ÷ÊÔ¹¤¾ß_V1.523_ZJ";
|
|
public static int LANG_TYPE = LANG_TYPE_CN;
|
public static final boolean APP_FBS9600_MON_EN = true;
|
public static final boolean APP_FBS9600_CURR_EN = true;
|
public static final boolean APP_FBS9600_GVOL_EN = true;
|
public static final boolean APP_FCF_GVOL_EN = true;
|
public static final boolean APP_FBS9600_ZDHJ_EN = true;
|
public static final boolean APP_BTSM_EN = true;
|
public static final boolean APP_NTM_EN = true;
|
public static final boolean APP_NTM_LORA_EN = true;
|
public static final boolean APP_BYBB_EN = true;
|
|
public int CommDevType = CommDevType_BYBB; //ĬÈÏÏÔʾtabÑ¡Ï
|
|
public boolean isDebugMode = true; //ÊÇ·ñΪµ÷ÊÔģʽtrue:µ÷ÊÔģʽ false:´ò°üģʽ[»áÒþ²Ø×ó²àÑ¡Ï]
|
|
public boolean MonVol_Is_Adj = false;
|
public boolean MonRes_Is_Test = false;
|
public boolean MonBianHao_Is_Test = false;
|
public String mLastTestID = "";
|
|
private JFrame frmSerialport;
|
private JButton btn_connet;
|
private JButton btn_break;
|
private JComboBox<String> cb_commport;
|
private JTextField tf_target_addr;
|
private JTextField tf_txcnt;
|
private JTextField tf_rxcnt;
|
|
private Timer mMainFormTimer = null;
|
static private ByteBuffer DataBuffer = ByteBuffer.allocate(256);
|
private JTabbedPane main_TabbedPane;
|
private JButton btn_renew_commport;
|
private JComboBox<String> cb_comm_bitrate;
|
|
private JComboBox<?> cb_dev_type;
|
private JButton btnNewButton;
|
private JButton btnNewButton_1;
|
private JLabel label;
|
private JTabbedPane tab_comm_type;
|
private JPanel panel_3;
|
private JTextField tf_ip_addr;
|
private JTextField tf_ip_port;
|
|
private module_mon_page panel_mon_base;
|
private module_curr_page panel_Curr_Module;
|
private module_vol_page panel_groupVol_Module;
|
private FCF651_groupvol_page panel_fcf651Vol_Module;
|
private zdhj_page_base panel_ZDHJ_base;
|
private bts_page_base panel_FBS9100_base;
|
private ntm_page_base panel_NTM_base;
|
private loratester_page_base panel_LoraTest_base;
|
private bybb_page_base panel_bybb_base;
|
|
|
/*********************************************************************************************/
|
static Logger m_Log = null;
|
@SuppressWarnings("rawtypes")
|
private JComboBox cb_tcp_udp;
|
static {
|
System.setProperty("log4j.configurationFile", "log4j2_batt_dev.xml");
|
// System.setProperty("contextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
|
}
|
/*********************************************************************************************/
|
|
/**
|
* Launch the application.
|
*/
|
public static void main(String[] args) {
|
m_Log = LogManager.getLogger(main_window.class);
|
|
//int dat = -30;
|
//System.out.println(String.format("dat=%4X", dat));
|
|
byte[] bf = new byte[8];
|
for(int n=0; n<bf.length; n++) {
|
bf[n] = (byte) n;
|
}
|
//short crc1 = Crc16.CalModBusCRC16(bf, bf.length);
|
//short crc2 = Crc16.CalCRC16(bf, bf.length);
|
//System.out.println("crc1:" + (crc1&0xFFFF) + ", " + "crc2:" + crc2);
|
/*
|
CRC32 crc32 = new CRC32();
|
crc32.reset();
|
crc32.update(bf);
|
System.out.println(ComFn.bytesToHexString(bf, bf.length));
|
System.out.println("byte[] crc32.getValue():" + crc32.getValue());
|
|
crc32.reset();
|
ByteBuffer bb = ByteBuffer.allocate(bf.length);
|
bb.put(bf);
|
bb.flip();
|
crc32.update(bb);
|
System.out.println("ByteBuffer crc32.getValue():" + crc32.getValue());
|
*/
|
|
String hostAddress = "127.0.0.1";
|
try {
|
//»ñÈ¡±¾»úipµØÖ·
|
hostAddress = InetAddress.getLocalHost().getHostAddress();
|
System.out.println(hostAddress);
|
} catch (UnknownHostException e1) {
|
e1.printStackTrace();
|
}
|
|
EventQueue.invokeLater(new Runnable() {
|
public void run() {
|
try {
|
main_window window = new main_window();
|
window.frmSerialport.setVisible(true);
|
} catch (Exception e) {
|
m_Log.error(e.toString(), e);
|
}
|
}
|
});
|
}
|
|
/**
|
* Create the application.
|
*/
|
public main_window() {
|
initialize();
|
}
|
|
/**
|
* Initialize the contents of the frame.
|
*/
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
private void initialize() {
|
frmSerialport = new JFrame();
|
frmSerialport.setFont(new Font("ËÎÌå", Font.PLAIN, 12));
|
//frmSerialport.setResizable(false);
|
frmSerialport.setTitle(mTitle);
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
frmSerialport.setTitle(this.mTitle + "_EN");
|
}
|
frmSerialport.setIconImage(Toolkit.getDefaultToolkit().getImage(main_window.class.getResource("/main/12164006.png")));
|
frmSerialport.setBounds(100, 100, 1030, 640);
|
frmSerialport.setMinimumSize(new Dimension(1030, 640) );
|
frmSerialport.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frmSerialport.setLocationRelativeTo(null);
|
|
Panel panel = new Panel();
|
frmSerialport.getContentPane().add(panel, BorderLayout.NORTH);
|
String comm_title = "ͨÐŵØÖ· / ²¨ÌØÂÊ";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
comm_title = "Comm Addr / Bit Rate";
|
}
|
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
|
JPanel panel_80 = new JPanel();
|
panel_80.setLayout(new GridLayout(0, 1));
|
|
tab_comm_type = new JTabbedPane(JTabbedPane.TOP);
|
panel_80.add(tab_comm_type);
|
|
panel.add(panel_80);
|
|
JPanel panel_8 = new JPanel();
|
tab_comm_type.addTab("RS485\u901A\u4FE1", null, panel_8, null);
|
panel_8.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u4E32\u53E3\u53F7 / \u6CE2\u7279\u7387", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
|
panel_8.setLayout(new FlowLayout(FlowLayout.CENTER, 2, 0));
|
btn_renew_commport = new JButton("\u5237\u65B0");
|
panel_8.add(btn_renew_commport);
|
btn_renew_commport.setIcon(new ImageIcon(main_window.class.getResource("/png_16x16/arrow_refresh.png")));
|
btn_renew_commport.setFont(new Font("ËÎÌå", Font.PLAIN, 12));
|
btn_renew_commport.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
CommSerialPort.searchCommPort(cb_commport);
|
if(cb_commport.getItemCount() > 0) {
|
cb_commport.setSelectedIndex(0);
|
}
|
}
|
});
|
|
cb_commport = new JComboBox<String>();
|
panel_8.add(cb_commport);
|
//cb_commport.setModel(new DefaultComboBoxModel<String>(new String[] {"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "COM10", "COM11", "COM12"}));
|
CommSerialPort.searchCommPort(cb_commport);
|
|
cb_comm_bitrate = new JComboBox();
|
cb_comm_bitrate.setModel(new DefaultComboBoxModel(new String[] {"2400", "4800", "9600", "19200", "38400", "57600", "115200"}));
|
cb_comm_bitrate.setSelectedIndex(2);
|
panel_8.add(cb_comm_bitrate);
|
|
cb_dev_type = new JComboBox();
|
cb_dev_type.setModel(new DefaultComboBoxModel(new String[] {"SAM", "MSP", "MSP_RF", "SWM(\u534E\u82AF\u5A01\u7279)"}));
|
panel_8.add(cb_dev_type);
|
|
label = new JLabel("");
|
panel_8.add(label);
|
|
panel_3 = new JPanel();
|
FlowLayout flowLayout = (FlowLayout) panel_3.getLayout();
|
flowLayout.setVgap(0);
|
panel_3.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "IP\u5730\u5740 / \u7AEF\u53E3", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
|
tab_comm_type.addTab("\u4EE5\u592A\u7F51\u901A\u4FE1", null, panel_3, null);
|
|
cb_tcp_udp = new JComboBox();
|
//cb_tcp_udp.setEnabled(false);
|
cb_tcp_udp.setModel(new DefaultComboBoxModel(new String[] {"TCP¿Í»§¶Ë", "TCP·þÎñÆ÷"}));
|
panel_3.add(cb_tcp_udp);
|
|
|
|
|
tf_ip_addr = new JTextField();
|
tf_ip_addr.setDocument(new LimitedDocument(16, "0123456789."));
|
tf_ip_addr.setText("192.168.10.102");
|
panel_3.add(tf_ip_addr);
|
tf_ip_addr.setColumns(10);
|
|
tf_ip_port = new JTextField();
|
tf_ip_port.setDocument(new LimitedDocument(6, "0123456789"));
|
tf_ip_port.setText("1025");
|
panel_3.add(tf_ip_port);
|
tf_ip_port.setColumns(10);
|
|
JPanel panel_1 = new JPanel();
|
comm_title = "´®¿ÚºÅ";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
comm_title = "Comm Port";
|
}
|
panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u8BBE\u5907\u5730\u5740", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
|
panel.add(panel_1);
|
if(cb_commport.getItemCount() > 0) {
|
cb_commport.setSelectedIndex(0);
|
}
|
|
comm_title = "Ë¢ÐÂ";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
comm_title = "Reflesh";
|
}
|
panel_1.setLayout(new GridLayout(0, 3, 0, 0));
|
|
btnNewButton = new JButton("\u4E0A\u4E00\u4E2A");
|
panel_1.add(btnNewButton);
|
btnNewButton.setIcon(new ImageIcon(main_window.class.getResource("/png_16x16/arrow_left.png")));
|
btnNewButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
int addr = Integer.parseInt(tf_target_addr.getText());
|
if(addr > 0) {
|
addr -= 1;
|
} else {
|
addr = 255;
|
}
|
tf_target_addr.setText(String.valueOf(addr));
|
}
|
});
|
|
tf_target_addr = new JTextField();
|
tf_target_addr.setHorizontalAlignment(SwingConstants.CENTER);
|
tf_target_addr.setFont(new Font("ËÎÌå", Font.PLAIN, 32));
|
panel_1.add(tf_target_addr);
|
tf_target_addr.addFocusListener(new FocusAdapter() {
|
@Override
|
public void focusLost(FocusEvent e) {
|
if(tf_target_addr.getText().trim().length() < 1) {
|
tf_target_addr.setText("255");
|
}
|
}
|
});
|
tf_target_addr.setDocument(new LimitedDocument(3, "0123456789"));
|
tf_target_addr.setText("255");
|
tf_target_addr.setColumns(4);
|
|
btnNewButton_1 = new JButton("\u4E0B\u4E00\u4E2A");
|
panel_1.add(btnNewButton_1);
|
btnNewButton_1.setIcon(new ImageIcon(main_window.class.getResource("/png_16x16/arrow_right.png")));
|
btnNewButton_1.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
int addr = Integer.parseInt(tf_target_addr.getText());
|
if(++addr > 255) {
|
addr = 0;
|
}
|
tf_target_addr.setText(String.valueOf(addr));
|
}
|
});
|
|
JPanel panel_2 = new JPanel();
|
comm_title = "²Ù×÷";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
comm_title = "Operation";
|
}
|
panel_2.setBorder(new TitledBorder(null, comm_title, TitledBorder.LEADING, TitledBorder.TOP, null, null));
|
panel.add(panel_2);
|
|
comm_title = "Á¬½Ó";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
comm_title = "Connect";
|
}
|
btn_connet = new JButton(comm_title);
|
btn_connet.setIcon(new ImageIcon(main_window.class.getResource("/png_16x16/connect.png")));
|
btn_connet.setFont(new Font("ËÎÌå", Font.PLAIN, 24));
|
btn_connet.setEnabled(true);
|
btn_connet.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
int comm_type = tab_comm_type.getSelectedIndex();
|
|
//System.out.println(comm_type);
|
String spname_or_ipaddr;
|
int bitrate_or_ipport = Integer.parseInt((String)cb_comm_bitrate.getSelectedItem());
|
|
if(SPCommMon.COMM_PORT_TYPE_Serial == comm_type) {
|
spname_or_ipaddr = cb_commport.getSelectedItem().toString();
|
if(cb_commport.getSelectedIndex() < 0) {
|
Toolkit.getDefaultToolkit().beep();
|
JOptionPane.showMessageDialog(frmSerialport, "ÕÒ²»µ½Èκδ®¿Ú!");
|
return;
|
}
|
} else {
|
spname_or_ipaddr = tf_ip_addr.getText().trim();
|
bitrate_or_ipport = Integer.parseInt(tf_ip_port.getText().trim());
|
}
|
|
int main_DevType = main_TabbedPane.getSelectedIndex();
|
boolean comm_open_res = true;
|
int monomer_devType = cb_dev_type.getSelectedIndex();
|
if(main_window.CommDevType_MON == main_DevType) {
|
int comm_multy_type = CommSerialPort.mutycomm_Type_Samd09;
|
if(0 == monomer_devType) {
|
comm_multy_type = CommSerialPort.mutycomm_Type_Samd09;
|
} else if(1 == monomer_devType) {
|
comm_multy_type = CommSerialPort.mutycomm_Type_Msp430;
|
} else if(2 == monomer_devType) {
|
comm_multy_type = CommSerialPort.mutycomm_Type_Samd09;
|
} else if(3 == monomer_devType) {
|
comm_multy_type = CommSerialPort.mutycomm_Type_SWM;
|
}
|
|
comm_open_res = panel_mon_base.openCommPort(comm_type, spname_or_ipaddr, bitrate_or_ipport,
|
monomer_devType, comm_multy_type, tf_target_addr, m_Log);
|
} else if(main_window.CommDevType_CURR == main_DevType) {
|
comm_open_res = panel_Curr_Module.openCommPort(comm_type, spname_or_ipaddr, bitrate_or_ipport,
|
monomer_devType, CommSerialPort.mutycomm_Type_Samd09, tf_target_addr, m_Log);
|
} else if(main_window.CommDevType_GROUPVOL == main_DevType) {
|
comm_open_res = panel_groupVol_Module.openCommPort(comm_type, spname_or_ipaddr, bitrate_or_ipport,
|
monomer_devType, CommSerialPort.mutycomm_Type_Samd09, tf_target_addr, m_Log);
|
} else if(main_window.CommDevType_FCF651VOL == main_DevType) {
|
comm_open_res = panel_fcf651Vol_Module.openCommPort(comm_type, spname_or_ipaddr, bitrate_or_ipport,
|
monomer_devType, CommSerialPort.mutycomm_Type_Samd09, tf_target_addr);
|
} else if(main_window.CommDevType_ZDHJ == main_DevType) {
|
int dev_addr = Integer.parseInt(tf_target_addr.getText().trim());
|
comm_open_res = panel_ZDHJ_base.openCommPort(comm_type, spname_or_ipaddr,
|
bitrate_or_ipport, dev_addr, m_Log);
|
} else if(main_window.CommDevType_FBS9100 == main_DevType) {
|
int dev_addr = Integer.parseInt(tf_target_addr.getText().trim());
|
comm_open_res = panel_FBS9100_base.openCommPort(comm_type, spname_or_ipaddr,
|
bitrate_or_ipport, dev_addr, m_Log);
|
} else if(main_window.CommDevType_NTM == main_DevType) {
|
int dev_addr = Integer.parseInt(tf_target_addr.getText().trim());
|
comm_open_res = panel_NTM_base.openCommPort(comm_type, spname_or_ipaddr,
|
bitrate_or_ipport, dev_addr, m_Log);
|
} else if(main_window.CommDevType_LoraTest == main_DevType) {
|
comm_open_res = panel_LoraTest_base.openCommPort(comm_type, spname_or_ipaddr, bitrate_or_ipport, m_Log);
|
} else if(main_window.CommDevType_BYBB == main_DevType) {
|
int dev_addr = Integer.parseInt(tf_target_addr.getText().trim());
|
comm_open_res = panel_bybb_base.openCommPort(comm_type, spname_or_ipaddr,
|
bitrate_or_ipport, dev_addr, m_Log);
|
}
|
|
if(true == comm_open_res) {
|
CommDevType = main_DevType;
|
|
main_TabbedPane.setEnabled(false);
|
tf_target_addr.setEditable(false);
|
btn_renew_commport.setEnabled(false);
|
cb_commport.setEnabled(false);
|
btn_connet.setEnabled(false);
|
btn_break.setEnabled(true);
|
cb_comm_bitrate.setEnabled(false);
|
cb_dev_type.setEnabled(false);
|
|
mMainFormTimer.start();
|
} else {
|
Toolkit.getDefaultToolkit().beep();
|
JOptionPane.showMessageDialog(frmSerialport, spname_or_ipaddr + "²»´æÔÚ»ò±»ÆäËûÓ¦ÓóÌÐòÕ¼ÓÃ!");
|
}
|
}
|
});
|
panel_2.setLayout(new GridLayout(0, 2, 0, 0));
|
panel_2.add(btn_connet);
|
|
comm_title = "¶Ï¿ª";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
comm_title = "Break";
|
}
|
btn_break = new JButton(comm_title);
|
btn_break.setIcon(new ImageIcon(main_window.class.getResource("/png_16x16/disconnect.png")));
|
btn_break.setFont(new Font("ËÎÌå", Font.PLAIN, 24));
|
panel_2.add(btn_break);
|
btn_break.setEnabled(false);
|
btn_break.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
mMainFormTimer.stop();
|
if(null != panel_mon_base) {
|
panel_mon_base.closeCommPort();
|
}
|
if(null != panel_Curr_Module) {
|
panel_Curr_Module.closeCommPort();
|
}
|
if(null != panel_groupVol_Module) {
|
panel_groupVol_Module.closeCommPort();
|
}
|
if(null != panel_fcf651Vol_Module) {
|
panel_fcf651Vol_Module.closeCommPort();
|
}
|
if(null != panel_ZDHJ_base) {
|
panel_ZDHJ_base.closeCommPort();
|
}
|
if(null != panel_FBS9100_base) {
|
panel_FBS9100_base.closeCommPort();
|
panel_FBS9100_base.setButttonState(false);
|
}
|
if(null != panel_NTM_base) {
|
panel_NTM_base.closeCommPort();
|
}
|
if(null != panel_LoraTest_base) {
|
panel_LoraTest_base.closeCommPort();
|
}
|
if(null != panel_bybb_base) {
|
panel_bybb_base.closeCommPort();
|
}
|
|
tf_target_addr.setEditable(true);
|
btn_renew_commport.setEnabled(true);
|
cb_commport.setEnabled(true);
|
btn_connet.setEnabled(true);
|
btn_break.setEnabled(false);
|
cb_dev_type.setEnabled(true);
|
cb_comm_bitrate.setEnabled(true);
|
|
if((LANG_TYPE_EN == LANG_TYPE)/* || (1 == APP_ZDHJ_ONLY)*/) {
|
main_TabbedPane.setSelectedIndex(1);
|
main_TabbedPane.setEnabled(false);
|
} else {
|
main_TabbedPane.setEnabled(true);
|
}
|
}
|
});
|
|
JPanel panel_9 = new JPanel();
|
comm_title = "ͨÐżÆÊý(TX / RX)";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
comm_title = "Comm Count(TX / RX)";
|
}
|
panel_9.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "\u901A\u4FE1\u8BA1\u6570(TX/RX)", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
|
panel.add(panel_9);
|
panel_9.setLayout(new GridLayout(0, 1, 0, 0));
|
|
tf_txcnt = new JTextField();
|
tf_txcnt.setFont(new Font("ËÎÌå", Font.PLAIN, 16));
|
panel_9.add(tf_txcnt);
|
tf_txcnt.setColumns(12);
|
|
tf_rxcnt = new JTextField();
|
tf_rxcnt.setFont(new Font("ËÎÌå", Font.PLAIN, 16));
|
panel_9.add(tf_rxcnt);
|
tf_rxcnt.setColumns(12);
|
|
main_TabbedPane = new JTabbedPane(JTabbedPane.LEFT);
|
main_TabbedPane.setFont(new Font("ËÎÌå", Font.PLAIN, 20));
|
main_TabbedPane.addChangeListener(new ChangeListener() {
|
public void stateChanged(ChangeEvent arg0) {
|
cb_dev_type.setSelectedIndex(0);
|
}
|
});
|
frmSerialport.getContentPane().add(main_TabbedPane, BorderLayout.CENTER);
|
|
//=======================================================================//
|
if(APP_FBS9600_MON_EN) {
|
panel_mon_base = new module_mon_page();
|
String dt_title = "µ¥ÌåÄ£¿é";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
dt_title = "Mon Module";
|
}
|
main_TabbedPane.add(dt_title, panel_mon_base);
|
main_TabbedPane.setIconAt(0, new ImageIcon(main_window.class.getResource("/png_16x16/application.png")));
|
} else {
|
main_TabbedPane.add("", new JPanel());
|
}
|
//=======================================================================//
|
if(APP_FBS9600_CURR_EN) {
|
panel_Curr_Module = new module_curr_page();
|
String Curr_Module_title = "µçÁ÷Ä£¿é";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
Curr_Module_title = "Curr Module";
|
}
|
main_TabbedPane.add(Curr_Module_title, panel_Curr_Module);
|
main_TabbedPane.setIconAt(1, new ImageIcon(main_window.class.getResource("/png_16x16/application_link.png")));
|
} else {
|
main_TabbedPane.add("", new JPanel());
|
}
|
//=======================================================================//
|
if(APP_FBS9600_GVOL_EN) {
|
panel_groupVol_Module = new module_vol_page();
|
String vol_Module_title = "×éѹģ¿é";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
vol_Module_title = "GroupVol Module";
|
}
|
main_TabbedPane.add(vol_Module_title, panel_groupVol_Module);
|
main_TabbedPane.setIconAt(2, new ImageIcon(main_window.class.getResource("/png_16x16/application_lightning.png")));
|
} else {
|
main_TabbedPane.add("", new JPanel());
|
}
|
|
if(APP_FCF_GVOL_EN) {
|
panel_fcf651Vol_Module = new FCF651_groupvol_page();
|
String vol_Module_title = "FCF×éѹ";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
vol_Module_title = "FCF651 GroupVol";
|
}
|
main_TabbedPane.add(vol_Module_title, panel_fcf651Vol_Module);
|
main_TabbedPane.setIconAt(3, new ImageIcon(main_window.class.getResource("/png_16x16/application_lightning.png")));
|
} else {
|
main_TabbedPane.add("", new JPanel());
|
}
|
|
//======================================================================//
|
if(APP_FBS9600_ZDHJ_EN) {
|
panel_ZDHJ_base = new zdhj_page_base();
|
String zdhj_title = "»ã¼¯Ä£¿é";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
zdhj_title = "Collect Module";
|
}
|
main_TabbedPane.add(zdhj_title, panel_ZDHJ_base);
|
main_TabbedPane.setIconAt(4, new ImageIcon(main_window.class.getResource("/png_16x16/application_view_tile.png")));
|
} else {
|
main_TabbedPane.add("", new JPanel());
|
}
|
//======================================================================//
|
if(APP_BTSM_EN) {
|
panel_FBS9100_base = new bts_page_base();
|
String fbs9100_title = "BTSÖ÷¿Ø";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
fbs9100_title = "BTS Module";
|
}
|
main_TabbedPane.add(fbs9100_title, panel_FBS9100_base);
|
main_TabbedPane.setIconAt(5, new ImageIcon(main_window.class.getResource("/png_16x16/application_home.png")));
|
} else {
|
main_TabbedPane.add("", new JPanel());
|
}
|
//======================================================================//
|
if(APP_NTM_EN) {
|
String ntm_title = "NT·ÅµçÒÇ";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
ntm_title = "NT Tester";
|
}
|
panel_NTM_base = new ntm_page_base(m_Log);
|
main_TabbedPane.add(ntm_title, panel_NTM_base);
|
main_TabbedPane.setIconAt(6, new ImageIcon(main_window.class.getResource("/png_16x16/layer_treansparent.png")));
|
} else {
|
main_TabbedPane.add("", new JPanel());
|
}
|
//======================================================================//
|
if(APP_NTM_LORA_EN) {
|
String loratest_title = "Lora²âÊÔ";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
loratest_title = "NT Tester";
|
}
|
panel_LoraTest_base = new loratester_page_base(m_Log);
|
main_TabbedPane.add(loratest_title, panel_LoraTest_base);
|
main_TabbedPane.setIconAt(7, new ImageIcon(main_window.class.getResource("/png_16x16/layer_treansparent.png")));
|
} else {
|
main_TabbedPane.add("", new JPanel());
|
}
|
//======================================================================//
|
if(APP_BYBB_EN) {
|
String bybb_title = "BYBB²âÊÔ";
|
if(LANG_TYPE_EN == LANG_TYPE) {
|
bybb_title = "bybb Tester";
|
}
|
panel_bybb_base = new bybb_page_base();
|
main_TabbedPane.add(bybb_title, panel_bybb_base);
|
main_TabbedPane.setIconAt(8, new ImageIcon(main_window.class.getResource("/png_16x16/layer_treansparent.png")));
|
if(APP_BYBB_EN) {
|
tf_ip_port.setText("6600");
|
tab_comm_type.setSelectedIndex(1);
|
//tab_comm_type.setEnabled(false);
|
main_TabbedPane.setSelectedIndex(main_window.CommDevType_BYBB);
|
main_TabbedPane.setEnabled(false);
|
}
|
} else {
|
main_TabbedPane.add("back_up", new JPanel());
|
}
|
/**************************************************************************/
|
if((LANG_TYPE_EN == LANG_TYPE)/* || (1 == APP_ZDHJ_ONLY)*/) {
|
main_TabbedPane.setSelectedIndex(1);
|
main_TabbedPane.setEnabled(false);
|
}
|
/**************************************************************************/
|
|
//´ò°üģʽÅжÏÑ¡Ïî--Òþ²Ø×ó²àÑ¡¿¨¿¨
|
if(CommDevType >= CommDevType_MON && CommDevType <= CommDevType_BYBB) {
|
//Ñ¡ÖÐĬÈÏÑ¡Ï
|
main_TabbedPane.setSelectedIndex(CommDevType);
|
if(!isDebugMode) {
|
main_TabbedPane.setVisible(false);
|
switch(CommDevType) {
|
case CommDevType_MON:{
|
frmSerialport.getContentPane().add(panel_mon_base, BorderLayout.CENTER);
|
}break;
|
case CommDevType_CURR:{
|
frmSerialport.getContentPane().add(panel_Curr_Module, BorderLayout.CENTER);
|
}break;
|
case CommDevType_GROUPVOL:{
|
frmSerialport.getContentPane().add(panel_groupVol_Module, BorderLayout.CENTER);
|
}break;
|
case CommDevType_FCF651VOL:{
|
frmSerialport.getContentPane().add(panel_fcf651Vol_Module, BorderLayout.CENTER);
|
}break;
|
case CommDevType_ZDHJ:{
|
//panel_3.setVisible(false);
|
tab_comm_type.remove(panel_3);
|
|
frmSerialport.getContentPane().add(panel_ZDHJ_base, BorderLayout.CENTER);
|
}break;
|
case CommDevType_FBS9100:{
|
frmSerialport.getContentPane().add(panel_FBS9100_base, BorderLayout.CENTER);
|
}break;
|
case CommDevType_NTM:{
|
frmSerialport.getContentPane().add(panel_NTM_base, BorderLayout.CENTER);
|
}break;
|
case CommDevType_LoraTest:{
|
frmSerialport.getContentPane().add(panel_LoraTest_base, BorderLayout.CENTER);
|
}break;
|
case CommDevType_BYBB:{
|
frmSerialport.getContentPane().add(panel_bybb_base, BorderLayout.CENTER);
|
}break;
|
}
|
}
|
}
|
/**************************************************************************/
|
mMainFormTimer = new Timer(200, new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
updateData();
|
}
|
});
|
/**************************************************************************/
|
}
|
|
public static void setCommData(ByteBuffer bf) {
|
DataBuffer.position(0);
|
DataBuffer.put(bf.array());
|
}
|
|
private void updateData() {
|
try{
|
frmSerialport.setTitle(this.mTitle + " " + Com.get_DTF(new Date(), Com.DTF_YMDhms));
|
|
if(CommDevType_MON == CommDevType) {
|
tf_txcnt.setText(String.format("TX:%d", panel_mon_base.Comm_Mon.comm_tx_cnt));
|
tf_rxcnt.setText(String.format("RX:%d", panel_mon_base.Comm_Mon.comm_rx_cnt));
|
|
panel_mon_base.updateData();
|
} else if(CommDevType_CURR == CommDevType) {
|
tf_txcnt.setText(String.format("TX:%d", panel_Curr_Module.Comm_Curr.comm_tx_cnt));
|
tf_rxcnt.setText(String.format("RX:%d", panel_Curr_Module.Comm_Curr.comm_rx_cnt));
|
|
panel_Curr_Module.updateData();
|
} else if(CommDevType_GROUPVOL == CommDevType) {
|
tf_txcnt.setText(String.format("TX:%d", panel_groupVol_Module.Comm_Vol.comm_tx_cnt));
|
tf_rxcnt.setText(String.format("RX:%d", panel_groupVol_Module.Comm_Vol.comm_rx_cnt));
|
|
panel_groupVol_Module.updateData();
|
} else if(CommDevType_FCF651VOL == CommDevType) {
|
tf_txcnt.setText(String.format("TX:%d", panel_fcf651Vol_Module.Comm_Vol.comm_tx_cnt));
|
tf_rxcnt.setText(String.format("RX:%d", panel_fcf651Vol_Module.Comm_Vol.comm_rx_cnt));
|
|
panel_fcf651Vol_Module.updateData();
|
} else if(CommDevType_ZDHJ == CommDevType) {
|
tf_txcnt.setText(String.format("TX:%d", panel_ZDHJ_base.Comm_ZDHJ.comm_tx_cnt));
|
tf_rxcnt.setText(String.format("RX:%d", panel_ZDHJ_base.Comm_ZDHJ.comm_rx_cnt));
|
|
panel_ZDHJ_base.updateData();
|
} else if(CommDevType_FBS9100 == CommDevType) {
|
tf_txcnt.setText(String.format("TX:%d", panel_FBS9100_base.Comm_BTS.comm_tx_cnt));
|
tf_rxcnt.setText(String.format("RX:%d", panel_FBS9100_base.Comm_BTS.comm_rx_cnt));
|
|
panel_FBS9100_base.updateData();
|
} if(CommDevType_NTM == CommDevType) {
|
tf_txcnt.setText(String.format("TX:%d", panel_NTM_base.Comm_NTM.comm_tx_cnt));
|
tf_rxcnt.setText(String.format("RX:%d", panel_NTM_base.Comm_NTM.comm_rx_cnt));
|
|
panel_NTM_base.updateData();
|
} if(CommDevType_LoraTest == CommDevType) {
|
tf_txcnt.setText(String.format("TX:%d", panel_LoraTest_base.Comm_LoraTester.comm_tx_cnt));
|
tf_rxcnt.setText(String.format("RX:%d", panel_LoraTest_base.Comm_LoraTester.comm_rx_cnt));
|
|
panel_LoraTest_base.updateData();
|
} if(CommDevType_BYBB == CommDevType) {
|
tf_txcnt.setText(String.format("TX:%d", panel_bybb_base.Comm_BYBB.comm_tx_cnt));
|
tf_rxcnt.setText(String.format("RX:%d", panel_bybb_base.Comm_BYBB.comm_rx_cnt));
|
|
panel_bybb_base.updateData();
|
}
|
} catch (Exception e) {
|
m_Log.error(e.toString(), e);
|
}
|
}
|
}
|