コード例 #1
0
ファイル: Controller.cs プロジェクト: tempbottle/INCC6
 public void ActivateDetector(Detector det = null)
 {
     if (!file)
     {
         DAQBind.ActivateDetector(det);
     }
 }
コード例 #2
0
ファイル: Controller.cs プロジェクト: hnordquist/INCC6
        /// <summary>
        /// Set up timer callback and action event handlers for a DAQController instance, uses DAQBind subclass
        /// </summary>
        /// <returns></returns>
        public bool InitializeDAQController()
        {
            // DAQ
            daqbind = new DAQBind();
            LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App);

            daqbind.SetEventHandler(ActionEvents.EventType.PreAction, (object o) =>
            {
                string s = DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.PreAction, applog, LogLevels.Verbose, o);
                daqbind.mProgressTracker.ReportProgress(0, s);//"...");
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionPrep, (object o) =>
            {
                string s = "Action Prep: ";
                //can also look at active instrument list here LogLevels.Verbose,
                s = s + Instr.Instruments.Active.Count + " devices found, [" + NC.App.Opstate.SOH + "] " + DateTimeOffset.Now.ToString("MMM dd yyy HH:mm:ss.ff K");
                applog.TraceEvent(LogLevels.Verbose, 0xABCE, "Action Prep: SOH " + o.ToString() + "'");
                daqbind.mProgressTracker.ReportProgress(0, s);//"Prep");
            });
            daqbind.SetEventHandler(ActionEvents.EventType.ActionStart, (object o) =>
            {
                string s = DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionStart, applog, LogLevels.Verbose, o);
                daqbind.mProgressTracker.ReportProgress(1, s);//"Starting...");
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionInProgress, (object o) =>
            {
                measStatus = new MeasurementStatus();
                measStatus.UpdateWithMeasurement();
                measStatus.UpdateWithInstruments();
                updateGUIWithChannelRatesData = true;
                string s2 = DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionInProgress, applog, LogLevels.Verbose, o);
                if (!string.IsNullOrEmpty(s2))
                    s2 = "(" + s2 + ")";
                int per = 0;
                try
                {
                    switch (daqbind.CurAction)
                    {
                    case NCCAction.HVCalibration:
                        if (measStatus.snaps.iss != null && measStatus.snaps.iss.hv != null)
                        {
                            per = Math.Abs(Math.Min(100, (int)Math.Round(100.0 * ((double)(measStatus.snaps.iss.hv.HVread - 1) / measStatus.snaps.iss.hv.HVsetpt))));
                            daqbind.mProgressTracker.ReportProgress(per, // a % est of steps
                                string.Format("{0} volts, with max voltage {1} {2}", measStatus.snaps.iss.hv.HVread, measStatus.snaps.iss.hv.HVsetpt, s2));
                        }
                        break;
                    default:
                        per = Math.Abs(Math.Min(100, (int)Math.Round(100.0 * ((double)(measStatus.CurrentRepetition - 1) / measStatus.RequestedRepetitions))));
                        daqbind.mProgressTracker.ReportProgress(per, // a % est of files
                            string.Format("{0} of {1} {2}", measStatus.CurrentRepetition, measStatus.RequestedRepetitions, s2)); // dev note: need a better focused description of the state
                        break;

                    }
                }
                catch (ArgumentOutOfRangeException)
                {
                    applog.TraceEvent(LogLevels.Verbose, 58,  "{0} inconsistent", per);
                }
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionStop, (object o) =>
            {
                string s = DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionStop, applog, LogLevels.Info, o);
                daqbind.mProgressTracker.ReportProgress(100, s);
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionCancel, (object o) =>
            {
                string s = DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionCancel, applog, LogLevels.Warning, o);
                daqbind.mProgressTracker.ReportProgress(100, s);
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionFinished, (object o) =>
            {
                string s = "";
                if (o != null && o is DAQControl)
                {
                    DAQControl f = (DAQControl)o;
                    measStatus = new MeasurementStatus();  // preps local state for refresh on channel and computed rates for now, follow up with all other state
                    measStatus.UpdateWithMeasurement();
                    s = DAQControl.MeasStatusString(measStatus);
                    updateGUIWithChannelRatesData = true;
                    UpdateGUIWithNewdata();
                }
                else
                {
                    s = "Finished: SOH " + NC.App.Opstate.SOH + " but no processing occurred  " + DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionFinished, applog, LogLevels.Verbose, o);
                }
                NC.App.Opstate.SOH = OperatingState.Stopped;  // in case we got here after a Cancel
                // general logger: to the console, and/or listbox and/or log file or DB
                daqbind.mProgressTracker.ReportProgress(100, s);
                applog.TraceEvent(LogLevels.Verbose, ActionEvents.logid[ActionEvents.EventType.ActionFinished], s);
                // specialized updater for UI or file
                daqbind.mProgressTracker.ReportProgress(100, s);

            });

            return true;
        }
