示例#1
0
文件: Collect.cs 项目: radtek/INCC6
        protected void ShiftRegisterRuntimeInit()
        {
            Detector det = NC.App.Opstate.Measurement.Detector;

            if (det.ListMode)
            {
                return;
            }
            SRInstrument sri = new SRInstrument(det);

            sri.selected = true;
            sri.Init(datalog, NC.App.Loggers.Logger(LMLoggers.AppSection.Analysis));
            if (!Instruments.All.Contains(sri))
            {
                Instruments.All.Add(sri); // add to global runtime list
            }
        }
示例#2
0
        //// BUTTONCLICK HANDLERS ///////////////////////////////////////////////

        public DialogResult OKButton_Click(object sender, EventArgs e)
        {
            DialogResult dr = DialogResult.Cancel;

            if (ap.modified)
            {
                INCCDB.AcquireSelector sel = new INCCDB.AcquireSelector(det, ap.item_type, DateTime.Now);
                ap.MeasDateTime = sel.TimeStamp; ap.lm.TimeStamp = sel.TimeStamp;
                NC.App.DB.AddAcquireParams(sel, ap);  // it's a new one, not the existing one modified
            }

            // The acquire is set to occur
            if (ap.data_src != ConstructedSource.Reanalysis)  // Reanalysis is a bit backwards, the correct measurement is fully constructed before this point
            {
                LMAcquire.ResetMeasurement();
            }

            switch (ap.data_src)
            {
            case ConstructedSource.Live:                 // set up the instrument list for the action controller
                Integ.BuildMeasurement(ap, det, mo);
                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 (det.ListMode)
                {
                    // patch override lm.Interval with run_count_time from dialog
                    // the acquire dialogs field values, as seen and modified by the user, override the LM-only acquire settings for virtual SR measurements
                    NC.App.Opstate.Measurement.AcquireState.lm.Interval = NC.App.Opstate.Measurement.AcquireState.run_count_time;
                    NC.App.Opstate.Measurement.AcquireState.lm.Cycles   = NC.App.Opstate.Measurement.AcquireState.num_runs;

                    // Check NC.App.Opstate.Measurement.AnalysisParams for at least one VSR
                    // If not present, inform and pop up the wizard
                    // If present, inform with new dialog, do not pop up the wizard
                    if (NC.App.Opstate.Measurement.AnalysisParams.HasMatchingVSR(det.MultiplicityParams))
                    {
                        dr = DialogResult.OK;
                    }
                    else
                    {
                        dr = (new LMAcquire(ap, det, fromINCC5Acq: true)).ShowDialog();        // analyzers are created in here, placed on global measurement
                        if (dr == DialogResult.OK)
                        {
                            NC.App.DB.UpdateAcquireParams(ap);     //update it again
                            NC.App.DB.UpdateDetector(det);
                        }
                    }

                    if (dr == DialogResult.OK)
                    {
                        // if ok, the analyzers are set up, so can kick it off now.
                        UIIntegration.Controller.ActivateDetector(det);
                    }
                }
                else
                {
                    SRInstrument sri = new SRInstrument(det);
                    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
                    }
                    dr = DialogResult.OK;
                }
                break;

            case ConstructedSource.DB:
                NC.App.AppContext.DBDataAssay = true;
                UIIntegration.Controller.file = true;
                IDDAcquireDBMeas dbdlg = new IDDAcquireDBMeas(this);
                if (dbdlg.HasItems())
                {
                    dr = dbdlg.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        Integ.BuildMeasurement(ap, det, mo);
                        DateTimeOffset dto = dbdlg.measurementId.MeasDateTime;
                        NC.App.Logger(LMLoggers.AppSection.App).TraceEvent(LogLevels.Info, 87654,
                                                                           "Using " + dto.ToString("MMM dd yyy HH:mm:ss.ff K"));
                        NC.App.Opstate.Measurement.MeasDate = dto;
                        // get the cycles for the selected measurement from the database, and add them to the current measurement
                        CycleList cl = NC.App.DB.GetCycles(det, dbdlg.measurementId, ap.data_src);     // APluralityOfMultiplicityAnalyzers: // URGENT: get all the cycles associated with each analzyer, restoring into the correct key->result pair
                        NC.App.Opstate.Measurement.Add(cl);
                        // use the cycle time interval as found in the data, taking the first entry because equal intervals are assumed
                        if (cl.Count > 0)
                        {
                            NC.App.Opstate.Measurement.AcquireState.lm.Interval             = NC.App.Opstate.Measurement.AcquireState.run_count_time
                                                                                            = cl[0].TS.TotalSeconds;
                        }
                        NC.App.DB.UpdateAcquireParams(ap);     //update it again
                    }
                }
                else
                {
                    MessageBox.Show("No items found in database matching these parameters", "WARNING");
                }
                break;

            case ConstructedSource.Manual:
                UIIntegration.Controller.file = true;
                NC.App.AppContext.DBDataAssay = true;
                IDDManualDataEntry mdlg = new IDDManualDataEntry();
                mdlg.AH = this;
                dr      = mdlg.ShowDialog(); // the work constructing the measurement is done in the dialog class
                break;

            case ConstructedSource.Reanalysis:
                UIIntegration.Controller.file = true;
                NC.App.AppContext.DBDataAssay = true;
                dr = DialogResult.OK;
                // the measurement re-creation work is done in the IDDReanalysisAssay dialog class prior to reaching this point
                break;

            case ConstructedSource.CycleFile:
                Integ.BuildMeasurementMinimal(ap, det, mo);                          // the measurement is reconstructed before each test data file processing, so this is meant as a carrier for certain kick-off values
                NC.App.AppContext.TestDataFileAssay = true;
                UIIntegration.Controller.file       = true;
                dr = UIIntegration.GetUsersFile("Select a test data (disk) file", NC.App.AppContext.FileInput, "INCC5 Test data (disk)", "dat", "cnn");
                break;

            case ConstructedSource.ReviewFile:
                Integ.BuildMeasurementMinimal(ap, det, mo);                          // acquire type and measurement option are read from each NCC file itself, so this instance is an acquire state kick-off carrier value
                NC.App.AppContext.ReviewFileAssay = true;
                UIIntegration.Controller.file     = true;
                dr = UIIntegration.GetUsersFile("Select an NCC file", NC.App.AppContext.FileInput, "INCC5 Review", "NCC");
                break;

            case ConstructedSource.NCDFile:
                Integ.BuildMeasurement(ap, det, mo);
                NC.App.AppContext.NCDFileAssay = true;
                UIIntegration.Controller.file  = true;
                if (det.ListMode || NC.App.Opstate.Measurement.MeasOption.IsListMode())
                {
                    dr = (new LMAcquire(ap, det, fromINCC5Acq: true)).ShowDialog();      // show LM-relevant acquire-style settings for modification or confirmation
                }
                else
                {
                    dr = UIIntegration.GetUsersFilesFolder("Select NCD files or folder", NC.App.AppContext.FileInput, "LMMM NCD", "ncd");
                }
                break;

            case ConstructedSource.SortedPulseTextFile:
                Integ.BuildMeasurement(ap, det, mo);
                NC.App.AppContext.PulseFileAssay = true;
                UIIntegration.Controller.file    = true;
                if (det.ListMode || NC.App.Opstate.Measurement.MeasOption.IsListMode())
                {
                    dr = (new LMAcquire(ap, det, fromINCC5Acq: true)).ShowDialog();      // show LM-relevant acquire-style settings for modification or confirmation
                }
                else
                {
                    dr = UIIntegration.GetUsersFilesFolder("Select pulse files or folder", NC.App.AppContext.FileInput, "pulse", "txt");
                }
                break;

            case ConstructedSource.PTRFile:
                Integ.BuildMeasurement(ap, det, mo);
                NC.App.AppContext.PTRFileAssay = true;
                UIIntegration.Controller.file  = true;
                if (det.ListMode || NC.App.Opstate.Measurement.MeasOption.IsListMode())
                {
                    dr = (new LMAcquire(ap, det, fromINCC5Acq: true)).ShowDialog();      // show LM-relevant acquire-style settings for modification or confirmation
                }
                else
                {
                    dr = UIIntegration.GetUsersFilesFolder("Select PTR-32 files or folder", NC.App.AppContext.FileInput, "PTR-32", "bin", "chn");
                }
                break;

            case ConstructedSource.MCA527File:
                Integ.BuildMeasurement(ap, det, mo);
                NC.App.AppContext.MCA527FileAssay = true;
                UIIntegration.Controller.file     = true;
                if (det.ListMode || NC.App.Opstate.Measurement.MeasOption.IsListMode())
                {
                    dr = (new LMAcquire(ap, det, fromINCC5Acq: true)).ShowDialog();      // show LM-relevant acquire-style settings for modification or confirmation
                }
                else
                {
                    dr = UIIntegration.GetUsersFilesFolder("Select MCA files or folder", NC.App.AppContext.FileInput, "MCA527", "mca");
                }
                break;

            default:
                break;
            }
            return(dr);
        }
