void CCDParamTest_Collect_L(bool bLight) { UIHide(); ParamTestChart1.Visible = true; ParamTestChart1.Dock = DockStyle.Fill; string str = ""; if (bLight) { textBox1.AppendText("50%饱和空域测试\r\n"); str = "50%饱和空域测试中"; L_TempFilePath = SystemParam.L_LightTempFilePath; tcpCCS.LightSet(SystemParam.lambda_Oe, SystemParam.Osat / 2); } else { textBox1.AppendText("暗场空域测试\r\n"); str = "暗场空域测试中"; L_TempFilePath = SystemParam.L_DarkTempFilePath; tcpCCS.LightSet(SystemParam.lambda_Oe, 0); } CreateTempFile(SystemParam.L, L_TempFilePath); ParamTestWaitingProc = new WaitingProc(); WaitingProcFunc wpf = null; ParamTestWaitingProc.MaxProgress = SystemParam.L; wpf = new WaitingProcFunc(WaitingCollect_L); if (!ParamTestWaitingProc.Execute(wpf, str, WaitingType.With_ConfirmCancel, "是否取消?")) { textBox1.AppendText("用户终止自动测试\r\n"); return; } }
void CCDParamTest_Collect_etaCurve() { UIHide(); ParamTestChart1.Visible = true; ParamTestChart1.Dock = DockStyle.Fill; Collect_etaCurve_miu = new List <List <double> >(); Collect_etaCurve_delta = new List <double>(); Collect_etaCurve_E = new List <double>(); Collect_etaCurve_miu_dark = new List <List <double> >(); Collect_etaCurve_delta_dark = new List <double>(); ParamTestWaitingProc = new WaitingProc(); string str = ""; WaitingProcFunc wpf = null; if (ExType == 1)//固定曝光时间,改变光源照度 { textBox1.AppendText("开始固定曝光时间,按逐步改变光源照度方式采集图像\r\n"); str = "固定曝光时间,按逐步改变光源照度方式采集图像中"; ParamTestWaitingProc.MaxProgress = SystemParam.Osat / SystemParam.Oe; wpf = new WaitingProcFunc(WaitingCollect_etaCurve_1); } else if (ExType == 2)//固定光源照度,改变曝光时间 { textBox1.AppendText("开始固定光源照度,按逐步改变曝光时间方式采集图像\r\n"); str = "固定光源照度,按逐步改变曝光时间方式采集图像中"; ParamTestWaitingProc.MaxProgress = 2 * SystemParam.Osat / SystemParam.Oe; wpf = new WaitingProcFunc(WaitingCollect_etaCurve_2); } if (!ParamTestWaitingProc.Execute(wpf, str, WaitingType.With_ConfirmCancel, "是否取消?")) { textBox1.AppendText("用户终止自动测试\r\n"); return; } }
private void toolStripButton4_Click(object sender, EventArgs e) { NiuJuPID.ResetPIDParam(); NiuZhenPID.ResetPIDParam(); WorkSetForm f = new WorkSetForm(); if (f.ShowDialog() == DialogResult.OK) { ReadSystemParam(); SetAllTime(AllTime1, AllTime2); wpStart = new WaitingProc(); wpStart.MaxProgress = 10; WaitingProcFunc wpf = new WaitingProcFunc(WaitingStart); if (wpStart.Execute(wpf, "等待电机启动", WaitingType.WithCancel, "")) { startDT = DateTime.Now; DateTime dt = DateTime.Now; TimeSpan ts = dt.Subtract(startDT); tbTime1.Visible = true; tbTime.Visible = true; tbTime.Text = ts.ToString(@"hh\:mm\:ss"); timer1.Enabled = true; toolStripButton4.Enabled = false; splitContainer1.Enabled = true; } } }
private void toolStripButton1_Click(object sender, EventArgs e) { if (!double.TryParse(toolStripTextBox2.Text, out motorRev)) { MessageBox.Show("转速设定有误"); return; } motorRev *= 7; if (motorRev > 3200 || motorRev <= 0) { MessageBox.Show("转速设定有误"); return; } if (!double.TryParse(toolStripTextBox1.Text, out motorTorque)) { MessageBox.Show("扭矩设定有误"); return; } if (motorTorque > 200 || motorTorque <= 0) { MessageBox.Show("扭矩设定有误"); return; } wpStart = new WaitingProc(); wpStart.MaxProgress = 10; WaitingProcFunc wpf = new WaitingProcFunc(WaitingStart); if (wpStart.Execute(wpf, "等待电机启动", WaitingType.WithCancel, "")) { toolStripButton1.Enabled = false; } }
public static bool CollectImage(IWin32Window _owner, int Tex, int nCount) { owner = _owner; if (UDPProc.UDPCommand_01() == null) { MessageBox.Show(owner, "与采集板通信失败"); return(false); } while (true) { ccdImageList = new List <ccdImage>(nCount); ccdImageRxConfirm = new List <bool>(nCount); for (int i = 0; i < nCount; i++) { ccdImageList.Add(new ccdImage()); ccdImageRxConfirm.Add(false); } if (UDPCommand_02(Tex, nCount) == null) { MessageBox.Show(owner, "与采集板通信失败"); return(false); } if (nCount < 3) { wp = null; WaitingImageList(oImage); } else { wp = new WaitingProc(owner); wp.MaxProgress = nCount; WaitingProcFunc wpf = new WaitingProcFunc(WaitingImageList); wp.Execute(wpf, "图像采集中", WaitingType.None, "是否取消?"); } bool bok = true; for (int i = 0; i < nCount; i++) { if (ccdImageRxConfirm[i] == false) { bok = false; break; } } if (bok) { return(true); } else { if (MessageBox.Show("图像采集失败,是否重试", "图像采集失败", MessageBoxButtons.RetryCancel) == DialogResult.Retry) { return(false); } } } }
private void toolStripButton1_Click(object sender, EventArgs e) { motorRev = double.Parse(toolStripTextBox1.Text) * 7; motorTorque = double.Parse(toolStripTextBox2.Text); Amplitude = double.Parse(toolStripTextBox3.Text); Torque = motorTorque; omega = 50; wpStart = new WaitingProc(); wpStart.MaxProgress = 10; WaitingProcFunc wpf = new WaitingProcFunc(WaitingStart); if (wpStart.Execute(wpf, "等待电机启动", WaitingType.WithCancel, "")) { toolStripButton1.Enabled = false; } }
public void ExcelExportProc() { if (Count > 65530) { MessageBox.Show("条目过多,无法导出"); return; } if (Count == 0) { MessageBox.Show("没有任何内容,无法导出"); return; } WaitingProcFunc wpf = new WaitingProcFunc(Proc); wp = new WFNetLib.WaitingProc(); string strTitle = "数据导出到Excel中"; wp.Execute(wpf, strTitle, WFNetLib.WaitingType.With_ConfirmCancel, "确定要取消么?"); }
double Imin, Imax;//照度范围 void ExposureTest() { UIHide(); exposureChart.Visible = true; exposureChart.Dock = DockStyle.Fill; exposureListView.Visible = true; exposureListView.Dock = DockStyle.Fill; exposureListView.Items[1].SubItems[1].Text = (SystemParam.NTmin.ToString()); textBox1.AppendText("开始明场曝光测试\r\n"); NT = SystemParam.NTmin; exposureWaitingProc = new WaitingProc(); exposureWaitingProc.MaxProgress = 10; WaitingProcFunc wpf = new WaitingProcFunc(WaitingExposureTest); if (!exposureWaitingProc.Execute(wpf, "曝光步距测试中", WaitingType.With_ConfirmCancel, "是否取消?")) { textBox1.AppendText("用户终止自动测试\r\n"); return; } }
void CCDParamTest_Collect_DarkI() { UIHide(); ParamTestChart1.Visible = true; ParamTestChart1.Dock = DockStyle.Fill; Collect_DarkI_miu = new List <double>(); Collect_DarkI_delta = new List <double>(); ParamTestWaitingProc = new WaitingProc(); string str = ""; WaitingProcFunc wpf = null; textBox1.AppendText("测量暗电流,暗场并按逐步改变曝光时间方式采集图像\r\n"); str = "测量暗电流,暗场并按逐步改变曝光时间方式采集图像中"; ParamTestWaitingProc.MaxProgress = 16; wpf = new WaitingProcFunc(WaitingCollect_DarkI); if (!ParamTestWaitingProc.Execute(wpf, str, WaitingType.With_ConfirmCancel, "是否取消?")) { textBox1.AppendText("用户终止自动测试\r\n"); return; } }
void ExposureVerify() { UIHide(); exposureVerifyChart.Visible = true; exposureVerifyChart.Dock = DockStyle.Fill; exposureVerifyListView.Visible = true; exposureVerifyListView.Dock = DockStyle.Fill; exposureVerifyListView.Items[1].SubItems[1].Text = SystemParam.NTmin.ToString(); exposureVerifyListView.Items[2].SubItems[1].Text = SystemParam.Oe.ToString(); exposureVerifyListView.Items[3].SubItems[1].Text = SystemParam.n.ToString(); exposureVerifyListView.Items[4].SubItems[1].Text = "0"; textBox1.AppendText("开始系统稳定性及曝光步距验证\r\n"); exposureVerifyWaitingProc = new WaitingProc(); exposureVerifyWaitingProc.MaxProgress = SystemParam.n; WaitingProcFunc wpf = new WaitingProcFunc(WaitingExposureVerify); if (!exposureVerifyWaitingProc.Execute(wpf, "系统稳定性及曝光步距验证", WaitingType.With_ConfirmCancel, "是否取消?")) { textBox1.AppendText("用户终止自动测试\r\n"); return; } }
private void startTimer_Tick(object sender, EventArgs e) { startTimer.Enabled = false; wp = new WaitingProc(); WaitingProcFunc wpf1 = new WaitingProcFunc(WaitingSQL); wp.Execute(wpf1, "等待数据库启动", WaitingType.None, ""); pCH368 = CH368.CH367mOpenDevice(CH368Index, TRUE, TRUE, 0x00); if (pCH368 == (IntPtr)(-1)) { wp = new WaitingProc(); WaitingProcFunc wpf = new WaitingProcFunc(WaitingPCIE); wp.Execute(wpf, "等待连接采集卡", WaitingType.With_ConfirmCancel, "未连接到采集卡,取消将退出软件,是否取消?"); } else { this.Invoke((EventHandler)(delegate { this.Enabled = true; })); InitPCIE(); } }
void CCDParamTest() { CCDParamTestResult.Reset(); if (ParamTestList[0])//曝光测试 { ExposureTest(); } UIHide(); CCDParamTestListView.Visible = true; for (int i = 12; i > 1; i--) { if (!ParamTestList[i]) { CCDParamTestListView.Items[5 + i].SubItems[1].Text = "不进行测试"; } else { CCDParamTestListView.Items[5 + i].SubItems[1].Text = "待测"; } } if (ExType == 1) { ParamTestChart1.Visible = true; CCDParamTestListView.Items[1].SubItems[1].Text = "固定曝光时间"; } else { ParamTestChart2.Visible = true; CCDParamTestListView.Items[1].SubItems[1].Text = "固定光源照度"; } CCDParamTestListView.Items[2].SubItems[1].Text = SystemParam.miu_sat.ToString(); CCDParamTestListView.Items[3].SubItems[1].Text = SystemParam.Osat.ToString(); CCDParamTestListView.Items[4].SubItems[1].Text = SystemParam.n.ToString(); CCDParamTestListView.Items[5].SubItems[1].Text = SystemParam.L.ToString(); //转换增益,量子效率,信噪比曲线,线性误差 if (ParamTestList[1] || ParamTestList[2] || ParamTestList[4] || ParamTestList[8]) { CCDParamTest_Collect_Step(); if (ParamTestList[1])//转换增益 { CCDParamTest_Calc_K(); CCDParamTestListView.Items[5 + 1].SubItems[1].Text = CCDParamTestResult.K.ToString(); } if (ParamTestList[2])//量子效率 { CCDParamTest_Calc_eta(); CCDParamTestListView.Items[5 + 2].SubItems[1].Text = CCDParamTestResult.eta.ToString(); } if (ParamTestList[4])//信噪比 { CCDParamTest_Calc_SNR(); CCDParamTestListView.Items[5 + 4].SubItems[1].Text = CCDParamTestResult.miu_p_min.ToString(); } if (ParamTestList[8])//线性误差 { CCDParamTest_Calc_LE(); CCDParamTestListView.Items[5 + 8].SubItems[1].Text = CCDParamTestResult.LE.ToString(); } } //量子效率曲线 if (ParamTestList[3]) { CCDParamTest_Collect_etaCurve(); CCDParamTest_Calc_etaCurve(); CCDParamTestListView.Items[5 + 3].SubItems[1].Text = "测试完成";//CCDParamTestResult.etaCurve.ToString(); } //动态范围、满阱容量、FPN if (ParamTestList[5] || ParamTestList[6] || ParamTestList[11]) { CCDParamTest_Collect_MinMax(); if (ParamTestList[5])//动态范围 { CCDParamTest_Calc_DR(); CCDParamTestListView.Items[5 + 5].SubItems[1].Text = CCDParamTestResult.DR.ToString(); } if (ParamTestList[6] || ParamTestList[11])//满阱容量或FPN { CCDParamTest_Calc_FWC(); CCDParamTestListView.Items[5 + 6].SubItems[1].Text = CCDParamTestResult.FWC.ToString(); } } //暗电流 if (ParamTestList[7]) { CCDParamTest_Collect_DarkI(); CCDParamTest_Calc_DarkI(); CCDParamTestListView.Items[5 + 7].SubItems[1].Text = CCDParamTestResult.miu_I_miu.ToString() + "; " + CCDParamTestResult.miu_I_delta.ToString(); } //DSNU,PRNU,读出噪声 if (ParamTestList[9] || ParamTestList[10] || ParamTestList[11] || ParamTestList[12]) { CCDParamTest_Collect_L(false); if (ParamTestList[10]) { CCDParamTest_Collect_L(true); } CCDParamTest_Calc_L_bLight = false; ParamTestWaitingProc = new WaitingProc(); WaitingProcFunc wpf = null; ParamTestWaitingProc.MaxProgress = SystemParam.L; wpf = new WaitingProcFunc(CCDParamTest_Calc_L); if (!ParamTestWaitingProc.Execute(wpf, "处理空域测试结果", WaitingType.With_ConfirmCancel, "是否取消?")) { textBox1.AppendText("用户终止自动测试\r\n"); return; } if (ParamTestList[9])//DSNU { CCDParamTestResult.DSNU = Math.Sqrt(CCDParamTestResult.L_S_y_dark) / CCDParamTestResult.K; CCDParamTestListView.Items[5 + 9].SubItems[1].Text = CCDParamTestResult.DSNU.ToString(); } if (ParamTestList[11])//FPN { CCDParamTestResult.DSNU = Math.Sqrt(CCDParamTestResult.L_S_y_dark) / CCDParamTestResult.K; CCDParamTestResult.FPN = CCDParamTestResult.DSNU / CCDParamTestResult.FWC; CCDParamTestListView.Items[5 + 11].SubItems[1].Text = CCDParamTestResult.FPN.ToString(); } if (ParamTestList[12])//读出噪声 { CCDParamTestResult.delta_raed = Math.Sqrt(CCDParamTestResult.delta_mid) / CCDParamTestResult.K; CCDParamTestListView.Items[5 + 12].SubItems[1].Text = CCDParamTestResult.delta_raed.ToString(); } if (ParamTestList[10])//PRNU { CCDParamTest_Calc_L_bLight = true; ParamTestWaitingProc = new WaitingProc(); wpf = null; ParamTestWaitingProc.MaxProgress = SystemParam.L; wpf = new WaitingProcFunc(CCDParamTest_Calc_L); if (!ParamTestWaitingProc.Execute(wpf, "处理空域测试结果", WaitingType.With_ConfirmCancel, "是否取消?")) { textBox1.AppendText("用户终止自动测试\r\n"); return; } CCDParamTestResult.PRNU = Math.Sqrt(CCDParamTestResult.L_S_y - CCDParamTestResult.L_S_y_dark) / (CCDParamTestResult.L_miu_y - CCDParamTestResult.L_miu_y_dark); CCDParamTestListView.Items[5 + 10].SubItems[1].Text = CCDParamTestResult.PRNU.ToString(); } } if (saveFileDialog1.ShowDialog() == DialogResult.OK) { TestReport.MakeReport(saveFileDialog1.FileName); textBox1.AppendText("自动测试结束,测试报告保存位置为:\r\n"); textBox1.AppendText(saveFileDialog1.FileName); } else { textBox1.AppendText("自动测试结束,用户未保存报告\r\n"); } MessageBox.Show("参数测试完成"); }
void CCD3TTest() { CCD3TTestResult.Reset(); UIHide(); CCD3TTestListView.Visible = true; for (int i = 0; i < 4; i++) { if (!ParamTestList[i]) { CCDParamTestListView.Items[4 + i].SubItems[1].Text = "不进行测试"; CCDParamTestListView.Items[4 + 5 + i].SubItems[1].Text = "不进行测试"; CCDParamTestListView.Items[4 + 10 + i].SubItems[1].Text = "不进行测试"; } else { CCDParamTestListView.Items[4 + i].SubItems[1].Text = "待测"; CCDParamTestListView.Items[4 + 5 + i].SubItems[1].Text = "待测"; CCDParamTestListView.Items[4 + 10 + i].SubItems[1].Text = "待测"; } } CCDParamTestListView.Items[1].SubItems[1].Text = CCDParamTestResult.K.ToString(); CCDParamTestListView.Items[2].SubItems[1].Text = SystemParam.L.ToString(); if (ParamTestList[0])//暗电流 { CCD3TTestResult.miu_I_miu = new double[3]; CCD3TTestResult.miu_I_delta = new double[3]; } //DSNU if (ParamTestList[1] || ParamTestList[2]) { CCD3TTestResult.DSNU = new double[3]; } //FPN if (ParamTestList[2]) { CCD3TTestResult.FPN = new double[3]; } //读出噪声 if (ParamTestList[3]) { CCD3TTestResult.delta_raed = new double[3]; } for (int i = 0; i < 3; i++) { while (!double.TryParse(InputBox.ShowInputBox("请设定温度" + (i + 1).ToString(), "25"), out CCD3TTestResult.T[i])) { MessageBox.Show("设定温度有误,请重新设定"); } if (ParamTestList[0])//暗电流 { CCDParamTest_Collect_DarkI(); CCDParamTest_Calc_DarkI(); CCD3TTestListView.Items[4 + 5 * i].SubItems[1].Text = CCDParamTestResult.miu_I_miu.ToString() + "; " + CCDParamTestResult.miu_I_delta.ToString(); CCD3TTestResult.miu_I_miu[i] = CCDParamTestResult.miu_I_miu; CCD3TTestResult.miu_I_delta[i] = CCDParamTestResult.miu_I_delta; FileOP.CopyFile(SystemParam.TempPicPath + "DarkI1.jpg", SystemParam.TempPicPath + "DarkI1_T" + (i + 1).ToString() + ".jpg"); FileOP.CopyFile(SystemParam.TempPicPath + "DarkI2.jpg", SystemParam.TempPicPath + "DarkI2_T" + (i + 1).ToString() + ".jpg"); } //DSNU,FPN,读出噪声 if (ParamTestList[1] || ParamTestList[2] || ParamTestList[3]) { CCDParamTest_Collect_L(false); CCDParamTest_Calc_L_bLight = false; ParamTestWaitingProc = new WaitingProc(); WaitingProcFunc wpf = null; ParamTestWaitingProc.MaxProgress = SystemParam.L; wpf = new WaitingProcFunc(CCDParamTest_Calc_L); if (!ParamTestWaitingProc.Execute(wpf, "处理暗场空域测试结果", WaitingType.With_ConfirmCancel, "是否取消?")) { textBox1.AppendText("用户终止自动测试\r\n"); return; } //DSNU if (ParamTestList[1] || ParamTestList[2]) { CCD3TTestResult.DSNU[i] = Math.Sqrt(CCDParamTestResult.L_S_y_dark) / CCDParamTestResult.K; CCD3TTestListView.Items[4 + 5 * i + 1].SubItems[1].Text = CCD3TTestResult.DSNU[i].ToString(); } //FPN if (ParamTestList[2]) { CCDParamTest_Collect_MinMax(); CCDParamTest_Calc_FWC(); CCD3TTestResult.FPN[i] = CCD3TTestResult.DSNU[i] / CCDParamTestResult.FWC; CCD3TTestListView.Items[4 + 5 * i + 2].SubItems[1].Text = CCD3TTestResult.FPN[i].ToString(); } //读出噪声 if (ParamTestList[3]) { CCD3TTestResult.delta_raed[i] = Math.Sqrt(CCDParamTestResult.delta_mid) / CCDParamTestResult.K; CCD3TTestListView.Items[4 + 5 * i + 3].SubItems[1].Text = CCD3TTestResult.delta_raed[i].ToString(); } } } if (saveFileDialog1.ShowDialog() == DialogResult.OK) { TestReport.MakeReport3T(saveFileDialog1.FileName); textBox1.AppendText("自动测试结束,测试报告保存位置为:\r\n"); textBox1.AppendText(saveFileDialog1.FileName); } else { textBox1.AppendText("自动测试结束,用户未保存报告\r\n"); } MessageBox.Show("三温测试完成"); }
private void toolStripButton1_Click(object sender, EventArgs e) { if (cbLambda.SelectedIndex == 0) { MessageBox.Show("请选择所需校准的光波长!!"); return; } if (!double.TryParse(tbStep.Text, out step) || step >= 100) { MessageBox.Show("校准步长输入有误,请重新输入!!"); return; } step = step / 100; lambadIndex = cbLambda.SelectedIndex - 2; a2 = new List <double>(); a1 = new List <double>(); a0 = new List <double>(); if (cbLambda.SelectedIndex != 1) { chart.Series[0].Points.Clear(); chart.Series[1].Points.Clear(); lambadIndex = cbLambda.SelectedIndex - 2; ccsWaitingProc = new WaitingProc(); ccsWaitingProc.MaxProgress = (int)(1 / step) + 1; WaitingProcFunc wpf = new WaitingProcFunc(WaitingCCS); if (!ccsWaitingProc.Execute(wpf, "光源波长" + tcpCCS.lambdaList[lambadIndex].ToString() + " nm校准中", WaitingType.With_ConfirmCancel, "是否取消?")) { return; } tcpCCS.L2E_a2[lambadIndex] = a2[0]; tcpCCS.L2E_a1[lambadIndex] = a1[0]; tcpCCS.L2E_a0[lambadIndex] = a0[0]; } else //全部 { for (int i = 0; i < tcpCCS.lambdaList.Length; i++) { chart.Series[0].Points.Clear(); chart.Series[1].Points.Clear(); lambadIndex = cbLambda.SelectedIndex - 2; ccsWaitingProc = new WaitingProc(); ccsWaitingProc.MaxProgress = (int)(1 / step) + 1; WaitingProcFunc wpf = new WaitingProcFunc(WaitingCCS); if (!ccsWaitingProc.Execute(wpf, "光源波长" + tcpCCS.lambdaList[lambadIndex].ToString() + " nm校准中", WaitingType.With_ConfirmCancel, "是否取消?")) { return; } MessageBox.Show("波长" + tcpCCS.lambdaList[lambadIndex].ToString() + " nm校准完成"); } for (int i = 0; i < tcpCCS.lambdaList.Length; i++) { tcpCCS.L2E_a2[i] = a2[i]; tcpCCS.L2E_a1[i] = a1[i]; tcpCCS.L2E_a0[i] = a0[i]; } } string stra2 = ""; string stra1 = ""; string stra0 = ""; for (int i = 0; i < tcpCCS.lambdaList.Length; i++) { stra2 += tcpCCS.L2E_a2[i].ToString(aFormat) + ","; stra1 += tcpCCS.L2E_a1[i].ToString(aFormat) + ","; stra0 += tcpCCS.L2E_a1[i].ToString(aFormat) + ","; } stra2 = stra2.Substring(0, stra2.Length - 1); stra1 = stra1.Substring(0, stra1.Length - 1); stra0 = stra0.Substring(0, stra0.Length - 1); iniFileOP.Write("Light Param", "L2E_a2", stra2); iniFileOP.Write("Light Param", "L2E_a1", stra1); iniFileOP.Write("Light Param", "L2E_a0", stra0); MessageBox.Show("校准完成!!!"); }