Beispiel #1
0
        /// <summary>
        /// Prepare a detector for live assay/HV by adding it to the active list.
        /// </summary>
        /// <param name="det"></param>
        public static void ActivateDetector(Detector det)
        {
            if (det.Id.SRType.IsSocketBasedLM())
            {
                if (det.Id.SRType == InstrType.LMMM)
                {
                    LMInstrument lm = new LMInstrument(det);
                    lm.DAQState = DAQInstrState.Offline;
                    lm.selected = false;                      //must broadcast first to get it selected
                    if (!Instruments.All.Contains(lm))
                    {
                        Instruments.All.Add(lm);                         // add to global runtime list
                    }
                }
                else if (det.Id.SRType == InstrType.MCA527)
                {
                    MCA527Instrument mca = new MCA527Instrument(NC.App.Opstate.Measurement.Detector);
                    mca.DAQState = DAQInstrState.Offline;
                    mca.selected = true;
                    if (!Instruments.Active.Contains(mca))
                    {
                        Instruments.Active.Add(mca);
                    }
                }
                else
                {
                    // LMMM and MCA-527 are the only socket-based devices supported
                }
            }
            else if (det.Id.SRType.IsUSBBasedLM())
            {
                Ptr32Instrument ptr = new Ptr32Instrument(det);
                ptr.RDT.ResetRawDataBuffer();                  // poor design recovery patch
                ptr.RDT.SetLMStateFlags(((LMConnectionInfo)(ptr.id.FullConnInfo)).NetComm);

                ptr.DAQState = DAQInstrState.Offline; // USB-based devices are manually initiated as opposed to auto-pickup
                if (!Instruments.All.Contains(ptr))
                {
                    Instruments.All.Add(ptr); // add to global runtime list
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Prepare a detector for live assay/HV by adding it to the active list.
 /// </summary>
 /// <param name="det"></param>
 public static void ActivateDetector(Detector det)
 {
     if (det.Id.SRType.IsSocketBasedLM())
     {
         if (det.Id.SRType == InstrType.LMMM)
         {
             LMInstrument lm = new LMInstrument(det);
             lm.DAQState = DAQInstrState.Offline;
             lm.selected = false;                      //must broadcast first to get it selected
             if (!Instruments.All.Contains(lm))
             {
                 Instruments.All.Add(lm);                         // add to global runtime list
             }
         }
         else if (det.Id.SRType == InstrType.MCA527)
         {
             MCA527Instrument mca = new MCA527Instrument(NC.App.Opstate.Measurement.Detector);
             mca.DAQState = DAQInstrState.Offline;
             mca.selected = true;
             if (!Instruments.Active.Contains(mca))
             {
                 Instruments.Active.Add(mca);
             }
         }
         else
         {
             // LMMM and MCA-527 are the only socket-based devices supported
         }
     }
     else if (det.Id.SRType.IsUSBBasedLM())
     {
         Ptr32Instrument ptr = new Ptr32Instrument(det);
         ptr.DAQState = DAQInstrState.Offline; // these are manually initiated as opposed to auto-pickup
         if (!Instruments.All.Contains(ptr))
         {
             Instruments.All.Add(ptr); // add to global runtime list
         }
     }
 }
Beispiel #3
0
        private void AnalysisWizardClick(object sender, RoutedEventArgs e)
        {
            AcquireParameters acq = null;
            Detector          det = null;

            NC.App.DB.ResetAcquireParametersMap();              // force read from DB to get as-is default acquire state
            // NEXT: do a refresh of the specific acquire instance, not the entire list
            Integ.GetCurrentAcquireDetectorPair(ref acq, ref det);
            if (!det.ListMode)
            {
                MessageBox.Show("'" + det.ToString() + "' is not a List Mode detector,\r\ncreate or select a List Mode detector\r\n with Setup > Facility/Inspection...", "List Mode Acquire");
                return;
            }
            LMAcquire a = new LMAcquire(acq, det);

            a.ShowDialog();
            if (a.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                if (acq.modified || acq.lm.modified)
                {
                    INCCDB.AcquireSelector sel = new INCCDB.AcquireSelector(det, acq.item_type, DateTime.Now);
                    acq.MeasDateTime = sel.TimeStamp; acq.lm.TimeStamp = sel.TimeStamp;
                    NC.App.DB.AddAcquireParams(sel, acq);  // it's a new one, not the existing one modified
                }

                switch (NC.App.Opstate.Measurement.AcquireState.data_src)  // global access to latest acq here, same as acq set in wizard
                {
                case ConstructedSource.Live:
                    UIIntegration.Controller.file = false;   // make sure to use the DAQ controller, not the file controller
                    NC.App.AppContext.FileInput   = null;    // reset the cmd line file input flag
                    if (NC.App.Opstate.Measurement.Detector.ListMode)
                    {
                        // if ok, the analyzers are set up, so can kick it off now.
                        if (NC.App.Opstate.Measurement.Detector.Id.SRType == InstrType.PTR32)
                        {
                            Ptr32Instrument instrument = new Ptr32Instrument(NC.App.Opstate.Measurement.Detector);
                            instrument.DAQState = DAQInstrState.Offline;
                            instrument.selected = true;
                            instrument.Init(NC.App.Logger(LMLoggers.AppSection.Data), NC.App.Logger(LMLoggers.AppSection.Analysis));      // redundant now
                            instrument.RDT.ResetRawDataBuffer();
                            instrument.RDT.SetLMStateFlags(((LMConnectionInfo)(instrument.id.FullConnInfo)).NetComm);
                            if (!Instruments.Active.Contains(instrument))
                            {
                                Instruments.Active.Add(instrument);
                            }
                        }
                        else if (NC.App.Opstate.Measurement.Detector.Id.SRType == InstrType.MCA527)
                        {
                            MCA527Instrument mca = new MCA527Instrument(NC.App.Opstate.Measurement.Detector);
                            mca.DAQState = DAQInstrState.Offline;                                                             // these are manually initiated as opposed to auto-pickup
                            mca.selected = true;
                            mca.Init(NC.App.Logger(LMLoggers.AppSection.Data), NC.App.Logger(LMLoggers.AppSection.Analysis)); // redundant now?
                            if (!Instruments.Active.Contains(mca))
                            {
                                Instruments.Active.Add(mca);
                            }
                        }
                        else                                 // LMMM
                        {
                            LMInstrument lm = new LMInstrument(NC.App.Opstate.Measurement.Detector);
                            lm.DAQState = DAQInstrState.Offline; // these are manually initiated as opposed to auto-pickup
                            lm.selected = false;                 //must broadcast first to get it selected
                            if (!Instruments.All.Contains(lm))
                            {
                                Instruments.All.Add(lm);     // add to global runtime list
                            }
                        }
                    }
                    else
                    {
                        SRInstrument sri = new SRInstrument(NC.App.Opstate.Measurement.Detector);
                        sri.selected = true;
                        sri.Init(NC.App.Loggers.Logger(LMLoggers.AppSection.Data), NC.App.Loggers.Logger(LMLoggers.AppSection.Analysis));
                        if (!Instruments.All.Contains(sri))
                        {
                            Instruments.All.Add(sri);     // add to global runtime list
                        }
                    }
                    break;

                case ConstructedSource.DB:
                    UIIntegration.Controller.file = true;
                    return;

                //break;
                case ConstructedSource.Manual:
                    UIIntegration.Controller.file = true;
                    return;

                //break;
                case ConstructedSource.CycleFile:
                case ConstructedSource.ReviewFile:
                    UIIntegration.Controller.file = true;
                    string xs = UIIntegration.GetUsersFolder("Select Input Folder", NC.App.AppContext.FileInput);
                    if (!string.IsNullOrEmpty(xs))
                    {
                        NC.App.AppContext.FileInput     = xs;
                        NC.App.AppContext.FileInputList = null;      // no explicit file list
                    }
                    SRInstrument sri2 = new SRInstrument(NC.App.Opstate.Measurement.Detector);
                    sri2.selected = true;
                    sri2.Init(NC.App.Loggers.Logger(LMLoggers.AppSection.Data), NC.App.Loggers.Logger(LMLoggers.AppSection.Analysis));
                    if (!Instruments.All.Contains(sri2))
                    {
                        Instruments.All.Add(sri2);     // add to global runtime list
                    }
                    break;

                case ConstructedSource.NCDFile:
                    NC.App.AppContext.NCDFileAssay = true;     // suntoucher, this is right here how we're flowing now
                    UIIntegration.Controller.file  = true;
                    break;

                case ConstructedSource.SortedPulseTextFile:
                    NC.App.AppContext.PulseFileAssay = true;
                    UIIntegration.Controller.file    = true;
                    break;

                case ConstructedSource.PTRFile:
                    NC.App.AppContext.PTRFileAssay = true;
                    UIIntegration.Controller.file  = true;
                    break;

                case ConstructedSource.MCA527File:
                    NC.App.AppContext.MCA527FileAssay = true;
                    UIIntegration.Controller.file     = true;
                    break;

                default:
                    break;
                }
                NC.App.Opstate.Measurement.Detector.Id.source = NC.App.Opstate.Measurement.AcquireState.data_src; // set the detector overall data source value here
                UIIntegration.Controller.SetAssay();                                                              // tell the controller to do an assay operation using the current measurement state
                UIIntegration.Controller.Perform();                                                               // start the measurement file or DAQ thread
            }
        }
Beispiel #4
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            if (hvp.modified)
            {
                DialogResult = DialogResult.OK;
                HVCalibrationParameters c = NC.App.DB.HVParameters.Get(det.Id.DetectorName);
                if (c != null)
                {
                    c.Copy(hvp);  // copy changes back to original on user affirmation
                }
                else
                {
                    c = hvp;
                    NC.App.DB.HVParameters.GetMap().Add(det, c);
                }
                NC.App.DB.HVParameters.Set(det, c);
                // dev note: LM HV vals on LM Acquire record, but SR uses separate DB table so move HV vals so unify the scheme
            }
            else
            {
                DialogResult = DialogResult.Ignore;
            }

            acq.data_src = ConstructedSource.Live;
            if (OpenInExcel.Checked != acq.lm.HVX)
            {
                acq.lm.HVX = OpenInExcel.Checked;
                NC.App.DB.UpdateAcquireParams(acq, det.ListMode);
            }

            // The acquire is set to occur, build up the measurement state
            Integ.BuildMeasurement(acq, det, AssaySelector.MeasurementOption.unspecified);
            NC.App.Opstate.Measurement.Detector.Id.source = ConstructedSource.Live;
            if (acq.modified)
            {
                INCCDB.AcquireSelector sel = new INCCDB.AcquireSelector(det, acq.item_type, DateTime.Now);
                acq.MeasDateTime = sel.TimeStamp; acq.lm.TimeStamp = sel.TimeStamp;
                NC.App.DB.AddAcquireParams(sel, acq);  // it's a new one, not the existing one modified
            }

            UIIntegration.Controller.file = false; // make sure to use the DAQ controller, not the file controller
            NC.App.AppContext.FileInput   = null;  // reset the cmd line file input flag
            Instrument instrument = null;

            if (NC.App.Opstate.Measurement.Detector.ListMode)
            {
                if (NC.App.Opstate.Measurement.Detector.Id.SRType == InstrType.PTR32)
                {
                    instrument = new Ptr32Instrument(NC.App.Opstate.Measurement.Detector);
                }
                else if (NC.App.Opstate.Measurement.Detector.Id.SRType == InstrType.MCA527)
                {
                    instrument = new MCA527Instrument(NC.App.Opstate.Measurement.Detector);
                    ((Analysis.MCA527ProcessingState)instrument.RDT.State).writingFile = false;                      // force this
                }
                else if (NC.App.Opstate.Measurement.Detector.Id.SRType == InstrType.LMMM)
                {
                    instrument = new LMInstrument(NC.App.Opstate.Measurement.Detector);
                }
                instrument.DAQState = DAQInstrState.Offline;
                instrument.selected = true;
                instrument.Init(NC.App.Logger(LMLoggers.AppSection.Data), NC.App.Logger(LMLoggers.AppSection.Analysis));
                if (!Instruments.Active.Exists(i => instrument.id.Equals(i.id)))
                {
                    Instruments.Active.Add(instrument);
                }
            }
            else
            {
                instrument          = new SRInstrument(NC.App.Opstate.Measurement.Detector);
                instrument.selected = true;
                instrument.Init(null, null);
                if (!Instruments.Active.Exists(i => instrument.id.Equals(i)))
                {
                    Instruments.All.Add(instrument);                     // add to global runtime list
                }
            }

            UIIntegration.Controller.SetHVCalib(); // tell the controller to do an HV operation using the current measurement state
            UIIntegration.Controller.Perform();    // start the HV DAQ thread


            Close();
        }
        private void OKBtn_Click(object sender, EventArgs e)
        {
            if (hvp.modified)
            {
                DialogResult = DialogResult.OK;
                HVCalibrationParameters c = NC.App.DB.HVParameters.Get(det.Id.DetectorName);
                if (c != null)
                    c.Copy(hvp);  // copy changes back to original on user affirmation
                else
                {
                    c = hvp;
                    NC.App.DB.HVParameters.GetMap().Add(det, c);
                }
                NC.App.DB.HVParameters.Set(det,c);
                // dev note: LM HV vals on LM Acquire record, but SR uses separate DB table so move HV vals so unify the scheme

            }
            else
                DialogResult = DialogResult.Ignore;

            acq.data_src = ConstructedSource.Live;
            if (OpenInExcel.Checked != acq.lm.HVX)
            {
                acq.lm.HVX = OpenInExcel.Checked;
                NC.App.DB.UpdateAcquireParams(acq, det.ListMode);
            }

            // The acquire is set to occur, build up the measurement state
            Integ.BuildMeasurement(acq, det, AssaySelector.MeasurementOption.unspecified);
            NC.App.Opstate.Measurement.Detector.Id.source =   ConstructedSource.Live;
            if (acq.modified)
            {
                INCCDB.AcquireSelector sel = new INCCDB.AcquireSelector(det, acq.item_type, DateTime.Now);
                acq.MeasDateTime = sel.TimeStamp; acq.lm.TimeStamp = sel.TimeStamp;
                NC.App.DB.AddAcquireParams(sel, acq);  // it's a new one, not the existing one modified
            }

            UIIntegration.Controller.file = false;  // make sure to use the DAQ controller, not the file controller
            NC.App.AppContext.FileInput = null;  // reset the cmd line file input flag
            Instrument instrument = null;
            if (NC.App.Opstate.Measurement.Detector.ListMode)
            {
                if (NC.App.Opstate.Measurement.Detector.Id.SRType == InstrType.PTR32)
                {
                    instrument = new Ptr32Instrument(NC.App.Opstate.Measurement.Detector);
                }
                else if (NC.App.Opstate.Measurement.Detector.Id.SRType == InstrType.MCA527)
                {
                    instrument = new MCA527Instrument(NC.App.Opstate.Measurement.Detector);
                    ((Analysis.MCA527ProcessingState)instrument.RDT.State).writingFile = false;  // force this
                }
                else if (NC.App.Opstate.Measurement.Detector.Id.SRType == InstrType.LMMM)
                {
                    instrument = new LMInstrument(NC.App.Opstate.Measurement.Detector);
                }
                instrument.DAQState = DAQInstrState.Offline;
                instrument.selected = true;
                instrument.Init(NC.App.Logger(LMLoggers.AppSection.Data), NC.App.Logger(LMLoggers.AppSection.Analysis));
                if (!Instruments.Active.Exists(i => instrument.id.Equals(i.id)))
                    Instruments.Active.Add(instrument);
            }
            else
            {
                instrument = new SRInstrument(NC.App.Opstate.Measurement.Detector);
                instrument.selected = true;
                instrument.Init(null, null);
                if (!Instruments.Active.Exists(i => instrument.id.Equals(i)))
                    Instruments.All.Add(instrument); // add to global runtime list
            }

            UIIntegration.Controller.SetHVCalib();  // tell the controller to do an HV operation using the current measurement state
            UIIntegration.Controller.Perform();  // start the HV DAQ thread

            Close();
        }
Beispiel #6
0
        private void AnalysisWizardClick(object sender, RoutedEventArgs e)
        {
            AcquireParameters acq = null;
            Detector det = null;
            NC.App.DB.ResetAcquireParametersMap();  // force read from DB to get as-is default acquire state
            // NEXT: do a refresh of the specific acquire instance, not the entire list
            Integ.GetCurrentAcquireDetectorPair(ref acq, ref det);
            if (!det.ListMode)
            {
                MessageBox.Show("'" + det.ToString() + "' is not a List Mode detector,\r\ncreate or select a List Mode detector\r\n with Setup > Facility/Inspection...", "List Mode Acquire");
                return;
            }
            LMAcquire a = new LMAcquire(acq, det);
            a.ShowDialog();
            if (a.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                if (acq.modified || acq.lm.modified)
                {
                    INCCDB.AcquireSelector sel = new INCCDB.AcquireSelector(det, acq.item_type, DateTime.Now);
                    acq.MeasDateTime = sel.TimeStamp; acq.lm.TimeStamp = sel.TimeStamp;
                    NC.App.DB.AddAcquireParams(sel, acq);  // it's a new one, not the existing one modified
                }

                switch (NC.App.Opstate.Measurement.AcquireState.data_src)  // global access to latest acq here, same as acq set in wizard
                {
                    case ConstructedSource.Live:
                        UIIntegration.Controller.file = false;  // make sure to use the DAQ controller, not the file controller
                        NC.App.AppContext.FileInput = null;  // reset the cmd line file input flag
                        if (NC.App.Opstate.Measurement.Detector.ListMode)
                        {
                            // if ok, the analyzers are set up, so can kick it off now.
                            if (NC.App.Opstate.Measurement.Detector.Id.SRType == InstrType.PTR32)
                            {
                                Ptr32Instrument instrument = new Ptr32Instrument(NC.App.Opstate.Measurement.Detector);
                                instrument.DAQState = DAQInstrState.Offline;
                                instrument.selected = true;
                                instrument.Init(NC.App.Logger(LMLoggers.AppSection.Data), NC.App.Logger(LMLoggers.AppSection.Analysis));  // redundant now
                                instrument.RDT.ResetRawDataBuffer();
                                instrument.RDT.SetLMStateFlags(((LMConnectionInfo)(instrument.id.FullConnInfo)).NetComm);
                                if (!Instruments.Active.Contains(instrument))
                                    Instruments.Active.Add(instrument);
                            }
                            else if (NC.App.Opstate.Measurement.Detector.Id.SRType == InstrType.MCA527)
                            {
                                MCA527Instrument mca = new MCA527Instrument(NC.App.Opstate.Measurement.Detector);
                                mca.DAQState = DAQInstrState.Offline; // these are manually initiated as opposed to auto-pickup
                                mca.selected = true;
                                mca.Init(NC.App.Logger(LMLoggers.AppSection.Data), NC.App.Logger(LMLoggers.AppSection.Analysis)); // redundant now?
                                if (!Instruments.Active.Contains(mca))
                                    Instruments.Active.Add(mca);
                            }
                            else // LMMM
                            {
                                LMInstrument lm = new LMInstrument(NC.App.Opstate.Measurement.Detector);
                                lm.DAQState = DAQInstrState.Offline; // these are manually initiated as opposed to auto-pickup
                                lm.selected = false;  //must broadcast first to get it selected
                                if (!Instruments.All.Contains(lm))
                                    Instruments.All.Add(lm); // add to global runtime list
                            }
                        }
                        else
                        {
                            SRInstrument sri = new SRInstrument(NC.App.Opstate.Measurement.Detector);
                            sri.selected = true;
                            sri.Init(NC.App.Loggers.Logger(LMLoggers.AppSection.Data), NC.App.Loggers.Logger(LMLoggers.AppSection.Analysis));
                            if (!Instruments.All.Contains(sri))
                                Instruments.All.Add(sri); // add to global runtime list
                        }
                        break;
                    case ConstructedSource.DB:
                        UIIntegration.Controller.file = true;
                        return;
                        //break;
                    case ConstructedSource.Manual:
                        UIIntegration.Controller.file = true;
                        return;
                        //break;
                    case ConstructedSource.CycleFile:
                    case ConstructedSource.ReviewFile:
                        UIIntegration.Controller.file = true;
                        string xs = UIIntegration.GetUsersFolder("Select Input Folder", NC.App.AppContext.FileInput);
                        if (!string.IsNullOrEmpty(xs))
                        {
                            NC.App.AppContext.FileInput = xs;
                            NC.App.AppContext.FileInputList = null;  // no explicit file list
                        }
                        SRInstrument sri2 = new SRInstrument(NC.App.Opstate.Measurement.Detector);
                        sri2.selected = true;
                        sri2.Init(NC.App.Loggers.Logger(LMLoggers.AppSection.Data), NC.App.Loggers.Logger(LMLoggers.AppSection.Analysis));
                        if (!Instruments.All.Contains(sri2))
                            Instruments.All.Add(sri2); // add to global runtime list
                        break;

                    case ConstructedSource.NCDFile:
                        NC.App.AppContext.NCDFileAssay = true; // suntoucher, this is right here how we're flowing now
                        UIIntegration.Controller.file = true;
                        break;
                    case ConstructedSource.SortedPulseTextFile:
                        NC.App.AppContext.PulseFileAssay = true;
                        UIIntegration.Controller.file = true;
                        break;
                    case ConstructedSource.PTRFile:
                        NC.App.AppContext.PTRFileAssay = true;
                        UIIntegration.Controller.file = true;
                        break;
                    case ConstructedSource.MCA527File:
                        NC.App.AppContext.MCA527FileAssay = true;
                        UIIntegration.Controller.file = true;
                        break;
                    default:
                        break;
                }
                NC.App.Opstate.Measurement.Detector.Id.source = NC.App.Opstate.Measurement.AcquireState.data_src;  // set the detector overall data source value here
                UIIntegration.Controller.SetAssay();  // tell the controller to do an assay operation using the current measurement state
                UIIntegration.Controller.Perform();  // start the measurement file or DAQ thread
            }
        }
Beispiel #7
0
        /// <summary>
        /// Prepare a detector for live assay/HV by adding it to the active list.
        /// </summary>
        /// <param name="det"></param>
        public static void ActivateDetector(Detector det)
        {
            if (det.Id.SRType.IsSocketBasedLM())
            {
                if (det.Id.SRType == InstrType.LMMM)
                {
                    LMInstrument lm = new LMInstrument(det);
                    lm.DAQState = DAQInstrState.Offline;
                    lm.selected = false;  //must broadcast first to get it selected
                    if (!Instruments.All.Contains(lm))
                        Instruments.All.Add(lm); // add to global runtime list
                }
                else if (det.Id.SRType == InstrType.MCA527)
                {
                    MCA527Instrument mca = new MCA527Instrument(NC.App.Opstate.Measurement.Detector);
                    mca.DAQState = DAQInstrState.Offline;
                    mca.selected = true;
                    if (!Instruments.Active.Contains(mca))
                        Instruments.Active.Add(mca);
                }
                else
                {
                    // LMMM and MCA-527 are the only socket-based devices supported
                }
            }
            else if (det.Id.SRType.IsUSBBasedLM())
            {
                Ptr32Instrument ptr = new Ptr32Instrument(det);
                ptr.RDT.ResetRawDataBuffer();  // poor design recovery patch
                ptr.RDT.SetLMStateFlags(((LMConnectionInfo)(ptr.id.FullConnInfo)).NetComm);

                ptr.DAQState = DAQInstrState.Offline; // USB-based devices are manually initiated as opposed to auto-pickup
                if (!Instruments.All.Contains(ptr))
                    Instruments.All.Add(ptr); // add to global runtime list
            }
        }