示例#3
0
        ///////////////////
        //  MOUSER MENU  //
        ///////////////////

        private void AnalysisWizardClick(object sender, RoutedEventArgs e)
        {
            AcquireParameters acq = null;
            Detector          det = null;

            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;
            }
            NewUI.AnalysisWizard f = new NewUI.AnalysisWizard(NewUI.AnalysisWizard.AWSteps.Step1, acq, det);
            System.Windows.Forms.DialogResult dr = f.ShowDialog();
            if (dr == 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.AcquireParametersMap().Add(sel, acq);  // it's a new one, not the existing one modified
                    NC.App.DB.UpdateAcquireParams(acq, det.ListMode);
                }

                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.Detectors[0].ListMode)
                    {
                        //  NC.App.DB.UpdateAcquireParams(ap, det.ListMode); //update it again
                        //   NC.App.DB.UpdateDetector(det);
                        // if ok, the analyzers are set up, so can kick it off now.
                        if (NC.App.Opstate.Measurement.Detectors[0].Id.SRType == InstrType.PTR32)
                        {
                            Ptr32Instrument instrument = new Ptr32Instrument(NC.App.Opstate.Measurement.Detectors[0]);
                            instrument.DAQState = DAQInstrState.Offline;
                            instrument.selected = true;
                            instrument.Init(NC.App.Logger(LMLoggers.AppSection.Data), NC.App.Logger(LMLoggers.AppSection.Analysis));

                            if (!Instruments.Active.Contains(instrument))
                            {
                                Instruments.Active.Add(instrument);
                            }
                        }
                        else
                        {
                            LMInstrument lm = new LMInstrument(NC.App.Opstate.Measurement.Detectors[0]);
                            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.Detectors[0]);
                        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.Detectors[0]);
                    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;

                default:
                    break;
                }
                NC.App.Opstate.Measurement.Detectors[0].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
            }
        }
