コード例 #1
0
        private void HDPLC_Information_Collector_Load(object sender, EventArgs e)
        {
            btn_OpenSer.Text = "打开串口";
            lab_testmodel.Text = "手动测试";
            lab_teststatus.Text = "未开始";
            lab_date.Text = DateTime.Now.ToShortDateString().ToString();
            //lab_date.Text = DateTime.Now.ToString();
            btn_showprint.Enabled = false;
            tb_RefMac.ReadOnly = true;
            tb_DutMac.ReadOnly = true;
            tb_PhyRate.ReadOnly = true;
            richTextBox1.ReadOnly = true;
            richTextBox1.Text = "";
            dataGridView1.ReadOnly = true;
            tb_current.ReadOnly = true;
            tb_voltage1.ReadOnly = true;
            tb_voltage2.ReadOnly = true;

            btn_ClearDevice_Click(null, null);
            panel_ser.Visible = false;

            responseDet = new Thread(responseDetect);
            responseDet.IsBackground = true;

            l_RxBytes.Text = "0";

            tb_MacToBeSet.Focus();
            tb_MacToBeSet.Select();
            //this.IsMdiContainer = true;

            lab_phyrate_res.Text = "";
            lab_result.Text = "";

            serialPort1.ReadBufferSize = 20000;     //set serialport read buffer size to 10000 bytes

            asc = new AutoSizeFormClass();

            try
            {
                GetPrivateProfileString("ADDRESS", "REFMAC", "No preset address", refMac, 25, ".\\HDPLC_TEST.ini");
                GetPrivateProfileString("STANDARD", "PHYRATE", "100", stdPhyrate, 25, ".\\HDPLC_TEST.ini");
                GetPrivateProfileString("STANDARD", "VOLTAGE1", "3300", stdVoltage1, 15, ".\\HDPLC_TEST.ini");
                GetPrivateProfileString("STANDARD", "VOLTAGE2", "1200", stdVoltage2, 15, ".\\HDPLC_TEST.ini");
                GetPrivateProfileString("STANDARD", "VOLTAGE1_DEV", "20", stdVoltage1_deviation, 15, ".\\HDPLC_TEST.ini");
                GetPrivateProfileString("STANDARD", "VOLTAGE2_DEV", "20", stdVoltage2_deviation, 15, ".\\HDPLC_TEST.ini");
                GetPrivateProfileString("STANDARD", "CURRENT", "600", stdCurrent, 15, ".\\HDPLC_TEST.ini");
                GetPrivateProfileString("STANDARD", "CURRENT_DEV", "10", stdCurrent_deviation, 15, ".\\HDPLC_TEST.ini");
                tb_RefMac.Text = refMac.ToString().ToUpper();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }

            int[] baud_item = {4800,9600,14400,38400,115200,230400};
            foreach(int a in baud_item)
            {
                cb_BaudRate.Items.Add(a.ToString());
            }
            cb_BaudRate.SelectedItem = cb_BaudRate.Items[4];

            string[] PortNames = SerialPort.GetPortNames();
            cb_Port.Items.AddRange(PortNames);
            cb_Port.SelectedItem = cb_Port.Items[0];

            lab_preset_phyrate.Text = stdPhyrate.ToString() + " mbps";
            lab_preset_vol1.Text = stdVoltage1.ToString() + " mV";
            lab_preset_vol2.Text = stdVoltage2.ToString() + " mV";
            lab_preset_cur.Text = stdCurrent.ToString() + " mA";

            asc.controllInitializeSize(this);
        }