示例#1
0
        /// <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);
        }
示例#2
0
 private void OKBtn_Click(object sender, EventArgs e)
 {
     DB.Measurements meas = new DB.Measurements ();
     bool success = true;
     foreach (ListViewItem lvi in MeasurementView.Items)
     {
         if (lvi.Selected)
         {
             DateTime dt;
             DateTime.TryParseExact (lvi.SubItems[4].Text + lvi.SubItems[5].Text,"yyyy/MM/ddHH:mm:ss",null,System.Globalization.DateTimeStyles.None, out dt);
             success = meas.Delete(lvi.SubItems[0].Text, dt, lvi.SubItems[1].Text) || success;
             LoadMeasurementList();
         }
     }
 }
示例#3
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            DB.Measurements meas    = new DB.Measurements();
            bool            success = true;

            foreach (ListViewItem lvi in MeasurementView.Items)
            {
                if (lvi.Selected)
                {
                    DateTime dt;
                    DateTime.TryParseExact(lvi.SubItems[4].Text + lvi.SubItems[5].Text, "yyyy/MM/ddHH:mm:ss", null, System.Globalization.DateTimeStyles.None, out dt);
                    success = meas.Delete(lvi.SubItems[0].Text, dt, lvi.SubItems[1].Text) || success;
                    LoadMeasurementList();
                }
            }
        }
示例#4
0
        /// <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);
        }
示例#5
0
        /// <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);
            }
        }
示例#6
0
        /// <summary>
        /// Save in the database the summary <see cref="INCCResults.results_rec"/> results for every type of INCC measurement.
        /// </summary>
        /// <param name="m">The measurement to preserve</param>
        /// <param name="moskey">The option selector+multiplicity key for the method results map</param> 
        static void SaveSummaryResultsForThisMeasurement(this Measurement m, MeasOptionSelector moskey)
        {
            DB.Measurements ms = new DB.Measurements();
            long mid = ms.Lookup(m.Detectors[0].Id.DetectorName, m.MeasDate, m.MeasOption.PrintName());

            DB.Results dbres = new DB.Results(ms.db);
            // save results with mid as foreign key
            bool b = dbres.Update(mid, m.INCCAnalysisResults.TradResultsRec.ToDBElementList());
            m.Logger.TraceEvent(NCCReporter.LogLevels.Info, 34045, (b ? "Preserved " : "Failed to save ") + "summary results");

        }
示例#7
0
 /// <summary>
 /// Save specific analysis results for Background, Initial Source, Normalization and Precision measurements.
 /// </summary>
 /// <param name="m">The measurement to preserve</param>
 /// <param name="res">The subclassed specific results instance</param> 
 static void SaveSpecificResultsForThisMeasurement(this Measurement m, INCCResult res)
 {
     DB.Measurements ms = new DB.Measurements();
     long mid = ms.Lookup(m.Detectors[0].Id.DetectorName, m.MeasDate, m.MeasOption.PrintName());
     DB.ElementList els = res.ToDBElementList(); // generates the Table property content too
     DB.ParamsRelatedBackToMeasurement ar = new DB.ParamsRelatedBackToMeasurement(res.Table, ms.db);
     long resid = ar.Create(mid, els);                          
     m.Logger.TraceEvent(NCCReporter.LogLevels.Verbose, 34103, String.Format("Results {0} preserved ({1})",resid, res.Table));
 }
示例#8
0
        /// <summary>
        /// Save in the database the method results and copies of the current method parameters.
        /// The table entries are related back to the measurement.
        /// The method results are preserved in the results_\<method table name\> and \<method table name\>_m DB tables.
        /// </summary>
        /// <param name="m">The measurement to preserve</param>
        /// <param name="moskey">The option selector+multiplicity key for the method results map</param> 
        static void SaveMethodResultsForThisMeasurement(this Measurement m, MeasOptionSelector moskey)
        {
            DB.Measurements ms = new DB.Measurements();
            long mid = ms.Lookup(m.Detectors[0].Id.DetectorName, m.MeasDate, m.MeasOption.PrintName());

            INCCMethodResults imrs;
            bool gotten = m.INCCAnalysisResults.TryGetINCCResults(moskey.MultiplicityParams, out imrs);
            if (gotten && imrs.Count > 0) // expected to be true for verification and calibration
            {
                //The distinct detector id and material type index the methods and the method results
                Dictionary<AnalysisMethod, INCCMethodResult> amimr = imrs[m.INCCAnalysisState.Methods.selector];
                // now get an enumerator over the map of method results
                Dictionary<AnalysisMethod, INCCMethodResult>.Enumerator ai = amimr.GetEnumerator();
                while (ai.MoveNext())
                {
                    INCCMethodResult imr = ai.Current.Value;
                    DB.ElementList els = imr.ToDBElementList(); // generates the Table property content too
                    DB.ParamsRelatedBackToMeasurement ar = new DB.ParamsRelatedBackToMeasurement(imr.Table, ms.db);
                    long resid = ar.Create(mid, els);  // save the method results in the relevant results table
                    long mresid = ar.CreateMethod(resid, mid, imr.methodParams.ToDBElementList()); // save the initial method params (the copy rides on the results)
                    m.Logger.TraceEvent(NCCReporter.LogLevels.Verbose, 34104, String.Format("Method results {0} preserved ({1}{2})", imr.Table, resid, mresid));
                }
            }                        
        }
示例#9
0
        /// <summary>
        /// Preserve a measurement cycle list in a database
        /// Limited to INCC5 SR values
        /// URGENT: save results for EACH mkey (e.g. LM), not just the first one; save LM-specific cycle info, e.g. list mode channel results, per cycle counting results for raw LM analyses, output file name
        /// URGENT: status shoud be set on db acquire lists, becuse it can read in 1500 but only 1450 are good, or cancel can cause only 20 to have been processed so we should only use the processed cycles.
        /// </summary>
        /// <param name="m">The measurement containing the cycles to preserve</param>
        public static void SaveMeasurementCycles(this Measurement m)
        {
            DB.Measurements ms = new DB.Measurements();
            long mid = ms.Lookup(m.Detectors[0].Id.DetectorName, m.MeasDate, m.MeasOption.PrintName());
            //Could we actually not do this when reanalyzing? hn 9.21.2015
            NC.App.DB.AddCycles(m.Cycles, m.Detectors[0].MultiplicityParams, mid, ms);
            m.Logger.TraceEvent(NCCReporter.LogLevels.Verbose, 34105, String.Format("{0} cycles stored", m.Cycles.Count));

        }