示例#4
0
        //// BUTTONCLICK HANDLERS ///////////////////////////////////////////////
        public DialogResult OKButton_Click(object sender, EventArgs e)
        {
            DialogResult dr = DialogResult.Cancel;
            if (ap.modified)
            {
                INCCDB.AcquireSelector sel = new INCCDB.AcquireSelector(det, ap.item_type, DateTime.Now);
                ap.MeasDateTime = sel.TimeStamp; ap.lm.TimeStamp = sel.TimeStamp;
                NC.App.DB.AddAcquireParams(sel, ap);  // it's a new one, not the existing one modified
            }

            // The acquire is set to occur
            if (ap.data_src != ConstructedSource.Reanalysis)  // Reanalysis is a bit backwards, the correct measurement is fully constructed before this point
                LMAcquire.ResetMeasurement();

            switch (ap.data_src)
            {
                case ConstructedSource.Live:             // set up the instrument list for the action controller
                    Integ.BuildMeasurement(ap, det, mo);
                    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 (det.ListMode)
                    {
                        // patch override lm.Interval with run_count_time from dialog
                        // the acquire dialogs field values, as seen and modified by the user, override the LM-only acquire settings for virtual SR measurements
                        NC.App.Opstate.Measurement.AcquireState.lm.Interval = NC.App.Opstate.Measurement.AcquireState.run_count_time;
                        NC.App.Opstate.Measurement.AcquireState.lm.Cycles = NC.App.Opstate.Measurement.AcquireState.num_runs;

                        // Check NC.App.Opstate.Measurement.AnalysisParams for at least one VSR
                        // If not present, inform and pop up the wizard
                        // If present, inform with new dialog, do not pop up the wizard
                        if (NC.App.Opstate.Measurement.AnalysisParams.HasMatchingVSR(det.MultiplicityParams))
                        {
                            dr = DialogResult.OK;
                        }
                        else
                        {
                            dr = (new LMAcquire(ap, det, fromINCC5Acq: true)).ShowDialog();// analyzers are created in here, placed on global measurement
                            if (dr == DialogResult.OK)
                            {
                                NC.App.DB.UpdateAcquireParams(ap); //update it again
                                NC.App.DB.UpdateDetector(det);
                            }
                        }

                        if (dr == DialogResult.OK)
                        {
                            // if ok, the analyzers are set up, so can kick it off now.
                            UIIntegration.Controller.ActivateDetector(det);
                        }
                    }
                    else
                    {
                        SRInstrument sri = new SRInstrument(det);
                        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
                        dr = DialogResult.OK;
                    }
                    break;
                case ConstructedSource.DB:
                    NC.App.AppContext.DBDataAssay = true;
                    UIIntegration.Controller.file = true;
                    IDDAcquireDBMeas dbdlg = new IDDAcquireDBMeas(this);
                    if (dbdlg.HasItems())
                    {
                        dr = dbdlg.ShowDialog();
                        if (dr == DialogResult.OK)
                        {
                            Integ.BuildMeasurement(ap, det, mo);
                            DateTimeOffset dto = dbdlg.measurementId.MeasDateTime;
                            NC.App.Logger(LMLoggers.AppSection.App).TraceEvent(LogLevels.Info, 87654,
                                    "Using " + dto.ToString("MMM dd yyy HH:mm:ss.ff K"));
                            NC.App.Opstate.Measurement.MeasDate = dto;
                            // get the cycles for the selected measurement from the database, and add them to the current measurement
                            CycleList cl = NC.App.DB.GetCycles(det, dbdlg.measurementId, ap.data_src); // APluralityOfMultiplicityAnalyzers: // URGENT: get all the cycles associated with each analyzer, restoring into the correct key->result pair
                            NC.App.Opstate.Measurement.Add(cl);
                            // use the cycle time interval as found in the data, taking the first entry because equal intervals are assumed
                            if (cl.Count > 0)
                                NC.App.Opstate.Measurement.AcquireState.lm.Interval = NC.App.Opstate.Measurement.AcquireState.run_count_time
                                    = cl[0].TS.TotalSeconds;
                            NC.App.DB.UpdateAcquireParams(ap); //update it again
                        }
                    }
                    else
                        MessageBox.Show("No items found in database matching these parameters", "WARNING");
                    break;
                case ConstructedSource.Manual:
                    UIIntegration.Controller.file = true;
                    NC.App.AppContext.DBDataAssay = true;
                    IDDManualDataEntry mdlg = new IDDManualDataEntry();
                    mdlg.AH = this;
                    dr = mdlg.ShowDialog(); // the work constructing the measurement is done in the dialog class
                    break;
                case ConstructedSource.Reanalysis:
                    UIIntegration.Controller.file = true;
                    NC.App.AppContext.DBDataAssay = true;
                    dr = DialogResult.OK;
                    // the measurement re-creation work is done in the IDDReanalysisAssay dialog class prior to reaching this point
                    break;
                case ConstructedSource.CycleFile:
             					Integ.BuildMeasurementMinimal(ap, det, mo);  // the measurement is reconstructed before each test data file processing, so this is meant as a carrier for certain kick-off values
                    NC.App.AppContext.TestDataFileAssay = true;
                    UIIntegration.Controller.file = true;
                    dr = UIIntegration.GetUsersFile("Select a test data (disk) file", NC.App.AppContext.FileInput, "INCC5 Test data (disk)", "dat", "cnn");
                    break;
                case ConstructedSource.ReviewFile:
                    Integ.BuildMeasurementMinimal(ap, det, mo);  // acquire type and measurement option are read from each NCC file itself, so this instance is an acquire state kick-off carrier value
                    NC.App.AppContext.ReviewFileAssay = true;
                    UIIntegration.Controller.file = true;
                    dr = UIIntegration.GetUsersFile("Select an NCC file", NC.App.AppContext.FileInput, "INCC5 Review", "NCC");
                    break;
                case ConstructedSource.NCDFile:
                    Integ.BuildMeasurement(ap, det, mo);
                    NC.App.AppContext.NCDFileAssay = true;
                    UIIntegration.Controller.file = true;
                    if (det.ListMode || NC.App.Opstate.Measurement.MeasOption.IsListMode())
                    {
                        dr = (new LMAcquire(ap, det, fromINCC5Acq: true)).ShowDialog();  // show LM-relevant acquire-style settings for modification or confirmation
                    }
                    else
                    {
                        dr = UIIntegration.GetUsersFilesFolder("Select NCD files or folder", NC.App.AppContext.FileInput, "LMMM NCD", "ncd");
                    }
                    break;
                case ConstructedSource.SortedPulseTextFile:
                    Integ.BuildMeasurement(ap, det, mo);
                    NC.App.AppContext.PulseFileAssay = true;
                    UIIntegration.Controller.file = true;
                    if (det.ListMode || NC.App.Opstate.Measurement.MeasOption.IsListMode())
                    {
                        dr = (new LMAcquire(ap, det, fromINCC5Acq: true)).ShowDialog();  // show LM-relevant acquire-style settings for modification or confirmation
                    }
                    else
                    {
                        dr = UIIntegration.GetUsersFilesFolder("Select pulse files or folder", NC.App.AppContext.FileInput, "pulse", "txt");
                    }
                    break;
                case ConstructedSource.PTRFile:
                    Integ.BuildMeasurement(ap, det, mo);
                    NC.App.AppContext.PTRFileAssay = true;
                    UIIntegration.Controller.file = true;
                    if (det.ListMode || NC.App.Opstate.Measurement.MeasOption.IsListMode())
                    {
                        dr = (new LMAcquire(ap, det, fromINCC5Acq: true)).ShowDialog();  // show LM-relevant acquire-style settings for modification or confirmation
                    }
                    else
                    {
                        dr = UIIntegration.GetUsersFilesFolder("Select PTR-32 files or folder", NC.App.AppContext.FileInput, "PTR-32", "bin", "chn");
                    }
                    break;
                case ConstructedSource.MCA527File:
             					Integ.BuildMeasurement(ap, det, mo);
                    NC.App.AppContext.MCA527FileAssay = true;
                    UIIntegration.Controller.file = true;
                    if (det.ListMode || NC.App.Opstate.Measurement.MeasOption.IsListMode())
                    {
                        dr = (new LMAcquire(ap, det, fromINCC5Acq: true)).ShowDialog();  // show LM-relevant acquire-style settings for modification or confirmation
                    }
                    else
                    {
                        dr = UIIntegration.GetUsersFilesFolder("Select MCA files or folder", NC.App.AppContext.FileInput, "MCA527", "mca");
                    }
                    break;
                default:
                    break;
            }
            return dr;
        }
