示例#1
0
        public string SavePXEAN(string fname, uint NumofSavedLines, byte [] dt, string comment)
        {
            float[] pxedata;
            string  sret = "";
            string  CommentFileName;

            try
            {
                UInt32    height = (UInt32)(dt.Length / NumofSavedLines);
                PxeAccess pa     = new PxeAccess();
                pa.CreatePXE(fname);
                pa.CreatePXEHeader(1, NumofSavedLines, height);
                //convert data to float array
                pxedata = new float[dt.Length];
                for (int i = 0; i < dt.Length; i++)
                {
                    pxedata[i] = (float)dt[i];
                }
                pa.WriteDataLines(1, pxedata, NumofSavedLines);
                pa.ClosePXE();
                if (comment != "")
                {
                    CommentFileName = fname + ".txt";
                    SaveComment(comment, CommentFileName);
                }
                sret = fname;
            }
            catch { }
            return(sret);
        }
示例#2
0
        public string SaveTimeData(byte[] inarr, int lnum, int [] sdet, bool chk, string nm)
        {
            string SavedFileName = "";
            int    nn            = sdet.Length;

            //=============== extra cleaning
            float[] detinfo = new float[lnum + 1];
            for (int i = 0; i < lnum + 1; i++)
            {
                detinfo[i] = 0;
            }
            //============================================================

            try
            {
                detinfo[0] = (float)nn;
                for (int i = 1; i < nn + 1; i++)
                {
                    detinfo[i] = (float)sdet[i - 1];
                }
                string  pp = "";
                float[] pxedata;
                string  dir    = ConfigurationManager.AppSettings["TimeModeFname"];
                UInt32  height = (UInt32)(inarr.Length / lnum);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                if (chk == true)
                {
                    string fname = dir + "\\test0.pxe";
                    CheckSavedFileName(fname, ref pp, 0, "");
                }
                else
                {
                    pp = nm;
                }
                PxeAccess pa = new PxeAccess();
                pa.CreatePXE(pp);
                pa.CreatePXEHeader(1, (uint)lnum, height);
                pxedata = new float[inarr.Length];
                for (int i = 0; i < inarr.Length; i++)
                {
                    pxedata[i] = (float)inarr[i];
                }
                pa.WriteDataLines(1, pxedata, (uint)lnum);
                int rt = pa.WriteRefSample(1, detinfo);
                pa.ClosePXE();
                SavedFileName = pp;
            }
            catch
            {
                SavedFileName = "";
            }
            return(SavedFileName);
        }
示例#3
0
        //=============================================================
        #region PXE files
        public string SavePXEFile(int savefilecnt, UInt32 NumofSavedLines, byte[] saveddata, bool chk, string fn)
        {//spatial mode
            string SavedFileName = "";
            string pp            = "";

            float[] pxedata;
            try
            {
                string dir    = ConfigurationManager.AppSettings["SPModeFname"];
                UInt32 height = (UInt32)saveddata.Length / NumofSavedLines;
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                if (chk == true)
                {
                    string fname = dir + "\\test" + savefilecnt.ToString() + ".pxe";
                    CheckSavedFileName(fname, ref pp, 0, "");
                }
                else
                {
                    pp = fn;
                }
                PxeAccess pa = new PxeAccess();
                pa.CreatePXE(pp);
                pa.CreatePXEHeader(1, NumofSavedLines, height);
                //convert saveddata to float array
                pxedata = new float[saveddata.Length];
                for (int i = 0; i < saveddata.Length; i++)
                {
                    pxedata[i] = (float)saveddata[i];
                }
                pa.WriteDataLines(1, pxedata, NumofSavedLines);
                pa.ClosePXE();
                SavedFileName = pp;
            }
            catch
            {
                SavedFileName = "";
            }
            return(SavedFileName);
        }
示例#4
0
 //=============================================================
 #region PXE files
 public string SavePXEFile(int savefilecnt, UInt32 NumofSavedLines, byte[] saveddata,bool chk,string fn)
 {//spatial mode
     string SavedFileName = "";
     string pp = "";
     float[] pxedata;
     try
     {
         string dir = ConfigurationManager.AppSettings["SPModeFname"];
         UInt32 height = (UInt32)saveddata.Length / NumofSavedLines;
         if (!Directory.Exists(dir))
             Directory.CreateDirectory(dir);
         if (chk == true)
         {
             string fname = dir + "\\test" + savefilecnt.ToString() + ".pxe";
             CheckSavedFileName(fname, ref pp, 0, "");
         }
         else
             pp = fn;
         PxeAccess pa = new PxeAccess();
         pa.CreatePXE(pp);
         pa.CreatePXEHeader(1, NumofSavedLines, height);
         //convert saveddata to float array 
         pxedata = new float[saveddata.Length];
         for (int i = 0; i < saveddata.Length; i++)
         {
             pxedata[i] = (float)saveddata[i];
         }
         pa.WriteDataLines(1, pxedata, NumofSavedLines);
         pa.ClosePXE();
         SavedFileName = pp;
     }
     catch
     {
         SavedFileName = "";
     }
     return SavedFileName;
 }
