/// <summary> /// Store the metadata identifier and the generalized results of a measurement into the database. /// Creates a unique entry for a new measurement. /// Creates an entry for the traditional INCC5 results table for the summary results. /// Detailed measurement results (e.g. cycles, param methods and results), are saved by other methods. /// </summary> /// <returns>Unique database id of the measurement</returns> public long Persist() { logger.TraceEvent(LogLevels.Verbose, 34001, "Preserving measurement ..."); DB.Measurements dbm = new DB.Measurements(); long mid = dbm.Add(name: Detector.Id.DetectorName, date: MeasDate, // NEXT: file-based ops use the file date, but we want to replace with current time stamp mtype: MeasOption.PrintName(), filename: MeasurementId.FileName, // the file names are generated at the end of the process, in GenerateReports, subsequently the database entry is updated with the new file names notes: "2016"); if (mid < 0) { logger.TraceEvent(LogLevels.Warning, 34001, "Measurement not saved"); return(mid); } logger.TraceEvent(LogLevels.Verbose, 34001, "Preserved measurement id {0}", mid); DB.Results dbres = new DB.Results(); // save results with mid as foreign key long rid = dbres.Create(mid, INCCAnalysisResults.TradResultsRec.ToDBElementList()); logger.TraceEvent(LogLevels.Verbose, 34045, "Preserved summary results with id {0}", rid); long c = dbm.CountOf(name: Detector.Id.DetectorName, dt: MeasDate, type: MeasOption.PrintName()); dbm.UpdateNote(c.ToString(), mid); MeasurementId.UniqueId = mid; return(mid); }
/// <summary> /// Store the metadata identfier and the generalized results of a measurement into the database. /// Creates a unique entry for a new measurement. /// Creates an entry for the traditional INCC5 results table for the summary results. /// Detailed measurement results (e.g. cycles, param methods and results), are saved by other methods. /// </summary> /// <returns>Unique database id of the measurement</returns> public long Persist() { logger.TraceEvent(LogLevels.Verbose, 34001, "Preserving measurement ..."); DB.Measurements dbm = new DB.Measurements(); long mid = dbm.Add(name: Detectors[0].Id.DetectorName, date: MeasDate, // NEXT: file-based ops use the file date, but we want to replace with current time stamp mtype: MeasOption.PrintName(), filename: MeasurementId.FileName, // the file names are generated at the end of the process, GenerateReports, update the database at the end notes: "2015"); logger.TraceEvent(LogLevels.Verbose, 34001, "Preserved measurement id {0}", mid); DB.Results dbres = new DB.Results(); // save results with mid as foreign key long rid = dbres.Create(mid, this.INCCAnalysisResults.TradResultsRec.ToDBElementList()); logger.TraceEvent(LogLevels.Verbose, 34045, "Preserved summary results with id {0}", rid); return(mid); }
/// <summary> /// Preserve first generated INCC or LM file name on the measurement id /// todo: save the other file names /// </summary> public void PersistFileNames() { string filename = ResultsFileName; // start with the LM csv default name, in case this is an LM measurement only // But always use the first INCC5 filename for legacy consistency if (INCCResultsFileNames != null && INCCResultsFileNames.Count > 0) // need a defined filename and fully initialized Measurement here { filename = INCCResultsFileNames[0]; } if (!String.IsNullOrEmpty(filename)) // only do the write if it's non-null { DB.Measurements ms = new DB.Measurements(); string type = MeasOption.ToString(); long id; int dupNum = 0; id = ms.Lookup(AcquireState.detector_id, MeasDate, MeasOption.PrintName()); logger.TraceEvent(LogLevels.Verbose, 34001, String.Format("Patching in the first file name...{0} " + filename, dupNum == 1 ? "Original measurement" : "Reanalysis #" + dupNum)); ms.UpdateFileName(filename, id); } }
/// <summary> /// create the results structures, including the methods map from (detector+multcounter) -> (detector+material) -> (results, method results) /// </summary> public void PrepareINCCResults() { IEnumerator iter = CountingAnalysisResults.GetATypedParameterEnumerator(typeof(AnalysisDefs.Multiplicity)); while (iter.MoveNext()) { Multiplicity mcr = (Multiplicity)iter.Current; try { logger.TraceEvent(NCCReporter.LogLevels.Verbose, 4028, "Preparing INCC {0} results for {1}", MeasOption.PrintName(), mcr.ToString()); INCCAnalysisState.PrepareINCCResults(MeasOption, mcr, (MultiplicityCountingRes)CountingAnalysisResults[mcr]); logger.TraceEvent(NCCReporter.LogLevels.Verbose, 4029, "Preparing INCC method {0} results for {1}", INCCAnalysisState.Methods.selector.ToString(), mcr.ToString()); INCCAnalysisState.PrepareINCCMethodResults(mcr, new INCCSelector(INCCAnalysisState.Methods.selector), this); } catch (Exception ex) { logger.TraceEvent(NCCReporter.LogLevels.Error, 4027, "PrepareINCCResults error: " + ex.Message); } } }
/// <summary> /// create the results structures, including the methods map from (detector+multcounter) -> (detector+material) -> (results, method results) /// </summary> public void PrepareINCCResults() { IEnumerator iter = CountingAnalysisResults.GetATypedParameterEnumerator(typeof(Multiplicity)); while (iter.MoveNext()) { bool existed = false; Multiplicity mcr = (Multiplicity)iter.Current; try { existed = INCCAnalysisState.PrepareINCCResults(MeasOption, mcr, (MultiplicityCountingRes)CountingAnalysisResults[mcr]); if (!existed) // it was created just now in PrepareINCCResults { if (logger != null) { logger.TraceEvent(LogLevels.Verbose, 4028, "Preparing INCC {0} results for {1}", MeasOption.PrintName(), mcr.ToString()); } } existed = INCCAnalysisState.PrepareINCCMethodResults(mcr, new INCCSelector(INCCAnalysisState.Methods.selector), this); if (!existed) // it was created just now in PrepareINCCMethodResults { if (logger != null) { logger.TraceEvent(LogLevels.Verbose, 4029, "Preparing INCC method {0} results for {1}", INCCAnalysisState.Methods.selector.ToString(), mcr.ToString()); } } } catch (Exception ex) { if (logger != null) { logger.TraceEvent(LogLevels.Error, 4027, "PrepareINCCResults error: " + ex.Message); } } } }