Пример #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);
        }
Пример #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.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);
        }
Пример #3
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;
        }
Пример #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.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;
        }