void FPNTest_ProcData(object LockWatingThread)
        {
            string strName = FPNFile_Path + "FPN_L" + FPN_L.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bin";

            /************************************************************************/
            /* FPN_y                                                                */
            /************************************************************************/
            miu_y = new List <double>();
            for (int i = 0; i < FPN_L; i++)
            {
                FPN_y = new ushort[m_Buffers.Height, m_Buffers.Width];
                ysave = new byte[SystemParam.ByteLen4Pic];
                for (int j = 0; j < FPN_Ns; j++)
                {
                    byte[] p = SystemParam.ReadTempFile(SystemParam.ByteLen4Pic, j, FPNFile_Path + "TempData\\Light\\" + (i + 1).ToString() + "bin");
                    ushort[,] pic = wfSapGUI.TransPicDatas(p, m_Buffers.Height, m_Buffers.Width, SystemParam.cmosInfo.PixelDepth);
                    for (int m = 0; m < m_Buffers.Height; m++)
                    {
                        for (int n = 0; n < m_Buffers.Width; n++)
                        {
                            FPN_y[m, n] += pic[m, n];
                        }
                    }
                    if (waitProc.HasBeenCancelled())
                    {
                        return;
                    }
                    waitProc.SetProcessBarPerformStep();
                }
                double miu = 0;
                for (int m = 0; m < m_Buffers.Height; m++)
                {
                    for (int n = 0; n < m_Buffers.Width; n++)
                    {
                        FPN_y[m, n] = (ushort)(FPN_y[m, n] / FPN_Ns);
                        miu        += FPN_y[m, n];
                    }
                }
                ysave = wfSapGUI.ReTransPicDatas(FPN_y, m_Buffers.Height, m_Buffers.Width);
                SystemParam.WriteTempFile(ysave, i, strName);
                miu = miu / m_Buffers.Height / m_Buffers.Width;
                miu_y.Add(miu);
            }

            this.Invoke((EventHandler)(delegate
            {
                textBox1.AppendText("FPN明场数据处理完成\r\n");
            }));

            strName = FPNFile_Path + "FPN_D" + FPN_L.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bin";
            /************************************************************************/
            /* FPN_y                                                                */
            /************************************************************************/
            miu_ydark = new List <double>();
            for (int i = 0; i < FPN_L; i++)
            {
                FPN_y = new ushort[m_Buffers.Height, m_Buffers.Width];
                ysave = new byte[SystemParam.ByteLen4Pic];
                for (int j = 0; j < FPN_Ns; j++)
                {
                    byte[] p = SystemParam.ReadTempFile(SystemParam.ByteLen4Pic, j, FPNFile_Path + "TempData\\Dark\\" + (i + 1).ToString() + "bin");
                    ushort[,] pic = wfSapGUI.TransPicDatas(p, m_Buffers.Height, m_Buffers.Width, SystemParam.cmosInfo.PixelDepth);
                    for (int m = 0; m < m_Buffers.Height; m++)
                    {
                        for (int n = 0; n < m_Buffers.Width; n++)
                        {
                            FPN_y[m, n] += pic[m, n];
                        }
                    }
                    if (waitProc.HasBeenCancelled())
                    {
                        return;
                    }
                    waitProc.SetProcessBarPerformStep();
                }
                double miu = 0;
                for (int m = 0; m < m_Buffers.Height; m++)
                {
                    for (int n = 0; n < m_Buffers.Width; n++)
                    {
                        FPN_y[m, n] = (ushort)(FPN_y[m, n] / FPN_Ns);
                        miu        += FPN_y[m, n];
                    }
                }
                ysave = wfSapGUI.ReTransPicDatas(FPN_y, m_Buffers.Height, m_Buffers.Width);
                SystemParam.WriteTempFile(ysave, i, strName);
                miu = miu / m_Buffers.Height / m_Buffers.Width;
                miu_ydark.Add(miu);
            }

            this.Invoke((EventHandler)(delegate
            {
                textBox1.AppendText("FPN暗场数据处理完成\r\n");
            }));

            TextLog.AddTextLog("--------------" + DateTime.Now.ToString() + "----------------", FPNFile_Path + "FPN" + FPN_L.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt", false);
            TextLog.AddTextLog(String.Format("{0,-11}{1,-11}{2,-11}", "曝光时间", "明场均值", "暗场均值"), FPNFile_Path + "FPN" + FPN_L.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt", false);
            uint lsup = SystemParam.eStart + (uint)(Calc1.saturation * FPN_Per / 100) * SystemParam.eStep;

            for (int i = 0; i < FPN_L; i++)
            {
                uint   ls = (uint)(lsup / FPN_L * (i + 1));
                double t  = ((double)(ls)) * SystemParam.Ts;
                TextLog.AddTextLog(String.Format("{0,-15}{1,-15}{2,-15}", t.ToString("F3"), miu_y[i].ToString("F6"), miu_ydark[i].ToString("F6")), FPNFile_Path + "FPN" + FPN_L.ToString() + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt", false);
            }
        }
        void FPNTest_Light(object LockWatingThread)
        {
            byte[] yByteArray;
            uint   lsup = SystemParam.eStart + (uint)(Calc1.saturation * FPN_Per / 100) * SystemParam.eStep;

            for (int k = 0; k < FPN_L; k++)
            {
                rxFrame = 0;
                uint ls = (uint)(lsup / FPN_L * (k + 1));
                Calc2.y50 = new double[m_Buffers.Height, m_Buffers.Width];

                int nCount = FPN_Ns / FPN_Len;
                this.Invoke((EventHandler)(delegate
                {
                    if (bLight)
                    {
                        textBox1.AppendText("开始" + (FPN_Per / FPN_L * (k + 1)).ToString("F2") + "%曝光明场采集\r\n");
                    }
                    else
                    {
                        textBox1.AppendText("开始" + (FPN_Per / FPN_L * (k + 1)).ToString("F2") + "%曝光暗场采集\r\n");
                    }
                    toolStripLabel3.Text = (ls * SystemParam.Ts).ToString("F2") + " ms";
                }));
                NopCam((ushort)(FPN_Len + +CamEx), ls);

                int saveindex = 0;
                for (int i = 0; i < nCount; i++)
                {
                    if (waitProc.HasBeenCancelled())
                    {
                        return;
                    }
                    SerialFunc.SerialCommand3((ushort)(FPN_Len + +CamEx), ls);
                    if (!WaitCam(FPN_Len + CamEx))
                    {
                        i--;
                        continue;
                    }
                    if (bLight)
                    {
                        for (int j = 1; j < FPN_Len + 1; j++)
                        {
                            saveindex++;
                            m_Buffers.Save(FPNFile_Path + "TempPic\\Light\\" + saveindex.ToString() + ".bmp", "-format bmp", j, 0);
                            Thread.Sleep(SystemParam.PicDelay);
                        }
                        for (int j = 1; j < FPN_Len + 1; j++)
                        {
                            yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j);
                            SystemParam.WriteTempFile(yByteArray, i * FPN_Len + j - 1, FPNFile_Path + "TempData\\Light\\" + (k + 1).ToString() + "bin");
                        }
                    }
                    else
                    {
                        for (int j = 1; j < FPN_Len + 1; j++)
                        {
                            saveindex++;
                            m_Buffers.Save(FPNFile_Path + "TempPic\\Dark\\" + saveindex.ToString() + ".bmp", "-format bmp", j, 0);
                            Thread.Sleep(SystemParam.PicDelay);
                        }
                        for (int j = 1; j < FPN_Len + 1; j++)
                        {
                            yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j);
                            SystemParam.WriteTempFile(yByteArray, i * FPN_Len + j - 1, FPNFile_Path + "TempData\\Dark\\" + (k + 1).ToString() + "bin");
                        }
                    }
                }
                if (nCount * FPN_Len < FPN_L)//还有一个
                {
                    while (true)
                    {
                        int left = FPN_L - nCount * FPN_Len;
                        rxFrame = 0;
                        SerialFunc.SerialCommand3((ushort)(FPN_Len + +CamEx), ls);
                        if (!WaitCam(SystemParam.Step2_len + CamEx))
                        {
                            continue;
                        }
                        if (bLight)
                        {
                            for (int j = 1; j < left + 1; j++)
                            {
                                saveindex++;
                                m_Buffers.Save(FPNFile_Path + "TempPic\\Light\\" + saveindex.ToString() + ".bmp", "-format bmp", j, 0);
                                Thread.Sleep(SystemParam.PicDelay);
                            }
                            for (int j = 1; j < left + 1; j++)
                            {
                                yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j);
                                SystemParam.WriteTempFile(yByteArray, nCount * FPN_Len + j - 1, FPNFile_Path + "TempData\\Light\\" + (k + 1).ToString() + "bin");
                            }
                        }
                        else
                        {
                            for (int j = 1; j < left + 1; j++)
                            {
                                saveindex++;
                                m_Buffers.Save(FPNFile_Path + "TempPic\\Dark\\" + saveindex.ToString() + ".bmp", "-format bmp", j, 0);
                                Thread.Sleep(SystemParam.PicDelay);
                            }
                            for (int j = 1; j < left + 1; j++)
                            {
                                yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j);
                                SystemParam.WriteTempFile(yByteArray, nCount * FPN_Len + j - 1, FPNFile_Path + "TempData\\Dark\\" + (k + 1).ToString() + "bin");
                            }
                        }
                        break;
                    }
                }
                waitProc.SetProcessBar(k + 1);
            }
            waitProc.SetProcessBar(FPN_L);
            this.Invoke((EventHandler)(delegate
            {
                if (bLight)
                {
                    textBox1.AppendText("FPN明场采集完成\r\n");
                }
                else
                {
                    textBox1.AppendText("FPN暗场采集完成\r\n");
                }
            }));
        }
