Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="meas"></param>
        /// <returns></returns>
        public override bool EndOfCycleProcessing(Measurement meas, bool last = false)
        {
            bool happyfun = true;

            if (NC.App.Opstate.SOH == NCC.OperatingState.Living) // all other states mean do not wait here
            {
                // drain analyzer queue
                EndCountingWhenFinishedWithPresentEventQueue();
                // wait for results to be available
                AssayPendingWait();
            }
            else
            {
                logger.TraceEvent(LogLevels.Warning, 952, "Processing is '{0}', not waiting for analyzer completion", NC.App.Opstate.SOH);
                EndAnalysisImmediately(); // again ok?
            }

            // the transformed results are already resident on each SR thread controller object

            try
            {
                // not much for this subclass
                happyfun = state.TransferResults(meas.AnalysisParams);
                Cycle.CountingAnalysisResults.Add(SRCtrl.Det.MultiplicityParams, SRCtrl.TransformedResults);
            }
            catch (System.Exception ex)
            {
                logger.TraceEvent(LogLevels.Error, 142, "EndOfCycleProcessing result transfer internal error: " + ex.Message);
                happyfun = false;
            }
            //try
            //{
            //    // reset the counters
            //    State.Sup.ResetCompletely();
            //}
            //catch (Exception ex)
            //{
            //    logger.TraceEvent(LogLevels.Error, 143, "EndOfCycleProcessing reset internal error: " + ex.Message);
            //    happyfun = false;
            //}
            try
            {
                state.cycle.SetDatastreamEndStatus();
                CycleProcessing.ApplyTheCycleConditioningSteps(state.cycle, meas);
                meas.CycleStatusTerminationCheck(state.cycle);
                FlushCycleSummaryResults();
            }
            catch (System.Exception ex)
            {
                logger.TraceEvent(LogLevels.Error, 144, "EndOfCycleProcessing summary internal error: " + ex.Message);
            }

            return(happyfun);
        }