コード例 #3
0
ファイル: Controller.cs プロジェクト: eric645/INCC6
        /// <summary>
        /// Set up timer callback and action event handlers for a DAQController instance, uses DAQBind subclass
        /// </summary>
        /// <returns></returns>
        public bool InitializeDAQController()
        {
            // DAQ
            daqbind = new DAQBind();
            LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App);


            daqbind.SetEventHandler(ActionEvents.EventType.PreAction, (object o) =>
            {
                string s = DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.PreAction, applog, LogLevels.Verbose, o);
                daqbind.mProgressTracker.ReportProgress(0, s);                //"...");
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionPrep, (object o) =>
            {
                string s = "Action Prep: ";
                //can also look at active instrument list here LogLevels.Verbose,
                s = s + Instr.Instruments.Active.Count + " devices found, [" + NC.App.Opstate.SOH + "] " + DateTimeOffset.Now.ToString("MMM dd yyy HH:mm:ss.ff K");
                applog.TraceEvent(LogLevels.Verbose, 0xABCE, "Action Prep: SOH " + o.ToString() + "'");
                daqbind.mProgressTracker.ReportProgress(0, s);                //"Prep");
            });
            daqbind.SetEventHandler(ActionEvents.EventType.ActionStart, (object o) =>
            {
                string s = DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionStart, applog, LogLevels.Verbose, o);
                daqbind.mProgressTracker.ReportProgress(1, s);//"Starting...");
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionInProgress, (object o) =>
            {
                measStatus = new MeasurementStatus();
                measStatus.UpdateWithMeasurement();
                measStatus.UpdateWithInstruments();
                updateGUIWithChannelRatesData = true;
                string s2 = DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionInProgress, applog, LogLevels.Verbose, o);
                if (!string.IsNullOrEmpty(s2))
                {
                    s2 = "(" + s2 + ")";
                }
                int per = 0;
                try
                {
                    switch (daqbind.CurAction)
                    {
                    case NCCAction.HVCalibration:
                        if (measStatus.snaps.iss != null && measStatus.snaps.iss.hv != null)
                        {
                            per = Math.Abs(Math.Min(100, (int)Math.Round(100.0 * ((double)(measStatus.snaps.iss.hv.HVread - 1) / measStatus.snaps.iss.hv.HVsetpt))));
                            daqbind.mProgressTracker.ReportProgress(per,                             // a % est of steps
                                                                    string.Format("{0} volts, with max voltage {1} {2}", measStatus.snaps.iss.hv.HVread, measStatus.snaps.iss.hv.HVsetpt, s2));
                        }
                        break;

                    default:
                        per = Math.Abs(Math.Min(100, (int)Math.Round(100.0 * ((double)(measStatus.CurrentRepetition - 1) / measStatus.RequestedRepetitions))));
                        daqbind.mProgressTracker.ReportProgress(per,                                                                                                 // a % est of files
                                                                string.Format("{0} of {1} {2}", measStatus.CurrentRepetition, measStatus.RequestedRepetitions, s2)); // dev note: need a better focused description of the state
                        break;
                    }
                }
                catch (ArgumentOutOfRangeException)
                {
                    applog.TraceEvent(LogLevels.Verbose, 58, "{0} inconsistent", per);
                }
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionStop, (object o) =>
            {
                string s = DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionStop, applog, LogLevels.Info, o);
                daqbind.mProgressTracker.ReportProgress(100, s);
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionCancel, (object o) =>
            {
                string s = DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionCancel, applog, LogLevels.Warning, o);
                daqbind.mProgressTracker.ReportProgress(100, s);
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionFinished, (object o) =>
            {
                string s = "";
                if (o != null && o is DAQControl)
                {
                    DAQControl f = (DAQControl)o;
                    measStatus   = new MeasurementStatus(); // preps local state for refresh on channel and computed rates for now, follow up with all other state
                    measStatus.UpdateWithMeasurement();
                    s = DAQControl.MeasStatusString(measStatus);
                    updateGUIWithChannelRatesData = true;
                    UpdateGUIWithNewdata();
                }
                else
                {
                    s = "Finished: SOH " + NC.App.Opstate.SOH + " but no processing occurred  " + DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionFinished, applog, LogLevels.Verbose, o);
                }
                NC.App.Opstate.SOH = OperatingState.Stopped;  // in case we got here after a Cancel
                // general logger: to the console, and/or listbox and/or log file or DB
                daqbind.mProgressTracker.ReportProgress(100, s);
                applog.TraceEvent(LogLevels.Verbose, ActionEvents.logid[ActionEvents.EventType.ActionFinished], s);
                // specialized updater for UI or file
                daqbind.mProgressTracker.ReportProgress(100, s);
            });

            return(true);
        }