Beispiel #3
0
 public ProductData(ref SystemParam sysParam)
 {
     systemParam = sysParam;
 }
Beispiel #4
0
        void 暗场采集(object LockWatingThread)
        {
            double y, d;
            double t;

            Calc1.miu_y_dark   = new List <double>();
            Calc1.delta_y_dark = new List <double>();
            this.Invoke((EventHandler)(delegate
            {
                chart1.Series[0].Points.Clear();
                chart1.Series[1].Points.Clear();
                chart1.ChartAreas[0].AxisY.Title = "暗场均值";
                chart1.ChartAreas[1].AxisY.Title = "暗场方差";
            }));
            NopCam((ushort)(PicN + 1), SystemParam.eStart);
            int saveindex = 0;
            int step      = (int)(MaxTime / SystemParam.Ts / PhotoNs);

            for (uint i = 0; i < PhotoNs; i++)
            {
                uint ls = SystemParam.eStart + (uint)(i * step);
                this.Invoke((EventHandler)(delegate
                {
                    toolStripLabel3.Text = SystemParam.GetTime((int)i).ToString("F2") + " ms";
                }));
                if (waitProc.HasBeenCancelled())
                {
                    return;
                }
                SerialFunc.SerialCommand3((ushort)(PicN + 1), ls);
                if (!WaitCam((ushort)(PicN + 1)))
                {
                    i--;
                    continue;
                }
                for (int j = 1; j < PicN + 1; j++)
                {
                    saveindex++;
                    m_Buffers.Save(Calc1.TempPicPath_Dark + saveindex.ToString() + ".bmp", "-format bmp", j, 0);
                    Thread.Sleep(SystemParam.PicDelay);
                }
                byte[] yByteArray;
                t = ls * SystemParam.Ts;
                for (int j = 1; j < PicN + 1; j++)
                {
                    yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, j);
                    SystemParam.CreateBINFile(yByteArray, SystemParam.TxtCustomDarkDataPath + dtStart.ToString("yyyyMMdd_HHmmss") + "\\" + t.ToString("F3") + "_" + j.ToString() + ".bin");
                }
//                 yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, 1);
//                 SystemParam.CreateBINFile(yByteArray, SystemParam.TxtCustomDarkDataPath + dtStart.ToString("yyyyMMdd_HHmmss") + "\\" + t.ToString("F3") + "_1.bin");
//                 yByteArray = wfSapGUI.ReadPicDatas(m_Buffers, 2);
//                 SystemParam.CreateBINFile(yByteArray, SystemParam.TxtCustomDarkDataPath + dtStart.ToString("yyyyMMdd_HHmmss") + "\\" + t.ToString("F3") + "_2.bin");
                ya = wfSapGUI.ReadPicDatas(m_Buffers, PicN);
                //yb = wfSapGUI.ReadPicDatas(m_Buffers, 2);
                Calc1.TestExposureTime1(ya, m_Buffers.Height, m_Buffers.Width, m_Buffers.PixelDepth, out y, out d);
                this.Invoke((EventHandler)(delegate
                {
                    chart1.Series[0].Points.AddXY(t, y);
                    chart1.Series[1].Points.AddXY(t, d);
                    waitProc.SetProcessBar((int)(i + 1));
                }));
                TextLog.AddTextLog(String.Format(SystemParam.TxtCustomDarkDataFormat, t.ToString("F3"), y.ToString("F6"), d.ToString("F6")), fileName, false);
            }
        }
        public ListSortedSystemParameters()
        {
            Title = "List Sorted System Parameters";

            // Create a ListView as content of the window.
            ListView lstvue = new ListView();

            Content = lstvue;

            // Create a GridView as the View of the ListView.
            GridView grdvue = new GridView();

            lstvue.View = grdvue;

            // Create two GridView columns.
            GridViewColumn col = new GridViewColumn();

            col.Header = "Property Name";
            col.Width  = 200;
            col.DisplayMemberBinding = new Binding("Name");
            grdvue.Columns.Add(col);

            col        = new GridViewColumn();
            col.Header = "Value";
            col.Width  = 200;
            grdvue.Columns.Add(col);

            // Create DataTemplate for second column.
            DataTemplate            template         = new DataTemplate(typeof(string));
            FrameworkElementFactory factoryTextBlock =
                new FrameworkElementFactory(typeof(TextBlock));

            factoryTextBlock.SetValue(TextBlock.HorizontalAlignmentProperty,
                                      HorizontalAlignment.Right);
            factoryTextBlock.SetBinding(TextBlock.TextProperty,
                                        new Binding("Value"));
            template.VisualTree = factoryTextBlock;
            col.CellTemplate    = template;

            // Get all the system parameters in one handy array.
            PropertyInfo[] props = typeof(SystemParameters).GetProperties();

            // Create a SortedList to hold the SystemParam objects.
            SortedList <string, SystemParam> sortlist =
                new SortedList <string, SystemParam>();

            // Fill up the SortedList from the PropertyInfo array.
            foreach (PropertyInfo prop in props)
            {
                if (prop.PropertyType != typeof(ResourceKey))
                {
                    SystemParam sysparam = new SystemParam();
                    sysparam.Name  = prop.Name;
                    sysparam.Value = prop.GetValue(null, null);
                    sortlist.Add(prop.Name, sysparam);
                }
            }

            // Set the ItemsSource property of the ListView.
            lstvue.ItemsSource = sortlist.Values;
        }
Beispiel #6
0
        public void CalculateRoutePrice(Route route)
        {
            SystemParam Param = SPCrud.GetPricePerKM <SystemParam>();

            route.Price = (route.Distance * Convert.ToDouble(Param.Value));
        }