Example #2
0
        // assumes initalized measurement with at least one cycle, and at least one defined counting analysis result indexed by the detector's mult params, including VSRs fror LM
        void ComputeFromINCC5SRData(Measurement m, bool ABCorrected = false)
        {
            string pre = (m.AcquireState.data_src == ConstructedSource.Reanalysis ? "Rec" : "C");

            ctrllog.TraceEvent(LogLevels.Info, 34071, pre + "omputing: '" + m.MeasurementId.MeasDateTime.ToString() + ", " + m.MeasOption.PrintName() + "'");
            if (m.Cycles.Count < 1)
            {
                ctrllog.TraceEvent(LogLevels.Error, 34830, "Skipping, no cycles on '" + m.MeasurementId.MeasDateTime.ToString() + ", " + m.MeasOption.PrintName() + "'");
                return;
            }

            if (m.CountingAnalysisResults.Count < 1 || !m.CountingAnalysisResults.HasMultiplicity)
            {
                ctrllog.TraceEvent(LogLevels.Error, 34831, "Bad match between detector and this file type." + (!m.CountingAnalysisResults.HasMultiplicity ? " No Multiplicity counter defined." : ""));
                return; //bad match between detector and this file type.
            }

            SRInstrument PseudoInstrument = new SRInstrument(m.Detector);

            PseudoInstrument.selected = true;
            if (!Instruments.Active.Contains(PseudoInstrument))
            {
                Instruments.Active.Add(PseudoInstrument); // add to global runtime list
            }
            m.CurrentRepetition = 0;
            NC.App.Opstate.SOH  = OperatingState.Living;

            try
            {
                MultiplicityCountingRes mcr = (MultiplicityCountingRes)m.CountingAnalysisResults[m.Detector.MultiplicityParams]; // APluralityOfMultiplicityAnalyzers: check for use of multiple analyzers
                // start counting using the per-cycle accumulation of summary results
                Array.Clear(mcr.RAMult, 0, mcr.RAMult.Length);
                Array.Clear(mcr.NormedAMult, 0, mcr.NormedAMult.Length);
                Array.Clear(mcr.UnAMult, 0, mcr.UnAMult.Length);

                mcr.AB.TransferIntermediates(src: m.Detector.AB);                  // remove, redundant copy in most cases
                CycleList cl = m.Cycles;
                m.Cycles = new CycleList();
                foreach (Cycle cycle in cl)             // process incrementally to match expected outlier processing behavior from INCC
                {
                    if (NC.App.Opstate.IsQuitRequested) // exit via abort or quit/save, follow-on code decides to continue with processing
                    {
                        ctrllog.TraceEvent(LogLevels.Warning, 430, "Cycle first-pass processing " + NC.App.Opstate.CancelStopAbortStateRep + " at sequence #" + cycle.seq + ", " + m.CurrentRepetition);
                        break;
                    }
                    m.CurrentRepetition++;
                    m.Cycles.Add(cycle);
                    m.SetQCStatus(cycle);
                    CycleProcessing.ApplyTheCycleConditioningSteps(cycle, m);
                    m.CycleStatusTerminationCheck(cycle);
                    ctrllog.TraceEvent(LogLevels.Verbose, 5439, "Cycle " + cycle.seq.ToString());
                    if (m.CurrentRepetition % 8 == 0)
                    {
                        FireEvent(EventType.ActionInProgress, this);
                    }
                }
                FireEvent(EventType.ActionInProgress, this);
                // trim any None's that were not processed (occurs during a cancel/stop intervention)
                m.Cycles.Trim(m.Detector.MultiplicityParams); // APluralityOfMultiplicityAnalyzers: expand when detector has multiple analyzers
            }
            catch (Exception e)
            {
                NC.App.Opstate.SOH = OperatingState.Trouble;
                ctrllog.TraceException(e, true);
                ctrllog.TraceEvent(LogLevels.Warning, 430, "Processing stopped at cycle " + m.CurrentRepetition);
            }
            finally
            {
                NC.App.Loggers.Flush();
            }

            if (!NC.App.Opstate.IsAbortRequested)  // stop/quit means continue with what is available
            {
                if (m.HasReportableData)
                {
                    m.CalculateMeasurementResults();
                    new ReportMangler(ctrllog).GenerateReports(m);
                    m.SaveMeasurementResults();
                }
            }
            NC.App.Opstate.ResetTokens();
            Instruments.All.Remove(PseudoInstrument);
        }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="meas"></param>
        /// <returns></returns>
        public override bool EndOfCycleProcessing(Measurement meas, bool last = false)
        {
            bool happyfun = true;

            if (last)
            {
                if (NC.App.Opstate.SOH == NCC.OperatingState.Living) // all other states mean do not wait here
                {
                    // drain analyzer queue
                    EndCountingWhenFinishedWithPresentEventQueue();
                    // wait for results to be available
                    AssayPendingWait();
                }
                else
                {
                    logger.TraceEvent(LogLevels.Warning, 952, "Processing is '{0}', not waiting for analyzer completion", NC.App.Opstate.SOH);
                    EndAnalysisImmediately(); // again ok?
                }
                try
                {
                    // reset the counters
                    State.Sup.ResetCompletely(last);
                }
                catch (Exception ex)
                {
                    logger.TraceEvent(LogLevels.Error, 143, "EndOfCycleProcessing reset internal error: " + ex.Message);
                    happyfun = false;
                }
            }
            else
            {
                if (NC.App.Opstate.SOH == NCC.OperatingState.Living) // all other states mean do not wait here
                {
                    // drain analyzer queue
                    EndCountingWhenFinishedWithPresentEventQueue();
                    // wait for results to be available
                    AssayPendingWait();
                }
                else
                {
                    logger.TraceEvent(LogLevels.Warning, 952, "Processing is '{0}', not waiting for analyzer completion", NC.App.Opstate.SOH);
                    EndAnalysisImmediately(); // again ok?
                }

                // get results and put them on the cycle object
                State.Sup.GetCountingResults();

                try
                {
                    // transfer results to my internal representation
                    happyfun = state.TransferResults(meas.AnalysisParams);
                }
                catch (Exception ex)
                {
                    logger.TraceEvent(LogLevels.Error, 142, "EndOfCycleProcessing result transfer internal error: " + ex.Message);
                    happyfun = false;
                }
                try
                {
                    // reset the counters
                    State.Sup.ResetCompletely(last);
                }
                catch (Exception ex)
                {
                    logger.TraceEvent(LogLevels.Error, 143, "EndOfCycleProcessing reset internal error: " + ex.Message);
                    happyfun = false;
                }
                try
                {
                    state.cycle.SetDatastreamEndStatus();
                    CycleProcessing.ApplyTheCycleConditioningSteps(state.cycle, meas);
                    meas.CycleStatusTerminationCheck(state.cycle);
                }
                catch (Exception ex)
                {
                    logger.TraceEvent(LogLevels.Error, 144, "EndOfCycleProcessing summary internal error: " + ex.Message);
                }
            }

            return(happyfun);
        }