示例#5
0
 protected void ShiftRegisterRuntimeInit()
 {
     Detector det = NC.App.Opstate.Measurement.Detector;
     if (det.ListMode)
         return;
     SRInstrument sri = new SRInstrument(det);
     sri.selected = true;
     sri.Init(datalog, NC.App.Loggers.Logger(LMLoggers.AppSection.Analysis));
     if (!Instruments.All.Contains(sri))
         Instruments.All.Add(sri); // add to global runtime list
 }
示例#6
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            if (hvp.modified)
            {
                DialogResult = System.Windows.Forms.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 = System.Windows.Forms.DialogResult.Ignore;

            // The acquire is set to occur, build up the measurement state 
            Integ.BuildMeasurement(acq, det, AssaySelector.MeasurementOption.unspecified);
            
            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.AcquireParametersMap().Add(sel, acq);  // it's a new one, not the existing one modified
                NC.App.DB.UpdateAcquireParams(acq, det.ListMode);
            }

            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.Detectors[0].ListMode)
            {
                if (NC.App.Opstate.Measurement.Detectors[0].Id.SRType == InstrType.PTR32) {
                    Ptr32Instrument instrument = new Ptr32Instrument(NC.App.Opstate.Measurement.Detectors[0]);
                    instrument.DAQState = DAQInstrState.Offline;
                    instrument.selected = true;
                    instrument.Init(NC.App.Logger(LMLoggers.AppSection.Data), NC.App.Logger(LMLoggers.AppSection.Analysis));

                    if (!Instruments.Active.Contains(instrument)) {
                        Instruments.Active.Add(instrument);
                    }
                }
                else {
                    // if ok, the analyzers are set up, so can kick it off now.
                    LMInstrument lm = new LMInstrument(NC.App.Opstate.Measurement.Detectors[0]);
                    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.Detectors[0]);
                sri.selected = true;
                sri.Init(null, null);
                if (!Instruments.All.Contains(sri))
                    Instruments.All.Add(sri); // 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
            
            
            this.Close();        
        }
