Newer
Older
RbFreqStand / RbFreqStandMeasure / info / DetailDlg.cs
yxw on 10 Jun 2021 33 KB 合并倩倩程序
using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model;
using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service;
using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl;
using Casic.Birmm.RbFreqStandMeasure.Tools;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Casic.Birmm.RbFreqStandMeasure.info
{
    public partial class DetailDlg : Form
    {
        #region 无边框拖动效果/最小化窗口/关闭窗口
        [DllImport("user32.dll")]//拖动无窗体的控件
        public static extern bool ReleaseCapture();
        [DllImport("user32.dll")]
        public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
        public const int WM_SYSCOMMAND = 0x0112;
        public const int SC_MOVE = 0xF010;
        public const int HTCAPTION = 0x0002;
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            //拖动窗体
            ReleaseCapture();
            SendMessage(Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
        }
        #endregion

        #region 样式常量定义
        private readonly Color titleBackColor = Color.FromArgb(63, 132, 215); // #3F64D7
        private readonly Color tableForeColor = Color.White;
        private readonly Font titleFont = new Font("微软雅黑", 14F, FontStyle.Regular, GraphicsUnit.Pixel, 134);

        private readonly Color inputBlack = Color.FromArgb(51, 51, 51); // #333333
        private readonly Color inputDefault = Color.FromArgb(204, 204, 204); // #CCCCCC
        #endregion


        DataTable tableOriginData = new DataTable();
        DataTable tableTimes = new DataTable();
        DetectionService detectionService = new DetectionServiceImpl();
        DetectionItemService detectionItemService = new DetectionItemServiceImpl();
        CounterDataService counterDataService = new CounterDataServiceImpl();

        public static DataGridView dataGridView;
        public static Label label_redetecting;
        public static DetailDlg detailDlg;
        long deviceId = -1;
        long detectionItemId = -1;
        string startTime = "";
        string endTime = "";
        public string resultAccStr = "";
        public string resultStaStr10 = "";
        public string resultStaStr20 = "";
        public string resultStaStr100 = "";
        public string resultStaStr1 = "";
        string resultBootStr = "";
        string resultAgeStr = "";

        public Action HideMaskAction
        {
            get;
            set;
        }

        public DetailDlg(long deviceId)
        {
            InitializeComponent();
            detailDlg = this;
            this.deviceId = deviceId;
            LoadTimes(deviceId);

            if (tableTimes.Rows.Count > 0)
            {
                detectionItemId = Convert.ToInt64(dataGridView_times.Rows[0].Cells[12].Value);
                startTime = Convert.ToDateTime(dataGridView_times.Rows[0].Cells[1].Value).ToString("yyyy-MM-dd HH:mm:ss");
                endTime = Convert.ToDateTime(dataGridView_times.Rows[0].Cells[2].Value).ToString("yyyy-MM-dd HH:mm:ss");
                resultAccStr = dataGridView_times.Rows[0].Cells[3].Value.ToString();
                resultStaStr10 = dataGridView_times.Rows[0].Cells[9].Value.ToString();
                resultStaStr20 = dataGridView_times.Rows[0].Cells[10].Value.ToString();
                resultStaStr100 = dataGridView_times.Rows[0].Cells[11].Value.ToString();
                resultStaStr1 = dataGridView_times.Rows[0].Cells[8].Value.ToString();
                resultBootStr = dataGridView_times.Rows[0].Cells[5].Value.ToString();
                resultAgeStr = dataGridView_times.Rows[0].Cells[6].Value.ToString();

                List<Detection> queryList = detectionService.search(deviceId, "2", startTime, endTime, detectionItemId);
                if (null != queryList && queryList.Count > 0) tabPageEvent("tab_accuracy");
                else
                {
                    queryList = detectionService.search(deviceId, "1-1", startTime, endTime, detectionItemId);
                    if (null != queryList && queryList.Count > 0)
                    {
                        tabPageEvent("tab_stability");
                        loadStability1();
                    }
                    else
                    {
                        queryList = detectionService.search(deviceId, "1-10", startTime, endTime, detectionItemId);
                        if (null != queryList && queryList.Count > 0)
                        {
                            tabPageEvent("tab_stability");
                            loadStability10();
                        }
                        else
                        {
                            queryList = detectionService.search(deviceId, "1-20", startTime, endTime, detectionItemId);
                            if (null != queryList && queryList.Count > 0)
                            {
                                tabPageEvent("tab_stability");
                                loadStability20();
                            }
                            else
                            {
                                queryList = detectionService.search(deviceId, "1-100", startTime, endTime, detectionItemId);
                                if (null != queryList && queryList.Count > 0)
                                {
                                    tabPageEvent("tab_stability");
                                    loadStability100();
                                }
                                else
                                {
                                    queryList = detectionService.search(deviceId, "3", startTime, endTime, detectionItemId);
                                    if (null != queryList && queryList.Count > 0)
                                    {
                                        tabPageEvent("tab_bootFeature");
                                    }
                                    else
                                    {
                                        queryList = detectionService.search(deviceId, "4", startTime, endTime, detectionItemId);
                                        if (null != queryList && queryList.Count > 0)
                                        {
                                            tabPageEvent("tab_ageRate");
                                        }
                                        else
                                        {
                                            tableOriginData.Rows.Clear();
                                            tabControl1.SelectedIndex = -1;
                                            btn_reDetec.Visible = false;
                                            dataGridView_times.Visible = true;
                                            panel_radios.Visible = false;
                                        }
                                    }
                                }
                            }
                        }
                    }


                }
                
            }
            if (dataGridView_Data.Rows.Count == 0) btn_reDetec.Enabled = false;
        }

        // 关闭对话框
        private void btnClose_Click(object sender, EventArgs e)
        {
            if (label_reDetecting.Visible == true)
            {
                MessageBox.Show("正在进行重新检测,请稍后再离开此界面...");
                return;
            }
            this.HideMaskAction();
            RbFreqStdMeas.rbFreqStdMeas.TopMost = true;
            RbFreqStdMeas.rbFreqStdMeas.TopMost = false;
        }


        // 数据列表
        private void LoadData(long deviceId, string detectionItem, string startTime, string endTime)
        {
            tableOriginData = new DataTable();

            // 设置表格的列
            tableOriginData.Columns.Add("序号", Type.GetType("System.String"));
            tableOriginData.Columns.Add("时间", Type.GetType("System.String"));
            tableOriginData.Columns.Add("相对频率偏差", Type.GetType("System.String"));
            tableOriginData.Columns.Add("id", Type.GetType("System.Int64"));

            // 获取当前页的数据
            List<Detection> queryList = detectionService.search(deviceId, detectionItem, startTime, endTime, detectionItemId);
            if (null != queryList && queryList.Count > 0)
            {               
                int index = 1;
                foreach (Detection detection in queryList)
                {
                    tableOriginData.Rows.Add(index, detection.LogTime, detection.Frequency, detection.Id);
                    index++;
                }

                label_noData.Visible = false;

                dataGridView_Data.DataSource = tableOriginData;

                // width=425px
                dataGridView_Data.Columns[0].Width = 60;
                dataGridView_Data.Columns[1].Width = 185;
                dataGridView_Data.Columns[2].Width = 180;
                dataGridView_Data.Columns[3].Visible = false;


                dataGridView_Data.Columns[0].ReadOnly = true;
                dataGridView_Data.Columns[1].ReadOnly = true;
                dataGridView_Data.Columns[2].ReadOnly = true;

                dataGridView_Data.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
                dataGridView_Data.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
                dataGridView_Data.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            else
            {
                dataGridView_Data.DataSource = null;
                label_noData.Visible = true;
            }
        }

        private void LoadData_Counter(long deviceId)
        {
            tableOriginData = new DataTable();

            // 设置表格的列
            tableOriginData.Columns.Add("序号", Type.GetType("System.String"));
            tableOriginData.Columns.Add("输出值", Type.GetType("System.String"));
            tableOriginData.Columns.Add("测量值", Type.GetType("System.String"));
            tableOriginData.Columns.Add("灵敏度(Vpp)", Type.GetType("System.String"));
            tableOriginData.Columns.Add("测量时间", Type.GetType("System.String"));


            // 获取当前页的数据
            List<CounterData> queryList = counterDataService.getHistory(deviceId, "", "");
            if (null != queryList && queryList.Count > 0)
            {
                int index = 1;
                foreach (CounterData counterData in queryList)
                {
                    tableOriginData.Rows.Add(index, counterData.OutValue, counterData.Value, counterData.Sensitivity,counterData.LogTime);
                    index++;
                }

                label_noData.Visible = false;
                dataGridView_Data.DataSource = tableOriginData;

                // width=425px
                dataGridView_Data.Columns[0].Width = 45;
                dataGridView_Data.Columns[1].Width = 60;
                dataGridView_Data.Columns[2].Width = 150;
                dataGridView_Data.Columns[3].Width = 85;
                dataGridView_Data.Columns[4].Width = 135;

                dataGridView_Data.Columns[0].ReadOnly = true;
                dataGridView_Data.Columns[1].ReadOnly = true;
                dataGridView_Data.Columns[2].ReadOnly = true;

                dataGridView_Data.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
                dataGridView_Data.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
                dataGridView_Data.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            else
            {
                dataGridView_Data.DataSource = null;
                label_noData.Visible = true;
            }
        }

        

        // 检测记录列表
        private void LoadTimes(long deviceId)
        {
            dataGridView_times.Columns.Clear();
            dataGridView_times.Rows.Clear();

            tableTimes = new DataTable();

            // 设置表格的列
            tableTimes.Columns.Add("序号", Type.GetType("System.String"));
            tableTimes.Columns.Add("开始时间", Type.GetType("System.String"));
            tableTimes.Columns.Add("结束时间", Type.GetType("System.String"));
            tableTimes.Columns.Add("accuracy", Type.GetType("System.String"));
            tableTimes.Columns.Add("stability", Type.GetType("System.String"));
            tableTimes.Columns.Add("boot", Type.GetType("System.String"));
            tableTimes.Columns.Add("age", Type.GetType("System.String"));
            tableTimes.Columns.Add("通道", Type.GetType("System.String"));
            tableTimes.Columns.Add("stability1", Type.GetType("System.String"));
            tableTimes.Columns.Add("stability10", Type.GetType("System.String"));
            tableTimes.Columns.Add("stability20", Type.GetType("System.String"));
            tableTimes.Columns.Add("stability100", Type.GetType("System.String"));
            tableTimes.Columns.Add("itemId", Type.GetType("System.Int64")); //12
            // 获取当前页的数据
            List<DetectionItem> queryList = detectionItemService.search(deviceId, false);
            if (null != queryList && queryList.Count > 0)
            {

                int index = 1;
                foreach (DetectionItem detection in queryList)
                {
                    tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime,detection.Accuracy,detection.Stability,detection.BootFeature,detection.AgeRate, detection.Channel,detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100, detection.Id);
                    index++;
                }

                label_noTimes.Visible = false;
                dataGridView_times.DataSource = tableTimes;
                               
                // width=407px
                dataGridView_times.Columns[0].Width = 40;
                dataGridView_times.Columns[1].Width = 120;
                dataGridView_times.Columns[2].Width = 120;
                dataGridView_times.Columns[3].Visible = false;
                dataGridView_times.Columns[4].Visible = false;
                dataGridView_times.Columns[5].Visible = false;
                dataGridView_times.Columns[6].Visible = false;
                dataGridView_times.Columns[7].Width = 70;
                dataGridView_times.Columns[8].Visible = false;
                dataGridView_times.Columns[9].Visible = false;
                dataGridView_times.Columns[10].Visible = false;
                dataGridView_times.Columns[11].Visible = false;
                dataGridView_times.Columns[12].Visible = false;

                dataGridView_times.Columns[0].ReadOnly = true;
                dataGridView_times.Columns[1].ReadOnly = true;
                dataGridView_times.Columns[2].ReadOnly = true;

                dataGridView_times.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
                dataGridView_times.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
                dataGridView_times.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
            }
            else
            {
                dataGridView_times.DataSource = null;
                label_noTimes.Visible = true;
            }
        }
               

        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string tabPageName = tabControl1.SelectedTab.Name;            
            tabPageEvent(tabPageName);
        }

        private void dataGridView_times_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowIndex = e.RowIndex;
            if (rowIndex > -1)
            {
                detectionItemId = Convert.ToInt64(dataGridView_times.Rows[rowIndex].Cells[12].Value);
                startTime = Convert.ToDateTime(dataGridView_times.Rows[rowIndex].Cells[1].Value).ToString("yyyy-MM-dd HH:mm:ss");
                endTime = Convert.ToDateTime(dataGridView_times.Rows[rowIndex].Cells[2].Value).ToString("yyyy-MM-dd HH:mm:ss");
                resultAccStr = dataGridView_times.Rows[rowIndex].Cells[3].Value.ToString();
                resultStaStr10 = dataGridView_times.Rows[rowIndex].Cells[9].Value.ToString();
                resultStaStr20 = dataGridView_times.Rows[rowIndex].Cells[10].Value.ToString();
                resultStaStr100 = dataGridView_times.Rows[rowIndex].Cells[11].Value.ToString();
                resultStaStr1 = dataGridView_times.Rows[rowIndex].Cells[8].Value.ToString();
                resultBootStr = dataGridView_times.Rows[rowIndex].Cells[5].Value.ToString();
                resultAgeStr = dataGridView_times.Rows[rowIndex].Cells[6].Value.ToString();

                List<Detection> queryList = detectionService.search(deviceId, "2", startTime, endTime, detectionItemId);
                if (null != queryList && queryList.Count > 0) tabPageEvent("tab_accuracy");
                else
                {
                    queryList = detectionService.search(deviceId, "1-1", startTime, endTime, detectionItemId);
                    if (null != queryList && queryList.Count > 0)
                    {
                        tabPageEvent("tab_stability");
                        loadStability1();
                    }
                    else
                    {
                        queryList = detectionService.search(deviceId, "1-10", startTime, endTime, detectionItemId);
                        if (null != queryList && queryList.Count > 0)
                        {
                            tabPageEvent("tab_stability");
                            loadStability10();
                        }
                        else
                        {
                            queryList = detectionService.search(deviceId, "1-20", startTime, endTime, detectionItemId);
                            if (null != queryList && queryList.Count > 0)
                            {
                                tabPageEvent("tab_stability");
                                loadStability20();
                            }
                            else
                            {
                                queryList = detectionService.search(deviceId, "1-100", startTime, endTime, detectionItemId);
                                if (null != queryList && queryList.Count > 0)
                                {
                                    tabPageEvent("tab_stability");
                                    loadStability100();
                                }
                                else
                                {
                                    queryList = detectionService.search(deviceId, "3", startTime, endTime, detectionItemId);
                                    if (null != queryList && queryList.Count > 0)
                                    {
                                        tabPageEvent("tab_bootFeature");
                                    }
                                    else
                                    {
                                        queryList = detectionService.search(deviceId, "4", startTime, endTime, detectionItemId);
                                        if (null != queryList && queryList.Count > 0)
                                        {
                                            tabPageEvent("tab_ageRate");
                                        }
                                        else
                                        {
                                            tableOriginData.Rows.Clear();
                                            panel_result.Controls.Clear();
                                            tabControl1.SelectedIndex = -1;
                                            btn_reDetec.Visible = false;
                                            dataGridView_times.Visible = true;
                                            panel_radios.Visible = false;
                                        }
                                    }
                                }
                            }
                        }
                    }


                }

                

                //if (!resultAccStr.Equals("-1") && !resultAccStr.Equals("-2") && !resultAccStr.Equals("-3") && !resultAccStr.Equals("0")) tabPageEvent("tab_accuracy");
                //else if ((!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3") && !resultStaStr1.Equals("0")) || (!resultStaStr10.Equals("-1") && !resultStaStr10.Equals("-2") && !resultStaStr10.Equals("-3") && !resultStaStr10.Equals("0")) || (!resultStaStr100.Equals("-1") && !resultStaStr100.Equals("-2") && !resultStaStr100.Equals("-3") && !resultStaStr100.Equals("0")))
                //{
                //    tabPageEvent("tab_stability");
                //    if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3") && !resultStaStr1.Equals("0")) loadStability1(); 
                //    else if (!resultStaStr10.Equals("-1") && !resultStaStr10.Equals("-2") && !resultStaStr10.Equals("-3") && !resultStaStr10.Equals("0")) loadStability10();
                //    else if (!resultStaStr20.Equals("-1") && !resultStaStr20.Equals("-2") && !resultStaStr20.Equals("-3") && !resultStaStr20.Equals("0")) loadStability20();
                //    else if (!resultStaStr100.Equals("-1") && !resultStaStr100.Equals("-2") && !resultStaStr100.Equals("-3") && !resultStaStr100.Equals("0")) loadStability100();
                //}
                //else if (!resultBootStr.Equals("-1") && !resultBootStr.Equals("-2") && !resultBootStr.Equals("-3") && !resultBootStr.Equals("0")) tabPageEvent("tab_bootFeature");
                //else if (!resultAgeStr.Equals("-1") && !resultAgeStr.Equals("-2") && !resultAgeStr.Equals("-3") && !resultAgeStr.Equals("0")) tabPageEvent("tab_ageRate");

            }
        }

        private void tabPageEvent(string tabPageName)
        {
            panel_result.Controls.Clear();
            switch (tabPageName)
            {
                case "tab_stability":
                    {
                        tabControl1.SelectedIndex = 0;
                        btn_reDetec.Visible = true;
                        dataGridView_times.Visible = true;
                        panel_radios.Visible = true;
                        btn_reDetec.Enabled = true;
                        radio_1s.Checked = true;
                        LoadData(deviceId, "1-1", startTime, endTime);
                        groupBox3.Text = "1s频率稳定度";
                        stability result = new stability();
                        result.label_stability.Text = "";
                        result.label_count.Text = "";
                        if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3"))
                        {
                            result.label_stability.Text = resultStaStr1;
                            result.label_count.Text = "101";
                        }
                        result.Show();
                        panel_result.Controls.Add(result);

                        if (dataGridView_Data.Rows.Count == 0) btn_reDetec.Enabled = false;
                        
                        break;
                    }
                case "tab_accuracy":
                    {
                        tabControl1.SelectedIndex = 1;
                        btn_reDetec.Visible = true;
                        dataGridView_times.Visible = true;
                        panel_radios.Visible = false;
                        btn_reDetec.Enabled = true;

                        LoadData(deviceId, "2", startTime, endTime);
                        groupBox3.Text = "频率准确度";
                        accuracy result = new accuracy();
                        result.label_accuracy.Text = "";
                       
                        if (!resultAccStr.Equals("-1") && !resultAccStr.Equals("-2") && !resultAccStr.Equals("-3")) result.label_accuracy.Text = resultAccStr;
                        result.Show();
                        panel_result.Controls.Add(result);

                        if (dataGridView_Data.Rows.Count == 0) btn_reDetec.Enabled = false;
                        break;
                    }
                case "tab_bootFeature":
                    {
                        tabControl1.SelectedIndex = 2;
                        btn_reDetec.Visible = false;
                        dataGridView_times.Visible = true;
                        panel_radios.Visible = false;

                        LoadData(deviceId, "3", startTime, endTime);
                        groupBox3.Text = "开机特性";
                        bootFeature result = new bootFeature(tableOriginData);
                        result.label_bootFeature.Text = "";
                        if (!resultBootStr.Equals("-1") && !resultBootStr.Equals("-2") && !resultBootStr.Equals("-3")) result.label_bootFeature.Text = resultBootStr;
                        result.Show();
                        panel_result.Controls.Add(result);
                        break;
                    }
                case "tab_ageRate":
                    {
                        tabControl1.SelectedIndex = 3;
                        btn_reDetec.Visible = false;
                        dataGridView_times.Visible = true;
                        panel_radios.Visible = false;
                        LoadData(deviceId, "4", startTime, endTime);
                        groupBox3.Text = "日老化率";
                        ageRate result = new ageRate(tableOriginData);
                        result.label_k.Text = "";
                        result.label_r.Text = "";
                        if (!resultAgeStr.Equals("-1") && !resultAgeStr.Equals("-2") && !resultAgeStr.Equals("-3"))
                        {
                            if (resultAgeStr.Split(',').Length > 1)
                            {
                                result.label_k.Text = resultAgeStr.Split(',')[0];
                                result.label_r.Text = resultAgeStr.Split(',')[1];
                            }
                        }
                        result.Show();
                        panel_result.Controls.Add(result);
                        break;
                    }
                case "tab_counter":
                    {
                        tabControl1.SelectedIndex = 4;
                        btn_reDetec.Visible = false;
                        dataGridView_times.Visible = false;
                        panel_radios.Visible = false;
                        LoadData_Counter(deviceId);
                        groupBox3.Text = "计数器范围及灵敏度";
                        
                        break;
                    }
                default: break;

            }
        }

        private void btn_reDetec_Click(object sender, EventArgs e)
        {
            if (label_reDetecting.Visible == true)
            {
                MessageBox.Show("正在重新检测!");
                return;
            }
            dataGridView = this.dataGridView_Data;
            label_redetecting = this.label_reDetecting;

            ReDetecDlg dlg = new ReDetecDlg(dataGridView_Data);
            dlg.detectionItemId = Convert.ToInt64(dataGridView_times.CurrentRow.Cells[12].Value);
            dlg.deviceId = deviceId;
            dlg.label_devCode.Text = label_devCode.Text;
            dlg.label_devModel.Text = label_devModel.Text;
            if (tabControl1.SelectedIndex == 1) dlg.label1.Text = "频率准确度";
            else
            {
                if(radio_1s.Checked) dlg.label1.Text = "频率稳定度 - 1s";
                else if (radio_10s.Checked) dlg.label1.Text = "频率稳定度 - 10s";
                else if (radio_20s.Checked) dlg.label1.Text = "频率稳定度 - 20s";
                else if (radio_100s.Checked) dlg.label1.Text = "频率稳定度 - 100s";
            }
            //dlg.text_channelNo.Text = dataGridView_times.CurrentRow.Cells[7].Value.ToString();
            dlg.HideMaskAction += () =>
            {
                this.HideMask();
            };
            this.ShowMask();
            dlg.StartPosition = FormStartPosition.CenterParent; // 指定窗口弹出在父窗口的中间位置
            dlg.ShowDialog();
        }

        private MaskForm maskForm;

        private void ShowMask()
        {
            maskForm = new MaskForm(this.Location, this.Size);
            maskForm.Show();
        }

        private void HideMask()
        {
            if (maskForm != null)
            {
                maskForm.Close();
            }
        }       

        private void radio_10s_CheckedChanged(object sender, EventArgs e)
        {
            if (radio_10s.Checked)
            {                
                loadStability10();
            }
        }
        private void loadStability10()
        {
            radio_10s.Checked = true;
            LoadData(deviceId, "1-10", startTime, endTime);
            groupBox3.Text = "10s频率稳定度";
            panel_result.Controls.Clear();
            stability result = new stability();
            result.label_stability.Text = "";
            if (!resultStaStr10.Equals("-1") && !resultStaStr10.Equals("-2") && !resultStaStr10.Equals("-3"))
            {
                result.label_stability.Text = resultStaStr10;
                result.label_count.Text = "101";
            }
            result.Show();
            panel_result.Controls.Add(result);
            btn_reDetec.Enabled = true;
            if (dataGridView_Data.Rows.Count == 0) btn_reDetec.Enabled = false;
        }

        private void radio_1s_CheckedChanged(object sender, EventArgs e)
        {
            if (radio_1s.Checked)
            {
                loadStability1();
            }
        }
        private void loadStability1()
        {
            radio_1s.Checked = true;
            LoadData(deviceId, "1-1", startTime, endTime);
            groupBox3.Text = "1s频率稳定度";
            panel_result.Controls.Clear();
            stability result = new stability();
            result.label_stability.Text = "";
            if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3"))
            {
                result.label_stability.Text = resultStaStr1;
                result.label_count.Text = "101";
            }
            result.Show();
            btn_reDetec.Enabled = true;
            panel_result.Controls.Add(result);
            if (dataGridView_Data.Rows.Count == 0) btn_reDetec.Enabled = false;
        }

        private void radio_20s_CheckedChanged(object sender, EventArgs e)
        {
            if (radio_20s.Checked)
            {
                loadStability20();
            }
        }
        private void loadStability20()
        {
            radio_20s.Checked = true;
            LoadData(deviceId, "1-20", startTime, endTime);
            groupBox3.Text = "20s频率稳定度";
            panel_result.Controls.Clear();
            stability result = new stability();
            result.label_stability.Text = "";
            if (!resultStaStr20.Equals("-1") && !resultStaStr20.Equals("-2") && !resultStaStr20.Equals("-3"))
            {
                result.label_stability.Text = resultStaStr20;
                result.label_count.Text = "101";
            }
            result.Show();
            panel_result.Controls.Add(result);
            btn_reDetec.Enabled = true;
            if (dataGridView_Data.Rows.Count == 0) btn_reDetec.Enabled = false;
        }

        private void radio_100s_CheckedChanged(object sender, EventArgs e)
        {
            if (radio_100s.Checked)
            {
                loadStability100();
            }
        }
        private void loadStability100()
        {
            radio_100s.Checked = true;
            LoadData(deviceId, "1-100", startTime, endTime);
            groupBox3.Text = "100s频率稳定度";
            panel_result.Controls.Clear();
            stability result = new stability();
            result.label_stability.Text = "";
            if (!resultStaStr100.Equals("-1") && !resultStaStr100.Equals("-2") && !resultStaStr100.Equals("-3"))
            {
                result.label_stability.Text = resultStaStr100;
                result.label_count.Text = "101";
            }
            result.Show();
            panel_result.Controls.Add(result);
            btn_reDetec.Enabled = true;
            if (dataGridView_Data.Rows.Count == 0) btn_reDetec.Enabled = false;
        }

        public void updateChannelNoRedetec()
        {
            dataGridView_times.CurrentRow.Cells[7].Value = ReDetecDlg.channelNoReDetec;
            detectionItemService.updateChannelNo(Convert.ToInt64(dataGridView_times.CurrentRow.Cells[12].Value), ReDetecDlg.channelNoReDetec);
        }


        private void roundButton1_Click_1(object sender, EventArgs e)
        {
            List<string> resultAgeRate = new List<string>();
            foreach (DataGridViewRow row in dataGridView_Data.Rows)
            {
                resultAgeRate.Add(row.Cells[2].Value.ToString());
            }
            double r = 0.0;
            double k = FreMath.DriftRate(resultAgeRate, out r);
            MessageBox.Show("r=" + r + ";" + "k=" + k);
        }
    }
}