private void LoadResultByItem(string text) { try { temp.Clear(); temp = analysisData.DefaultView.ToTable(false, text); dataGridView_Result.DataSource = temp; result_list.Clear();//清空测试结果 textBox_USL.Text = ""; textBox_LSL.Text = ""; chart_Analysis_Normal.ChartAreas[0].AxisX.MajorGrid.Enabled = false; //关闭网格线 chart_Analysis_Poisson.ChartAreas[0].AxisY.MajorGrid.Enabled = false; //关闭网格线 chart_Analysis_Normal.Series[0].Points.Clear(); chart_Analysis_Normal.Series[1].Points.Clear(); chart_Analysis_Poisson.Series[0].Points.Clear(); chart_Analysis_Poisson.ChartAreas[0].AxisY.StripLines.Clear(); chart_Analysis_Normal.ChartAreas[0].AxisX.StripLines.Clear(); foreach (DataRow row in analysisData.Rows) { if (row[text].ToString() != "\\" && row[text].ToString() != "" && row[text].ToString() != "\"\"") { if (IsNum(row[text].ToString())) { result_list.Add(double.Parse(row[text].ToString())); } } } for (int i = temp.Rows.Count - 1; i > 0; i--) { if (temp.Rows[i][text].ToString() == "\\" || temp.Rows[i][text].ToString() == "" || temp.Rows[i][text].ToString() == "\"\"") { temp.Rows.Remove(temp.Rows[i]); } } //去掉最大最小值 if (result_list.Count > 1000) { for (int i = 0; i < 50; i++) { result_list.Remove(result_list.Max()); result_list.Remove(result_list.Min()); } } textBox_Max.Text = result_list.Max().ToString("00.000"); textBox_Min.Text = result_list.Min().ToString("00.000"); textBox_TestCount.Text = result_list.Count.ToString(); textBox_AVG.Text = result_list.Average().ToString("00.000"); textBox_stdevResult.Text = (Stdev(result_list)).ToString("00.0000");//计算标准差 btn_Cp.Text = "计算"; btn_CPK.Text = "计算"; } catch (Exception ex) { myf.writeErrorLog(ex.ToString()); MessageBox.Show(ex.Message); this.FindForm().Close(); } }
//读取配置信息 private void loadConfig() { try { string filepath = Application.StartupPath + @"\CONFIG.ini"; if (!File.Exists(filepath)) { File.Create(filepath); Config config = new Config(); config.ShowDialog(); return; } #region 读取config配置 //AVI-1主站测试结果 StringBuilder str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine1_S1_TestResult, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine1_S1_TestResult = str_tmp.ToString(); //AVI-1从站测试结果 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine1_S2_TestResult, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine1_S2_TestResult = str_tmp.ToString(); //AVI-1从站副测试结果 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine1_S3_TestResult, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine1_S3_TestResult = str_tmp.ToString(); //AVI-1主站测试项 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine1_S1_TestVal, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine1_S1_TestVal = str_tmp.ToString(); //AVI-1从站测试项 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine1_S2_TestVal, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine1_S2_TestVal = str_tmp.ToString(); //AVI-1从站副测试项 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine1_S3_TestVal, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine1_S3_TestVal = str_tmp.ToString(); //AVI-2主站测试结果 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine2_S1_TestResult, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine2_S1_TestResult = str_tmp.ToString(); //AVI-2从站测试结果 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine2_S2_TestResult, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine2_S2_TestResult = str_tmp.ToString(); //AVI-2从站副测试结果 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine2_S3_TestResult, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine2_S3_TestResult = str_tmp.ToString(); //AVI-2主站测试项 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine2_S1_TestVal, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine2_S1_TestVal = str_tmp.ToString(); //AVI-2从站测试项 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine2_S2_TestVal, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine2_S2_TestVal = str_tmp.ToString(); //AVI-2从站副测试项 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine2_S3_TestVal, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine2_S3_TestVal = str_tmp.ToString(); //AVI-3主站测试结果 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine3_S1_TestResult, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine3_S1_TestResult = str_tmp.ToString(); //AVI-3从站测试结果 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine3_S2_TestResult, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine3_S2_TestResult = str_tmp.ToString(); //AVI-3从站副测试结果 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine3_S3_TestResult, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine3_S3_TestResult = str_tmp.ToString(); //AVI-3主站测试项 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine3_S1_TestVal, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine3_S1_TestVal = str_tmp.ToString(); //AVI-3从站测试项 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine3_S2_TestVal, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine3_S2_TestVal = str_tmp.ToString(); //AVI-3从站副测试项 str_tmp = new StringBuilder(100); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine3_S3_TestVal, "", str_tmp, 100, filepath); GlobalVar.gl_val_Machine3_S3_TestVal = str_tmp.ToString(); //AVI-1是否启用 str_tmp = new StringBuilder(50); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine1_Check, "", str_tmp, 50, filepath); GlobalVar.gl_val_Machine1_Check = str_tmp.ToString(); //AVI-2是否启用 str_tmp = new StringBuilder(50); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine2_Check, "", str_tmp, 50, filepath); GlobalVar.gl_val_Machine2_Check = str_tmp.ToString(); //AVI-3是否启用 str_tmp = new StringBuilder(50); MyFunctions.GetPrivateProfileString(GlobalVar.gl_section_Global, GlobalVar.gl_key_Machine3_Check, "", str_tmp, 50, filepath); GlobalVar.gl_val_Machine3_Check = str_tmp.ToString(); #endregion if (GlobalVar.gl_val_Machine1_Check == "1") { checkBox_Machine1.Checked = true; } if (GlobalVar.gl_val_Machine2_Check == "1") { checkBox_Machine2.Checked = true; } if (GlobalVar.gl_val_Machine3_Check == "1") { checkBox_Machine3.Checked = true; } }catch (Exception ex) { myf.writeErrorLog("读取Config文件异常:" + ex.Message); MessageBox.Show("读取Config文件异常:" + ex.Message); //System.Environment.Exit(0); } }