示例#7
0
        ///////////////////
        //  MOUSER MENU  //
        ///////////////////

        private void AnalysisWizardClick(object sender, RoutedEventArgs e)
        {
            AcquireParameters acq = null;
            Detector det = null;
            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;
            }
            NewUI.AnalysisWizard f = new NewUI.AnalysisWizard(NewUI.AnalysisWizard.AWSteps.Step1, acq, det);
            System.Windows.Forms.DialogResult dr = f.ShowDialog();
            if (dr == 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.AcquireParametersMap().Add(sel, acq);  // it's a new one, not the existing one modified
                    NC.App.DB.UpdateAcquireParams(acq, det.ListMode);
                }

                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.Detectors[0].ListMode)
                        {
                            //  NC.App.DB.UpdateAcquireParams(ap, det.ListMode); //update it again
                            //   NC.App.DB.UpdateDetector(det);
                            // if ok, the analyzers are set up, so can kick it off now.
                            if (NC.App.Opstate.Measurement.Detectors[0].Id.SRType == InstrType.PTR32)
                            {
                                Ptr32Instrument instrument = new Ptr32Instrument(NC.App.Opstate.Measurement.Detectors[0]);
                                instrument.DAQState = DAQInstrState.Offline;
                                instrument.selected = true;
                                instrument.Init(NC.App.Logger(LMLoggers.AppSection.Data), NC.App.Logger(LMLoggers.AppSection.Analysis));

                                if (!Instruments.Active.Contains(instrument))
                                {
                                    Instruments.Active.Add(instrument);
                                }
                            }
                            else
                            {
                                LMInstrument lm = new LMInstrument(NC.App.Opstate.Measurement.Detectors[0]);
                                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.Detectors[0]);
                            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.Detectors[0]);
                        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;
                    default:
                        break;
                }
                NC.App.Opstate.Measurement.Detectors[0].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
            }
        }
