Example #1
0
        private void ShowBinary(string fname)
        {
            int nn;
            byte[] bindata;
            FileSubs fs = new FileSubs();
            int[] prm = fs.GetReadingsCount(AnFileName);
            if (prm[0] == 0 || prm[1] == 0)
                return;
            else
            {
                bindata = fs.ReadBinary(fname);
                //======== add replot array
                pxedata = new float[bindata.Length];
                for (int jj = 0; jj < bindata.Length; jj++)
                {
                    pxedata[jj] = (float)bindata[jj];
                }
                //prepare chart=====================================
                AnChart.Series.Clear();
                AnChart.Legends.Clear();
                AnChart.ChartAreas.Clear();
                SetupChart(AnChart, 0);
                AnChart.ChartAreas[0].AxisX.CustomLabels.Clear();
                AnChart.ChartAreas[0].AxisX.ScaleView.Size = Double.NaN;
                AnChart.ChartAreas[0].AxisX.Minimum = 0;
                AnChart.ChartAreas[0].AxisY.ScaleView.Size = Double.NaN;
                //====================================================
                if (prm[1] > 1)//time mode
                {
                    AnShowMode = 1;
                    DetectorDisplayGB.Visibility = System.Windows.Visibility.Visible;
                    AnDetSelList.Visibility = System.Windows.Visibility.Visible;
                    AnDetInfoGB.Visibility = System.Windows.Visibility.Visible;
                    AnDetSelList.Items.Clear();
                    AnDetSelCmb.Items.Clear();
                    nn = 1;//to start
                    AnDetSelList.Items.Add("1");
                    AnDetSelCmb.Items.Add("1");
                    AnDetSelCmb.SelectedIndex = 0;
                    CreateChartSeriesA();
                    //fill by data
                    CurrentPXEWidth = prm[1];
                    for (int k = 1; k <= nn; k++)
                    {
                        for (int l = 0; l < CurrentPXEWidth; l++)
                        {
                            ushort dt = (ushort)bindata[l + CurrentPXEWidth * (k - 1)];
                            DataPoint pt = new DataPoint(l, GetMaskedData(dt));
                            AnChart.Series[k - 1].Points.Add(pt);
                        }
                    }
                    AnChart.Update();

                }
                else//spatial
                {
                    AnShowMode = 0;
                    DetectorDisplayGB.Visibility = System.Windows.Visibility.Hidden;
                    AnDetSelList.Visibility = System.Windows.Visibility.Hidden;
                    AnDetInfoGB.Visibility = System.Windows.Visibility.Hidden;
                    Series line = new Series();
                    line.MarkerStyle = MarkerStyle.Circle;
                    line.MarkerSize = SeriesMarkerSize; //2;
                    line.ChartType = SeriesChartType.Point;
                    AnChart.Series.Add(line);
                    for (int j = 0; j < bindata.Length; j++)
                    {
                        // 
                        ushort dt = (ushort)bindata[j];
                        DataPoint pt = new DataPoint(j, GetMaskedData(dt));
                        line.Points.Add(pt);
                    }
                    AnChart.Update();
                }
            }
        }
Example #2
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 = "";
        }
Example #3
0
        private void SaveRes(string fname)
        {
            byte[] chartdata;
            string ext = System.IO.Path.GetExtension(fname);
            string fn = "";
            int snum = AnChart.Series.Count;
            if (snum > 0)
            {
                int dlen = AnChart.Series[0].Points.Count;
                chartdata = new byte[snum * dlen];
                //prepare data
                for (int i = 0; i < snum; i++)
                {
                    for (int k = 0; k < dlen; k++)
                    {
                        chartdata[snum * i + k] = (byte)AnChart.Series[i].Points[k].YValues[0];
                    }
                }
                //=========================
                if (ext == ".pxe")
                {
                    fn = fname;
                }
                else if (ext == ".pbn")
                {
                    fn = System.IO.Path.GetFileName(fname);
                    string dir = System.IO.Path.GetDirectoryName(fname);
                    string extra = chartdata.Length.ToString() + "X" + snum.ToString();
                    fn = dir + "\\" + extra + fn;


                }
                FileSubs fs = new FileSubs();
                if (ext == ".pxe")
                {
                    AnSavedFileName = fs.SavePXEAN(fn, (uint)snum, chartdata, comments);  //something is not correct
                }
                else if (ext == ".pbn")
                {
                    AnSavedFileName = fs.SaveBinAn(fn, chartdata, comments);
                }
                //  }
                //============== start timer
                timercnt = 0;
                dispatcherTimer.Start();
            }
        }
Example #4
0
 private void AnAddCommentBtn_Click(object sender, RoutedEventArgs e)
 {
     //add comments and save it
     string CommentFileName;
     Comment cm = new Comment();
     cm.CommentsText = comments;//if any
     bool? dres = cm.ShowDialog();
     if (dres == true)
         comments = cm.CommentsText;
     if (AnFileName != "")
     {
         CommentFileName = AnFileName + ".txt";
         FileSubs fs = new FileSubs();
         fs.SaveComment(comments, CommentFileName);
     }
     else
         comments = "";
 }
Example #5
0
 private void ChartSaveDataBtn_Click(object sender, RoutedEventArgs e)
 {
     FileSubs fs = new FileSubs();
     ChartSaveDataBtn.IsEnabled = false;
     if (SaveType == 0 || SaveType == 2)
     {
         if (DisplayMode == 1)//time mode
         {
             SavedFileName = fs.SaveTimeData(tempstorage, NumberOfRuns, seldet, true, "");
         }
         else if (DisplayMode == 0)//spatial mode
         {
             SavedFileName = fs.SavePXEFile(savefilecnt, 1, DataStorage, true, "");
         }
         if (comments != "" && SavedFileName != "")
         {
             fs.SaveComment(comments, SavedFileName + ".txt");
         }
     }
     if (SaveType == 1 || SaveType == 2)
     {//binary
         if (DisplayMode == 1)//time mode
             SavedFileName = fs.SaveBinary(tempstorage, comments, NumberOfRuns, DisplayMode, true, "");
         else
             SavedFileName = fs.SaveBinary(DataStorage, comments, 1, DisplayMode, true, "");
     }
     SaveLocation = 1;
     timercnt = 0;
     dispatcherTimer.Start();
 }