Example #1
0
        /// <summary>
        /// populates dialog fields from current state, can be moved out of here later
        /// </summary>
        void LoadParams(AnalysisWizard.AWSteps step)
        {
            switch (step)
            {
                case AnalysisWizard.AWSteps.Step1:
                    break;
                case AnalysisWizard.AWSteps.Step2A:
                    Step2InputDirectoryTextBox.Text = NC.App.AppContext.FileInput;
                    Step2RecurseCheckBox.CheckState = (NC.App.AppContext.Recurse ? CheckState.Checked : CheckState.Unchecked);
                    Step2AutoOpenCheckBox.CheckState = (NC.App.AppContext.OpenResults ? CheckState.Checked : CheckState.Unchecked);
                    Step2IncludeConfigCheckBox.CheckState = (ap.lm.IncludeConfig ? CheckState.Checked : CheckState.Unchecked);
                    Step2SaveEarlyTermCheckBox.CheckState = (ap.lm.SaveOnTerminate ? CheckState.Checked : CheckState.Unchecked);

                    // el radio buton setter
                    if (NC.App.AppContext.PTRFileAssay)
                    {
                        Step2PTR32RadioBtn.Checked = true;
                        Step2ConvertPTR32toNCDCheckBox.Checked = NC.App.AppContext.PTRFileNCD;
                        ap.data_src = ConstructedSource.PTRFile;
                    }
                    else if (NC.App.AppContext.PulseFileAssay)
                    {
                        Step2SortedPulseRadioBtn.Checked = true;
                        Step2ConvertSPtoNCDCheckBox.Checked = NC.App.AppContext.PulseFileNCD;
                        ap.data_src = ConstructedSource.SortedPulseTextFile;
                    }
                    else if (NC.App.AppContext.NILAFileAssay)
                    {
                        Step2NILA2RadioBtn.Checked = true;
                        Step2ConvertNILAtoNCDCheckBox.Checked = NC.App.AppContext.NILAFileNCD;
                        ap.data_src = ConstructedSource.NILAFile;
                    }
                    else // always the default
                    {
                        Step2NCDRadioBtn.Checked = true;
                    }

                    Step2OutputDirectoryTextBox.Text = ap.lm.Results; // jfl todo: expand to full path (if relative?)
                    RefreshDetectorCombo(Step2ADetCB);
                    break;
                case AnalysisWizard.AWSteps.Step2B:
                    Step2BAutoOpenCheckBox.CheckState = (NC.App.AppContext.OpenResults ? CheckState.Checked : CheckState.Unchecked);
                    Step2BIncludeConfigCheckBox.CheckState = (ap.lm.IncludeConfig ? CheckState.Checked : CheckState.Unchecked);
                    Step2BSaveEarlyTermCheckBox.CheckState = (ap.lm.SaveOnTerminate ? CheckState.Checked : CheckState.Unchecked);
                    if (fromINCCAcquire)
                        IntervalTextBox.Text = ap.run_count_time.ToString();
                    else
                        IntervalTextBox.Text = ap.lm.Interval.ToString();
                    Step2BOutputDirectoryTextBox.Text = ap.lm.Results; // jfl todo: expand to full path (if relative?)
                    if (fromINCCAcquire)
                        CycleNumTextBox.Text = ap.num_runs.ToString();
                    else
                        CycleNumTextBox.Text = ap.lm.Cycles.ToString();
                    Step2BAutoOpenCheckBox.CheckState = (NC.App.AppContext.OpenResults ? CheckState.Checked : CheckState.Unchecked);
                    Step2BWriteDataFiles.CheckState = (NC.App.AppContext.LiveFileWrite ? CheckState.Checked : CheckState.Unchecked);

                    RefreshDetectorCombo(Step2BDetectorComboBox);
                    break;
                case AnalysisWizard.AWSteps.Step3:
                    SetCheckListBoxAnalyzers();
                    ShowCurrentAnalzyerSelection();

                    break;
                case AnalysisWizard.AWSteps.Step4:
                    // step 4 next creates the selected analyzer and adds it to the ap var
                    break;
                case AnalysisWizard.AWSteps.Step5:

                    break;
                default:
                    break;
            }
        }
Example #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;
        }