예제 #1
0
        void UpdateIsotopics(bool straight)      // straight means from iso button
        {
            IDDIsotopics f   = new IDDIsotopics(ah.ap.isotopics_id);
            DialogResult dlg = f.ShowDialog();

            if (dlg != DialogResult.OK)
            {
                return;
            }
            ah.RefreshParams();
            Isotopics selected = f.GetSelectedIsotopics;

            if (ah.ap.isotopics_id != selected.id) /* They changed the isotopics id. Isotopics already saved to DB in IDDIsotopics*/
            {
                ah.ap.isotopics_id = selected.id;
                // NEXT: do new item id stuff right after this
            }
            else if (straight)     // same iso name from iso selector but params might have changed, new item id application update occurs elsewhere
            {
                // isotopic settings will be loaded from DB prior to running measurement

                // change the isotopics setting on the current item id state
                ItemId Cur = NC.App.DB.ItemIds.Get(ah.ap.item_id);
                if (Cur == null)                         // blank or unspecified somehow
                {
                    return;
                }
                Cur.IsoApply(NC.App.DB.Isotopics.Get(ah.ap.isotopics_id));           // apply the iso dates to the item
                Cur.modified = true;
            }
        }
예제 #2
0
        private void RefreshIdComboWithDefaultOrSet(string id = "default")
        {
            IsotopicsIdComboBox.Items.Clear();

            // get the in-memory list
            List <Isotopics> isolist = NC.App.DB.Isotopics.GetList();

            if (isolist.Count > 0)  // look for id on the list
            {
                //This never loaded all the isotopics before?? hn 4.30.2015
                foreach (Isotopics tope in isolist)
                {
                    IsotopicsIdComboBox.Items.Add(tope.id);
                }
                m_iso = isolist.Find(i => string.Equals(i.id, id, StringComparison.OrdinalIgnoreCase));
            }
            else // Should never hit here, happens if DB is blank. Add a single "Default"
            {
                m_iso          = new Isotopics();
                m_iso.modified = true;
                isolist.Add(m_iso);              // add to in-memory list
                NC.App.DB.Isotopics.Set(m_iso);  // set in database
            }

            PuPlusAmRadioButton.Checked      = false;
            AmPercentOfPuRadioButton.Checked = true;
            IsotopicsIdComboBox.SelectedItem = m_iso.id;  // forces event handler to load dialog fields
        }
예제 #3
0
        void UpdateIsotopics(bool straight)      // straight means from iso button
        {
            IDDIsotopics f   = new IDDIsotopics(ah.ap.isotopics_id);
            DialogResult dlg = f.ShowDialog();

            if (dlg != DialogResult.OK)
            {
                return;
            }
            ah.RefreshParams();
            Isotopics selected = f.GetSelectedIsotopics;

            if (ah.ap.isotopics_id != selected.id) /* They changed the isotopics id. Isotopics already saved to DB in IDDIsotopics*/
            {
                ah.ap.isotopics_id = selected.id;
            }
            // change the isotopics setting on the current item id state
            ItemId Cur = NC.App.DB.ItemIds.Get(ah.ap.item_id);

            if (Cur == null)                             // blank or unspecified somehow
            {
                return;
            }
            Cur.IsoApply(NC.App.DB.Isotopics.Get(ah.ap.isotopics_id));               // apply the iso dates to the item
            Cur.modified = true;
        }
예제 #4
0
        protected void IsotopicGen()
        {
            // for each isotopics found, either overwrite existing isotopics, or add them to the list
            // write all the changes to the DB

            List <AnalysisDefs.Isotopics> l = NC.App.DB.Isotopics.GetList();

            foreach (Isotopics isotopics in NOPIsotopics)
            {
                // if sum of Pu isotopes <= 0 then use default isotopics vals
                if ((isotopics.pu238 + isotopics.pu239 + isotopics.pu240 + isotopics.pu241 + isotopics.pu242) <= 0.0)
                {
                    isotopics.InitVals();
                }

                Isotopics ex = l.Find(iso => string.Compare(iso.id, isotopics.id, true) == 0);
                if (ex == null)
                {
                    l.Add(isotopics); isotopics.modified = true;
                    NC.App.DB.Isotopics.Set(isotopics);
                }
                else
                {
                    ex.Copy(isotopics); ex.modified = true;
                    NC.App.DB.Isotopics.Set(ex);
                }
            }
        }
