Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            CalibrationCurveList list = new CalibrationCurveList();

            foreach (ListViewItem lvi in listView1.Items)
            {
                if (lvi.Selected)
                {
                    list.Add((DoublesDclMass)lvi.Tag);
                    lvi.Selected = false;
                }
            }
            if (list.Count < 1)
            {
                return;
            }
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter           = "CSV files (.csv)|*.csv|                 (.txt)| *.txt";
            dlg.DefaultExt       = ".csv";
            dlg.FileName         = Material + AnalysisMethod.FullName() + ".csv";
            dlg.InitialDirectory = N.App.AppContext.ResultsFilePath;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                using (StreamWriter w = new StreamWriter(dlg.FileName))
                {
                    foreach (DoublesDclMass x in list)
                    {
                        w.WriteLine(x.ToString());
                    }
                    w.Close();
                }
            }
        }
Exemplo n.º 2
0
 public void CurveTypeSelectionStep()
 {
     if (CalcDataList == null)
     {
         CalcDataList = new CalibrationCurveList(); // one-time init upon first use.
     }
     ict.CalcDataList = CalcDataList;               // pre-load last best result, not maybe the best approach ...
     ict.ShowDialog();
     CalcDataList = ict.CalcDataList;               // preserve the last list generated by any processing
 }
Exemplo n.º 3
0
 public IDDCurveType()
 {
     InitializeComponent();
     det   = Integ.GetCurrentAcquireDetector();
     Text += " for detector " + det.Id.DetectorName;
     CurveTypeComboBox.Items.Clear();
     foreach (INCCAnalysisParams.CurveEquation cs in Enum.GetValues(typeof(INCCAnalysisParams.CurveEquation)))
     {
         CurveTypeComboBox.Items.Add(cs.ToDisplayString());
     }
     CurveTypeComboBox.Refresh();
     CurveTypeComboBox.SelectedIndex = 0;
     CalcDataList = new CalibrationCurveList();
 }
Exemplo n.º 4
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            CalibrationCurveList list = new CalibrationCurveList();

            foreach (ListViewItem lvi in listView1.Items)
            {
                if (lvi.Selected)
                {
                    list.Add((DoublesDclMass)lvi.Tag);
                    lvi.Selected = false;
                }
            }
            SaveCurveXYValues(list);
            Close();
        }
Exemplo n.º 5
0
 public EqCoeffViewer(INCCAnalysisParams.CurveEquationVals coeff, INCCAnalysisParams.CurveEquation eq, CalibrationCurveList cclist)
 {
     InitializeComponent();
     det           = Integ.GetCurrentAcquireDetector();
     Text         += " for detector " + det.Id.DetectorName;
     disprows      = new List <DataLoad>();
     CurveEquation = eq;
     Coefficients  = coeff;
     CalcDataList  = cclist;
     BuildRep();
     BuildRows();
     BuildCurveCombo();
     LowerMassLimitTextBox.Text = CalcDataList.LowerMassLimit.ToString("N4");
     UpperMassLimitTextBox.Text = CalcDataList.UpperMassLimit.ToString("N4");
     _reg = new Regex("[1-9][0-9]*\\.?[0-9]*([Ee][+-]?[0-9]+)?");              // reg ex for number test
 }
Exemplo n.º 6
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            DialogResult  = DialogResult.OK;
            CurveEquation = (INCCAnalysisParams.CurveEquation)CurveTypeComboBox.SelectedIndex;
            Close();
            IDDDemingFitSelect measlist = new IDDDemingFitSelect();

            measlist.CurveEquation  = CurveEquation;
            measlist.AnalysisMethod = AnalysisMethod;
            measlist.Material       = Material;
            measlist.Init(det.Id.DetectorId);
            if (measlist.bGood)
            {
                measlist.ShowDialog();
            }
            CalcDataList = measlist.CalcDataList;
        }
Exemplo n.º 7
0
        void SaveCurveXYValues(CalibrationCurveList list)
        {
            CalcDataList = new CalibrationCurveList();
            if (list.Count < 1)
            {
                return;
            }

            // save the data-points for use in the Get file op that replaces the deming
            System.Collections.IEnumerator _iter = list.GetEnumerator();
            while (_iter.MoveNext())
            {
                DoublesDclMass dl = (DoublesDclMass)_iter.Current;
                CalcDataList.Add(dl);
            }
            CalcDataList.CalcLowerUpper();                              // compute upper and lower mass limits from the data points,

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter           = "DMD files (*.dmd)|*.dmd|in files (*.in)|*.in|All files (*.*)|*.*";
            dlg.DefaultExt       = ".in";
            dlg.FileName         = "deming.in";
            dlg.InitialDirectory = N.App.AppContext.ResultsFilePath;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    StreamWriter tx = File.CreateText(dlg.FileName);
                    System.Collections.IEnumerator iter = list.GetEnumerator();
                    while (iter.MoveNext())
                    {
                        string entry = iter.Current.ToString();
                        tx.WriteLine(entry);
                    }
                    tx.Close();
                    N.App.Loggers.Logger(LMLoggers.AppSection.Control).TraceInformation("Fitting data written to " + dlg.FileName);
                } catch (IOException ex)
                {
                    MessageBox.Show(ex.Message, "Error on " + dlg.FileName);
                }
            }
        }
