示例#1
0
        static void StopThisSRAssayImmediately(SRTakeDataHandler.SRControlThread srct)
        {
            srct.sri.PendingComplete();
            // stop the single SR thread
            srct.CancelMe();
            srct.sri.DAQState = DAQInstrState.Offline;
            srct.SRCtrl.Log.TraceEvent(LogLevels.Info, 428, "SR {0} DAQ cancelled", srct.sri.id.Identifier());

            // dev note: this still isn't working very well, need to completely fix the early termination logic, it should exit cleanly without extra cycle and results processing
            //srct.sri.RDT.EndOfCycleProcessing(NC.App.Opstate.Measurement);
            //srct.sri.selected = false;
            DAQControl.CurState.State = DAQInstrState.Online;
            gControl.MajorOperationCompleted(); // the overall pend handle used by cmd line
        }
示例#2
0
        // register this using StartSRControl
        public static void SREventHandler(object sender, SRTakeDataHandler.SROpCompletedEventArgs e)
        {
            SRControl sr = (SRControl)e.UserState;

            // SRTakeDataHandler.SROp next = SRTakeDataHandler.NextOp(e.Op, e.OpStatus);
            sr.Log.TraceEvent(LogLevels.Verbose, 87266, "SR {0} operation {1} completed '{2}'",
                              sr.Identifier, e.Op, INCCSR.SRAPIReturnStatusCode(e.OpStatus));
            try
            {
                switch (e.Op)
                {
                case SRTakeDataHandler.SROp.Shutdown:

                    break;

                case SRTakeDataHandler.SROp.Nothing:

                    break;

                case SRTakeDataHandler.SROp.InitializeContext:

                    break;

                case SRTakeDataHandler.SROp.InitializeSR:
                case SRTakeDataHandler.SROp.ReInitializeSR:
                    if (!(e.OpStatus == INCCSR.SUCCESS || e.OpStatus == INCCSR.MEAS_CONTINUE))
                    {
                        StopThisSRAssayImmediately((SRTakeDataHandler.SRControlThread)sender);
                        //Action<object> action = (object obj) =>
                        //{
                        //    StopThisSRAssayImmediately((SRTakeDataHandler.SRControlThread)obj);
                        //};
                        //Task signifyingnothing = Task.Factory.StartNew(action, sender);
                    }
                    break;

                case SRTakeDataHandler.SROp.StartSRDAQ:
                    if (!(e.OpStatus == INCCSR.SUCCESS || e.OpStatus == INCCSR.MEAS_CONTINUE))
                    {
                        StopThisSRAssayImmediately((SRTakeDataHandler.SRControlThread)sender);
                        //Action<object> action = (object obj) =>
                        //{
                        //    StopThisSRAssayImmediately((SRTakeDataHandler.SRControlThread)obj);
                        //};
                        //Task signifyingnothing = Task.Factory.StartNew(action, sender);
                    }
                    break;

                case SRTakeDataHandler.SROp.WaitForResults:
                    if (!(e.OpStatus == INCCSR.SUCCESS || e.OpStatus == INCCSR.MEAS_CONTINUE))
                    {
                        StopThisSRAssayImmediately((SRTakeDataHandler.SRControlThread)sender);
                        //Action<object> action = (object obj) =>
                        //{
                        //    StopThisSRAssayImmediately((SRTakeDataHandler.SRControlThread)obj);
                        //};
                        //Task signifyingnothing = Task.Factory.StartNew(action, sender);
                    }
                    else
                    {
                        SRTakeDataHandler.SRControlThread srct = (SRTakeDataHandler.SRControlThread)sender;
                        sr.Log.TraceEvent(LogLevels.Verbose, 87225, "Transform the results, or get the transformed results");
                        srct.sri.PendingComplete();                            // when we get here, the raw results are already available on the SR thread structure
                        if (srct.sri.DAQState == DAQInstrState.HVCalib)
                        {
                        }
                        else
                        {
                            srct.SRCtrl.TransformResults(srct.SRCtrl.Det.Id, srct.sri.RDT.Cycle);     // convert to enhanced results
                        }
                        HandleEndOfCycleProcessing(srct.sri);
                    }
                    break;

                case SRTakeDataHandler.SROp.CloseSR:
                    break;
                }
            }
            catch (AnalysisDefs.CancellationRequestedException)  // thrown from this method
            {
                StopActiveAssayImmediately();
            }
            catch (Exception oddex)
            {
                sr.Log.TraceEvent(LogLevels.Error, 643, "Internal error, stopping active processing, {0}", oddex.Message);
                if (sender != null)
                {
                    SRTakeDataHandler.SRControlThread srct = (SRTakeDataHandler.SRControlThread)sender;
                    HandleFatalGeneralError(srct.sri, oddex);
                }
                else
                {
                    // will blow if not really an Assay subclass, e.g. not running in the context of the full DAQCOntrol class
                    CurState.State = DAQInstrState.Offline;            // remaining buffers should now bypass DAQ section
                    gControl.StopLMCAssay(removeCurLMDataFile: false); // stop the instruments
                    gControl.collog.TraceException(oddex, false);
                    gControl.collog.TraceEvent(LogLevels.Info, 429, "DAQ processing incomplete: {0}, processing stopped", oddex.Message);
                    //activeInstr.RDT.EndOfCycleProcessing(CurState.Measurement);
                    gControl.MajorOperationCompleted();  // signal the controlling loop we are done
                }
            }
        }