コード例 #4
0
ファイル: Controller.cs プロジェクト: tempbottle/INCC6
        /// <summary>
        /// Set up timer callback and action event handlers for a DAQController instance, uses DAQBind subclass
        /// </summary>
        /// <returns></returns>
        public bool InitializeDAQController()
        {
            // DAQ
            daqbind = new DAQBind((MLMEmulation.IEmulatorDiversion)(new LMProcessor.NullEmulation()));
            LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App);


            daqbind.SetEventHandler(ActionEvents.EventType.PreAction, (object o) =>
            {
                string s = LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.PreAction, applog, LogLevels.Verbose, o);
				daqbind.mProgressTracker.ReportProgress(0, s);//"...");
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionPrep, (object o) =>
            {
                string s = "Action Prep: ";
                //can also look at active instrument list here LogLevels.Verbose,
                s = s + LMDAQ.Instruments.Active.Count + " devices found, [" + NC.App.Opstate.SOH + "] " + DateTimeOffset.Now.ToString("MMM dd yyy HH:mm:ss.ff K");
                applog.TraceEvent(LogLevels.Verbose, 0xABCE, "Action Prep: SOH " + o.ToString() + "'");
				daqbind.mProgressTracker.ReportProgress(0, s);//"Prep");
            });
            daqbind.SetEventHandler(ActionEvents.EventType.ActionStart, (object o) =>
            {
                enablecontrols(false);
                string s = LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionStart, applog, LogLevels.Verbose, o);
                daqbind.mProgressTracker.ReportProgress(1, s);//"Starting...");
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionInProgress, (object o) =>
            {
                measStatus = new LMProcessor.MeasurementStatus();
                measStatus.UpdateWithMeasurement();
                measStatus.UpdateWithInstruments();
                updateGUIWithChannelRatesData = true;
                string s2 = LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionInProgress, applog, LogLevels.Verbose, o);
				int per = Math.Min(100, (int)Math.Round(100.0 * ((double)measStatus.CurrentRepetition / (double)measStatus.RequestedRepetitions)));
				daqbind.mProgressTracker.ReportProgress(per, // a % est of files
					String.Format("{0} of {1} ({2})", measStatus.CurrentRepetition, measStatus.RequestedRepetitions, s2)); // dev note: need a better focused description of the state
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionStop, (object o) =>
            {
                string s = LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionStop, applog, LogLevels.Warning, o);
                daqbind.mProgressTracker.ReportProgress(100, s);
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionCancel, (object o) =>
            {
                string s = LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionCancel, applog, LogLevels.Warning, o);
                daqbind.mProgressTracker.ReportProgress(100, s);
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionFinished, (object o) =>
            {
                string s = "";
                if (o != null && o is LMDAQ.DAQControl)
                {
                    LMDAQ.DAQControl f = (LMDAQ.DAQControl)o;
                    measStatus = new LMProcessor.MeasurementStatus();  // preps local state for refresh on channel and computed rates for now, follow up with all other state
                    measStatus.UpdateWithMeasurement();
                    s = LMDAQ.DAQControl.MeasStatusString(measStatus);
                    updateGUIWithChannelRatesData = true;
                    UpdateGUIWithNewdata();
                }
                else
                {
                    s = "Finished: SOH " + NC.App.Opstate.SOH + " but no processing occurred  " + LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionFinished, applog, LogLevels.Verbose, o);
                }
                NC.App.Opstate.SOH = NCC.OperatingState.Stopped;  // in case we got here after a Cancel
                // general logger: to the console, and/or listbox and/or log file or DB
                applog.TraceEvent(LogLevels.Verbose, FileCtrl.logid[ActionEvents.EventType.ActionFinished], s);
                // specialized updater for UI or file
                daqbind.mProgressTracker.ReportProgress(100, s);
                enablecontrols(true);

            });

            return true;
        }
