Example #1
0
        private void BackupAllDataClick(object sender, RoutedEventArgs e)
        {
            string dest = UIIntegration.GetUsersFolder("Select Destination", "Select a path to backup data.");

            if (dest != String.Empty)
            {
                string source = System.IO.Path.GetDirectoryName(NC.App.Pest.GetDBFileFromConxString());
                string destFileName;
                destFileName = String.Format("\\INCC-{0}", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
                FileStream    fs = File.Create(dest + destFileName + ".gz");
                GZipStream    compressionStream = new GZipStream(fs, CompressionMode.Compress);
                DirectoryInfo selectedDir       = new DirectoryInfo(source);
                foreach (FileInfo fileToCompress in selectedDir.GetFiles())
                {
                    using (FileStream originalFileStream = new FileStream(fileToCompress.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        if ((File.GetAttributes(fileToCompress.FullName) & FileAttributes.Hidden) != FileAttributes.Hidden & fileToCompress.Extension != ".gz")
                        {
                            originalFileStream.CopyTo(compressionStream);
                        }
                    }
                }
                fs.Close();
            }
            else
            {
                MessageBox.Show("The destination folder could not be created", "ERROR");
            }
        }
Example #2
0
        public static DialogResult GetUsersFilesFolder(string title, string dir, string name, string ext, string ext2 = "")
        {
            FoldorFile.FileOrFolderChoice choice = ChooseFiles();
            if (choice == FoldorFile.FileOrFolderChoice.Cancel)
            {
                return(DialogResult.Cancel);
            }

            if (choice == FoldorFile.FileOrFolderChoice.Folder)
            {
                string xs = UIIntegration.GetUsersFolder("Select folder", dir);
                if (!String.IsNullOrEmpty(xs))
                {
                    NC.App.AppContext.FileInput     = xs;
                    NC.App.AppContext.FileInputList = null;  // no explicit file list
                    return(DialogResult.OK);
                }
                else
                {
                    return(DialogResult.Cancel);
                }
            }
            // choice == files
            System.Windows.Forms.OpenFileDialog RestoreFileDialog = new System.Windows.Forms.OpenFileDialog();
            List <string> paths = new List <string>();

            RestoreFileDialog.CheckFileExists = false;
            RestoreFileDialog.DefaultExt      = "ext";
            RestoreFileDialog.Filter          = name + " files (." + ext + ")|*." + ext;
            if (!String.IsNullOrEmpty(ext2))
            {
                RestoreFileDialog.Filter += "| (." + ext2 + ")|*." + ext2;
            }
            RestoreFileDialog.Filter          += "|All files (*.*)|*.*";
            RestoreFileDialog.InitialDirectory = NC.App.AppContext.FileInput;
            RestoreFileDialog.Title            = title;
            RestoreFileDialog.Multiselect      = true;
            RestoreFileDialog.RestoreDirectory = true;
            DialogResult r = DialogResult.No;

            r = RestoreFileDialog.ShowDialog();
            if (r == DialogResult.OK)
            {
                foreach (string s in RestoreFileDialog.FileNames)
                {
                    paths.Add(s);
                }
                FileSel fs = new FileSel(paths);
                r = fs.ShowDialog();
                if (r == DialogResult.OK)
                {
                    NC.App.AppContext.FileInputList = paths;
                    NC.App.AppContext.FileInput     = null; // no explicit folder System.IO.Path.GetDirectoryName(paths[0]);
                }
            }
            return(r);
        }
Example #3
0
        private void TransferFileOutClick(object sender, RoutedEventArgs e)
        {
            String s = UIIntegration.GetUsersFolder("Select Transfer File Folder for Output", NC.App.AppContext.FileInput);

            if (!String.IsNullOrEmpty(s))
            {
                UIIntegration.Controller.file = true;
                // JFL todo: we do not have a way to export transfer files in this code, so this is a placeholder
            }
        }
Example #4
0
        private void TransferFileInClick(object sender, RoutedEventArgs e)
        {
            String s = UIIntegration.GetUsersFolder("Select Input Transfer File Folder", NC.App.AppContext.FileInput);

            if (!String.IsNullOrEmpty(s))
            {
                NC.App.AppContext.FileInput     = s;
                NC.App.AppContext.FileInputList = null;                                            // no explicit file list
                UIIntegration.Controller.file   = true;
                UIIntegration.Controller.SetFileTransform();                                       // it is a file action
                NC.App.AppContext.MutuallyExclusiveFileActions(NCCConfig.NCCFlags.INCCXfer, true); //enable only xfer file processing
                UIIntegration.Controller.Perform();                                                // run the current specified operation
            }
        }
Example #5
0
        private void incc5IniLoc_Click(object sender, EventArgs e)
        {
            string str = UIIntegration.GetUsersFolder("Data file folder location", (string)maybe[(NCCFlags)((Control)sender).Tag]);

            if (!string.IsNullOrEmpty(str))
            {
                maybe[(NCCFlags)((Control)sender).Tag] = str;
                DataFileLoc.Text = str;
                if (!string.IsNullOrEmpty(str))
                {
                    incc5IniLoc.Text = System.IO.Path.GetFullPath(str);
                }
            }
        }
Example #6
0
        private void OKBtn_Click(object sender, EventArgs e)
        {
            NCCReporter.LMLoggers.LognLM applog = NC.App.Logger(NCCReporter.LMLoggers.AppSection.App);
            string dest = UIIntegration.GetUsersFolder("Select Destination", string.Empty);

            if (string.IsNullOrEmpty(dest))
            {
                return;
            }
            if (DetectorCurrentRadioButton.Checked)
            {
                List <Detector> l = new List <Detector>();
                l.Add(Integ.GetCurrentAcquireDetector());
                INCCInitialDataDetectorFile iddf = INCCKnew.FromDetectors(l);
                iddf.Save(dest);
            }
            else if (DetectorAllRadioButton.Checked)
            {
                List <Detector>             l    = NC.App.DB.Detectors;
                INCCInitialDataDetectorFile iddf = INCCKnew.FromDetectors(l);
                iddf.Save(dest);
            }
            else if (CalibrationCurrentRadioButton.Checked)
            {
                List <Detector> l = new List <Detector>();
                l.Add(Integ.GetCurrentAcquireDetector());
                List <INCCInitialDataCalibrationFile> lidcf = INCCKnew.CalibFromDetectors(l);
                if (lidcf.Count > 0)
                {
                    if (!lidcf[0].Save(dest))
                    {
                        applog.TraceEvent(NCCReporter.LogLevels.Warning, 33154, "No calibration parameters for " + lidcf[0].Name);
                    }
                }
            }
            else if (CalibrationAllRadioButton.Checked)
            {
                List <Detector> l = NC.App.DB.Detectors;
                List <INCCInitialDataCalibrationFile> lidcf = INCCKnew.CalibFromDetectors(l);
                foreach (INCCInitialDataCalibrationFile idcf in lidcf)
                {
                    if (!idcf.Save(dest))
                    {
                        applog.TraceEvent(NCCReporter.LogLevels.Warning, 33154, "No calibration parameters for " + idcf.Name);
                    }
                }
            }
            Close();
        }
Example #7
0
        // possible to append daily path to the daily path, so do not do that.
        private void root_Click(object sender, EventArgs e)
        {
            string str = UIIntegration.GetUsersFolder("Working folder (the current directory) location", (string)maybe[(NCCFlags)((Control)sender).Tag]);

            //Adding date to this path is sticking.  Need to just display the root location. hn 10-2
            //Checking for extra date presence to skip it, to keep the daily path override of the overall root path in play, to fix  hn 10-2 bug,

            if (!String.IsNullOrEmpty(str))
            {
                maybe[(NCCFlags)((Control)sender).Tag] = str;
                if ((bool)maybe[NCCFlags.dailyRootPath])
                {
                    string part = DateTime.Now.ToString("yyyy-MMdd");
                    if (!str.EndsWith(part))  // it's not the current day
                    {
                        Match m = Regex.Match(str, "\\d{4}-\\d{4}$");
                        if (m.Success)  // it is a pattern match
                        {
                            // so strip and replace with current date
                            string s = str.Remove(m.Index);
                            s = System.IO.Path.Combine(s, part);
                            WorkingDirTextBox.Text = s;
                        }
                        else
                        {
                            WorkingDirTextBox.Text = System.IO.Path.Combine(str, part);
                        }
                    }
                    else
                    {
                        WorkingDirTextBox.Text = System.IO.Path.GetFullPath(str);
                    }
                }
                else
                {
                    WorkingDirTextBox.Text = System.IO.Path.GetFullPath(str);
                }
            }
        }
Example #8
0
        private void BackupAllDataClick(object sender, RoutedEventArgs e)
        {
            string dest = UIIntegration.GetUsersFolder("Select Destination", string.Empty);

            if (!string.IsNullOrEmpty(dest))
            {
                //Path to sql or sqlite files
                string destFileName;
                destFileName = string.Format("INCC-{0}.zip", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
                using (FileStream zipToOpen = new FileStream(Path.Combine(dest, destFileName), FileMode.OpenOrCreate))
                {
                    using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update))
                    {
                        // Cannot archive connected DB or cfg, copy, archive, then delete.
                        // TODO: is this all that we want to save? HN 7/27/2016
                        string DBFolder   = Path.GetDirectoryName(NC.App.Pest.GetDBFileFromConxString());
                        string DBFile     = Path.GetFullPath(NC.App.Pest.GetDBFileFromConxString());
                        string DBFileName = Path.GetFileName(NC.App.Pest.GetDBFileFromConxString());
                        string CfgPath    = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

                        File.Copy(Path.Combine(DBFolder, DBFile), Path.Combine(dest, DBFileName), true);
                        File.Copy(CfgPath, Path.Combine(dest, Path.GetFileName(CfgPath)), true);

                        ZipArchiveEntry dbFile  = archive.CreateEntryFromFile(Path.Combine(dest, DBFileName), DBFileName);
                        ZipArchiveEntry cfgFile = archive.CreateEntryFromFile(Path.Combine(dest, Path.GetFileName(CfgPath)), Path.GetFileName(CfgPath));
                        NC.App.Loggers.AppLogger.TraceEvent(LogLevels.Info, 1111, String.Format("Zip file containing database and config created: {0}", Path.Combine(dest, destFileName)));
                        File.Delete(Path.Combine(dest, DBFileName));
                        File.Delete(Path.Combine(dest, Path.GetFileName(CfgPath)));
                    }
                }
            }
            else
            {
                MessageBox.Show("The destination folder could not be created", "ERROR");
            }
        }
Example #9
0
 private void OKBtn_Click(object sender, EventArgs e)
 {
     if (CurrentDetectorRadioButton.Checked)
     {
         IDDSaveCampaignId f = new IDDSaveCampaignId();
         DialogResult      r = f.ShowDialog();
         if (r == DialogResult.OK)
         {
             string dest = UIIntegration.GetUsersFolder("Select Directory for Saving Measurement Data", string.Empty);
             if (string.IsNullOrEmpty(dest))
             {
                 return;
             }
             IDDMeasurementList measlist = new IDDMeasurementList();
             measlist.Init(f.FilteredList,
                           AssaySelector.MeasurementOption.unspecified,
                           lmonly: false, goal: IDDMeasurementList.EndGoal.Transfer, inspnum: f.inspnum, detector: f.det);
             DialogResult dr = DialogResult.None;
             if (measlist.bGood)
             {
                 measlist.ShowDialog();
             }
             dr = measlist.DialogResult;
             if (dr != DialogResult.OK)
             {
                 return;
             }
             List <Measurement> mlist = measlist.GetSelectedMeas();
             foreach (Measurement m in mlist)
             {
                 CycleList cl = NC.App.DB.GetCycles(f.det, m.MeasurementId, m.AcquireState.data_src);                         // APluralityOfMultiplicityAnalyzers: // URGENT: get all the cycles associated with each analyzer, restoring into the correct key->result pair
                 m.Cycles.AddRange(cl);
                 // NEXT: m.CFCyles for AAS not used for INCC6 created measurements, only INCC5 transfer measurements have them m.Add(c, i);
                 m.INCCAnalysisResults.TradResultsRec = NC.App.DB.ResultsRecFor(m.MeasurementId);
                 m.ReportRecalc();                         // dev note: not strictly from INCC5, but based on usage complaint from LANL
             }
             List <INCCTransferFile> itdl = INCCKnew.XFerFromMeasurements(mlist);
             foreach (INCCTransferFile itd in itdl)
             {
                 itd.Save(dest);
             }
         }
     }
     else if (AllDetectorsRadioButton.Checked)
     {
         string dest = UIIntegration.GetUsersFolder("Select Directory for Saving Measurement Data", string.Empty);
         if (string.IsNullOrEmpty(dest))
         {
             return;
         }
         List <Detector> l = NC.App.DB.Detectors;
         foreach (Detector det in l)
         {
             List <Measurement> mlist = NC.App.DB.MeasurementsFor(det.Id.DetectorId);
             foreach (Measurement m in mlist)
             {
                 CycleList cl = NC.App.DB.GetCycles(det, m.MeasurementId, m.AcquireState.data_src);                         // APluralityOfMultiplicityAnalyzers: // URGENT: get all the cycles associated with each analyzer, restoring into the correct key->result pair
                 m.Add(cl);
                 if (m.MeasOption == AssaySelector.MeasurementOption.rates)
                 {
                     return;
                 }
                 else
                 {
                     m.INCCAnalysisResults.TradResultsRec = NC.App.DB.ResultsRecFor(m.MeasurementId);
                 }
             }
             List <INCCTransferFile> itdl = INCCKnew.XFerFromMeasurements(mlist);
             foreach (INCCTransferFile itd in itdl)
             {
                 itd.Save(dest);
             }
         }
     }
 }
Example #10
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);
        }
Example #11
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
            }
        }
Example #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);
        }