예제 #5
0
        private void AddNewSetBtn_Click(object sender, EventArgs e)
        {
            IDDIsotopicsAdd ia = new IDDIsotopicsAdd();

            if (ia.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (string.IsNullOrEmpty(ia.ID))
                {
                    return;
                }

                // check for Id existence
                if (!NC.App.DB.Isotopics.Has(ia.ID))
                {
                    Isotopics iso = new Isotopics(m_iso); // copy current values to new iso
                    iso.id   = String.Copy(ia.ID);
                    modified = iso.modified = true;
                    NC.App.DB.Isotopics.Revert(m_iso);  // revert originating selection on in-memory list back to DB values

                    //PopulateWithSelectedItem();
                    NC.App.DB.Isotopics.GetList().Add(iso);
                    // do not add to database until the OK or the Save set button is selected NC.App.DB.Isotopics.Set(m_iso);
                    applog.TraceInformation("New isotopics " + iso.id + " (not saved to database)");
                    IsotopicsIdComboBox.Items.Add(iso.id);
                    IsotopicsIdComboBox.SelectedItem = iso.id;  // force m_iso assignment in event handler
                }
                else
                {
                    MessageBox.Show("'" + ia.ID + "' is already in use", "I .... uuuh oh");
                }
            }
        }
예제 #6
0
        private void IsotopicsBtn_Click(object sender, EventArgs e)
        {
            Isotopics selected = UpdateIsotopics(straight: true);

            if (selected != null && selected.CompareTo(meas.Isotopics) != 0)             // copy any changes to the measurement
            {
                meas.Isotopics.Copy(selected);
                meas.MeasurementId.Item.IsoApply(selected);                           // apply the possibly new iso dates to the item
            }
        }
예제 #7
0
        private void IsoList_Click(object sender, EventArgs e)
        {
            IsotopicsList il = new IsotopicsList(iso: true);

            if (il.ShowDialog() == DialogResult.OK)
            {
                m_iso = il.GetSingleSelectedIsotopics();
                IsotopicsIdComboBox.SelectedItem = m_iso.id;
            }
        }
예제 #8
0
        private void IsotopicsIdComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox cb    = (ComboBox)sender;
            string   newid = (string)cb.SelectedItem;

            try
            {
                if (NC.App.DB.Isotopics.Has(newid))
                {
                    m_iso = NC.App.DB.Isotopics.Get(newid);
                }
            }
            catch (InvalidOperationException)  //?? this was an early experiment that doesn't make sense now
            {
                // iso is a new entry that has not yet been saved to the real list
                m_iso          = new Isotopics();
                m_iso.id       = cb.Text;
                m_iso.modified = true;
                NC.App.DB.Isotopics.GetList().Add(m_iso); // add to the in-memory list
                NC.App.DB.Isotopics.Set(m_iso);           // add to the database
            }
            PopulateWithSelectedItem();                   // Populated with local copy for now
        }
예제 #9
0
        private void IsotopicsBtn_Click(object sender, EventArgs e)
        {
            IDDIsotopics f   = new IDDIsotopics(ah.ap.isotopics_id);
            DialogResult dlg = f.ShowDialog();
            //check to see if they changed the isotopic id hn 5.12.2015
            Isotopics selected = f.GetSelectedIsotopics;

            if (ah.ap.isotopics_id != selected.id) /* They changed the isotopics id.  Isotopics already saved to DB in IDDIsotopics*/
            {
                selected.modified = true;
                NC.App.DB.Isotopics.Set(selected);
                ItemId Cur = NC.App.DB.ItemIds.Get(ah.ap.item_id);
                Cur.isotopics = selected.id;
                Cur.modified  = true;
                //force item for new id.... hn 5.13.2015
                NC.App.DB.ItemIds.Set(Cur);
                ah.ap.ApplyItemId(Cur);
                ah.ap.isotopics_id = selected.id;
            }
            else
            {
                //refresh isotopic settings?? Will these now load from DB prior to running measurement?  Let's see hn 5.13.2015
            }
        }
예제 #10
0
        private void RefreshIdComboWithDefaultOrSet(string id="default")
        {
            IsotopicsIdComboBox.Items.Clear();

            // get the in-memory list
            List<Isotopics> isolist = NC.App.DB.Isotopics.GetList();

            if (isolist.Count > 0)  // look for id on the list
            {
                //This never loaded all the isotopics before?? hn 4.30.2015
                foreach (Isotopics tope in isolist)
                {
                    IsotopicsIdComboBox.Items.Add(tope.id);
                }
                m_iso = isolist.Find(i => string.Equals(i.id, id, StringComparison.OrdinalIgnoreCase));
            }
            else // Should never hit here, happens if DB is blank. Add a single "Default"
            {
                m_iso = new Isotopics();
                m_iso.modified = true;
                isolist.Add(m_iso); // add to in-memory list
                NC.App.DB.Isotopics.Set(m_iso);  // set in database
            }

            PuPlusAmRadioButton.Checked = false;
            AmPercentOfPuRadioButton.Checked = true;
            IsotopicsIdComboBox.SelectedItem = m_iso.id;  // forces event handler to load dialog fields
        }
