void WaitingCollect_Step_1(object LockWatingThread) { int Oe = 0; double miu; double miuCC; double delta; //double E; this.Invoke((EventHandler)(delegate { WFGlobal.WaitMS(1); ParamTestChart1.Series["miu"].Points.Clear(); ParamTestChart1.Series["delta"].Points.Clear(); ParamTestChart1.Series["E"].Points.Clear(); })); while (true) { this.Invoke((EventHandler)(delegate { tcpCCS.LightSet(SystemParam.lambda_Oe, Oe); // exposureListView.Items[2].SubItems[1].Text = (Imin.ToString("F2") + "-" + Imax.ToString("F2")); // exposureListView.Items[3].SubItems[1].Text = oe_per.ToString("F2"); if (!UDPProc.CollectImage(this, SystemParam.NTmin, 2)) { ParamTestWaitingProc.ExitWatting(); return; } UDPProc.ccdImageList[0].save(SystemParam.TempPicPath + "E" + Oe.ToString("") + "_0.bin"); UDPProc.ccdImageList[1].save(SystemParam.TempPicPath + "E" + Oe.ToString("") + "_1.bin"); ccdImage.Calc_miu_delta(UDPProc.ccdImageList[0], UDPProc.ccdImageList[1], out miu, out delta, out miuCC); ParamTestChart1.Series["miu"].Points.AddXY(Oe, miu); ParamTestChart1.Series["delta"].Points.AddXY(Oe, delta); DeviceState ds = UDPProc.UDPCommand_04(); if (ds == null) { textBox1.AppendText("照度采集失败,测试终止\r\n"); ParamTestWaitingProc.ExitWatting(); return; } ParamTestChart1.Series["E"].Points.AddXY(Oe, ds.Illuminance); Collect_Step_miu.Add(miu); Collect_Step_delta.Add(delta); Collect_Step_E.Add(ds.Illuminance); if (miu >= SystemParam.miu_sat)//均值达到本文第二章(曝光步距)所确定的饱和均值 { double max = Collect_Step_delta.Max(); if (Collect_Step_delta.Last() < max * 0.5)//方差由最大峰值迅速下降(超过50%) { return; } } Oe += SystemParam.Oe; ParamTestWaitingProc.SetProcessBarPerformStep(); })); if (exposureWaitingProc.HasBeenCancelled()) { return; } } }
void WaitingCollect_L(object LockWatingThread) { int Tex; //double E; this.Invoke((EventHandler)(delegate { WFGlobal.WaitMS(1); // exposureChart.Series["miu"].Points.Clear(); // exposureChart.Series["delta"].Points.Clear(); // tcpCCS.LightSet(SystemParam.lambda_Oe, 0);//暗场 })); Tex = SystemParam.NTmin; //明场 for (int i = 0; i < SystemParam.L; i++) { this.Invoke((EventHandler)(delegate { // exposureListView.Items[2].SubItems[1].Text = (Imin.ToString("F2") + "-" + Imax.ToString("F2")); // exposureListView.Items[3].SubItems[1].Text = oe_per.ToString("F2"); if (!UDPProc.CollectImage(this, Tex, 1)) { ParamTestWaitingProc.ExitWatting(); return; } WriteTempFile(UDPProc.ccdImageList[0].byteList, i, L_TempFilePath); })); if (exposureWaitingProc.HasBeenCancelled()) { return; } ParamTestWaitingProc.SetProcessBarPerformStep(); } }
void WaitingCollect_DarkI(object LockWatingThread) { double miu = 0; double miuCC; double delta; int Tex; //double E; this.Invoke((EventHandler)(delegate { WFGlobal.WaitMS(1); exposureChart.Series["miu"].Points.Clear(); exposureChart.Series["delta"].Points.Clear(); tcpCCS.LightSet(SystemParam.lambda_Oe, 0);//暗场 })); Tex = SystemParam.NTdark; //明场 for (int i = 0; i < 16; i++) { this.Invoke((EventHandler)(delegate { // exposureListView.Items[2].SubItems[1].Text = (Imin.ToString("F2") + "-" + Imax.ToString("F2")); // exposureListView.Items[3].SubItems[1].Text = oe_per.ToString("F2"); if (!UDPProc.CollectImage(this, Tex, 2)) { ParamTestWaitingProc.ExitWatting(); return; } UDPProc.ccdImageList[0].save(SystemParam.TempPicPath + "DarkI" + Tex.ToString("") + "_0.bin"); UDPProc.ccdImageList[1].save(SystemParam.TempPicPath + "DarkI" + Tex.ToString("") + "_1.bin"); ccdImage.Calc_miu_delta(UDPProc.ccdImageList[0], UDPProc.ccdImageList[1], out miu, out delta, out miuCC); exposureChart.Series["miu"].Points.AddXY(Tex, miu); exposureChart.Series["delta"].Points.AddXY(Tex, delta); Collect_DarkI_miu.Add(miu); Collect_DarkI_delta.Add(delta); })); if (exposureWaitingProc.HasBeenCancelled()) { return; } Tex += SystemParam.delta_Tdark; ParamTestWaitingProc.SetProcessBarPerformStep(); } }
void CCDParamTest_Calc_L(object LockWatingThread) { //int count = SystemParam.L * 4; string file; if (CCDParamTest_Calc_L_bLight) { file = SystemParam.L_LightTempFilePath; } else { file = SystemParam.L_DarkTempFilePath; } double[,] y = new double[SystemParam.CCD_M, SystemParam.CCD_N]; /************************************************************************/ /* <y> */ /************************************************************************/ ParamTestWaitingProc.SetTitle("相同曝光条件下数据处理---计算暗场像素点均值"); ParamTestWaitingProc.SetProcessBar(0); ParamTestWaitingProc.SetProcessBarRange(0, SystemParam.L); for (int i = 0; i < SystemParam.L; i++) { byte[] p = ReadTempFile(2 * SystemParam.CCD_M * SystemParam.CCD_N, i, SystemParam.L_DarkTempFilePath); ushort[,] pic = ccdImage.TransImageDatas(p); for (int m = 0; m < SystemParam.CCD_M; m++) { for (int n = 0; n < SystemParam.CCD_N; n++) { y[m, n] += pic[m, n]; } } if (ParamTestWaitingProc.HasBeenCancelled()) { return; } ParamTestWaitingProc.SetProcessBarPerformStep(); this.Invoke((EventHandler)(delegate { //listView1.Items[14].SubItems[1].Text = (((double)(i + 1)) * 100 / count).ToString("F1") + "%"; })); } for (int m = 0; m < SystemParam.CCD_M; m++) { for (int n = 0; n < SystemParam.CCD_N; n++) { y[m, n] = y[m, n] / SystemParam.L; } } /************************************************************************/ /* miu_y */ /************************************************************************/ double miu_y = 0; for (int m = 0; m < SystemParam.CCD_M; m++) { for (int n = 0; n < SystemParam.CCD_N; n++) { miu_y += y[m, n]; } } miu_y = miu_y / SystemParam.CCD_M / SystemParam.CCD_N; if (CCDParamTest_Calc_L_bLight) { CCDParamTestResult.L_miu_y = miu_y; } else { CCDParamTestResult.L_miu_y_dark = miu_y; } /************************************************************************/ /* S_y_measured^2 */ /************************************************************************/ double S_y_measured = 0; for (int m = 0; m < SystemParam.CCD_M; m++) { for (int n = 0; n < SystemParam.CCD_N; n++) { S_y_measured += Math.Pow((y[m, n] - CCDParamTestResult.L_miu_y_dark), 2); } } S_y_measured = S_y_measured / SystemParam.CCD_M / SystemParam.CCD_N; /************************************************************************/ /* delta_s^2 */ /************************************************************************/ ParamTestWaitingProc.SetTitle("相同曝光条件下数据处理---计算暗场像素点方差"); ParamTestWaitingProc.SetProcessBar(0); ParamTestWaitingProc.SetProcessBarRange(0, SystemParam.L); double[,] delta_s = new double[SystemParam.CCD_M, SystemParam.CCD_N]; for (int i = 0; i < SystemParam.L; i++) { byte[] p = ReadTempFile(2 * SystemParam.CCD_M * SystemParam.CCD_N, i, SystemParam.L_DarkTempFilePath); ushort[,] pic = ccdImage.TransImageDatas(p); for (int m = 0; m < SystemParam.CCD_M; m++) { for (int n = 0; n < SystemParam.CCD_N; n++) { delta_s[m, n] += Math.Pow(pic[m, n] - y[m, n], 2); } } if (ParamTestWaitingProc.HasBeenCancelled()) { return; } ParamTestWaitingProc.SetProcessBarPerformStep(); this.Invoke((EventHandler)(delegate { //listView1.Items[14].SubItems[1].Text = (((double)(i + 1)) * 100 / count).ToString("F1") + "%"; })); } for (int m = 0; m < SystemParam.CCD_M; m++) { for (int n = 0; n < SystemParam.CCD_N; n++) { delta_s[m, n] = delta_s[m, n] / SystemParam.L; } } double max = 0; if (!CCDParamTest_Calc_L_bLight)//暗场,计算方差中值 { for (int m = 0; m < SystemParam.CCD_M; m++) { for (int n = 0; n < SystemParam.CCD_N; n++) { if (max < delta_s[m, n]) { max = delta_s[m, n]; } } } CCDParamTestResult.delta_mid = max / 2; } /************************************************************************/ /* delta_y_stack^2 */ /************************************************************************/ double delta_y_stack = 0; for (int m = 0; m < SystemParam.CCD_M; m++) { for (int n = 0; n < SystemParam.CCD_N; n++) { delta_y_stack += Math.Pow(delta_s[m, n], 2); } } delta_y_stack = delta_y_stack / SystemParam.CCD_M / SystemParam.CCD_N; /************************************************************************/ /* delta_s_stack^2 */ /************************************************************************/ if (CCDParamTest_Calc_L_bLight) { CCDParamTestResult.L_S_y = S_y_measured - delta_y_stack / SystemParam.L; } else { CCDParamTestResult.L_S_y_dark = S_y_measured - delta_y_stack / SystemParam.L; } }
void WaitingCollect_etaCurve_2(object LockWatingThread) { double miu = 0; double miuCC; double delta; int Tex; int stepCount = 0; for (double lamba = SystemParam.L_lambda; lamba < SystemParam.H_lambda; lamba += SystemParam.delta_lambda) { stepCount = 0; List <double> eta_miu = new List <double>(); Collect_etaCurve_delta = new List <double>(); this.Invoke((EventHandler)(delegate { WFGlobal.WaitMS(1); ParamTestChart2.Series["miu"].Points.Clear(); ParamTestChart2.Series["delta"].Points.Clear(); ParamTestChart2.Series["miu_dark"].Points.Clear(); ParamTestChart2.Series["delta_dark"].Points.Clear(); tcpCCS.LightSet((int)lamba, SystemParam.Oe); })); Tex = SystemParam.NTmin; //明场 while (true) { this.Invoke((EventHandler)(delegate { // exposureListView.Items[2].SubItems[1].Text = (Imin.ToString("F2") + "-" + Imax.ToString("F2")); // exposureListView.Items[3].SubItems[1].Text = oe_per.ToString("F2"); if (!UDPProc.CollectImage(this, Tex, 2)) { ParamTestWaitingProc.ExitWatting(); return; } UDPProc.ccdImageList[0].save(SystemParam.TempPicPath + "ET" + Tex.ToString("") + "_0.bin"); UDPProc.ccdImageList[1].save(SystemParam.TempPicPath + "ET" + Tex.ToString("") + "_1.bin"); ccdImage.Calc_miu_delta(UDPProc.ccdImageList[0], UDPProc.ccdImageList[1], out miu, out delta, out miuCC); ParamTestChart2.Series["miu"].Points.AddXY(Tex, miu); ParamTestChart2.Series["delta"].Points.AddXY(Tex, delta); DeviceState ds = UDPProc.UDPCommand_04(); if (ds == null) { textBox1.AppendText("照度采集失败,测试终止\r\n"); ParamTestWaitingProc.ExitWatting(); return; } eta_miu.Add(miu); Collect_etaCurve_delta.Add(delta); Collect_etaCurve_E.Add(ds.Illuminance); Tex += SystemParam.NTexp; stepCount++; ParamTestWaitingProc.SetProcessBarPerformStep(); })); if (miu >= SystemParam.miu_sat)//均值达到本文第二章(曝光步距)所确定的饱和均值 { double max = Collect_etaCurve_delta.Max(); if (Collect_etaCurve_delta.Last() < max * 0.5)//方差由最大峰值迅速下降(超过50%) { Collect_etaCurve_miu.Add(eta_miu); break; } } if (exposureWaitingProc.HasBeenCancelled()) { return; } } this.Invoke((EventHandler)(delegate { WFGlobal.WaitMS(1); tcpCCS.LightSet(SystemParam.lambda_Oe, 0); })); Tex = SystemParam.NTmin; List <double> eta_miu_dark = new List <double>(); for (int i = 0; i < stepCount; i++) { this.Invoke((EventHandler)(delegate { // exposureListView.Items[2].SubItems[1].Text = (Imin.ToString("F2") + "-" + Imax.ToString("F2")); // exposureListView.Items[3].SubItems[1].Text = oe_per.ToString("F2"); if (!UDPProc.CollectImage(this, Tex, 2)) { ParamTestWaitingProc.ExitWatting(); return; } UDPProc.ccdImageList[0].save(SystemParam.TempPicPath + "EDT" + Tex.ToString("") + "_0.bin"); UDPProc.ccdImageList[1].save(SystemParam.TempPicPath + "EDT" + Tex.ToString("") + "_1.bin"); ccdImage.Calc_miu_delta(UDPProc.ccdImageList[0], UDPProc.ccdImageList[1], out miu, out delta, out miuCC); ParamTestChart2.Series["miu_dark"].Points.AddXY(Tex, miu); ParamTestChart2.Series["delta_dark"].Points.AddXY(Tex, delta); eta_miu_dark.Add(miu); Collect_etaCurve_delta_dark.Add(delta); })); if (exposureWaitingProc.HasBeenCancelled()) { return; } Tex += SystemParam.NTexp; ParamTestWaitingProc.SetProcessBarPerformStep(); } Collect_etaCurve_miu_dark.Add(eta_miu_dark); } }