public IDDMeasurementList(AssaySelector.MeasurementOption filter, bool alltypes, EndGoal goal, Detector detector = null, ItemId id = null) { InitializeComponent(); System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; try { InitSort(); PrepNotepad(); SetTitlesAndChoices(filter, alltypes, goal, detector == null ? string.Empty : detector.Id.DetectorId, string.Empty); if (id == null) { mlist = N.App.DB.MeasurementsFor(detector == null ? string.Empty : detector.Id.DetectorId, filter, ""); } else { mlist = N.App.DB.MeasurementsFor(detector == null ? string.Empty : detector.Id.DetectorId, filter, id); } bGood = PrepList(filter, detector); AllowMultiSelect = goal == EndGoal.GetSelection?false:true; } finally { System.Windows.Input.Mouse.OverrideCursor = null; } SummarySelections = null; }
public static AssaySelector.MeasurementOption SrcToEnum(this string src) { AssaySelector.MeasurementOption res = AssaySelector.MeasurementOption.unspecified; if (String.IsNullOrEmpty(src)) { return(res); } bool match = false; foreach (KeyValuePair <AssaySelector.MeasurementOption, string> pair in PrintableName) { if (pair.Value.Equals(src)) { res = pair.Key; match = true; break; } } if (!match) // non-null string that does not match, ry a direct conversion { System.Enum.TryParse <AssaySelector.MeasurementOption>(src, out res); } return(res); }
public void Init(string id, AssaySelector.MeasurementOption mo = AssaySelector.MeasurementOption.verification) { MeasDataList = new MeasPointList(); CalibDataList = new CalibList(); 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 = "Decl U235 Mass"; } if (AnalysisMethod == AnalysisMethod.KnownA) { listView1.Columns[3].Text = "Mult Corr Dbls Rt"; } }
public Measurement(AssaySelector.MeasurementOption at) { mt = new MeasurementTuple(); this.logger = null; mid = new MeasId(at); InitMisc(); }
/// <summary> /// Constructs a new Measurement object with default values /// </summary> /// <param name="at">The measurement method or goal</param> /// <param name="logger">the logger handle</param> public Measurement(AssaySelector.MeasurementOption at, LMLoggers.LognLM logger) { mt = new MeasurementTuple(); this.logger = logger; mid = new MeasId(at); InitMisc(); }
public Measurement(MeasurementTuple newMT, AssaySelector.MeasurementOption at, NCCReporter.LMLoggers.LognLM logger) { mt = newMT; this.logger = logger; mid = new MeasId(at); InitMisc(); }
void LoadList(AssaySelector.MeasurementOption filter) { listView1.ShowItemToolTips = true; int mlistIndex = 0; foreach (Measurement m in mlist) { int CycleCount = N.App.DB.GetCycleCount(m.MeasurementId); string ItemWithNumber = string.IsNullOrEmpty(m.MeasurementId.Item.item) ? "-" : m.AcquireState.ItemId.item; if (Path.GetFileName(m.MeasurementId.FileName).Contains("_") && (AssaySelector.MeasurementOption.verification == filter) && (filter == m.MeasOption)) { //scan file name to display subsequent reanalysis number...... hn 9.21.2015 ItemWithNumber += "(" + Path.GetFileName(m.MeasurementId.FileName).Substring(Path.GetFileName(m.MeasurementId.FileName).IndexOf('_') + 1, 2) + ")"; } string col0; if (Goal == EndGoal.Reanalysis) { col0 = m.MeasurementId.UniqueId.ToString(); } else { col0 = m.MeasOption.PrintName(); } ListViewItem lvi = new ListViewItem(new string[] { col0, m.Detector.Id.DetectorId, ItemWithNumber, string.IsNullOrEmpty(m.AcquireState.stratum_id.Name) ? "-" : m.AcquireState.stratum_id.Name, m.MeasDate.DateTime.ToString("yy.MM.dd HH:mm:ss"), GetMainFilePath(m.ResultsFiles, m.MeasOption, true), CycleCount.ToString(), AssaySelector.ForMass(m.MeasOption) ? m.AcquireState.item_type : string.Empty, m.AcquireState.comment, mlistIndex.ToString() // subitem at index 9 has the original mlist index of this element }); listView1.Items.Add(lvi); lvi.Tag = m.MeasDate; // for proper column sorting string p = GetMainFilePath(m.ResultsFiles, m.MeasOption, false); if (string.IsNullOrEmpty(p)) { lvi.ToolTipText = "(" + m.MeasurementId.UniqueId.ToString() + ") No results file available"; } else { lvi.ToolTipText = "(" + m.MeasurementId.UniqueId.ToString() + ") " + p; } mlistIndex++; } MCount.Text = listView1.Items.Count.ToString() + " measurements"; if (listView1.SelectedItems.Count > 0) { MCountSel.Text = listView1.SelectedItems.Count.ToString(); } else { MCountSel.Text = string.Empty; } }
bool PrepList(AssaySelector.MeasurementOption filter, Detector det) { if (Goal == EndGoal.Report) { if (LMOnly) // LMOnly { mlist.RemoveAll(EmptyCSVFile); // cull those without LM CSV results } else { mlist.RemoveAll(EmptyINCC5File); // cull those with traditional INCC5 results } } ctrllog = N.App.Loggers.Logger(LMLoggers.AppSection.Control); if (mlist.Count == 0) { string msg = string.Format("No {0}measurements for {1} found.", TypeTextFragment(filter), det == null ? "any" : det.Id.DetectorId); MessageBox.Show(msg, "WARNING"); return(false); } LoadList(filter); if (Goal == EndGoal.Report || Goal == EndGoal.Reanalysis || Goal == EndGoal.Transfer) // it is for a named detector so elide the detector column { listView1.Columns[1].Width = 0; } if (!AllMeas) { listView1.Columns[0].Width = 0; } if (filter == AssaySelector.MeasurementOption.rates) // show item id { listView1.Columns[2].Width = 0; } if (filter == AssaySelector.MeasurementOption.normalization) { listView1.Columns[2].Width = 0; listView1.Columns[3].Width = 0; } if (filter == AssaySelector.MeasurementOption.background) // NEXT: add configuration active or passive column { listView1.Columns[2].Width = 0; listView1.Columns[3].Width = 0; } if (!AssaySelector.ForMass(filter) && !filter.IsWildCard()) { listView1.Columns[7].Width = 0; // material column } if (Goal == EndGoal.Reanalysis) { listView1.Columns[0].Text = "Id"; listView1.Columns[0].Width = 43; } return(true); }
void LoadMeasurementDetails(TreeNode tn, string d, AssaySelector.MeasurementOption mo) { List <INCCDB.IndexedResults> ilist = N.App.DB.IndexedResultsFor(d, mo.ToString(), "All"); foreach (INCCDB.IndexedResults ir in ilist) { ir.Rid = N.App.DB.GetCycleCount(ir.Mid); string l = ir.DateTime.ToString("yy.MM.dd HH:mm:ss"); TreeNode nn = tn.Nodes.Add(l); nn.Tag = ir; } }
static void BuildMeasurement() { Detector det = null; AcquireParameters ap = null; AssaySelector.MeasurementOption mo = (AssaySelector.MeasurementOption)N.App.Config.Cur.AssayType; Integ.GetCurrentAcquireDetectorPair(ref ap, ref det); INCCDB.AcquireSelector sel = new INCCDB.AcquireSelector(det, ap.item_type, DateTime.Now); N.App.DB.ReplaceAcquireParams(sel, ap); // add new or replace existing with new // The acquire is set to occur, build up the measurement state Integ.BuildMeasurement(ap, det, mo); }
static void BuildMeasurement() { Detector det = null; AcquireParameters ap = null; AssaySelector.MeasurementOption mo = (AssaySelector.MeasurementOption)NC.App.Config.Cur.AssayType; Integ.GetCurrentAcquireDetectorPair(ref ap, ref det); INCCDB.AcquireSelector sel = new INCCDB.AcquireSelector(det, ap.item_type, DateTime.Now); NC.App.DB.AcquireParametersMap().Add(sel, ap); // it's a new one, not the existing one modified NC.App.DB.UpdateAcquireParams(ap, det.ListMode); // The acquire is set to occur, build up the measurement state Integ.BuildMeasurement(ap, det, mo); }
public IDDMeasurementList(AssaySelector.MeasurementOption filter, bool alltypes, EndGoal goal, Detector detector = null) { InitializeComponent(); System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; try { InitSort(); PrepNotepad(); SetTitlesAndChoices(filter, alltypes, goal, detector == null ? string.Empty : detector.Id.DetectorId, string.Empty); mlist = N.App.DB.MeasurementsFor(detector == null ? string.Empty : detector.Id.DetectorId, filter); bGood = PrepList(filter, detector); } finally { System.Windows.Input.Mouse.OverrideCursor = null; } SummarySelections = null; }
string TypeTextFragment(AssaySelector.MeasurementOption filter) { if (filter.IsListMode() && LMOnly) { return("List Mode "); } else { if (AllMeas) { return(string.Empty); } else { return((AssaySelector.MeasurementOption.rates == filter ? "Rates Only" : filter.PrintName()) + " "); } } }
AssaySelector.MeasurementOption NCCMeasOption(INCCReviewFile irf) { // INCC5 semantics: ASCII vV 86 118, bB 66 98, nN 78 110 AssaySelector.MeasurementOption mo = AssaySelector.MeasurementOption.unspecified; if (irf.meas_option == 118 || irf.meas_option == 86) { mo = AssaySelector.MeasurementOption.verification; } else if (irf.meas_option == 66 || irf.meas_option == 98) { mo = AssaySelector.MeasurementOption.background; } else if (irf.meas_option == 78 || irf.meas_option == 110) { mo = AssaySelector.MeasurementOption.normalization; } return(mo); }
/// <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)); FillInMeasurementDetails(meas); // ready for insertion of methods and processing start }
void SetTitlesAndChoices(AssaySelector.MeasurementOption filter, bool alltypes, EndGoal goal, string detector = "", string inspnum = "") { string upthehill = "Measurement Selection for Detector"; string backwards = "Measurement Selection for All Detectors"; string itwillbe = "Select Measurement for Detector"; string allright = "Select Measurements to Save for Detector"; AllMeas = alltypes; Goal = goal; string title = ""; if (Goal == EndGoal.Report) { title = upthehill; } else if (Goal == EndGoal.Summary) { title = backwards; } else if (Goal == EndGoal.Reanalysis) { title = itwillbe; listView1.MultiSelect = false; } else // if (Goal == EndGoal.Transfer) { title = allright; } if (!AllMeas && Goal != EndGoal.Reanalysis) { title = (filter.PrintName() + " " + title); } if (!string.IsNullOrEmpty(detector)) { title += (" " + detector); } if (!string.IsNullOrEmpty(inspnum)) { title += (", Inspection #" + inspnum); } Text = title; }
private string GetMainFilePath(ResultFiles files, AssaySelector.MeasurementOption mo, bool elide) { string res = string.Empty; switch (mo) { case AssaySelector.MeasurementOption.unspecified: res = files.CSVResultsFileName.Path; break; default: res = files.PrimaryINCC5Filename.Path; break; } if (elide) { res = Path.GetFileName(res); } return(res); }
public IDDAssaySummary(string whuchuwan) { InitializeComponent(); mlist = N.App.DB.IndexedResultsFor(whuchuwan); if (sel == null) sel = new ResultsSummary(); sel.Option = whuchuwan; LoadInspNumCombo(); SortByStratRadioBtn.Checked = sel.SortStratum; DefaultCurrentRadioBtn.Checked = sel.WithCurrentEndDate; StartDateTimePicker.Value = sel.Start.DateTime; LoadSelections(treeView1.Nodes); string l = option.PrintName(); if (!Enum.TryParse(whuchuwan, out option)) { option = AssaySelector.MeasurementOption.unspecified; l = "Measurement"; } Text = l + " " + Text; }
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"; } }
public void Init(List <INCCDB.IndexedResults> ilist, AssaySelector.MeasurementOption filter, EndGoal goal, bool lmonly, string inspnum = "", Detector detector = null) { LMOnly = lmonly; bool alltypes = filter.IsWildCard() && !lmonly; System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait; try { PrepNotepad(); SetTitlesAndChoices(filter, alltypes, goal, detector == null ? string.Empty : detector.Id.DetectorId, string.Empty); mlist = N.App.DB.MeasurementsFor(ilist, LMOnly, skipMethods: false); bGood = PrepList(filter, detector); } finally { System.Windows.Input.Mouse.OverrideCursor = null; } }
public IDDAssaySummary(string whuchuwan) { InitializeComponent(); mlist = N.App.DB.IndexedResultsFor(whuchuwan); if (sel == null) { sel = new ResultsSummary(); } sel.Option = whuchuwan; LoadInspNumCombo(); SortByStratRadioBtn.Checked = sel.SortStratum; DefaultCurrentRadioBtn.Checked = sel.WithCurrentEndDate; StartDateTimePicker.Value = sel.Start.DateTime; LoadSelections(treeView1.Nodes); string l = option.PrintName(); if (!Enum.TryParse(whuchuwan, out option)) { option = AssaySelector.MeasurementOption.unspecified; l = "Measurement"; } Text = l + " " + Text; }
/// <summary> /// Process one or more .NCC Review measurement data files, with related .NOP/.COP files. /// Presence of NOP/COP files is optional /// See Import Operator Declarations from Operator Review and Measurements from Radiation Review p. 24, /// See Operator Declaration File Format p. 87, /// See Operator Declaration File Format for Curium Ratio Measurements p. 88, /// See Radiation Review Measurement Data File Format p. 93, INCC Software Users Manual, March 29, 2009 /// </summary> void INCCReviewFileProcessing() { FireEvent(EventType.ActionPrep, this); NC.App.Opstate.StampOperationStartTime(); // This code would be the same for an interactive version of this operation // > Start here // first find and process and .NOP files List <string> exts = new List <string>() { ".nop", ".cop" }; FileList <CSVFile> hdlr = new FileList <CSVFile>(); hdlr.Init(exts, ctrllog); FileList <CSVFile> files = null; OPFiles opfiles = new OPFiles(); // The INCC5 semantics if (NC.App.AppContext.FileInputList == null) { files = (FileList <CSVFile>)hdlr.BuildFileList(NC.App.AppContext.FileInput, NC.App.AppContext.Recurse, true); } else { files = (FileList <CSVFile>)hdlr.BuildFileList(NC.App.AppContext.FileInputList); } if (files != null && files.Count > 0) { // construct lists of isotopics and items from the NOP and COP files opfiles.Process(files); ctrllog.TraceEvent(LogLevels.Verbose, 33085, "NOP items " + opfiles.Results.ItemIds.Count); //ctrllog.TraceEvent(LogLevels.Verbose, 33085, "COP entries " + opfiles.Results.COPRatioRecs.Count); } else { ctrllog.TraceEvent(LogLevels.Warning, 33085, "No operator declarations available, continuing with default values"); } // process the NCC files only INCCFileOrFolderInfo foo = new INCCFileOrFolderInfo(ctrllog, "*.NCC"); if (NC.App.AppContext.FileInputList == null) { foo.SetPath(NC.App.AppContext.FileInput); } else { foo.SetFileList(NC.App.AppContext.FileInputList); } foo.eh += new TransferEventHandler((s, e) => { FireEvent(EventType.ActionInProgress, e); }); List <INCCTransferBase> res = foo.Restore(); // use RemoveAll to cull those NCC files that reference a non-existent detector DetectorList dl = NC.App.DB.Detectors; foreach (INCCReviewFile rf in res) { List <Detector> tdk = dl.FindAll(d => 0 == string.Compare(d.Id.DetectorName, rf.detector, true)); if (tdk.Count < 1) { rf.skip = true; ctrllog.TraceEvent(LogLevels.Warning, 33085, "No detector " + rf.detector + " defined, cannot complete processing NCC review file " + System.IO.Path.GetFileName(rf.Path)); } } res.RemoveAll(rf => (rf as INCCReviewFile).skip); res.Sort((rf1, rf2) => // sort chronologically { return(DateTime.Compare((rf1 as INCCReviewFile).dt, (rf2 as INCCReviewFile).dt)); }); /// end here > The sorted, filtered and processed list here would be returned to the UI for display and interactive selection if (res == null || res.Count < 1) { NC.App.Opstate.StopTimer(); NC.App.Opstate.StampOperationStopTime(); FireEvent(EventType.ActionStop, this); ctrllog.TraceEvent(LogLevels.Warning, 33085, "No usable NCC review files found in " + System.IO.Path.GetFullPath(foo.GetPath())); return; } AcquireParameters orig_acq = new AcquireParameters(NC.App.Opstate.Measurement.AcquireState); // Each NCC file is a separate measurement foreach (INCCReviewFile irf in res) { ResetMeasurement(); if (NC.App.Opstate.IsQuitRequested) { break; } // Find the detector named in the NCC file (existence shown in earlier processing above) Detector curdet = NC.App.DB.Detectors.Find(d => string.Compare(d.Id.DetectorName, irf.detector, true) == 0); if (curdet.AB.Unset) { ABKey abkey = new ABKey(curdet.MultiplicityParams, 512); // NEXT: maxbins is arbitrary, just the first of many for VSR LMRawAnalysis.SDTMultiplicityCalculator.SetAlphaBeta(abkey, curdet.AB); } // set up acquire state based on the NCC file content AcquireParameters newacq = ConfigureAcquireState(curdet, orig_acq, irf); AssaySelector.MeasurementOption mo = NCCMeasOption(irf); // make a temp MeasId MeasId thisone = new MeasId(mo, newacq.MeasDateTime); // get the list of measurement Ids for this detector List <MeasId> list = NC.App.DB.MeasurementIds(curdet.Id.DetectorName, mo.PrintName()); MeasId already = list.Find(mid => mid.Equals(thisone)); if (already != null) { // URGENT: do the replacement as it says ctrllog.TraceEvent(LogLevels.Warning, 33085, "Replacing the matching {0} measurement, timestamp {1} (in a future release)", already.MeasOption.PrintName(), already.MeasDateTime.ToString()); } IntegrationHelpers.BuildMeasurement(newacq, curdet, mo); Measurement meas = NC.App.Opstate.Measurement; meas.MeasDate = newacq.MeasDateTime; // use the date and time from the NCC file content meas.Persist(); // preserve the basic results record if (AssaySelector.ForMass(meas.MeasOption) && !meas.INCCAnalysisState.Methods.AnySelected()) { ctrllog.TraceEvent(LogLevels.Warning, 437, "No mass methods for " + meas.INCCAnalysisState.Methods.selector.ToString()); } try { ushort total_number_runs = 0; double run_count_time = 0; double total_good_count_time = 0; if (irf.num_runs == 0) { ctrllog.TraceEvent(LogLevels.Error, 440, "This measurement has no good cycles."); continue; } if (meas.MeasOption == AssaySelector.MeasurementOption.holdup) { continue; } /* convert to total count time */ total_number_runs = irf.num_runs; total_good_count_time = irf.num_runs * run_count_time; meas.RequestedRepetitions = total_number_runs; // convert runs to cycles for (int i = 0; i < irf.num_runs; i++) { /* run date and time (IAEA format) */ AddReviewFileCycle(i, irf.runs[i], irf.times[i], meas, irf.Path); if (i % 8 == 0) { FireEvent(EventType.ActionInProgress, this); } } FireEvent(EventType.ActionInProgress, this); // NEXT: handle true AAS cycles as in INCC5 if (meas.MeasOption == AssaySelector.MeasurementOption.verification && meas.INCCAnalysisState.Methods.Has(AnalysisMethod.AddASource) && meas.AcquireState.well_config == WellConfiguration.Passive) { ctrllog.TraceEvent(LogLevels.Error, 440, "No add-a-source data processed because the implementation is incomplete. AAS"); //AddASourceSetup aass = IntegrationHelpers.GetCurrentAASSParams(meas.Detector); //for (int n = 1; n <= aass.number_positions; n++) //{ // /* number of good runs */ // string l = td.reader.ReadLine(); // if (td.reader.EndOfStream) // { // ctrllog.TraceEvent(LogLevels.Error, 440, "No add-a-source data found in disk file. " + "AAS p" + n.ToString()); // } //} } } catch (Exception e) { NC.App.Opstate.SOH = OperatingState.Trouble; ctrllog.TraceException(e, true); ctrllog.TraceEvent(LogLevels.Error, 437, "NCC file processing stopped with error: '" + e.Message + "'"); } finally { NC.App.Loggers.Flush(); } FireEvent(EventType.ActionInProgress, this); ComputeFromINCC5SRData(meas); FireEvent(EventType.ActionInProgress, this); } NC.App.Opstate.ResetTokens(); NC.App.Opstate.SOH = OperatingState.Stopping; NC.App.Opstate.StampOperationStopTime(); FireEvent(EventType.ActionFinished, this); }
public AssayState(AssaySelector.MeasurementOption at = AssaySelector.MeasurementOption.unspecified) { }
void DatazFileAssay() { List <string> exts = new List <string>() { ".dataz" }; FileList <DatazFile> hdlr = new FileList <DatazFile>(); hdlr.Init(exts, ctrllog); FileList <DatazFile> files = null; // initialize operation timer here NC.App.Opstate.ResetTimer(filegather, files, 170, (int)NC.App.AppContext.StatusTimerMilliseconds); FireEvent(EventType.ActionPrep, this); NC.App.Opstate.StampOperationStartTime(); if (NC.App.AppContext.FileInputList == null) { files = (FileList <DatazFile>)hdlr.BuildFileList(NC.App.AppContext.FileInput, NC.App.AppContext.Recurse, true); } else { files = (FileList <DatazFile>)hdlr.BuildFileList(NC.App.AppContext.FileInputList); } if (files == null || files.Count < 1) { NC.App.Opstate.StopTimer(); NC.App.Opstate.StampOperationStopTime(); FireEvent(EventType.ActionStop, this); ctrllog.TraceEvent(LogLevels.Warning, 33085, "No usable Dataz files found"); return; } AssaySelector.MeasurementOption mo = NC.App.Opstate.Measurement.MeasOption; foreach (DatazFile mc in files) { Measurement meas = null; try { if (!mc.OpenForReading()) { continue; } if (NC.App.Opstate.IsQuitRequested) { break; } mc.ScanSections(); mc.ProcessSections(); if (mc.Cycles.Count == 0) { ctrllog.TraceEvent(LogLevels.Error, 404, "This Dataz file has no good cycles."); } if (mc.Plateaux.Count == 0) { ctrllog.TraceEvent(LogLevels.Error, 404, $"This Dataz file has no defined sequences, over {mc.Cycles.Count} cycles."); } else { AcquireParameters orig_acq = new AcquireParameters(NC.App.Opstate.Measurement.AcquireState); Detector curdet = NC.App.Opstate.Measurement.Detector; if (mc.AcquistionStateChanged) { orig_acq = new AcquireParameters(NC.App.Opstate.Measurement.AcquireState); curdet = mc.DataZDetector; if (curdet.AB.Unset) { ABKey abkey = new ABKey(curdet.MultiplicityParams, mc.MaxBins); LMRawAnalysis.SDTMultiplicityCalculator.SetAlphaBeta(abkey, curdet.AB); } } ctrllog.TraceInformation($"{mc.Cycles.Count} cycles and {mc.Plateaux.Count} sequences encountered in Dataz file {mc.Filename}"); System.Collections.IEnumerator iter = mc.GetSequences(); while (iter.MoveNext()) { DatazFile.Plateau pla = (DatazFile.Plateau)iter.Current; ResetMeasurement(); // update acq and then meas here AcquireParameters newacq = ConfigureAcquireState(curdet, orig_acq, pla.Cycles[0].DTO, (ushort)pla.Num, mc.Filename); newacq.data_src = ConstructedSource.DatazFile; IntegrationHelpers.BuildMeasurement(newacq, curdet, mo); meas = NC.App.Opstate.Measurement; meas.MeasDate = newacq.MeasDateTime; meas.Persist(); // preserve the basic results record meas.RequestedRepetitions = (ushort)pla.Num; for (int i = 0; i < meas.RequestedRepetitions; i++) { /* run date and time (IAEA format) */ AddMCSRDataCycle(i, pla.Cycles[i], meas, mc.Filename); if (i % 8 == 0) { FireEvent(EventType.ActionInProgress, this); } } FireEvent(EventType.ActionInProgress, this); ComputeFromINCC5SRData(meas); FireEvent(EventType.ActionInProgress, this); } } } catch (Exception e) { NC.App.Opstate.SOH = OperatingState.Trouble; ctrllog.TraceException(e, true); ctrllog.TraceEvent(LogLevels.Error, 437, "Dataz data file processing stopped with error: '" + e.Message + "'"); } finally { mc.CloseReader(); NC.App.Loggers.Flush(); } } NC.App.Opstate.ResetTokens(); NC.App.Opstate.SOH = OperatingState.Stopping; NC.App.Opstate.StampOperationStopTime(); FireEvent(EventType.ActionFinished, this); }
public static void BuildMeasurementMinimal(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)); CentralizedState.App.Opstate.Measurement = meas; // put the measurement definition on the global state }
public static string PrintName(this AssaySelector.MeasurementOption src) { return(PrintableName[src]); }
void TestDataAssay() { List <string> exts = new List <string>() { ".dat", ".cnn" }; FileList <TestDataFile> hdlr = new FileList <TestDataFile>(); hdlr.Init(exts, ctrllog); FileList <TestDataFile> files = null; // initialize operation timer here NC.App.Opstate.ResetTimer(filegather, files, 170, (int)NC.App.AppContext.StatusTimerMilliseconds); FireEvent(EventType.ActionPrep, this); NC.App.Opstate.StampOperationStartTime(); if (NC.App.AppContext.FileInputList == null) { files = (FileList <TestDataFile>)hdlr.BuildFileList(NC.App.AppContext.FileInput, NC.App.AppContext.Recurse, true); } else { files = (FileList <TestDataFile>)hdlr.BuildFileList(NC.App.AppContext.FileInputList); } if (files == null || files.Count < 1) { NC.App.Opstate.StopTimer(); NC.App.Opstate.StampOperationStopTime(); FireEvent(EventType.ActionStop, this); ctrllog.TraceEvent(LogLevels.Warning, 33085, "No usable Test data/Disk .dat or .cnn files found"); return; } AcquireParameters orig_acq = new AcquireParameters(NC.App.Opstate.Measurement.AcquireState); Detector curdet = NC.App.Opstate.Measurement.Detector; AssaySelector.MeasurementOption mo = NC.App.Opstate.Measurement.MeasOption; if (curdet.AB.Unset) { ABKey abkey = new ABKey(curdet.MultiplicityParams, 512); // NEXT: maxbins is arbitrary, just the first of many for VSR LMRawAnalysis.SDTMultiplicityCalculator.SetAlphaBeta(abkey, curdet.AB); } // Each .dat file is a separate measurement foreach (TestDataFile td in files) { Measurement meas = null; ResetMeasurement(); try { if (!td.OpenForReading()) { continue; } if (NC.App.Opstate.IsQuitRequested) { break; } uint run_seconds; ushort number_good_runs = 0; ushort total_number_runs = 0; double run_count_time = 0; double total_good_count_time = 0; if (mo != AssaySelector.MeasurementOption.holdup) { /* number of good runs */ string l = td.reader.ReadLine(); ushort.TryParse(l, out number_good_runs); if (number_good_runs == 0) { ctrllog.TraceEvent(LogLevels.Error, 440, "This measurement has no good cycles."); continue; } /* run count time */ l = td.reader.ReadLine(); double.TryParse(l, out run_count_time); if (run_count_time <= 0.0) { ctrllog.TraceEvent(LogLevels.Error, 441, "Count time is <= 0."); continue; } } // update acq and then meas here AcquireParameters newacq = ConfigureAcquireState(curdet, orig_acq, DateTimeOffset.Now, number_good_runs, td.Filename); IntegrationHelpers.BuildMeasurement(newacq, curdet, mo); meas = NC.App.Opstate.Measurement; meas.MeasDate = newacq.MeasDateTime; meas.Persist(); // preserve the basic results record /* convert to total count time */ total_number_runs = number_good_runs; total_good_count_time = number_good_runs * run_count_time; meas.RequestedRepetitions = total_number_runs; // update the acq status and do the persist /* read in run data */ for (int i = 0; i < number_good_runs; i++) { /* run date and time (IAEA format) */ run_seconds = (uint)(i * (ushort)run_count_time); // from start time AddTestDataCycle(i, run_seconds, run_count_time, meas, td); if (i % 8 == 0) { FireEvent(EventType.ActionInProgress, this); } } FireEvent(EventType.ActionInProgress, this); if (meas.MeasOption == AssaySelector.MeasurementOption.verification && meas.INCCAnalysisState.Methods.Has(AnalysisMethod.AddASource) && meas.AcquireState.well_config == WellConfiguration.Passive) { AddASourceSetup aass = IntegrationHelpers.GetCurrentAASSParams(meas.Detector); for (int n = 1; n <= aass.number_positions; n++) { /* number of good runs */ string l = td.reader.ReadLine(); if (td.reader.EndOfStream) { ctrllog.TraceEvent(LogLevels.Error, 440, "No add-a-source data found in disk file. AAS p" + n.ToString()); } ushort.TryParse(l, out number_good_runs); if (number_good_runs == 0) { ctrllog.TraceEvent(LogLevels.Error, 440, "This measurement has no good cycles. AAS p" + n.ToString()); continue; } /* run count time */ l = td.reader.ReadLine(); double.TryParse(l, out run_count_time); if (run_count_time <= 0.0) { ctrllog.TraceEvent(LogLevels.Error, 441, "Count time is <= 0. AAS p" + n.ToString()); continue; } /* read in run data */ for (int i = 0; i < number_good_runs; i++) { /* run date and time (IAEA format) */ run_seconds = (uint)((n + 1) * (i + 1) * (ushort)run_count_time); // from start time AddTestDataCycle(i, run_seconds, run_count_time, meas, td, " AAS p" + n.ToString(), n); if (i % 8 == 0) { FireEvent(EventType.ActionInProgress, this); } } FireEvent(EventType.ActionInProgress, this); } } } catch (Exception e) { NC.App.Opstate.SOH = OperatingState.Trouble; ctrllog.TraceException(e, true); ctrllog.TraceEvent(LogLevels.Error, 437, "Test data file processing stopped with error: '" + e.Message + "'"); } finally { td.CloseReader(); NC.App.Loggers.Flush(); } FireEvent(EventType.ActionInProgress, this); ComputeFromINCC5SRData(meas); FireEvent(EventType.ActionInProgress, this); } NC.App.Opstate.ResetTokens(); NC.App.Opstate.SOH = OperatingState.Stopping; NC.App.Opstate.StampOperationStopTime(); FireEvent(EventType.ActionFinished, this); }
public static Measurement BuildMeasurementTemp(AcquireParameters acq, Detector det, AssaySelector.MeasurementOption mo, TestParameters tp, BackgroundParameters bkg, NormParameters np, AnalysisDefs.Isotopics iso, HVCalibrationParameters hvp) { // gather it all together MeasurementTuple mt = new MeasurementTuple(new DetectorList(det), tp, np, bkg, iso, acq, hvp); 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); FillInMeasurementDetails(meas); // ready for insertion of methods and processing start return(meas); }
public static string INCC5Suffix(this AssaySelector.MeasurementOption src) { return(Suffix[src]); }
/// <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 }
public static bool IsListMode(this AssaySelector.MeasurementOption src) { return(src == AssaySelector.MeasurementOption.unspecified); }