예제 #11
0
        private void AddNewSetBtn_Click(object sender, EventArgs e)
        {
            IDDIsotopicsAdd ia = new IDDIsotopicsAdd();
            if (ia.ShowDialog() == DialogResult.OK)
            {
                if (string.IsNullOrEmpty(ia.ID))
                    return;

                // check for Id existence
                if (!NC.App.DB.Isotopics.Has(ia.ID))
                {
                    Isotopics iso = new Isotopics(m_iso); // copy current values to new iso
                    iso.id = string.Copy(ia.ID);
                    modified = iso.modified = true;
                    NC.App.DB.Isotopics.Revert(m_iso);  // revert originating selection on in-memory list back to DB values

                    //PopulateWithSelectedItem();
                    NC.App.DB.Isotopics.GetList().Add(iso);
                    // do not add to database until the OK or the Save set button is selected NC.App.DB.Isotopics.Set(m_iso);
                    applog.TraceInformation("New isotopics " + iso.id + " (not saved to database)");
                    IsotopicsIdComboBox.Items.Add(iso.id);
                    IsotopicsIdComboBox.SelectedItem = iso.id;  // force m_iso assignment in event handler
                }
                else
                    MessageBox.Show("'" + ia.ID + "' is already in use", "I .... uuuh oh");

            }
        }
예제 #12
0
 private void IsoList_Click(object sender, EventArgs e)
 {
     IsotopicsList il = new IsotopicsList(iso: true);
     if (il.ShowDialog() == DialogResult.OK)
     {
         m_iso = il.GetSingleSelectedIsotopics();
         IsotopicsIdComboBox.SelectedItem = m_iso.id;
     }
 }
예제 #13
0
        private void IsotopicsIdComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox cb = (ComboBox)sender;
            string newid = (string)cb.SelectedItem;

            try
            {
                if (NC.App.DB.Isotopics.Has(newid))
                    m_iso = NC.App.DB.Isotopics.Get(newid);
            }
            catch (InvalidOperationException)  //?? this was an early experiment that doesn't make sense now
            {
                // iso is a new entry that has not yet been saved to the real list
                m_iso = new Isotopics();
                m_iso.id = cb.Text;
                m_iso.modified = true;
                NC.App.DB.Isotopics.GetList().Add(m_iso);  // add to the in-memory list
                NC.App.DB.Isotopics.Set(m_iso); // add to the database
            }
            PopulateWithSelectedItem(); // Populated with local copy for now
        }