Example #4
0
        // assumes initalized measurement with at least one cycle, and at least one defined counting analysis result indexed by the detector's mult params
        // NEXT: implement for LM results
        void ComputeFromINCC5SRData(Measurement m)
        {
            ctrllog.TraceEvent(LogLevels.Info, 34071, "Recomputing: '" + m.MeasurementId.MeasDateTime.ToString() + ", " + m.MeasOption.PrintName() + "'");
            if (m.Cycles.Count < 1)
            {
                ctrllog.TraceEvent(LogLevels.Error, 34830, "Skipping, no cycles on '" + m.MeasurementId.MeasDateTime.ToString() + ", " + m.MeasOption.PrintName() + "'");
                return;
            }

            if (m.CountingAnalysisResults.Count < 1 || !m.CountingAnalysisResults.HasMultiplicity)
            {
                ctrllog.TraceEvent(LogLevels.Error, 34831, "Bad match between detector and this file type." + (!m.CountingAnalysisResults.HasMultiplicity ? " No Multiplicity counter defined." : ""));
                return; //bad match between detector and this file type.
            }

            SRInstrument PseudoInstrument = new SRInstrument(m.Detectors[0]);

            PseudoInstrument.selected = true;
            if (!Instruments.Active.Contains(PseudoInstrument))
            {
                Instruments.Active.Add(PseudoInstrument); // add to global runtime list
            }
            m.CurrentRepetition = 0;
            NC.App.Opstate.SOH  = NCC.OperatingState.Living;

            try
            {
                // urgent: there is more work to do for the bins and AB here, AB can be copied from the detector values
                MultiplicityCountingRes mcr = (MultiplicityCountingRes)m.CountingAnalysisResults[m.Detectors[0].MultiplicityParams]; // multmult
                // start counting using the per-cycle accumulation of summary results
                Array.Clear(mcr.RAMult, 0, mcr.RAMult.Length);
                Array.Clear(mcr.NormedAMult, 0, mcr.NormedAMult.Length);
                mcr.AB.TransferIntermediates(src: m.Detectors[0].AB);

                foreach (AnalysisDefs.Cycle cycle in m.Cycles)
                {
                    if (NC.App.Opstate.IsQuitRequested)  // exit via abort or quit/save, follow-on code decides to continue with processing
                    {
                        ctrllog.TraceEvent(LogLevels.Warning, 430, "Cycle first-pass processing " + NC.App.Opstate.CancelStopAbortStateRep + " at sequence #" + cycle.seq + ", " + m.CurrentRepetition);
                        break;
                    }
                    m.CurrentRepetition++;
                    cycle.SetQCStatus(m.Detectors[0].MultiplicityParams, QCTestStatus.Pass, cycle.HighVoltage);  // multmult prep for analyis one by one
                    CycleProcessing.ApplyTheCycleConditioningSteps(cycle, m);
                    m.CycleStatusTerminationCheck(cycle);
                    ctrllog.TraceEvent(LogLevels.Verbose, 5439, "Cycle " + cycle.seq.ToString());
                    if (m.CurrentRepetition % 8 == 0)
                    {
                        FireEvent(EventType.ActionInProgress, this);
                    }
                }
                FireEvent(EventType.ActionInProgress, this);
                // trim any None's that were not processed (occurs during a cancel/stop intervention)
                m.Cycles.Trim(m.Detectors[0].MultiplicityParams); // multmult
            }
            catch (Exception e)
            {
                NC.App.Opstate.SOH = NCC.OperatingState.Trouble;
                ctrllog.TraceException(e, true);
                ctrllog.TraceEvent(LogLevels.Warning, 430, "Processing stopped at cycle " + m.CurrentRepetition);
            }
            finally
            {
                NC.App.Loggers.Flush();
            }

            if (!NC.App.Opstate.IsAbortRequested)  // stop/quit means continue with what is available
            {
                // todo:            if (meas.HasReportableData)
                m.CalculateMeasurementResults();
                new ReportMangler(ctrllog).GenerateReports(m);
                m.SaveMeasurementResults();
            }
            NC.App.Opstate.ResetTokens();
            Instruments.All.Remove(PseudoInstrument);
        }