コード例 #5
0
ファイル: Controller.cs プロジェクト: tempbottle/INCC6
        /// <summary>
        /// Set up timer callback and action event handlers for a DAQController instance, uses DAQBind subclass
        /// </summary>
        /// <returns></returns>
        public bool InitializeDAQController()
        {
            // DAQ
            daqbind = new DAQBind((MLMEmulation.IEmulatorDiversion)(new LMProcessor.NullEmulation()));
            LMLoggers.LognLM applog = NC.App.Logger(LMLoggers.AppSection.App);


            daqbind.SetEventHandler(ActionEvents.EventType.PreAction, (object o) =>
            {
                string s = LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.PreAction, applog, LogLevels.Verbose, o);
                daqbind.mProgressTracker.ReportProgress(0, s);                //"...");
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionPrep, (object o) =>
            {
                string s = "Action Prep: ";
                //can also look at active instrument list here LogLevels.Verbose,
                s = s + LMDAQ.Instruments.Active.Count + " devices found, [" + NC.App.Opstate.SOH + "] " + DateTimeOffset.Now.ToString("MMM dd yyy HH:mm:ss.ff K");
                applog.TraceEvent(LogLevels.Verbose, 0xABCE, "Action Prep: SOH " + o.ToString() + "'");
                daqbind.mProgressTracker.ReportProgress(0, s);                //"Prep");
            });
            daqbind.SetEventHandler(ActionEvents.EventType.ActionStart, (object o) =>
            {
                enablecontrols(false);
                string s = LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionStart, applog, LogLevels.Verbose, o);
                daqbind.mProgressTracker.ReportProgress(1, s);//"Starting...");
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionInProgress, (object o) =>
            {
                measStatus = new LMProcessor.MeasurementStatus();
                measStatus.UpdateWithMeasurement();
                measStatus.UpdateWithInstruments();
                updateGUIWithChannelRatesData = true;
                string s2 = LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionInProgress, applog, LogLevels.Verbose, o);
                int per   = Math.Min(100, (int)Math.Round(100.0 * ((double)measStatus.CurrentRepetition / (double)measStatus.RequestedRepetitions)));
                daqbind.mProgressTracker.ReportProgress(per,                                                                                                   // a % est of files
                                                        String.Format("{0} of {1} ({2})", measStatus.CurrentRepetition, measStatus.RequestedRepetitions, s2)); // dev note: need a better focused description of the state
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionStop, (object o) =>
            {
                string s = LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionStop, applog, LogLevels.Warning, o);
                daqbind.mProgressTracker.ReportProgress(100, s);
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionCancel, (object o) =>
            {
                string s = LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionCancel, applog, LogLevels.Warning, o);
                daqbind.mProgressTracker.ReportProgress(100, s);
            });

            daqbind.SetEventHandler(ActionEvents.EventType.ActionFinished, (object o) =>
            {
                string s = "";
                if (o != null && o is LMDAQ.DAQControl)
                {
                    LMDAQ.DAQControl f = (LMDAQ.DAQControl)o;
                    measStatus         = new LMProcessor.MeasurementStatus(); // preps local state for refresh on channel and computed rates for now, follow up with all other state
                    measStatus.UpdateWithMeasurement();
                    s = LMDAQ.DAQControl.MeasStatusString(measStatus);
                    updateGUIWithChannelRatesData = true;
                    UpdateGUIWithNewdata();
                }
                else
                {
                    s = "Finished: SOH " + NC.App.Opstate.SOH + " but no processing occurred  " + LMDAQ.DAQControl.LogAndSkimDAQProcessingStatus(ActionEvents.EventType.ActionFinished, applog, LogLevels.Verbose, o);
                }
                NC.App.Opstate.SOH = NCC.OperatingState.Stopped;  // in case we got here after a Cancel
                // general logger: to the console, and/or listbox and/or log file or DB
                applog.TraceEvent(LogLevels.Verbose, FileCtrl.logid[ActionEvents.EventType.ActionFinished], s);
                // specialized updater for UI or file
                daqbind.mProgressTracker.ReportProgress(100, s);
                enablecontrols(true);
            });

            return(true);
        }