private void button1_Click(object sender, EventArgs e) { SystemParam.CCD_M = (int)nCCD_M.Value; SystemParam.CCD_N = (int)nCCD_N.Value; SystemParam.CCD_phi = cbCCD_phi.SelectedIndex; SystemParam.CCD_PGA = cbCCD_PGA.SelectedIndex; DeviceState ds = UDPProc.UDPCommand_01(); if (ds == null) { MessageBox.Show("设置失败"); } else { MessageBox.Show("设置成功"); } }
void WaitingCCS(object LockWatingThread) { List <double> OeList = new List <double>(); List <double> EList = new List <double>(); for (double Oe = 0; Oe < 1; Oe += step) { OeList.Add(Oe); tcpCCS.LightSet(tcpCCS.lambdaList[lambadIndex], Oe); WFGlobal.WaitMS(100); DeviceState ds = UDPProc.UDPCommand_04(); if (ds == null) { MessageBox.Show("照度采集失败,测试终止\r\n"); ccsWaitingProc.ExitWatting(); return; } EList.Add(ds.Illuminance); this.Invoke((EventHandler)(delegate { chart.Series[0].Points.AddXY(Oe, ds.Illuminance); })); if (ccsWaitingProc.HasBeenCancelled()) { return; } } double[] fitret = FittingMultiLine.MultiLine(OeList.ToArray(), EList.ToArray(), OeList.Count, 2); a2.Add(double.Parse(fitret[2].ToString(aFormat))); a1.Add(double.Parse(fitret[1].ToString(aFormat))); a0.Add(double.Parse(fitret[0].ToString(aFormat))); this.Invoke((EventHandler)(delegate { for (double Oe = 0; Oe < 1; Oe += step) { chart.Series[1].Points.AddXY(Oe, a2.Last() * Oe * Oe + a1.Last() * Oe + a0.Last()); } chart.SaveImage(SystemParam.TempPicPath + "ccs_" + tcpCCS.lambdaList[lambadIndex].ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); })); }
void WaitingCollect_etaCurve_1(object LockWatingThread) { int Oe = 0; double miu = 0; double miuCC; double delta; //double E; for (double lamba = SystemParam.L_lambda; lamba < SystemParam.H_lambda; lamba += SystemParam.delta_lambda) { List <double> eta_miu = new List <double>(); Collect_etaCurve_delta = new List <double>(); 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((int)lamba, 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); eta_miu.Add(miu); Collect_etaCurve_delta.Add(delta); Collect_etaCurve_E.Add(ds.Illuminance); Oe += SystemParam.Oe; ParamTestWaitingProc.SetProcessBarPerformStep(); })); if (miu >= SystemParam.miu_sat)//均值达到本文第二章(曝光步距)所确定的饱和均值 { double max = Collect_Step_delta.Max(); if (Collect_Step_delta.Last() < max * 0.5)//方差由最大峰值迅速下降(超过50%) { Collect_etaCurve_miu.Add(eta_miu); break; } } if (exposureWaitingProc.HasBeenCancelled()) { return; } } } }
void WaitingCollect_Step_2(object LockWatingThread) { double miu = 0; double miuCC; double delta; int Tex; int stepCount = 0; //double E; 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(SystemParam.lambda_Oe, 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; } Collect_Step_miu.Add(miu); Collect_Step_delta.Add(delta); Collect_Step_E.Add(ds.Illuminance); Tex += SystemParam.NTexp; stepCount++; ParamTestWaitingProc.SetProcessBarPerformStep(); })); if (miu >= SystemParam.miu_sat)//均值达到本文第二章(曝光步距)所确定的饱和均值 { double max = Collect_Step_delta.Max(); if (Collect_Step_delta.Last() < max * 0.5)//方差由最大峰值迅速下降(超过50%) { break; } } if (exposureWaitingProc.HasBeenCancelled()) { return; } } this.Invoke((EventHandler)(delegate { WFGlobal.WaitMS(1); tcpCCS.LightSet(SystemParam.lambda_Oe, 0); })); Tex = SystemParam.NTmin; 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); Collect_Step_miu_dark.Add(miu); Collect_Step_delta_dark.Add(delta); })); if (exposureWaitingProc.HasBeenCancelled()) { return; } Tex += SystemParam.NTexp; ParamTestWaitingProc.SetProcessBarPerformStep(); } }