示例#5
0
        public string SaveTimeData(byte[] inarr, int lnum,int [] sdet,bool chk,string nm)
        {
            string SavedFileName = "";
            int nn = sdet.Length;
            //=============== extra cleaning
            float[] detinfo = new float[lnum + 1];
            for (int i = 0; i < lnum + 1; i++)
                detinfo[i] = 0;
            //============================================================

            try
            {
                detinfo[0] = (float)nn;
                for (int i = 1; i < nn + 1; i++)
                    detinfo[i] = (float)sdet[i - 1];
                string pp = "";
                float[] pxedata;
                string dir = ConfigurationManager.AppSettings["TimeModeFname"];
                UInt32 height = (UInt32)(inarr.Length / lnum);
                if (!Directory.Exists(dir))
                    Directory.CreateDirectory(dir);
                if (chk == true)
                {
                    string fname = dir + "\\test0.pxe";
                    CheckSavedFileName(fname, ref pp, 0, "");
                }
                else
                    pp = nm;
                PxeAccess pa = new PxeAccess();
                pa.CreatePXE(pp);
                pa.CreatePXEHeader(1, (uint)lnum, height);
                pxedata = new float[inarr.Length];
                for (int i = 0; i < inarr.Length; i++)
                {
                    pxedata[i] = (float)inarr[i];
                }
                pa.WriteDataLines(1, pxedata, (uint)lnum);
                int rt = pa.WriteRefSample(1, detinfo);
                pa.ClosePXE();
                SavedFileName = pp;
            }
            catch
            {
                SavedFileName = "";
            }
            return SavedFileName;
        }
示例#6
0
 public string SavePXEAN(string fname, uint NumofSavedLines,byte [] dt,string comment )
 {
     float[] pxedata;
     string sret = "";
     string CommentFileName;
     try
     {
         UInt32 height = (UInt32)(dt.Length / NumofSavedLines);
         PxeAccess pa = new PxeAccess();
         pa.CreatePXE(fname);
         pa.CreatePXEHeader(1, NumofSavedLines, height);
         //convert data to float array 
         pxedata = new float[dt.Length];
         for (int i = 0; i < dt.Length; i++)
         {
             pxedata[i] = (float)dt[i];
         }
         pa.WriteDataLines(1, pxedata, NumofSavedLines);
         pa.ClosePXE();
         if (comment != "")
         {
             CommentFileName = fname + ".txt";
             SaveComment(comment, CommentFileName);
         }
         sret = fname;
     }
     catch { }
     return sret;
 }
示例#7
0
        private void EmulatorLoadPEX_Click_1(object sender, RoutedEventArgs e)
        {
            //load pxe for emulator
            bool? dr;
            int detpbrd;

            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.Filter = "PXE files (*.pxe)|*.pxe";
            ofd.InitialDirectory = "C:\\Work\\PXE Collection";
            dr = ofd.ShowDialog();
            if (dr == false)
            {
                EmulatorDataTypeChk.IsChecked = false;
            }
            else
                if (dr == true)
                {
                    PxeAccess opxe = new PxeAccess();
                    bool r = opxe.OpenPXEFile(ofd.FileName);
                    if (r == true)
                    {
                        CurrentPXEHeight = opxe.m_Img_Ht;
                        CurrentPXEWidth = opxe.m_Img_Width;
                        float[] tmp = new float[CurrentPXEHeight * CurrentPXEWidth];
                        opxe.m_rawData.CopyTo(tmp, 0);
                        CreateLineData(CurrentPXEHeight, CurrentPXEWidth, tmp);
                        EmulatorDataTypeChk.IsChecked = true;
                        //====================
                        detpbrd = Convert.ToInt32(ConfigurationManager.AppSettings["DetPerBoard"]);
                        if (detpbrd > 0)
                        {
                            long rem;
                            EmulatorBoardsCount = (int)Math.DivRem((long)CurrentPXEHeight, (long)detpbrd, out rem);
                            if (rem > 0)
                            {
                                EmulatorBoardsCount++;//add extra board if not even
                            }
                            NumofEmulatorBoardsUpdown.Value = EmulatorBoardsCount;
                            NumofEmulatorBoardsUpdown.Refresh();
                            opxe.ClosePXE();
                            opxe = null;
                        }

                        else
                        {
                            EmulatorDataTypeChk.IsChecked = false;
                        }

                    }
                    else
                    {
                        EmulatorDataTypeChk.IsChecked = false;
                    }
                }
        }