private void OKBtn_Click(object sender, EventArgs e) { INCCDB.Descriptor candidate = new INCCDB.Descriptor(StratumIdTextBox.Text, StratumIdDescTextBox.Text); st = new INCCDB.StratumDescriptor(candidate, st.Stratum); INCCDB.StratumDescriptor realst = (INCCDB.StratumDescriptor)CurrentStratumIdsComboBox.SelectedItem; if (realst != null && st.CompareTo(realst) != 0) { if (list.Exists(i => { return st.Desc.Name.CompareTo(i.Desc.Name) == 0; })) return; st.Desc.modified = true; NC.App.DB.UpdateStratum(st.Desc, st.Stratum); // creates it NC.App.DB.AssociateStratum(det, st.Desc, st.Stratum); // associates it with the detector RefreshCombo(); INCCDB.StratumDescriptor newst = list.Find(i => { return st.Desc.Name.CompareTo(i.Desc.Name) == 0; }); CurrentStratumIdsComboBox.SelectedItem = newst; } else { // It is brand spanking new..... st.Desc.modified = true; NC.App.DB.UpdateStratum(st.Desc, st.Stratum); // creates it NC.App.DB.AssociateStratum(det, st.Desc, st.Stratum); // associates it with the detector RefreshCombo(); INCCDB.StratumDescriptor newst = list.Find(i => { return st.Desc.Name.CompareTo(i.Desc.Name) == 0; }); CurrentStratumIdsComboBox.SelectedItem = newst; } // Refreshes Strata List after add. list = NC.App.DB.StrataList(det); }
private void OKBtn_Click(object sender, EventArgs e) { INCCDB.Descriptor candidate = new INCCDB.Descriptor(StratumIdTextBox.Text, StratumIdDescTextBox.Text); st = new INCCDB.StratumDescriptor(candidate, st.Stratum); INCCDB.StratumDescriptor realst = (INCCDB.StratumDescriptor)CurrentStratumIdsComboBox.SelectedItem; if (realst != null && st.CompareTo(realst) != 0) { if (list.Exists(i => { return(st.Desc.Name.CompareTo(i.Desc.Name) == 0); })) { return; } // todo: do the prefix match check here (1st 3 chars match on one or more existing entries) // todo: what the hell is jl talking about? // todo: I dunno, where was his mind? st.Desc.modified = true; NC.App.DB.UpdateStratum(st.Desc, st.Stratum); // creates it NC.App.DB.AssociateStratum(det, st.Desc, st.Stratum); // associates it with the detector RefreshCombo(); INCCDB.StratumDescriptor newst = list.Find(i => { return(st.Desc.Name.CompareTo(i.Desc.Name) == 0); }); CurrentStratumIdsComboBox.SelectedItem = newst; } else { // It is brand spanking new..... st.Desc.modified = true; NC.App.DB.UpdateStratum(st.Desc, st.Stratum); // creates it NC.App.DB.AssociateStratum(det, st.Desc, st.Stratum); // associates it with the detector RefreshCombo(); INCCDB.StratumDescriptor newst = list.Find(i => { return(st.Desc.Name.CompareTo(i.Desc.Name) == 0); }); CurrentStratumIdsComboBox.SelectedItem = newst; } // Refreshes Strata List after add. list = NC.App.DB.StrataList(det); }
private void StrataView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { int row = e.RowIndex; int col = e.ColumnIndex; if (row >= 0) { INCCDB.StratumDescriptor changed = sl.ElementAt(row); double d; switch (col) { case 1: Double.TryParse((StrataView[col, row]).Value.ToString(), out d); changed.Stratum.bias_uncertainty = d; changed.Stratum.modified = true; break; case 2: Double.TryParse((StrataView[col, row]).Value.ToString(), out d); changed.Stratum.random_uncertainty = d; changed.Stratum.modified = true; break; case 3: Double.TryParse((StrataView[col, row]).Value.ToString(), out d); changed.Stratum.systematic_uncertainty = d; changed.Stratum.modified = true; break; } } }
private void CurrentStratumIdsComboBox_SelectedIndexChanged(object sender, EventArgs e) { INCCDB.StratumDescriptor lst = (INCCDB.StratumDescriptor)CurrentStratumIdsComboBox.SelectedItem; st = new INCCDB.StratumDescriptor(lst); StratumIdTextBox.Text = st.Item1.Name; StratumIdDescTextBox.Text = st.Item1.Desc; HistoricalBiasTextBox.Text = st.Item2.bias_uncertainty.ToString("F3"); RandomUncertaintyTextBox.Text = st.Item2.random_uncertainty.ToString("F3"); SystematicUncertaintyTextBox.Text = st.Item2.systematic_uncertainty.ToString("F3"); }
public IDDStratumIdAdd(Detector d) { det = d; InitializeComponent(); RefreshCombo(); if (CurrentStratumIdsComboBox.Items.Count > 0) CurrentStratumIdsComboBox.SelectedIndex = 0; else st = new INCCDB.StratumDescriptor(); this.Text += " for detector " + det.Id.DetectorName; }
private void StrataView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { int row = e.RowIndex; int col = e.ColumnIndex; if (row >= 0) { if (row >= sl.Count) // Is a new stratum { INCCDB.Descriptor candidate = new INCCDB.Descriptor(StrataView[0, row].Value.ToString(), StrataView[0, row].Value.ToString()); Stratum st = new Stratum(); INCCDB.StratumDescriptor newst = new INCCDB.StratumDescriptor(candidate, st); AcquireParameters acq = NC.App.DB.LastAcquire(); string curdet = acq.detector_id; if (!String.IsNullOrEmpty(StrataView[0, row].Value.ToString())) { NC.App.DB.StrataList().Add(newst); NC.App.DB.AssociateStratum(NC.App.DB.Detectors.Find(di => string.Compare(di.Id.DetectorName, curdet, true) == 0), candidate, st); } sl.Add(newst); } else { INCCDB.StratumDescriptor changed = sl.ElementAt(row); double d; switch (col) { case 1: Double.TryParse((StrataView[col, row]).Value.ToString(), out d); changed.Stratum.bias_uncertainty = d; changed.Stratum.modified = true; StrataView[col, row].Value = d.ToString("F2"); break; case 2: Double.TryParse((StrataView[col, row]).Value.ToString(), out d); changed.Stratum.random_uncertainty = d; changed.Stratum.modified = true; StrataView[col, row].Value = d.ToString("F2"); break; case 3: Double.TryParse((StrataView[col, row]).Value.ToString(), out d); changed.Stratum.systematic_uncertainty = d; StrataView[col, row].Value = d.ToString("F2"); changed.Stratum.modified = true; break; } } } }
protected void StratumIds() { List <INCCDB.StratumDescriptor> l = NC.App.DB.StrataList(); foreach (ItemId f in NOPItemIds) { if (string.IsNullOrEmpty(f.stratum)) { continue; } INCCDB.StratumDescriptor ex = l.Find(sd => string.Compare(sd.Desc.Name, f.stratum, true) == 0); if (ex != null) { continue; } INCCDB.Descriptor d = new INCCDB.Descriptor(f.stratum, f.stratum); INCCDB.StratumDescriptor d2 = new INCCDB.StratumDescriptor(d, new Stratum()); l.Add(d2); d2.Desc.modified = true; NC.App.DB.UpdateStratum(d2.Desc, d2.Stratum); // creates it // NC.App.DB.AssociateStratum(det, d2.Desc, d2.Stratum); // associates it with the detector } }
/// <summary> /// Construct a full measurement state and set it on the internal lameness /// </summary> /// <param name="acq">Acquire Parameters</param> /// <param name="det">Detector</param> /// <param name="mo">MeasurementOption</param> public static void BuildMeasurement(AcquireParameters acq, Detector det, AssaySelector.MeasurementOption mo) { // gather it all together MeasurementTuple mt = new MeasurementTuple(new DetectorList(det), CentralizedState.App.DB.TestParameters.Get(), GetCurrentNormParams(det), GetCurrentBackgroundParams(det), GetAcquireIsotopics(acq), acq, GetCurrentHVCalibrationParams(det)); det.Id.source = acq.data_src; // set the detector overall data source value here // create the context holder for the measurement. Everything is rooted here ... Measurement meas = new Measurement(mt, mo, CentralizedState.App.Logger(LMLoggers.AppSection.Data)); if (det.ListMode) { // dev note: design flaw exposed by this mess here, when LM has > 1 SVR, there is no way to associate > 1 SVRs with a single detector/SR/Mult/Conn pairing // It should be the other way around, the Mult params for each LMMultiplicity analyzer override the single entry on the sr_parms_rec when each analyis is performed. meas.AnalysisParams = CentralizedState.App.LMBD.CountingParameters(det, applySRFromDetector: true); if (mo == AssaySelector.MeasurementOption.unspecified) // pure List Mode, not INCC5 { // for a list-mode-only measurement with a multiplicity analyzer the detector SR params must match at least one of the multiplicity analyzer SR params ApplyVSRChangesToDefaultDetector(meas); } else // it is an INCC5 analysis driven with LM data { // check to see if detector settings are copied into an active CA entry if (!meas.AnalysisParams.Exists(w => { return((w is Multiplicity) && (w as Multiplicity).Equals(det.MultiplicityParams) && w.Active); })) { meas.AnalysisParams.Add(det.MultiplicityParams); } } } else { // prepare analyzer params from detector SR params meas.AnalysisParams = CentralizedState.App.LMBD.CountingParameters(det, applySRFromDetector: false); if (!meas.AnalysisParams.Exists(w => { return((w is Multiplicity) && (w as Multiplicity).Equals(det.MultiplicityParams)); })) { meas.AnalysisParams.Add(det.MultiplicityParams); } } // get the INCC5 analysis methods meas.INCCAnalysisState = new INCCAnalysisState(); INCCSelector sel = new INCCSelector(acq.detector_id, acq.item_type); AnalysisMethods am; bool found = CentralizedState.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am); if (found) { am.selector = sel; // gotta do this so that the equality operator is not incorrect meas.INCCAnalysisState.Methods = am; } else { meas.INCCAnalysisState.Methods = new AnalysisMethods(sel); } meas.InitializeContext(); meas.PrepareINCCResults(); // next: stratum not set List <INCCDB.StratumDescriptor> sl = CentralizedState.App.DB.StrataList(); INCCDB.StratumDescriptor s = sl.Find(w => w.Desc.CompareTo(acq.stratum_id) == 0); if (s == null) { meas.Stratum = new Stratum(); } else { meas.Stratum = new Stratum(s.Stratum); } INCCResults.results_rec xres = new INCCResults.results_rec(meas); meas.INCCAnalysisResults.TradResultsRec = xres; CentralizedState.App.Opstate.Measurement = meas; // put the measurement definition on the global state // ready for insertion of methods and processing start }
private void OKBtn_Click(object sender, EventArgs e) { INCCDB.Descriptor candidate = new INCCDB.Descriptor(StratumIdTextBox.Text, StratumIdDescTextBox.Text); st = new INCCDB.StratumDescriptor(candidate, st.Stratum); INCCDB.StratumDescriptor realst = (INCCDB.StratumDescriptor)CurrentStratumIdsComboBox.SelectedItem; if (realst != null && st.CompareTo(realst) != 0) { if (list.Exists(i => { return st.Desc.Name.CompareTo(i.Desc.Name) == 0; })) return; // todo: do the prefix match check here (1st 3 chars match on one or more existing entries) // todo: what the hell is jl talking about? // todo: I dunno, where was his mind? st.Desc.modified = true; NC.App.DB.UpdateStratum(st.Desc, st.Stratum); // creates it NC.App.DB.AssociateStratum(det, st.Desc, st.Stratum); // associates it with the detector RefreshCombo(); INCCDB.StratumDescriptor newst = list.Find(i => { return st.Desc.Name.CompareTo(i.Desc.Name) == 0; }); CurrentStratumIdsComboBox.SelectedItem = newst; } else { // It is brand spanking new..... st.Desc.modified = true; NC.App.DB.UpdateStratum(st.Desc, st.Stratum); // creates it NC.App.DB.AssociateStratum(det, st.Desc, st.Stratum); // associates it with the detector RefreshCombo(); INCCDB.StratumDescriptor newst = list.Find(i => { return st.Desc.Name.CompareTo(i.Desc.Name) == 0; }); CurrentStratumIdsComboBox.SelectedItem = newst; } // Refreshes Strata List after add. list = NC.App.DB.StrataList(det); }
/// <summary> /// Finalize measurement instance content for analysis /// Populate calibration parameters maps /// </summary> /// <param name="meas">The partially initialized measurement instance</param> /// <param name="useCurCalibParams">Default behavior is to use active method and other calibration parameters; /// skipped if Reanalysis prepared the details from database measurement results /// </param> static public void FillInReanalysisRemainingDetails(Measurement meas, bool useCurCalibParams = true) { // get the current INCC5 analysis methods if (useCurCalibParams || meas.INCCAnalysisState == null) { meas.INCCAnalysisState = new INCCAnalysisState(); INCCSelector sel = new INCCSelector(meas.AcquireState.detector_id, meas.AcquireState.item_type); AnalysisMethods am; bool found = CentralizedState.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am); if (found) { am.selector = sel; // gotta do this so that the equality operator is not incorrect meas.INCCAnalysisState.Methods = am; } else { meas.INCCAnalysisState.Methods = new AnalysisMethods(sel); } } // else use what was there meas.InitializeContext(clearCounterResults: false); meas.PrepareINCCResults(); System.Collections.IEnumerator iter = meas.CountingAnalysisResults.GetATypedParameterEnumerator(typeof(Multiplicity)); while (iter.MoveNext()) { Multiplicity mkey = (Multiplicity)iter.Current; try { MultiplicityCountingRes mcr = (MultiplicityCountingRes)meas.CountingAnalysisResults[mkey]; if (mcr.AB.Unset) { LMRawAnalysis.SDTMultiplicityCalculator.SetAlphaBeta(mkey, mcr); // works only if MaxBins is set } MeasOptionSelector mos = new MeasOptionSelector(meas.MeasOption, mkey); INCCResult result = meas.INCCAnalysisState.Lookup(mos); result.CopyFrom(mcr); } catch (Exception) { //logger.TraceEvent(LogLevels.Error, 4027, "PrepareINCCResults error: " + ex.Message); } } // stratum look up, finds existing stratum by name if (useCurCalibParams || meas.Stratum == null) { List <INCCDB.StratumDescriptor> sl = CentralizedState.App.DB.StrataList(); INCCDB.StratumDescriptor s = sl.Find(w => string.Compare(w.Desc.Name, meas.AcquireState.stratum_id.Name, true) == 0); if (s == null) { meas.Stratum = new Stratum(); } else { meas.Stratum = new Stratum(s.Stratum); } } INCCResults.results_rec xres = new INCCResults.results_rec(meas); meas.INCCAnalysisResults.TradResultsRec = xres; CentralizedState.App.Opstate.Measurement = meas; // put the measurement definition on the global state }
/// <summary> /// Prepare measurement instance content for analysis /// Populate calibration and counting parameters maps /// Create general results and specific results dictionary map entries /// Set up stratum details /// </summary> /// <param name="meas">The partially initialized measurement instance</param> /// <param name="useCurCalibParams">Default behavior is to use active method and other calibration parameters; /// skipped if Reanalysis prepared the details from database measurement results /// </param> static public void FillInMeasurementDetails(Measurement meas, bool useCurCalibParams = true) { if (meas.Detector.ListMode) { // APluralityOfMultiplicityAnalyzers: see below // URGENT: see below //if (an INCC5 DB cycle read or DB Ver reanalysis then rebuild the analyzers from the associated saved LM results:) // object x = CentralizedState.App.DB.GetAnalyzersFromResults(meas.Detector, meas.MeasurementId); //else meas.AnalysisParams = CentralizedState.App.LMBD.CountingParameters(meas.Detector, applySRFromDetector: true); if (meas.MeasOption.IsListMode()) // pure List Mode, not INCC5 { // for a list-mode-only measurement with a multiplicity analyzer the detector SR params must match at least one of the multiplicity analyzer SR params ApplyVSRChangesToDefaultDetector(meas); } else // it is an INCC5 analysis driven with LM data { // prepare or identify an active CA entry with matching CA gatewidth and FA, and has the same SR params as the detector if (meas.AnalysisParams.PrepareMatchingVSR(meas.Detector.MultiplicityParams)) { CentralizedState.App.LMBD.UpdateCounters(meas.Detector.Id.DetectorName, meas.AnalysisParams); // added one, save it } } } else // construct param key source with the single mkey entry point { // prepare analyzer params from detector SR params meas.AnalysisParams = CentralizedState.App.LMBD.CountingParameters(meas.Detector, applySRFromDetector: false); if (!meas.AnalysisParams.Exists(w => { return((w is Multiplicity) && (w as Multiplicity).Equals(meas.Detector.MultiplicityParams)); })) { meas.AnalysisParams.Add(meas.Detector.MultiplicityParams); } } // get the current INCC5 analysis methods if (useCurCalibParams || meas.INCCAnalysisState == null) { meas.INCCAnalysisState = new INCCAnalysisState(); INCCSelector sel = new INCCSelector(meas.AcquireState.detector_id, meas.AcquireState.item_type); AnalysisMethods am; bool found = CentralizedState.App.DB.DetectorMaterialAnalysisMethods.TryGetValue(sel, out am); if (found) { am.selector = sel; // gotta do this so that the equality operator is not incorrect meas.INCCAnalysisState.Methods = am; } else { meas.INCCAnalysisState.Methods = new AnalysisMethods(sel); } } // else use what was there meas.InitializeContext(clearCounterResults: true); meas.PrepareINCCResults(); // stratum look up, finds existing stratum by name if (useCurCalibParams || meas.Stratum == null) { List <INCCDB.StratumDescriptor> sl = CentralizedState.App.DB.StrataList(); INCCDB.StratumDescriptor s = sl.Find(w => string.Compare(w.Desc.Name, meas.AcquireState.stratum_id.Name, true) == 0); if (s == null) { meas.Stratum = new Stratum(); } else { meas.Stratum = new Stratum(s.Stratum); } } INCCResults.results_rec xres = new INCCResults.results_rec(meas); meas.INCCAnalysisResults.TradResultsRec = xres; CentralizedState.App.Opstate.Measurement = meas; // put the measurement definition on the global state }
private void StrataView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { int row = e.RowIndex; int col = e.ColumnIndex; if (row >= 0) { if (row >= sl.Count) // Is a new stratum { INCCDB.Descriptor candidate = new INCCDB.Descriptor(StrataView[0, row].Value.ToString(), StrataView[0, row].Value.ToString()); Stratum st = new Stratum(); INCCDB.StratumDescriptor newst = new INCCDB.StratumDescriptor(candidate, st); AcquireParameters acq = NC.App.DB.LastAcquire(); string curdet = acq.detector_id; if (!String.IsNullOrEmpty(StrataView[0, row].Value.ToString())) { NC.App.DB.StrataList().Add(newst); NC.App.DB.AssociateStratum(NC.App.DB.Detectors.Find(di => string.Compare(di.Id.DetectorName, curdet, true) == 0), candidate, st); } sl.Add(newst); } else { INCCDB.StratumDescriptor changed = sl.ElementAt(row); double d; switch (col) { case 1: Double.TryParse((StrataView[col, row]).Value.ToString(), out d); changed.Stratum.bias_uncertainty = d; changed.Stratum.modified = true; StrataView[col,row].Value = d.ToString("F2"); break; case 2: Double.TryParse((StrataView[col, row]).Value.ToString(), out d); changed.Stratum.random_uncertainty = d; changed.Stratum.modified = true; StrataView[col, row].Value = d.ToString("F2"); break; case 3: Double.TryParse((StrataView[col, row]).Value.ToString(), out d); changed.Stratum.systematic_uncertainty = d; StrataView[col, row].Value = d.ToString("F2"); changed.Stratum.modified = true; break; } } } }
protected void StratumIds() { List<INCCDB.StratumDescriptor> l = NC.App.DB.StrataList(); foreach (ItemId f in NOPItemIds) { if (string.IsNullOrEmpty(f.stratum)) continue; INCCDB.StratumDescriptor ex = l.Find(sd => string.Compare(sd.Desc.Name, f.stratum, true) == 0); if (ex != null) continue; INCCDB.Descriptor d = new INCCDB.Descriptor(f.stratum, f.stratum); INCCDB.StratumDescriptor d2 = new INCCDB.StratumDescriptor(d, new Stratum()); l.Add(d2); d2.Desc.modified = true; NC.App.DB.UpdateStratum(d2.Desc, d2.Stratum); // creates it // NC.App.DB.AssociateStratum(det, d2.Desc, d2.Stratum); // associates it with the detector } }
private void OKBtn_Click(object sender, EventArgs e) { //todo: Check that this works as planned hn INCCDB.StratumDescriptor ToDelete = list.ElementAt(StratumIdComboBox.SelectedIndex); string name = ToDelete.Desc.Name; //Check for associated detectors, warn if associated DB.Strata strata = new DB.Strata(); List <string> dets = strata.GetAssociationsByStratum(name); if (dets.Count > 0) { if (MessageBox.Show("There are detectors associated with this stratum. Do you still want to delete?", "WARNING", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } //check for associated items, warn if associated ItemIdListImpl il = new ItemIdListImpl(); List <ItemId> ItemList = il.GetListByStratumID(name); if (ItemList.Count > 0) { if (MessageBox.Show("There are items associated with this stratum. Do you still want to delete?", "WARNING", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } //Check acquire_recs for the stratum id, warn if used List <AcquireParameters> acq_with_stratum = new List <AcquireParameters>(); Dictionary <INCCDB.AcquireSelector, AcquireParameters> all_acq = NC.App.DB.AcquireParametersMap; foreach (KeyValuePair <INCCDB.AcquireSelector, AcquireParameters> kv in all_acq) { if (((AcquireParameters)kv.Value).stratum_id.Name == name) { acq_with_stratum.Add((AcquireParameters)kv.Value); } } if (acq_with_stratum.Count > 0) { if (MessageBox.Show("There are acquisition records associated with this stratum. Do you still want to delete?", "WARNING", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } //they have chosen to go ahead with the delete, remove detector associations foreach (string det_name in dets) { strata.Unassociate(det_name); } if (NC.App.DB.DeleteStratum(ToDelete.Desc)) { RefreshCombo(); } else { MessageBox.Show("Failed to delete stratum from DB", "There was a problem deleting this stratum from the database.", MessageBoxButtons.OKCancel); } DialogResult = DialogResult.OK; // Refreshes global strata list list = NC.App.DB.StrataList(det); this.Close(); }