Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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;
 }
Exemplo n.º 7
0
        private void AnOpenFileBtn_Click(object sender, RoutedEventArgs e)
        {
            string ext = "";
            bool? DialogResult;
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.Filter = "PXE files (*.pxe)|*.pxe|Binary files (*.pbn)|*.pbn|All files (*.*)|*.*";
            ofd.FilterIndex = 1;
            ofd.InitialDirectory = "C:\\Pipe Data";
            pxedata = new float[0];
            DialogResult = ofd.ShowDialog();
            if (DialogResult == true)
            {
                AnFileName = ofd.FileName;
                AnChart.Titles.Clear();
                AnChart.Titles.Add(AnFileName);
                FileSubs fs = new FileSubs();
                ext = System.IO.Path.GetExtension(AnFileName);
                //========================
                AnSaveFileBtn.IsEnabled = true;
                AnShowToolTipChk.IsEnabled = true;
                AnRestoreScaleBtn.IsEnabled = true;
                AnAddCommentBtn.IsEnabled = true;
                //==============================
                if (ext == ".pxe")
                {
                    pxa = new PxeAccess();
                    showPXE(AnFileName);
                    pxa = null;
                }

                else if (ext == ".pbn")
                {

                    ShowBinary(AnFileName);

                }
                else if (ext == ".txt")
                {
                    System.Diagnostics.Process.Start(AnFileName);
                }

                comments = fs.ReadComment(AnFileName + ".txt");
                if (comments != "")
                {
                    Comment cm = new Comment();
                    cm.CommentsText = comments;
                    cm.ShowDialog();
                }
            }
            else
                AnFileName = "";
        }
Exemplo n.º 8
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;
                    }
                }
        }