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_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;
                }
            }
        }
 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);
             }
         }
     }
 }
Example #4
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            double d;

            if (!(int.TryParse(tbCount.Text, out nCount) && (double.TryParse(tbTex.Text, out d))))
            {
                MessageBox.Show("参数设置有误");
                return;
            }
            Tex = (int)(d / SystemParam.Ts);
            UDPProc.CollectImage(this, Tex, nCount);
        }
 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;
         }
     }
 }
Example #6
0
        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("设置成功");
            }
        }
Example #7
0
        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();
            }
        }
Example #8
0
        void CCDParamTest_Collect_MinMax()
        {
            double miuCC;

            tcpCCS.LightSet(SystemParam.lambda_Oe, SystemParam.Osat);
            if (!UDPProc.CollectImage(this, SystemParam.NTmin, 2))
            {
                return;
            }
            UDPProc.ccdImageList[0].save(SystemParam.TempPicPath + "Max_0.bin");
            UDPProc.ccdImageList[1].save(SystemParam.TempPicPath + "Max_1.bin");
            ccdImage.Calc_miu_delta(UDPProc.ccdImageList[0], UDPProc.ccdImageList[1], out miu_sat, out delta_sat, out miuCC);
            tcpCCS.LightSet(SystemParam.lambda_Oe, 0);
            if (!UDPProc.CollectImage(this, SystemParam.NTmin, 2))
            {
                return;
            }
            UDPProc.ccdImageList[0].save(SystemParam.TempPicPath + "Min_0.bin");
            UDPProc.ccdImageList[1].save(SystemParam.TempPicPath + "Min_1.bin");
            ccdImage.Calc_miu_delta(UDPProc.ccdImageList[0], UDPProc.ccdImageList[1], out miu_dark, out delta_dark, out miuCC);
        }
        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);
            }));
        }
Example #10
0
        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);
            }
        }
        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;
                }
            }
        }