void WaitingExposureVerify(object LockWatingThread) { while (true) { double miu; double delta; double miuCC; this.Invoke((EventHandler)(delegate { exposureVerifyChart.Series["miu"].Points.Clear(); exposureVerifyChart.Series["delta"].Points.Clear(); exposureVerifyChart.Series["miuCC"].Points.Clear(); for (int step = 0; step < SystemParam.n; step++) { WFGlobal.WaitMS(1); int ex = SystemParam.NTmin + step * SystemParam.NTexp; tcpCCS.LightSet(SystemParam.lambda_Oe, SystemParam.Oe); exposureVerifyListView.Items[4].SubItems[1].Text = step.ToString(); if (!UDPProc.CollectImage(this, ex, 2)) { exposureVerifyWaitingProc.ExitWatting(); return; } UDPProc.ccdImageList[0].save(SystemParam.TempPicPath + "Ev" + step.ToString() + "_0.bin"); UDPProc.ccdImageList[1].save(SystemParam.TempPicPath + "Ev" + step.ToString() + "_1.bin"); ccdImage.Calc_miu_delta(UDPProc.ccdImageList[0], UDPProc.ccdImageList[1], out miu, out delta, out miuCC); exposureVerifyChart.Series["miu"].Points.AddXY(step, miu); exposureVerifyChart.Series["delta"].Points.AddXY(step, delta); exposureVerifyChart.Series["miuCC"].Points.AddXY(step, miuCC); if (exposureVerifyWaitingProc.HasBeenCancelled()) { return; } exposureVerifyWaitingProc.SetProcessBarPerformStep(); } })); if (exposureVerifyWaitingProc.HasBeenCancelled()) { return; } if (MessageBox.Show("测试完毕,是否修改要修改参数", "测试完成", MessageBoxButtons.YesNo) == DialogResult.Yes) { FormParam f = new FormParam(); f.ShowDialog(); } else { return; } } }
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 WaitingExposureTest(object LockWatingThread) { Imin = 0; Imax = 100; while (true) { double[] miu = new double[10]; double[] delta = new double[10]; double[] miuCC = new double[10]; exposureWaitingProc.SetProcessBar(0); this.Invoke((EventHandler)(delegate { WFGlobal.WaitMS(1); exposureChart.Series["miu"].Points.Clear(); exposureChart.Series["delta"].Points.Clear(); double gap = (Imax - Imin) / 9; for (int step = 0; step < 10; step++) { double oe_per = Imin + gap * step; tcpCCS.LightSet(SystemParam.lambda_Oe, oe_per); 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, NT, 2)) { exposureWaitingProc.ExitWatting(); return; } UDPProc.ccdImageList[0].save(SystemParam.TempPicPath + "E" + step.ToString() + "_0.bin"); UDPProc.ccdImageList[1].save(SystemParam.TempPicPath + "E" + step.ToString() + "_1.bin"); ccdImage.Calc_miu_delta(UDPProc.ccdImageList[0], UDPProc.ccdImageList[1], out miu[step], out delta[step], out miuCC[step]); exposureChart.Series["miu"].Points.AddXY(oe_per, miu[step]); exposureChart.Series["delta"].Points.AddXY(oe_per, delta[step]); if (exposureWaitingProc.HasBeenCancelled()) { return; } exposureWaitingProc.SetProcessBarPerformStep(); } })); if (exposureWaitingProc.HasBeenCancelled()) { return; } // 方差全部相等(且接近0),则在之前照度第一个区间分10个照度等级 double close0 = 0.01; if (delta[0] < close0 && delta[1] < close0) { Imax = (Imax - Imin) / 9; } //如果方差单调升则修改NT=10*NT_min else if (delta[0] < delta[1])//单调增 { bool bMonotonicity = true; for (int i = 0; i < 9; i++) { if (delta[i + 1] < delta[i])//增减转折 { Imin = (Imax - Imin) * (i + 1); bMonotonicity = false; break; } } if (bMonotonicity) { NT = NT * 10; // while(true) // { // string strNTmin = InputBox.ShowInputBox("请重新设定最小曝光周期数", SystemParam.NTmin.ToString()); // if (!int.TryParse(strNTmin, out SystemParam.NTmin)) // { // MessageBox.Show("所设定的最小曝光周期数有误!!!"); // } // break; // } } } else//第一个就是减,那应该都是减函数 { SystemParam.Oe = tcpCCS.Per2LX(Imin / (SystemParam.n - 5)); iniFileOP.Write("Light Param", "Oe", SystemParam.Oe.ToString()); SystemParam.Osat = tcpCCS.Per2LX(Imin); iniFileOP.Write("CCD Param", "Osat", SystemParam.Osat.ToString(), strCCDINIPath); SystemParam.miu_sat = miu[0]; iniFileOP.Write("CCD Param", "miu_sat", SystemParam.miu_sat.ToString(), strCCDINIPath); SystemParam.NTexp = SystemParam.NTmin * (SystemParam.n - 5) / SystemParam.n; iniFileOP.Write("Collect Param", "NTexp", SystemParam.NTexp.ToString()); this.Invoke((EventHandler)(delegate { exposureListView.Items[4].SubItems[1].Text = SystemParam.Oe.ToString("F2"); exposureListView.Items[5].SubItems[1].Text = miu[0].ToString("F2"); exposureListView.Items[6].SubItems[1].Text = SystemParam.NTexp.ToString("F2"); })); MessageBox.Show("曝光步距测试完毕"); return; } } }