Esempio n. 1
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);
        }
Esempio n. 2
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
            }
        }