示例#8
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            if (hvp.modified)
            {
                DialogResult = System.Windows.Forms.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 = System.Windows.Forms.DialogResult.Ignore;
            }

            // The acquire is set to occur, build up the measurement state
            Integ.BuildMeasurement(acq, det, AssaySelector.MeasurementOption.unspecified);

            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.AcquireParametersMap().Add(sel, acq);  // it's a new one, not the existing one modified
                NC.App.DB.UpdateAcquireParams(acq, det.ListMode);
            }

            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.Detectors[0].ListMode)
            {
                if (NC.App.Opstate.Measurement.Detectors[0].Id.SRType == InstrType.PTR32)
                {
                    Ptr32Instrument instrument = new Ptr32Instrument(NC.App.Opstate.Measurement.Detectors[0]);
                    instrument.DAQState = DAQInstrState.Offline;
                    instrument.selected = true;
                    instrument.Init(NC.App.Logger(LMLoggers.AppSection.Data), NC.App.Logger(LMLoggers.AppSection.Analysis));

                    if (!Instruments.Active.Contains(instrument))
                    {
                        Instruments.Active.Add(instrument);
                    }
                }
                else
                {
                    // if ok, the analyzers are set up, so can kick it off now.
                    LMInstrument lm = new LMInstrument(NC.App.Opstate.Measurement.Detectors[0]);
                    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.Detectors[0]);
                sri.selected = true;
                sri.Init(null, null);
                if (!Instruments.All.Contains(sri))
                {
                    Instruments.All.Add(sri); // 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


            this.Close();
        }
示例#9
0
        //// BUTTONCLICK HANDLERS ///////////////////////////////////////////////

        public DialogResult OKButton_Click(object sender, EventArgs e)
        {
            DialogResult dr = DialogResult.Cancel;

            if (ap.modified)
            {
                INCCDB.AcquireSelector sel = new INCCDB.AcquireSelector(det, ap.item_type, DateTime.Now);
                ap.MeasDateTime = sel.TimeStamp; ap.lm.TimeStamp = sel.TimeStamp;
                NC.App.DB.AcquireParametersMap().Add(sel, ap);  // it's a new one, not the existing one modified
                NC.App.DB.UpdateAcquireParams(ap, det.ListMode);
            }

            // The acquire is set to occur, build up the measurement state
            AnalysisWizard.ResetMeasurement();
            Integ.BuildMeasurement(ap, det, mo);

            switch (ap.data_src)
            {
            case ConstructedSource.Live:                 // set up the instrument list for the action controller
                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 (det.ListMode)
                {
                    // patch override lm.Interval with run_count_time from dialog
                    NC.App.Opstate.Measurement.AcquireState.lm.Interval = NC.App.Opstate.Measurement.AcquireState.run_count_time;

                    // Check NC.App.Opstate.Measurement.AnalysisParams for at least one VSR
                    // If not present, inform and pop up the wizard
                    // If present, inform with new dialog, do not pop up the wizard
                    if (NC.App.Opstate.Measurement.AnalysisParams.HasMultiplicity())
                    {
                        dr = DialogResult.OK;
                    }
                    else
                    {
                        AnalysisWizard awl = new AnalysisWizard(AnalysisWizard.AWSteps.Step2B, ap, det);      // analyzers are created in here, placed on global measurement
                        dr = awl.ShowDialog();
                        if (dr == DialogResult.OK)
                        {
                            NC.App.DB.UpdateAcquireParams(ap);     //update it again
                            NC.App.DB.UpdateDetector(det);
                        }
                    }

                    if (dr == DialogResult.OK)
                    {
                        // if ok, the analyzers are set up, so can kick it off now.
                        UIIntegration.Controller.ActivateDetector(det);
                    }
                }
                else
                {
                    SRInstrument sri = new SRInstrument(det);
                    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
                    }
                    dr = DialogResult.OK;
                }
                break;

            case ConstructedSource.DB:
                NC.App.AppContext.DBDataAssay = true;
                UIIntegration.Controller.file = true;
                IDDAcquireDBMeas dbdlg = new IDDAcquireDBMeas(this);
                if (dbdlg.HasItems())
                {
                    dr = dbdlg.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        DateTimeOffset dto = dbdlg.measurementId.MeasDateTime;
                        DateTimeOffset cur = new DateTimeOffset(dto.Ticks, dto.Offset);
                        NC.App.Logger(NCCReporter.LMLoggers.AppSection.App).TraceEvent(NCCReporter.LogLevels.Info, 87654,
                                                                                       "Using " + dto.ToString("MMM dd yyy HH:mm:ss.ff K"));

                        // get the cycles for the selected measurement from the database, and add them to the current measurement
                        CycleList cl = NC.App.DB.GetCycles(det, dbdlg.measurementId);
                        foreach (Cycle cycle in cl)     // add the necessary meta-data to the cycle identifier instance
                        {
                            cycle.UpdateDataSourceId(ap.data_src, det.Id.SRType,
                                                     cur.AddTicks(cycle.TS.Ticks), det.Id.FileName);
                            cur = cycle.DataSourceId.dt;
                        }

                        NC.App.Opstate.Measurement.Add(cl);

                        // TODO: for Reanalysis, a full reconstruction of the measurement state based on the ResultsRec state and the method parameter map contents (for Calib and Verif)
                    }
                }
                else
                {
                    MessageBox.Show("No items found in database matching these parameters", "WARNING");
                }
                break;

            case ConstructedSource.Manual:
                UIIntegration.Controller.file = true;
                NC.App.AppContext.DBDataAssay = true;
                IDDManualDataEntry mdlg = new IDDManualDataEntry();
                mdlg.AH = this;
                dr      = mdlg.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    // the work is done in the dialog class
                }
                break;

            case ConstructedSource.CycleFile:
                NC.App.AppContext.TestDataFileAssay = true;
                UIIntegration.Controller.file       = true;
                dr = UIIntegration.GetUsersFile("Select a test data (disk) file", NC.App.AppContext.FileInput, "INCC5 Test data (disk)", "dat");
                break;

            case ConstructedSource.ReviewFile:
                NC.App.AppContext.ReviewFileAssay = true;
                UIIntegration.Controller.file     = true;
                dr = UIIntegration.GetUsersFile("Select an NCC file", NC.App.AppContext.FileInput, "INCC5 Review", "NCC");
                break;

            case ConstructedSource.NCDFile:
                NC.App.AppContext.NCDFileAssay = true;
                UIIntegration.Controller.file  = true;
                if (NC.App.Opstate.Measurement.MeasOption == AssaySelector.MeasurementOption.unspecified)
                {
                    AnalysisWizard aw = new AnalysisWizard(AnalysisWizard.AWSteps.Step2A, ap, det);
                    dr = aw.ShowDialog();     // show LM-relevant acquire-style settings for modification or confirmation
                }
                else
                {
                    dr = UIIntegration.GetUsersFilesFolder("Select NCD files or folder", NC.App.AppContext.FileInput, "LMMM NCD", "ncd");
                }
                break;

            case ConstructedSource.SortedPulseTextFile:
                NC.App.AppContext.PulseFileAssay = true;
                UIIntegration.Controller.file    = true;
                if (NC.App.Opstate.Measurement.MeasOption == AssaySelector.MeasurementOption.unspecified)
                {
                    AnalysisWizard aw1 = new AnalysisWizard(AnalysisWizard.AWSteps.Step2A, ap, det);
                    dr = aw1.ShowDialog();      // show LM-relevant acquire-style settings for modification or confirmation
                }
                else
                {
                    dr = UIIntegration.GetUsersFilesFolder("Select pulse files or folder", NC.App.AppContext.FileInput, "pulse", "txt");
                }
                break;

            case ConstructedSource.PTRFile:
                NC.App.AppContext.PTRFileAssay = true;
                UIIntegration.Controller.file  = true;
                if (NC.App.Opstate.Measurement.MeasOption == AssaySelector.MeasurementOption.unspecified)
                {
                    AnalysisWizard aw2 = new AnalysisWizard(AnalysisWizard.AWSteps.Step2A, ap, det);
                    dr = aw2.ShowDialog();      // show LM-relevant acquire-style settings for modification or confirmation
                }
                else
                {
                    dr = UIIntegration.GetUsersFilesFolder("Select PTR-32 files or folder", NC.App.AppContext.FileInput, "PTR-32", "bin", "chn");
                }
                break;

            case ConstructedSource.NILAFile:
                NC.App.AppContext.NILAFileAssay = true;
                UIIntegration.Controller.file   = true;
                dr = UIIntegration.GetUsersFilesFolder("Select NILA files or folder", NC.App.AppContext.FileInput, "MTS NILA", "dat");
                //dr = DialogResult.Cancel;
                break;

            default:
                break;
            }
            return(dr);
        }
