// dev note: could make this a single function on four subclassed variants of a parent class protected Section ConstructReportSection(RawReportSections section, CycleList cycles) { Section sec = null; if (!(bool)selectedReportSections.GetValue((int)section)) // user selection return sec; try { int i = 1; Row[] temp; IEnumerator iter; switch (section) { case RawReportSections.CoincidenceMatrix: iter = meas.CountingAnalysisResults.GetATypedParameterEnumerator(typeof(AnalysisDefs.Coincidence), true); while (iter.MoveNext()) { SpecificCountingAnalyzerParams sap = (SpecificCountingAnalyzerParams)iter.Current; if (sec == null) sec = new Section(typeof(CoincidenceMatrix), 1); Row r = new Row(); r.Add(0, "Coincidence RA, A and R Matrix results (" + i + ")"); if (sap.suspect || !meas.CountingAnalysisResults.ContainsKey(sap)) { r.Add(1, "Unusable results"); r.Add(2, sap.reason); continue; } sec.AddLabelAndColumn(r, "Cycle"); Row hcrow = sec[sec.Count - 1]; hcrow.Clear(); hcrow.TS = CoincidenceHeader; hcrow.GenFromEnum(typeof(CoincidenceMatrix), "Cycle", 0); foreach (Cycle cyc in cycles) { CoincidenceMatrixResult cor = (CoincidenceMatrixResult)cyc.CountingAnalysisResults[sap]; temp = GenCoincidenceRows(cor, cyc); sec.AddRange(temp); } i++; } break; case RawReportSections.HitsPerChn: // using cycle.HitsPerChannel //iter = meas.CountingAnalysisResults.GetATypedParameterEnumerator(typeof(AnalysisDefs.BaseRate), true); //while (iter.MoveNext()) //{ // SpecificCountingAnalyzerParams sap = (SpecificCountingAnalyzerParams)iter.Current; // if (sec == null) sec = new Section(typeof(RateInterval), 1); // Row r = new Row(); r.Add(0, "Hits per channel (" + i + ")"); // if (sap.suspect || !meas.CountingAnalysisResults.ContainsKey(sap)) // { // r.Add(1, "Unusable results"); // r.Add(2, sap.reason); // continue; // } // sec.AddLabelAndColumn(r, "Cycle"); // Row hcrow = sec[sec.Count - 1]; // hcrow.Clear(); // hcrow.TS = RateHeader; // hcrow.GenFromEnum(typeof(RateInterval), "Cycle", 0); // foreach (Cycle cyc in cycles) // { // RatesResultEnhanced ccrrm = (RatesResultEnhanced)cyc.CountingAnalysisResults[sap]; // temp = GenChnCountsRows(ccrrm, cyc); // sec.AddRange(temp); // } // i++; //} { if (sec == null) sec = new Section(typeof(RateIntervalCalc), 1); Row r = new Row(); r.Add(0, "Hits per channel"); sec.AddLabelAndColumn(r, "Cycle"); Row hcrow = sec[sec.Count - 1]; hcrow.Clear(); hcrow.TS = RateHeader; hcrow.GenFromEnum(typeof(RateInterval), "Cycle", 0); foreach (Cycle cyc in cycles) { temp = GenChnCountsRows(cyc); sec.AddRange(temp); } i++; } break; case RawReportSections.RatePerChn: // Using cycle.HitsPerChannel { if (sec == null) sec = new Section(typeof(RateIntervalCalc), 1); Row r = new Row(); r.Add(0, "Channel hits per second"); sec.AddLabelAndColumn(r, "Cycle"); Row hcrow = sec[sec.Count - 1]; hcrow.Clear(); hcrow.TS = RateHeader; hcrow.GenFromEnum(typeof(RateInterval), "Cycle", 0); foreach (Cycle cyc in cycles) { temp = GenRatesRows(cyc); sec.AddRange(temp); } i++; } break; case RawReportSections.Feynman: iter = meas.CountingAnalysisResults.GetATypedParameterEnumerator(typeof(AnalysisDefs.Feynman), true); while (iter.MoveNext()) { SpecificCountingAnalyzerParams sap = (SpecificCountingAnalyzerParams)iter.Current; if (sec == null) sec = new Section(typeof(Feynman), 1); Row r = new Row(); r.Add(0, "Feynman results (" + i + ")"); sec.AddLabelAndColumn(r, "Cycle"); foreach (Cycle cyc in cycles) { Object obj; bool there = cyc.CountingAnalysisResults.TryGetValue(sap, out obj); if (!there) continue; temp = GenFeynRows((FeynmanResultExt)obj, cyc); sec.AddRange(temp); } i++; } break; case RawReportSections.Rossi: iter = meas.CountingAnalysisResults.GetATypedParameterEnumerator(typeof(AnalysisDefs.Rossi), true); while (iter.MoveNext()) { if (sec == null) sec = new Section(typeof(Rossi), 1); SpecificCountingAnalyzerParams sap = (SpecificCountingAnalyzerParams)iter.Current; Row r = new Row(); r.Add(0, "Rossi-" + '\u03B1' + " results (" + i + ")"); sec.AddLabelAndColumn(r, "Cycle"); foreach (Cycle cyc in cycles) { Object obj; bool there = cyc.CountingAnalysisResults.TryGetValue(sap, out obj); if (!there) continue; temp = GenRossiRows((RossiAlphaResultExt)obj, cyc); sec.AddRange(temp); } i++; } break; case RawReportSections.TimeInterval: iter = meas.CountingAnalysisResults.GetATypedParameterEnumerator(typeof(AnalysisDefs.TimeInterval), true); while (iter.MoveNext()) { if (sec == null) sec = new Section(typeof(TimeInterval), 1); SpecificCountingAnalyzerParams sap = (SpecificCountingAnalyzerParams)iter.Current; Row r = new Row(); r.Add(0, "Time Interval results (" + i + ")"); sec.AddLabelAndColumn(r, "Cycle"); foreach (Cycle cyc in cycles) { Object obj; bool there = cyc.CountingAnalysisResults.TryGetValue(sap, out obj); if (!there) continue; temp = GenTimeIntervalRows((TimeIntervalResult)obj, cyc); sec.AddRange(temp); } i++; } break; } } catch (Exception e) { ctrllog.TraceException(e); } return sec; }
protected Section ConstructReportSection(RawReportSections section) { Section sec = null; if (!(bool)selectedReportSections.GetValue((int)section)) // user selection return sec; try { int i = 1; Row[] temp; IEnumerator iter; switch (section) { case RawReportSections.CoincidenceMatrix: iter = meas.CountingAnalysisResults.GetATypedResultEnumerator(typeof(AnalysisDefs.Coincidence)); while (iter.MoveNext()) { CoincidenceMatrixResult cor = (CoincidenceMatrixResult)iter.Current; if (sec == null) sec = new Section(typeof(CoincidenceMatrix), 1); temp = GenCoincidenceRows(cor); Row r = new Row(); r.Add(0, "Coincidence RA, A and R Matrix results (" + i + ")"); sec.AddLabelAndColumn(r); Row hcrow = sec[sec.Count - 1]; hcrow.Clear(); hcrow.TS = CoincidenceHeader; hcrow.GenFromEnum(typeof(CoincidenceMatrix), null, 0); sec.AddRange(temp); i++; } break; case RawReportSections.Feynman: iter = meas.CountingAnalysisResults.GetATypedResultEnumerator(typeof(AnalysisDefs.Feynman)); while (iter.MoveNext()) { FeynmanResultExt fr = (FeynmanResultExt)iter.Current; if (sec == null) sec = new Section(typeof(Feynman), 1); temp = GenFeynRows(fr); Row r = new Row(); r.Add(0, "Feynman results (" + i + ")"); sec.AddLabelAndColumn(r); sec.AddRange(temp); i++; } break; case RawReportSections.Rossi: iter = meas.CountingAnalysisResults.GetATypedResultEnumerator(typeof(AnalysisDefs.Rossi)); while (iter.MoveNext()) { RossiAlphaResultExt rar = (RossiAlphaResultExt)iter.Current; if (sec == null) sec = new Section(typeof(Rossi), 1); temp = GenRossiRows(rar); Row r = new Row(); r.Add(0, "Rossi-" + '\u03B1' + " results (" + i + ")"); sec.AddLabelAndColumn(r); sec.AddRange(temp); i++; } break; case RawReportSections.TimeInterval: iter = meas.CountingAnalysisResults.GetATypedResultEnumerator(typeof(AnalysisDefs.TimeInterval)); while (iter.MoveNext()) { TimeIntervalResult tir = (TimeIntervalResult)iter.Current; if (sec == null) sec = new Section(typeof(TimeInterval), 1); temp = GenTimeIntervalRows(tir); Row r = new Row(); r.Add(0, "Time Interval results (" + i + ")"); sec.AddLabelAndColumn(r); sec.AddRange(temp); i++; } break; } } catch (Exception e) { ctrllog.TraceException(e); } return sec; }