Exemplo n.º 8
0
 public void Init(string id, AssaySelector.MeasurementOption mo = AssaySelector.MeasurementOption.calibration)
 {
     CalcDataList = new CalibrationCurveList();
     DetectorId   = id;
     System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
     try
     {
         InitSort();
         mopt  = mo;
         mlist = N.App.DB.MeasurementsFor(DetectorId, mopt);
         bGood = PrepList(DetectorId);
     } finally
     {
         System.Windows.Input.Mouse.OverrideCursor = null;
     }
     if (AnalysisMethod == AnalysisMethod.Active)
     {
         listView1.Columns[2].Text = "U235 Mass";
     }
 }
Exemplo n.º 9
0
        void ApplyCoefficients(INCCAnalysisParams.CurveEquationVals coeff, CalibrationCurveList cclist)
        {
            INCCSelector    sel = new INCCSelector(det.Id.DetectorId, Material);
            AnalysisMethods lam;
            bool            found = N.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out lam);

            if (!found)
            {
                lam = new AnalysisMethods(sel);
            }
            if (!lam.HasMethod(AnalysisMethod))              // create it from scratch here ????
            {
                MessageBox.Show(string.Format("{0} method not specified for detector {1} and material {2}",
                                              AnalysisMethod.FullName(), det.Id.DetectorId, Material),
                                "Coefficient File Ingester", MessageBoxButtons.OK);
                return;
            }

            INCCAnalysisParams.INCCMethodDescriptor imd = lam.GetMethodParameters(AnalysisMethod);
            switch (AnalysisMethod)
            {
            case AnalysisMethod.CalibrationCurve:
                INCCAnalysisParams.cal_curve_rec c = (INCCAnalysisParams.cal_curve_rec)imd;
                CopyCoefficients(coeff, c.cev);
                c.cev.cal_curve_equation = CurveEquation;
                c.cev.lower_mass_limit   = cclist.LowerMassLimit;
                c.cev.upper_mass_limit   = cclist.UpperMassLimit;
                c.dcl_mass = cclist.MassAsArray;
                c.doubles  = cclist.DoublesAsArray;
                break;

            case AnalysisMethod.KnownA:
                INCCAnalysisParams.known_alpha_rec ka = (INCCAnalysisParams.known_alpha_rec)imd;
                CopyCoefficients(coeff, ka.cev);
                ka.cev.cal_curve_equation = CurveEquation;
                ka.cev.lower_mass_limit   = cclist.LowerMassLimit;
                ka.cev.upper_mass_limit   = cclist.UpperMassLimit;
                ka.dcl_mass = cclist.MassAsArray;
                ka.doubles  = cclist.DoublesAsArray;
                break;

            case AnalysisMethod.AddASource:
                INCCAnalysisParams.add_a_source_rec aas = (INCCAnalysisParams.add_a_source_rec)imd;
                CopyCoefficients(coeff, aas.cev);
                aas.cev.cal_curve_equation = CurveEquation;
                aas.cev.lower_mass_limit   = cclist.LowerMassLimit;
                aas.cev.upper_mass_limit   = cclist.UpperMassLimit;
                aas.dcl_mass = cclist.MassAsArray;
                aas.doubles  = cclist.DoublesAsArray;
                break;

            case AnalysisMethod.Active:
                INCCAnalysisParams.active_rec ac = (INCCAnalysisParams.active_rec)imd;
                CopyCoefficients(coeff, ac.cev);
                ac.cev.cal_curve_equation = CurveEquation;
                ac.cev.lower_mass_limit   = cclist.LowerMassLimit;
                ac.cev.upper_mass_limit   = cclist.UpperMassLimit;
                ac.dcl_mass = cclist.MassAsArray;
                ac.doubles  = cclist.DoublesAsArray;
                break;
            }
            imd.modified = true;
            // ok save it now
            N.App.DB.UpdateAnalysisMethod(sel, lam);              // flush changes on internal map to the DB
            MessageBox.Show(string.Format("Calibration data for analysis method {0} and material type {1} successfully stored in the database",
                                          det.Id.DetectorId, Material),
                            "Coefficient File Ingester", MessageBoxButtons.OK);
        }