示例#10
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();
        }
示例#11
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();
        }
示例#12
0
        //// BUTTONCLICK HANDLERS ///////////////////////////////////////////////

        public DialogResult OKButton_Click(object sender, EventArgs e)
        {
            DialogResult dr = DialogResult.Cancel;
            if (ap.modified)
            {
                INCCDB.AcquireSelector sel = new INCCDB.AcquireSelector(det, ap.item_type, DateTime.Now);
                ap.MeasDateTime = sel.TimeStamp; ap.lm.TimeStamp = sel.TimeStamp;
                NC.App.DB.AcquireParametersMap().Add(sel, ap);  // it's a new one, not the existing one modified
                NC.App.DB.UpdateAcquireParams(ap, det.ListMode);
            }

            // The acquire is set to occur, build up the measurement state 
            AnalysisWizard.ResetMeasurement();
            Integ.BuildMeasurement(ap, det, mo);

            switch (ap.data_src)
            {
                case ConstructedSource.Live:             // set up the instrument list for the action controller
                    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 (det.ListMode)
                    {
                        // patch override lm.Interval with run_count_time from dialog
                        NC.App.Opstate.Measurement.AcquireState.lm.Interval = NC.App.Opstate.Measurement.AcquireState.run_count_time;

                        // Check NC.App.Opstate.Measurement.AnalysisParams for at least one VSR 
                        // If not present, inform and pop up the wizard
                        // If present, inform with new dialog, do not pop up the wizard
                        if (NC.App.Opstate.Measurement.AnalysisParams.HasMultiplicity())
                        {
                            dr = DialogResult.OK;
                        }
                        else
                        {
                            AnalysisWizard awl = new AnalysisWizard(AnalysisWizard.AWSteps.Step2B, ap, det);  // analyzers are created in here, placed on global measurement
                            dr = awl.ShowDialog();
                            if (dr == DialogResult.OK)
                            {
                                NC.App.DB.UpdateAcquireParams(ap); //update it again
                                NC.App.DB.UpdateDetector(det);
                            }
                        }

                        if (dr == DialogResult.OK)
                        {
                            // if ok, the analyzers are set up, so can kick it off now.
                            UIIntegration.Controller.ActivateDetector(det); 
                        }
                    }
                    else
                    {
                        SRInstrument sri = new SRInstrument(det);
                        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 
                        dr = DialogResult.OK;
                    }
                    break;
                case ConstructedSource.DB:
                    NC.App.AppContext.DBDataAssay = true;
                    UIIntegration.Controller.file = true;
                    IDDAcquireDBMeas dbdlg = new IDDAcquireDBMeas(this);
                    if (dbdlg.HasItems())
                    {
                        dr = dbdlg.ShowDialog();
                        if (dr == DialogResult.OK)
                        {
                            DateTimeOffset dto = dbdlg.measurementId.MeasDateTime;
                            DateTimeOffset cur = new DateTimeOffset(dto.Ticks, dto.Offset);
                            NC.App.Logger(NCCReporter.LMLoggers.AppSection.App).TraceEvent(NCCReporter.LogLevels.Info, 87654,
                                    "Using " + dto.ToString("MMM dd yyy HH:mm:ss.ff K"));

                            // get the cycles for the selected measurement from the database, and add them to the current measurement
                            CycleList cl = NC.App.DB.GetCycles(det, dbdlg.measurementId);
                            foreach(Cycle cycle in cl)  // add the necessary meta-data to the cycle identifier instance
                            {
                                cycle.UpdateDataSourceId(ap.data_src, det.Id.SRType, 
                                                    cur.AddTicks(cycle.TS.Ticks), det.Id.FileName);
                                cur = cycle.DataSourceId.dt;
                            }

                            NC.App.Opstate.Measurement.Add(cl);

                            // TODO: for Reanalysis, a full reconstruction of the measurement state based on the ResultsRec state and the method parameter map contents (for Calib and Verif)
                        }
                    }
                    else
                        MessageBox.Show("No items found in database matching these parameters", "WARNING");
                    break;
                case ConstructedSource.Manual:
                    UIIntegration.Controller.file = true;
                    NC.App.AppContext.DBDataAssay = true;
                    IDDManualDataEntry mdlg = new IDDManualDataEntry();
                    mdlg.AH = this;
                    dr = mdlg.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        // the work is done in the dialog class
                    }
                    break;

                case ConstructedSource.CycleFile:
                    NC.App.AppContext.TestDataFileAssay = true;
                    UIIntegration.Controller.file = true;
                    dr = UIIntegration.GetUsersFile("Select a test data (disk) file", NC.App.AppContext.FileInput, "INCC5 Test data (disk)", "dat");
                    break;
                case ConstructedSource.ReviewFile:
                    NC.App.AppContext.ReviewFileAssay = true;
                    UIIntegration.Controller.file = true;
                    dr = UIIntegration.GetUsersFile("Select an NCC file", NC.App.AppContext.FileInput, "INCC5 Review", "NCC");
                    break;
                case ConstructedSource.NCDFile:
                    NC.App.AppContext.NCDFileAssay = true;
                    UIIntegration.Controller.file = true;
                    if (NC.App.Opstate.Measurement.MeasOption == AssaySelector.MeasurementOption.unspecified)
                    {
                        AnalysisWizard aw = new AnalysisWizard(AnalysisWizard.AWSteps.Step2A, ap, det);
                        dr = aw.ShowDialog(); // show LM-relevant acquire-style settings for modification or confirmation
                    }
                    else
                    {
                        dr = UIIntegration.GetUsersFilesFolder("Select NCD files or folder", NC.App.AppContext.FileInput, "LMMM NCD", "ncd");
                    }
                    break;
                case ConstructedSource.SortedPulseTextFile:
                    NC.App.AppContext.PulseFileAssay = true;
                    UIIntegration.Controller.file = true;
                    if (NC.App.Opstate.Measurement.MeasOption == AssaySelector.MeasurementOption.unspecified)
                    {
                        AnalysisWizard aw1 = new AnalysisWizard(AnalysisWizard.AWSteps.Step2A, ap, det);
                        dr = aw1.ShowDialog();  // show LM-relevant acquire-style settings for modification or confirmation
                    }
                    else
                    {
                        dr = UIIntegration.GetUsersFilesFolder("Select pulse files or folder", NC.App.AppContext.FileInput, "pulse", "txt");
                    }
                    break;
                case ConstructedSource.PTRFile: 
                    NC.App.AppContext.PTRFileAssay = true;
                    UIIntegration.Controller.file = true;
                    if (NC.App.Opstate.Measurement.MeasOption == AssaySelector.MeasurementOption.unspecified)
                    {
                        AnalysisWizard aw2 = new AnalysisWizard(AnalysisWizard.AWSteps.Step2A, ap, det);
                        dr = aw2.ShowDialog();  // show LM-relevant acquire-style settings for modification or confirmation
                    }
                    else
                    {
                        dr = UIIntegration.GetUsersFilesFolder("Select PTR-32 files or folder", NC.App.AppContext.FileInput, "PTR-32", "bin", "chn");
                    }
                    break;
                case ConstructedSource.NILAFile:
                    NC.App.AppContext.NILAFileAssay = true;
                    UIIntegration.Controller.file = true;
                    dr = UIIntegration.GetUsersFilesFolder("Select NILA files or folder", NC.App.AppContext.FileInput, "MTS NILA", "dat");
                    //dr = DialogResult.Cancel;
                    break;
                default:
                    break;
            }
            return dr;
        }