whyclxw
2021-01-07 b176b5ddfc7540a688f6e73a6bfa7415c75c63e3
修改为只含大功率整流电源
3个文件已删除
1 文件已重命名
1个文件已添加
2个文件已修改
3262 ■■■■ 已修改文件
Demo_Rectifier_power_4MwModBus_Tester/.settings/org.eclipse.core.resources.prefs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Demo_Rectifier_power_4MwModBus_Tester/src/com/dev/Rectifier_power/Rectifier_power.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Demo_Rectifier_power_4MwModBus_Tester/src/com/dev/central/Central_ST_Data.java 356 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Demo_Rectifier_power_4MwModBus_Tester/src/com/sp_comm/Central_Monitor_Thread.java 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Demo_Rectifier_power_4MwModBus_Tester/src/com/sp_comm/Rectifier_Power_Thread.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Demo_Rectifier_power_4MwModBus_Tester/src/main/main_window_Rectifier_power_4MW.java 610 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Demo_Rectifier_power_4MwModBus_Tester/src/main/main_window_central_monitor.java 2209 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Demo_Rectifier_power_4MwModBus_Tester/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/main_window_central_monitor.java=GBK
encoding//src/main/main_window_Rectifier_power_4MW.java=GBK
encoding/<project>=GBK
Demo_Rectifier_power_4MwModBus_Tester/src/com/dev/Rectifier_power/Rectifier_power.java
File was renamed from Demo_Rectifier_power_4MwModBus_Tester/src/com/dev/central/Rectifier_power.java
@@ -1,4 +1,4 @@
package com.dev.central;
package com.dev.Rectifier_power;
import java.io.Serializable;
import java.util.Date;
@@ -11,7 +11,6 @@
import com.serotonin.modbus4j.BatchRead;
import com.serotonin.modbus4j.BatchResults;
import com.serotonin.modbus4j.code.DataType;
import com.sp_comm.Central_Monitor_Thread;
public class Rectifier_power implements Serializable{
      private int num ;//,
Demo_Rectifier_power_4MwModBus_Tester/src/com/dev/central/Central_ST_Data.java
File was deleted
Demo_Rectifier_power_4MwModBus_Tester/src/com/sp_comm/Central_Monitor_Thread.java
File was deleted
Demo_Rectifier_power_4MwModBus_Tester/src/com/sp_comm/Rectifier_Power_Thread.java
@@ -1,7 +1,6 @@
package com.sp_comm;
import com.dev.central.Central_ST_Data;
import com.dev.central.Rectifier_power;
import com.dev.Rectifier_power.Rectifier_power;
import com.intelligt.modbus.MyJlibModbus;
import com.modbus.data.MyModbusMaster;
Demo_Rectifier_power_4MwModBus_Tester/src/main/main_window_Rectifier_power_4MW.java
New file
@@ -0,0 +1,610 @@
package main;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import javax.swing.JFrame;
import java.awt.Panel;
import java.awt.BorderLayout;
import javax.swing.JComboBox;
import java.awt.GridLayout;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import javax.swing.JButton;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFileChooser;
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.JToggleButton;
import javax.swing.UIManager;
import java.awt.Color;
import java.nio.ByteBuffer;
import java.util.Date;
import java.util.Vector;
import javax.swing.JTabbedPane;
import javax.swing.JScrollPane;
import java.awt.Font;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.event.ChangeListener;
import javax.swing.event.ChangeEvent;
import com.LimitedDocument;
import com.dev.Rectifier_power.Rectifier_power;
import com.intelligt.modbus.jlibmodbus.exception.IllegalDataAddressException;
import com.intelligt.modbus.jlibmodbus.exception.IllegalDataValueException;
import com.modbus.data.MyModbusMaster;
import com.modbus.data.MyModbusUtils;
import com.sp_comm.Rectifier_Power_Thread;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
 *    集中监控系统
 * @author LiJun
 *
 */
public class main_window_Rectifier_power_4MW {
    public static final int PanelDevType_Rectifier_power =5;        //大功率整流电源
    public int main_TabbedPane_SelIndex = 0;
    private JFrame frmSerialport;
    private JButton btn_connet;
    private JButton btn_break;
    private JComboBox<String> cb_commport;
    private Rectifier_Power_Thread rectifier_Power_Thread;
    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 JTextField tf_slave_id;
    private JComboBox<String> comboBox;
    private JTabbedPane tab_panel_zdhj;
    /**************************** 大功率整流电源 ***********************************************/
    private JPanel panel_rectifier_power;
    private JPanel panel_601;
    private JPanel panel_602;
    private JPanel panel_603;
    private JPanel panel_604;
    private JPanel panel_605;
    private JPanel panel_606;
    private JPanel panel_607;
    private JPanel panel_608;
    private JPanel panel_609;
    private JPanel panel_6010;
    private JPanel panel_6011;
    private JPanel panel_6012;
    private JPanel panel_6013;
    private JPanel panel_6014;
    private JPanel panel_6015;
    private JTextField tf_switch_on10kv;            //'10kv开关合闸信号',
    private JTextField tf_switch_off10kv;            //'10kv开关分闸信号',
    private JTextField tf_switch_allow;                //'10KV高压开关允许合闸信号',
    private JTextField tf_rectifier_falut;            //'整流器故障跳闸信号',
    private JTextField rectifier_power_state;        //'大功率整流电源运行/停止状态信号',
    private JTextField rectifier_alarm;                //'大功率整流电源故障状态信号',
    private JTextField rectifier_vol;                //'大功率整流电源电压信号',
    private JTextField rectifier_curr;                //'大功率整流电源电流信号',
    private JTextField com_signal;                //'通讯信号',
    private JToggleButton btn_remote_stop;                //'工艺、综控远方停止大功率整流器',
    private JToggleButton btn_emergency_stop;                //'工艺、综控远方紧急停止大功率整流器',
    private JButton btn_start_rectifier;        //开始自动模拟
    private JButton btn_stop_rectifier;        //停止停止模拟
    private JButton btn_read_rectifier;        //读取数据
    private JButton btn_write_rectifier;        //写入数据
    public static Logger logger = null;
    public static MyModbusMaster mymaster = null;
    static{
        System.setProperty("log4j.configurationFile", "log4j2_modbus_tester.xml");
    }
    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        logger = LogManager.getLogger(main_window_Rectifier_power_4MW.class);
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    main_window_Rectifier_power_4MW window = new main_window_Rectifier_power_4MW();
                    window.frmSerialport.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
    /**
     * Create the application.
     */
    public main_window_Rectifier_power_4MW() {
        initialize();
    }
    /**
     * Initialize the contents of the frame.
     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    private void initialize() {
        frmSerialport = new JFrame();
        //frmSerialport.setResizable(false);
        frmSerialport.setTitle("MyModBus-TESTER_V1.00");
        frmSerialport.setIconImage(Toolkit.getDefaultToolkit().getImage(main_window_Rectifier_power_4MW.class.getResource("/main/uis.png")));
        frmSerialport.setBounds(100, 100, 805, 570);
        frmSerialport.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frmSerialport.setLocationRelativeTo(null);
        Panel panel = new Panel();
        frmSerialport.getContentPane().add(panel, BorderLayout.NORTH);
        panel.setLayout(new GridLayout(0, 4, 0, 0));
        JPanel panel_8 = new JPanel();
        panel_8.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "IP地址", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        //panel_8.setFont(arg0);
        panel_8.setFont(new Font("宋体", Font.PLAIN, 12));
        panel.add(panel_8);
        panel_8.setLayout(new GridLayout(0, 1, 0, 0));
        tf_target_addr = new JTextField();
        tf_target_addr.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
                if(tf_target_addr.getText().trim().length() < 1) {
                    tf_target_addr.setText("127.0.0.1");
                }
            }
        });
        tf_target_addr.setDocument(new LimitedDocument(15, "0123456789."));
        tf_target_addr.setText("127.0.0.1");
        panel_8.add(tf_target_addr);
        tf_target_addr.setColumns(10);
        comboBox = new JComboBox();
        comboBox.setModel(new DefaultComboBoxModel(new String[] {"9600", "19200", "38400", "57600", "115200"}));
        comboBox.setSelectedIndex(4);
        //panel_8.add(comboBox);
        JPanel panel_1 = new JPanel();
        panel_1.setBorder(new TitledBorder(null, "Slave ID", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel.add(panel_1);
        cb_commport = new JComboBox<String>();
        if(cb_commport.getItemCount() > 0) {
            cb_commport.setSelectedIndex(0);
        }
        panel_1.setLayout(new GridLayout(0, 1, 0, 0));
        //slave ID
        tf_slave_id = new JTextField();
        tf_slave_id.addFocusListener(new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
                if(tf_slave_id.getText().trim().length() < 1) {
                    tf_slave_id.setText("2");
                }
            }
        });
        tf_slave_id.setDocument(new LimitedDocument(1, "123456789"));
        tf_slave_id.setText("2");
        panel_1.add(tf_slave_id);
        tf_slave_id.setColumns(10);
        btn_renew_commport = new JButton("\u5237\u65B0");
        btn_renew_commport.setFont(new Font("宋体", Font.PLAIN, 12));
        /*btn_renew_commport.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                SPCommFBS9100.searchCommPort(cb_commport);
                if(cb_commport.getItemCount() > 0) {
                    cb_commport.setSelectedIndex(0);
                }
            }
        });*/
        //panel_1.add(btn_renew_commport);
        //panel_1.add(cb_commport);
        JPanel panel_2 = new JPanel();
        panel_2.setBorder(new TitledBorder(null, "操作", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel.add(panel_2);
        btn_connet = new JButton("开始监听");
        btn_connet.setFont(new Font("宋体", Font.PLAIN, 12));
        btn_connet.setEnabled(true);
        btn_connet.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                int slave_id = Integer.parseInt(tf_slave_id.getText());
                String serverip = tf_target_addr.getText();
                if(slave_id < 0 && serverip.length()< 1) {
                    Toolkit.getDefaultToolkit().beep();
                    JOptionPane.showMessageDialog(frmSerialport, "请输入配置信息!");
                    return;
                }
                boolean comm_open_res = true;
                {
                    rectifier_Power_Thread = new Rectifier_Power_Thread(serverip, slave_id);
                    new Thread(rectifier_Power_Thread).start();
                }
                if(true == comm_open_res) {
                    main_TabbedPane.setEnabled(false);
                    tf_target_addr.setEditable(false);
                    btn_renew_commport.setEnabled(false);
                    tf_slave_id.setEnabled(false);
                    cb_commport.setEnabled(false);
                    btn_connet.setEnabled(false);
                    panel_rectifier_power.setEnabled(false);
                    btn_break.setEnabled(true);
                    //4MW大功率整流电源
                    btn_remote_stop.setEnabled(true);
                    btn_emergency_stop.setEnabled(true);
                    btn_start_rectifier.setEnabled(true);                    //开始自动模拟
                    //btn_stop_simul_dcdis.setEnabled(true);                //停止停止模拟
                    btn_read_rectifier.setEnabled(true);                    //读取数据
                    btn_write_rectifier.setEnabled(true);                    //写入数据
                    mMainFormTimer.start();
                } else {
                    Toolkit.getDefaultToolkit().beep();
                    JOptionPane.showMessageDialog(frmSerialport, "不存在或被其他应用程序占用!");
                }
            }
        });
        panel_2.setLayout(new GridLayout(0, 2, 0, 0));
        panel_2.add(btn_connet);
        btn_break = new JButton("停止监听");
        btn_break.setFont(new Font("宋体", Font.PLAIN, 12));
        panel_2.add(btn_break);
        btn_break.setEnabled(false);
        btn_break.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                //System.out.println("关闭串口");
                mMainFormTimer.stop();
                /*if(null != SerialComm_FBS9100) {
                    SerialComm_FBS9100.CloseCommPort();
                }*/
                tf_target_addr.setEditable(true);
                btn_renew_commport.setEnabled(true);
                cb_commport.setEnabled(true);
                btn_connet.setEnabled(true);
                tf_slave_id.setEnabled(true);
                btn_break.setEnabled(false);
                panel_rectifier_power.setEnabled(true);
                main_TabbedPane.setEnabled(true);
                //4MW大功率整流电源
                btn_emergency_stop.setEnabled(false);
                btn_remote_stop.setEnabled(false);
                btn_start_rectifier.setEnabled(false);                //开始自动模拟
                btn_stop_rectifier.setEnabled(false);                    //停止停止模拟
                btn_read_rectifier.setEnabled(false);                    //读取数据
                btn_write_rectifier.setEnabled(false);                //写入数据
                rectifier_Power_Thread.running_en=false;
                rectifier_Power_Thread.mymodbus.destory();
            }
        });
        JPanel panel_9 = new JPanel();
        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, 2, 0, 0));
        tf_txcnt = new JTextField();
        panel_9.add(tf_txcnt);
        tf_txcnt.setColumns(10);
        tf_rxcnt = new JTextField();
        panel_9.add(tf_rxcnt);
        tf_rxcnt.setColumns(10);
        tab_panel_zdhj = new JTabbedPane(JTabbedPane.TOP);
        main_TabbedPane = new JTabbedPane(JTabbedPane.TOP);
        main_TabbedPane.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent arg0) {
                /*
                if(null != SerialComm_Mon) {
                    SerialComm_Mon.setNormalCommState(1!=main_TabbedPane.getSelectedIndex());
                }
                */
                //System.err.println("###########");
            }
        });
        frmSerialport.getContentPane().add(main_TabbedPane, BorderLayout.CENTER);
        /**************************************************************************/
        main_TabbedPane.add("MODBUS TCP 模块", tab_panel_zdhj);
        /******************************************************************************/
        panel_rectifier_power=new JPanel();
        tab_panel_zdhj.add("4MW大功率整流电源",panel_rectifier_power);
        panel_rectifier_power.setVisible(false);
        panel_rectifier_power.setLayout(new BorderLayout(0, 0));
        panel_601 = new JPanel();
        panel_rectifier_power.add(panel_601);
        panel_601.setLayout(new GridLayout(1, 1, 4, 0));
        panel_602 = new JPanel();
        panel_601.add(panel_602);
        panel_602.setLayout(new FlowLayout(0));
        panel_603 = new JPanel();
        panel_602.add(panel_603);
        panel_603.setLayout(new GridLayout(3, 4, 0, 0));
        panel_604 = new JPanel();
        panel_604.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "10kv开关合闸信号", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_603.add(panel_604);
        panel_604.setLayout(new GridLayout(0, 1, 8, 0));
        tf_switch_on10kv = new JTextField("0");
        panel_604.add(tf_switch_on10kv);
        tf_switch_on10kv.setColumns(16);
        panel_605 = new JPanel();
        panel_605.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "10kv开关分闸信号", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_603.add(panel_605);
        panel_605.setLayout(new GridLayout(0, 1, 8, 0));
        tf_switch_off10kv = new JTextField("0");
        panel_605.add(tf_switch_off10kv);
        tf_switch_off10kv.setColumns(16);
        panel_606 = new JPanel();
        panel_606.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "10KV高压开关允许合闸信号", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_603.add(panel_606);
        panel_606.setLayout(new GridLayout(0, 1, 8, 0));
        tf_switch_allow = new JTextField("0");
        panel_606.add(tf_switch_allow);
        tf_switch_allow.setColumns(16);
        panel_607 = new JPanel();
        panel_607.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "整流器故障跳闸信号", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_603.add(panel_607);
        panel_607.setLayout(new GridLayout(0, 1, 8, 0));
        tf_rectifier_falut = new JTextField("0");
        panel_607.add(tf_rectifier_falut);
        tf_rectifier_falut.setColumns(16);
        panel_608 = new JPanel();
        panel_608.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "大功率整流电源运行/停止状态信号", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_603.add(panel_608);
        panel_608.setLayout(new GridLayout(0, 1, 8, 0));
        rectifier_power_state = new JTextField("0");
        panel_608.add(rectifier_power_state);
        rectifier_power_state.setColumns(16);
        panel_609 = new JPanel();
        panel_609.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "大功率整流电源故障状态信号", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_603.add(panel_609);
        panel_609.setLayout(new GridLayout(0, 1, 8, 0));
        rectifier_alarm = new JTextField("0");
        panel_609.add(rectifier_alarm);
        rectifier_alarm.setColumns(16);
        panel_6010 = new JPanel();
        panel_6010.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "大功率整流电源电压信号", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_603.add(panel_6010);
        panel_6010.setLayout(new GridLayout(0, 1, 8, 0));
        rectifier_vol = new JTextField("0");
        panel_6010.add(rectifier_vol);
        rectifier_vol.setColumns(16);
        panel_6011 = new JPanel();
        panel_6011.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "大功率整流电源电流信号", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_603.add(panel_6011);
        panel_6011.setLayout(new GridLayout(0, 1, 8, 0));
        rectifier_curr = new JTextField("0");
        panel_6011.add(rectifier_curr);
        rectifier_curr.setColumns(16);
        panel_6012 = new JPanel();
        panel_6012.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "通讯信号", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_603.add(panel_6012);
        panel_6012.setLayout(new GridLayout(0, 1, 8, 0));
        com_signal = new JTextField("0");
        panel_6012.add(com_signal);
        com_signal.setColumns(16);
        panel_603.add(new JPanel());
        //按钮
        panel_6013 = new JPanel();
        panel_602.add(panel_6013);
        panel_6013.setLayout(new GridLayout(2, 1,0,0));
        panel_6014 = new JPanel();
        panel_6013.add(panel_6014);
        panel_6014.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "远程控制", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
        panel_6014.setLayout(new GridLayout(1, 4, 4, 2));
        btn_remote_stop= new JToggleButton("远方停止大功率整流器");
        btn_remote_stop.setEnabled(false);
        btn_remote_stop.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //点击停止按钮
                try {
                    //System.out.println("btn_remote_stop:"+btn_remote_stop.isSelected());
                    rectifier_Power_Thread.mymodbus.holdings_ser.set(11, MyModbusUtils.readBooleanToInt(btn_remote_stop.isSelected()));
                } catch (IllegalDataAddressException | IllegalDataValueException e1) {
                    e1.printStackTrace();
                }
            }
        });
        btn_remote_stop.setFont(new Font("宋体", Font.PLAIN, 12));
        panel_6014.add(btn_remote_stop);
        btn_emergency_stop= new JToggleButton("远方紧急停止大功率整流器");
        btn_emergency_stop.setEnabled(false);
        btn_emergency_stop.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //点击远方紧急停止大功率整流器
                try {
                    //System.out.println("btn_emergency_stop:"+btn_emergency_stop.isSelected());
                    rectifier_Power_Thread.mymodbus.holdings_ser.set(12, MyModbusUtils.readBooleanToInt(btn_emergency_stop.isSelected()));
                } catch (IllegalDataAddressException | IllegalDataValueException e1) {
                    e1.printStackTrace();
                }
            }
        });
        btn_emergency_stop.setFont(new Font("宋体", Font.PLAIN, 12));
        panel_6014.add(btn_emergency_stop);
        panel_6015 = new JPanel();
        panel_6013.add(panel_6015);
        panel_6015.setBorder(new TitledBorder(null, "模拟数据", TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel_6015.setLayout(new GridLayout(1,4,4,2));
        btn_start_rectifier = new JButton("开始动态更新");
        btn_start_rectifier.setEnabled(false);
        btn_start_rectifier.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //点击分闸按钮
                //System.out.println("点击开始更新按钮");
                btn_start_rectifier.setEnabled(false);
                btn_stop_rectifier.setEnabled(true);
                rectifier_Power_Thread.auto_update_data = true;
            }
        });
        btn_start_rectifier.setFont(new Font("宋体", Font.PLAIN, 12));
        panel_6015.add(btn_start_rectifier);
        btn_stop_rectifier = new JButton("停止动态更新");
        btn_stop_rectifier.setEnabled(false);
        btn_stop_rectifier.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //点击分闸按钮
                System.out.println("点击停止动态更新按钮");
                btn_start_rectifier.setEnabled(true);
                btn_stop_rectifier.setEnabled(false);
                rectifier_Power_Thread.auto_update_data = false;
            }
        });
        btn_stop_rectifier.setFont(new Font("宋体", Font.PLAIN, 12));
        panel_6015.add(btn_stop_rectifier);
        btn_read_rectifier = new JButton("读取数据");
        btn_read_rectifier.setEnabled(false);
        btn_read_rectifier.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //点击分闸按钮
                System.out.println("点击读取数据按钮");
                rectifier_Power_Thread.read_data = true;
            }
        });
        btn_read_rectifier.setFont(new Font("宋体", Font.PLAIN, 12));
        panel_6015.add(btn_read_rectifier);
        btn_write_rectifier = new JButton("写入数据");
        btn_write_rectifier.setEnabled(false);
        btn_write_rectifier.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //点击写入数据
                readPanelData();
                rectifier_Power_Thread.write_data = true;
            }
        });
        btn_write_rectifier.setFont(new Font("宋体", Font.PLAIN, 12));
        panel_6015.add(btn_write_rectifier);
        /**************************************************************************/
        mMainFormTimer = new Timer(500, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                //updateData();
                updatePanelData();
            }
        });
    }
    public static void setCommData(ByteBuffer bf) {
        DataBuffer.position(0);
        DataBuffer.put(bf.array());
    }
    private void updatePanelData() {
        if(null != rectifier_Power_Thread && (rectifier_Power_Thread.auto_update_data || rectifier_Power_Thread.read_data)) {
                Rectifier_power rPower=rectifier_Power_Thread.rPower;
                tf_switch_on10kv.setText(String.format("%d", rPower.getSwitch_on10kv()));
                tf_switch_off10kv.setText(String.format("%d", rPower.getSwitch_off10kv()));
                tf_switch_allow.setText(String.format("%d", rPower.getSwitch_allow()));
                tf_rectifier_falut.setText(String.format("%d", rPower.getRectifier_falut()));
                rectifier_power_state.setText(String.format("%d", rPower.getRectifier_power_state()));
                rectifier_alarm.setText(String.format("%d", rPower.getRectifier_alarm()));
                rectifier_vol.setText(String.format("%1.1f", rPower.getRectifier_vol()));
                rectifier_curr.setText(String.format("%1.1f", rPower.getRectifier_curr()));
                com_signal.setText(String.format("%d", rPower.getCom_signal()));
                btn_remote_stop.setSelected((rPower.getRemote_stop()==0)?false:true);
                btn_emergency_stop.setSelected((rPower.getEmergency_stop()==0)?false:true);
                rectifier_Power_Thread.read_data = false;
        }
    }
    private void readPanelData() {
        if(rectifier_Power_Thread!=null) {
                Rectifier_power rPower=rectifier_Power_Thread.rPower;
                rPower.setSwitch_on10kv(Integer.parseInt(tf_switch_on10kv.getText()));
                rPower.setSwitch_off10kv(Integer.parseInt(tf_switch_off10kv.getText()));
                rPower.setSwitch_allow(Integer.parseInt(tf_switch_allow.getText()));
                rPower.setRectifier_falut(Integer.parseInt(tf_rectifier_falut.getText()));
                rPower.setRectifier_power_state(Integer.parseInt(rectifier_power_state.getText()));
                rPower.setRectifier_alarm(Integer.parseInt(rectifier_alarm.getText()));
                rPower.setRectifier_vol(Float.parseFloat(rectifier_vol.getText()));
                rPower.setRectifier_curr(Float.parseFloat(rectifier_curr.getText()));
                rPower.setCom_signal(Integer.parseInt(com_signal.getText()));
                rectifier_Power_Thread.read_data = false;
        }
    }
}
Demo_Rectifier_power_4MwModBus_Tester/src/main/main_window_central_monitor.java
File was deleted