예제 #14
0
        /// <summary>
        /// Create a list of Isotopics instances from each CSV parsed line set
        /// </summary>
        /// <param name="csv">The field-scanned csv file instance with an array of tokenized lines</param>
        void GenerateIsotopics(CSVFile csv)
        {
            List <Isotopics> l = NOPIsotopics;  // local alias

            foreach (string[] sa in csv.Lines)
            {
                Isotopics i = new Isotopics();
                String    s = String.Empty;
                double    v = 0, err = 0;
                foreach (NOPCol op in System.Enum.GetValues(typeof(NOPCol)))
                {
                    try
                    {
                        s = String.Empty;
                        s = sa[(int)op];  // might blow here when file was badly created
                        switch (op)
                        {
                        case NOPCol.AmDate:
                            Match amd = yyyymmdd.Match(s);
                            if (amd.Success)
                            {
                                i.am_date = GenFromYYYYMMDD(s);
                            }
                            break;

                        case NOPCol.PuDate:
                            Match pud = yyyymmdd.Match(s);
                            if (pud.Success)
                            {
                                i.pu_date = GenFromYYYYMMDD(s);
                            }
                            break;

                        case NOPCol.IsoSourceCode:
                            System.Enum.TryParse <Isotopics.SourceCode>(s, out i.source_code);
                            break;

                        case NOPCol.IsoId:
                            i.id = String.Copy(s);
                            break;

                        case NOPCol.Pu238:
                            Double.TryParse(s, out v); i.SetVal(Isotope.pu238, v);
                            break;

                        case NOPCol.Pu239:
                            Double.TryParse(s, out v); i.SetVal(Isotope.pu239, v);
                            break;

                        case NOPCol.Pu240:
                            Double.TryParse(s, out v); i.SetVal(Isotope.pu240, v);
                            break;

                        case NOPCol.Pu241:
                            Double.TryParse(s, out v); i.SetVal(Isotope.pu241, v);
                            break;

                        case NOPCol.Pu242:
                            Double.TryParse(s, out v); i.SetVal(Isotope.pu242, v);
                            break;

                        case NOPCol.Am241:
                            Double.TryParse(s, out v); i.SetVal(Isotope.am241, v);
                            break;

                        case NOPCol.Pu238err:
                            Double.TryParse(s, out err); i.SetError(Isotope.pu238, err);
                            break;

                        case NOPCol.Pu239err:
                            Double.TryParse(s, out err); i.SetError(Isotope.pu239, err);
                            break;

                        case NOPCol.Pu240err:
                            Double.TryParse(s, out err); i.SetError(Isotope.pu240, err);
                            break;

                        case NOPCol.Pu241err:
                            Double.TryParse(s, out err); i.SetError(Isotope.pu241, err);
                            break;

                        case NOPCol.Pu242err:
                            Double.TryParse(s, out err); i.SetError(Isotope.pu242, err);
                            break;

                        case NOPCol.Am241err:
                            Double.TryParse(s, out err); i.SetVal(Isotope.am241, err);
                            break;

                        case NOPCol.Norm:
                            // todo: the values in this field are related to COP file usage, bu I don't quite understand this yet, appears it should be looking for "Cf" in this field according to the documentation
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        mlogger.TraceEvent(LogLevels.Warning, 34100, s + " fails as isotopics element " + op.ToString() + " " + ex.Message);
                    }
                }

                l.Add(i);
            }
        }
예제 #15
0
파일: OPFiles.cs 프로젝트: tempbottle/INCC6
        /// <summary>
        /// Create a list of Isotopics instances from each CSV parsed line set
        /// </summary>
        /// <param name="csv">The field-scanned csv file instance with an array of tokenized lines</param>
        void GenerateIsotopics(CSVFile csv)
        {
            List<Isotopics> l = NOPIsotopics;  // local alias
            foreach (string[] sa in csv.Lines)
            {
                Isotopics i = new Isotopics();
                String s = String.Empty;
                double v = 0, err = 0;
                foreach (NOPCol op in System.Enum.GetValues(typeof(NOPCol)))
                {
                    try
                    {
                        s = String.Empty;
                        s = sa[(int)op];  // might blow here when file was badly created
                        switch (op)
                        {
                            case NOPCol.AmDate:
                                Match amd = yyyymmdd.Match(s);
                                if (amd.Success)
                                    i.am_date = GenFromYYYYMMDD(s);
                                break;
                            case NOPCol.PuDate:
                                Match pud = yyyymmdd.Match(s);
                                if (pud.Success)
                                    i.pu_date = GenFromYYYYMMDD(s);
                                break;
                            case NOPCol.IsoSourceCode:
                                System.Enum.TryParse<Isotopics.SourceCode>(s, out i.source_code);
                                break;
                            case NOPCol.IsoId:
                                i.id = String.Copy(s);
                                break;
                            case NOPCol.Pu238:
                                Double.TryParse(s, out v); i.SetVal(Isotope.pu238, v);
                                break;
                            case NOPCol.Pu239:
                                Double.TryParse(s, out v); i.SetVal(Isotope.pu239, v);
                                break;
                            case NOPCol.Pu240:
                                Double.TryParse(s, out v); i.SetVal(Isotope.pu240, v);
                                break;
                            case NOPCol.Pu241:
                                Double.TryParse(s, out v); i.SetVal(Isotope.pu241, v);
                                break;
                            case NOPCol.Pu242:
                                Double.TryParse(s, out v); i.SetVal(Isotope.pu242, v);
                                break;
                            case NOPCol.Am241:
                                Double.TryParse(s, out v); i.SetVal(Isotope.am241, v);
                                break;
                            case NOPCol.Pu238err:
                                Double.TryParse(s, out err); i.SetError(Isotope.pu238, err);
                                break;
                            case NOPCol.Pu239err:
                                Double.TryParse(s, out err); i.SetError(Isotope.pu239, err);
                                break;
                            case NOPCol.Pu240err:
                                Double.TryParse(s, out err); i.SetError(Isotope.pu240, err);
                                break;
                            case NOPCol.Pu241err:
                                Double.TryParse(s, out err); i.SetError(Isotope.pu241, err);
                                break;
                            case NOPCol.Pu242err:
                                Double.TryParse(s, out err); i.SetError(Isotope.pu242, err);
                                break;
                            case NOPCol.Am241err:
                                Double.TryParse(s, out err); i.SetVal(Isotope.am241, err);
                                break;
                            case NOPCol.Norm:
                                // todo: the values in this field are related to COP file usage, bu I don't quite understand this yet, appears it should be looking for "Cf" in this field according to the documentation
                                break;
                        }
                    }
                    catch (Exception ex)
                    {
                        mlogger.TraceEvent(LogLevels.Warning, 34100, s + " fails as isotopics element " + op.ToString() + " " + ex.Message);
                    }
                }

                l.Add(i);
            }
        }
예제 #16
0
        protected Section ConstructReportSection(INCCReportSection section, Detector det, MeasOptionSelector moskey = null)
        {
            INCCStyleSection sec = null;
            try
            {
                switch (section)
                {
                    case INCCReportSection.Header:
                        sec = new INCCStyleSection(null, 1);
                        sec.AddHeader(N.App.Name + " " + N.App.Config.VersionString);  // section header
                        break;
                    case INCCReportSection.Context:
                        sec = new INCCStyleSection(null, 1);
                        ConstructContextContent(sec, det);
                        break;
                    case INCCReportSection.Isotopics:
                        if (AssaySelector.ForMass(meas.MeasOption))
                        {
                            sec = new INCCStyleSection(null, 1);
                            sec.SetFPCurrentFormatPrecision(4);
                            Isotopics curiso = Isotopics.update_isotopics(1.0, meas.MeasDate, meas.Isotopics, meas.logger, N.App.AppContext.INCCParity);
                            if (curiso == null)
                            {
                                curiso = new Isotopics();
                                meas.Isotopics.CopyTo(curiso);
                                ctrllog.TraceEvent(LogLevels.Warning, 82034,  "Using incorrect updated defaults for " + meas.Isotopics.id);
                            }
                            sec.AddTwo("Isotopics id:", meas.Isotopics.id);
                            sec.AddTwo("Isotopics source code:", meas.Isotopics.source_code.ToString());
                            sec.AddDualNumericRow("Pu238:", meas.Isotopics[Isotope.pu238], curiso[Isotope.pu238]);
                            sec.AddDualNumericRow("Pu239:", meas.Isotopics[Isotope.pu239], curiso[Isotope.pu239]);
                            sec.AddDualNumericRow("Pu240:", meas.Isotopics[Isotope.pu240], curiso[Isotope.pu240]);
                            sec.AddDualNumericRow("Pu241:", meas.Isotopics[Isotope.pu241], curiso[Isotope.pu241]);
                            sec.AddDualNumericRow("Pu242:", meas.Isotopics[Isotope.pu242], curiso[Isotope.pu242]);
                            sec.AddDualDateOnlyRow("Pu date:", meas.Isotopics.pu_date, curiso.pu_date);
                            sec.AddDualNumericRow("Am241:", meas.Isotopics[Isotope.am241], curiso[Isotope.am241]);
                            sec.AddDualDateOnlyRow("Am date:", meas.Isotopics.am_date, curiso.am_date);
                            // dev note: here is where the alternative K vals are added in the Euratom version
                        }
                        break;
                    case INCCReportSection.ShiftRegister:
                        sec = new INCCStyleSection(null, 1);
                        ConstructSRSection(sec, moskey.MultiplicityParams, det);
                        break;
                    case INCCReportSection.Adjustments:
                        sec = new INCCStyleSection(null, 1);
                        if (AssaySelector.ForMass(meas.MeasOption) || meas.MeasOption == AssaySelector.MeasurementOption.rates)
                        {
                            ushort push = sec.FPFormatPrecision;
                            sec.SetFPCurrentFormatPrecision(4);
                            sec.AddNumericRow("Normalization constant:", meas.Norm.currNormalizationConstant);
                            sec.SetFPCurrentFormatPrecision(push);
                        }
                        if (AssaySelector.UsesBackground(meas.MeasOption))
                        {
                            sec.AddNumericRow("Passive singles bkgrnd:", meas.Background.DeadtimeCorrectedSinglesRate);
                            sec.AddNumericRow("Passive doubles bkgrnd:", meas.Background.DeadtimeCorrectedDoublesRate);
                            sec.AddNumericRow("Passive triples bkgrnd:", meas.Background.DeadtimeCorrectedTriplesRate);

                            if (det.Id.SRType <= InstrType.AMSR)
                            {
                                sec.AddNumericRow("Passive scaler1 bkgrnd:", meas.Background.Scaler1.v);
                                sec.AddNumericRow("Passive scaler2 bkgrnd:", meas.Background.Scaler2.v);
                            }

                            sec.AddNumericRow("Active singles bkgrnd:", meas.Background.INCCActive.Singles);
                            sec.AddNumericRow("Active doubles bkgrnd:", meas.Background.INCCActive.Doubles);
                            sec.AddNumericRow("Active triples bkgrnd:", meas.Background.INCCActive.Triples);
                            if (det.Id.SRType <= InstrType.AMSR)
                            {
                                sec.AddNumericRow("Passive scaler1 bkgrnd:", meas.Background.INCCActive.Scaler1Rate);
                                sec.AddNumericRow("Passive scaler2 bkgrnd:", meas.Background.INCCActive.Scaler2Rate);
                            }
                        }
                        break;
                    case INCCReportSection.CycleSummary:
                        sec = new INCCStyleSection(null, 1);
                        sec.AddIntegerRow(String.Format("Number {0} cycles:",meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected()?"Active":"Passive"), (int)meas.Cycles.GetValidCycleCountForThisKey(moskey.MultiplicityParams)); //det.MultiplicityParams)); // could also use CycleList length but CycleList can be longer when a reanalysis occurs and the analysis processing stops short of the end of the list due to modified termination conditions
                        sec.AddNumericRow("Count time (sec):", (meas.Cycles.Count > 0 ? meas.Cycles[0].TS.TotalSeconds : 0.0));
                        break;

                    case INCCReportSection.Messages:
                        List<MeasurementMsg> sl = null;
                        bool found = meas.Messages.TryGetValue(moskey.MultiplicityParams, out sl);
                        if (found)
                        {
                            sec = new INCCStyleSection(null, 1);
                            sec.AddHeader(String.Format("{0} messages", meas.INCCAnalysisState.Methods.HasActiveSelected() || meas.INCCAnalysisState.Methods.HasActiveMultSelected() ? "Active" : "Passive"));  /// todo: is there an active messages section header analog?
                            foreach (MeasurementMsg m in sl)
                            {
                                Row r = new Row();
                                r.Add(0, m.text);  // expand to log style with toString?
                                sec.Add(r);
                            }
                        }
                        break;
                    case INCCReportSection.Reference:
                        sec = new INCCStyleSection(null, 1);
                        sec.AddHeader("Counting results, summaries and cycle counts file name");  // section header
                        Row resline = new Row(); resline.Add(0, "  " + meas.ResultsFileName);
                        sec.Add(resline);
                        break;
                    default:
                        break;
                }
            }
            catch (Exception e)
            {
                ctrllog.TraceException(e);
            }
            return sec;
        }
예제 #17
0
 string[] Convert(Isotopics i)
 {
     Array ev = Enum.GetValues(typeof(IsoFiles.IsoCol));
     string[] sa = new string[ev.Length];
     sa[(int)IsoFiles.IsoCol.AmDate] = Quote(i.am_date.ToString("yyyyMMdd"));
     sa[(int)IsoFiles.IsoCol.PuDate] = Quote(i.pu_date.ToString("yyyyMMdd"));
     sa[(int)IsoFiles.IsoCol.IsoSourceCode] = Quote(i.source_code.ToString());
     sa[(int)IsoFiles.IsoCol.IsoId] = Quote(i.id.ToString());
     sa[(int)IsoFiles.IsoCol.Pu238] = i.pu238.ToString();
     sa[(int)IsoFiles.IsoCol.Pu238err] = i.pu238_err.ToString();
     sa[(int)IsoFiles.IsoCol.Pu239] = i.pu239.ToString();
     sa[(int)IsoFiles.IsoCol.Pu239err] = i.pu239_err.ToString();
     sa[(int)IsoFiles.IsoCol.Pu240] = i.pu240.ToString();
     sa[(int)IsoFiles.IsoCol.Pu240err] = i.pu240_err.ToString();
     sa[(int)IsoFiles.IsoCol.Pu241] = i.pu241.ToString();
     sa[(int)IsoFiles.IsoCol.Pu241err] = i.pu241_err.ToString();
     sa[(int)IsoFiles.IsoCol.Pu242] = i.pu242.ToString();
     sa[(int)IsoFiles.IsoCol.Pu242err] = i.pu242_err.ToString();
     sa[(int)IsoFiles.IsoCol.Am241] = i.am241.ToString();
     sa[(int)IsoFiles.IsoCol.Am241err] = i.am241_err.ToString();
     return sa;
 }
예제 #18
0
        object CompositeIsotopics(string[] sa, bool headtest)
        {
            var res = new object();
            CompositeIsotopics cis = null;
            CompositeIsotopic ci = null;
            Array ev = Enum.GetValues(typeof(CompIsCol));
            if (headtest)  // full iso line
            {
                if (sa.Length != ev.Length)
                    return null;
                cis = new CompositeIsotopics();
                res = cis;
            }
            else  // comp iso subentry line
            {
                if (sa.Length != ev.Length - 2)
                    return null;
                ci = new CompositeIsotopic();
                res = ci;
            }
            float pumass = 0;
            Isotopics iso = new Isotopics();
            string s = string.Empty;
            double v = 0, err = 0;
            foreach (CompIsCol op in ev)
            {
                try
                {
                    if (headtest)
                        s = sa[(int)op];
                    else
                    {
                        if (op > CompIsCol.IsoSourceCode)
                            s = sa[(int)op - 2];
                        else
                            s = string.Empty;
                    }

                    switch (op)
                    {
                    case CompIsCol.IsoSourceCode:
                        if (headtest) {  Enum.TryParse(s, out cis.source_code); iso.source_code = cis.source_code; }
                        break;
                    case CompIsCol.IsoId:
                        if (headtest) { cis.id = string.Copy(s); iso.id = cis.id; }
                        break;
                    case CompIsCol.PuMass:
                        //if (!headtest)  // comp iso lines start with mass
                        //{
                            float sv = 0f;
                            float.TryParse(s, out sv);
                            pumass = sv;
                        //}
                        break;
                    case CompIsCol.AmDate:
                        INCC5FileImportUtils.GenFromYYYYMMDD(s, ref iso.am_date);
                        break;
                    case CompIsCol.PuDate:
                        INCC5FileImportUtils.GenFromYYYYMMDD(s, ref iso.pu_date);
                        break;
                    case CompIsCol.Pu238:
                        double.TryParse(s, out v);
                        iso.SetVal(Isotope.pu238, v);
                        break;
                    case CompIsCol.Pu239:
                        double.TryParse(s, out v);
                        iso.SetVal(Isotope.pu239, v);
                        break;
                    case CompIsCol.Pu240:
                        double.TryParse(s, out v);
                        iso.SetVal(Isotope.pu240, v);
                        break;
                    case CompIsCol.Pu241:
                        double.TryParse(s, out v);
                        iso.SetVal(Isotope.pu241, v);
                        break;
                    case CompIsCol.Pu242:
                        double.TryParse(s, out v);
                        iso.SetVal(Isotope.pu242, v);
                        break;
                    case CompIsCol.Am241:
                        double.TryParse(s, out v);
                        iso.SetVal(Isotope.am241, v);
                        break;
                    case CompIsCol.Pu238err:
                        double.TryParse(s, out err);
                        iso.SetError(Isotope.pu238, err);
                        break;
                    case CompIsCol.Pu239err:
                        double.TryParse(s, out err);
                        iso.SetError(Isotope.pu239, err);
                        break;
                    case CompIsCol.Pu240err:
                        double.TryParse(s, out err);
                        iso.SetError(Isotope.pu240, err);
                        break;
                    case CompIsCol.Pu241err:
                        double.TryParse(s, out err);
                        iso.SetError(Isotope.pu241, err);
                        break;
                    case CompIsCol.Pu242err:
                        double.TryParse(s, out err);
                        iso.SetError(Isotope.pu242, err);
                        break;
                    case CompIsCol.Am241err:
                        double.TryParse(s, out err);
                        iso.SetError(Isotope.am241, err);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Results.mlogger.TraceEvent(LogLevels.Warning, 34100, s + " fails as composite isotopics summary element " + op.ToString() + " " + ex.Message);
                    return null;
                }
            }
            // copy values onto the relevant object
            if (cis != null)
                cis.Copy(iso, pumass);
            if (ci != null)
                ci.Copy(iso, pumass);
            return res;
        }
예제 #19
0
 Isotopics GenIso(string[] sa)
 {
     Array ev = Enum.GetValues(typeof(IsoCol));
     if (sa.Length != ev.Length)
         return null;
     Isotopics i = new Isotopics();
     string s = string.Empty;
     double v = 0, err = 0;
     foreach (IsoCol op in ev)
     {
         try
         {
             s = sa[(int)op];
             switch (op)
             {
             case IsoCol.AmDate:
                 INCC5FileImportUtils.GenFromYYYYMMDD(s, ref i.am_date);
                 break;
             case IsoCol.PuDate:
                 INCC5FileImportUtils.GenFromYYYYMMDD(s, ref i.pu_date);
                 break;
             case IsoCol.IsoSourceCode:
                 Enum.TryParse(s, out i.source_code);
                 break;
             case IsoCol.IsoId:
                 i.id = string.Copy(s);
                 break;
             case IsoCol.Pu238:
                 double.TryParse(s, out v);
                 i.SetVal(Isotope.pu238, v);
                 break;
             case IsoCol.Pu239:
                 double.TryParse(s, out v);
                 i.SetVal(Isotope.pu239, v);
                 break;
             case IsoCol.Pu240:
                 double.TryParse(s, out v);
                 i.SetVal(Isotope.pu240, v);
                 break;
             case IsoCol.Pu241:
                 double.TryParse(s, out v);
                 i.SetVal(Isotope.pu241, v);
                 break;
             case IsoCol.Pu242:
                 double.TryParse(s, out v);
                 i.SetVal(Isotope.pu242, v);
                 break;
             case IsoCol.Am241:
                 double.TryParse(s, out v);
                 i.SetVal(Isotope.am241, v);
                 break;
             case IsoCol.Pu238err:
                 double.TryParse(s, out err);
                 i.SetError(Isotope.pu238, err);
                 break;
             case IsoCol.Pu239err:
                 double.TryParse(s, out err);
                 i.SetError(Isotope.pu239, err);
                 break;
             case IsoCol.Pu240err:
                 double.TryParse(s, out err);
                 i.SetError(Isotope.pu240, err);
                 break;
             case IsoCol.Pu241err:
                 double.TryParse(s, out err);
                 i.SetError(Isotope.pu241, err);
                 break;
             case IsoCol.Pu242err:
                 double.TryParse(s, out err);
                 i.SetError(Isotope.pu242, err);
                 break;
             case IsoCol.Am241err:
                 double.TryParse(s, out err);
                 i.SetError(Isotope.am241, err);
                 break;
             }
         }
         catch (Exception ex)
         {
             Results.mlogger.TraceEvent(LogLevels.Warning, 34100, s + " fails as isotopics element " + op.ToString() + " " + ex.Message);
             return null;
         }
     }
     return i;
 }
예제 #20
0
        void CalculateAndPersist(CompositeIsotopics comp_iso)
        {
            if (!GutCheck(calc: true))
            {
                return;
            }
            Isotopics newiso  = null;
            uint      retcode = comp_iso.CombinedCalculation(out newiso, NC.App.AppContext.INCCParity, applog);

            if (retcode == 36783)
            {
                MessageBox.Show("Unable to update isotopics, sum of Pu isotopes must be greater than zero");
            }
            else if (retcode == 36784)
            {
                MessageBox.Show("Sum of masses = 0.\r\nNew isotopics not calculated and stored.");
            }
            else
            {
                newiso.modified = comp_iso.modified = true;
                if (!NC.App.DB.CompositeIsotopics.Has(comp_iso.id))
                {
                    NC.App.DB.CompositeIsotopics.GetList().Add(comp_iso);                       // add to in-memory list
                }
                List <CompositeIsotopics> list = NC.App.DB.CompositeIsotopics.GetMatch(i => i.modified);
                foreach (CompositeIsotopics iso in list)
                {
                    long pk = NC.App.DB.CompositeIsotopics.Set(iso);                                 // add to database
                    applog.TraceInformation((pk >= 0 ? "Saved " : "Unable to save ") + iso.id + " composite isotopics");
                }
                comp_iso.modified = false;
                LoadEntry(comp_iso);
                string msg = string.Format(
                    "Composite Isotopics id:\t{0}\n\nIsotopics Source Code:\t{1}\n\nMass\t\t{2,8:F3}\nPu238\t\t{3,8:F6}\nPu239\t\t{4,8:F6}\nPu240\t\t{5,8:F6}\nPu241\t\t{6,8:F6}\nPu242\t\t{7,8:F6}\nPu Date\t\t{8}\nAm241\t\t{9,8:F6}\nAm Date\t\t{10}\n\nIsotopics are updated to the reference date.",
                    newiso.id, newiso.source_code, comp_iso.MassSum,
                    newiso.pu238, newiso.pu239, newiso.pu240,
                    newiso.pu241, newiso.pu242, newiso.pu_date,
                    newiso.am241, newiso.am_date);
                DialogResult res = MessageBox.Show(msg, "Accept Results", MessageBoxButtons.OKCancel);
                if (res == DialogResult.OK)
                {
                    if (!NC.App.DB.Isotopics.Has(newiso.id))
                    {
                        NC.App.DB.Isotopics.GetList().Add(newiso);
                        long pk = NC.App.DB.Isotopics.Set(newiso);                                      // add to database
                        applog.TraceInformation((pk >= 0 ? "Saved " : "Unable to save ") + newiso.id + " isotopics");
                        if (pk >= 0)
                        {
                            NC.App.DB.Isotopics.Refresh();
                        }
                    }
                    else
                    {
                        NC.App.DB.Isotopics.Replace(newiso);
                        applog.TraceInformation("Replaced " + newiso.id + " isotopics");
                    }
                    calcQ = false;
                }
                else
                {
                    MessageBox.Show("New isotopics not stored.");
                }
            }
        }