Exemplo n.º 1
0
        private void cmdStartAcq_Click(object eventSender, System.EventArgs eventArgs)         /* Handles cmdStartAcq.Click */
        {
            cmdStartAcq.Enabled    = false;
            cmdStartAcq.Visible    = false;
            cmdStopConvert.Enabled = true;
            cmdStopConvert.Visible = true;

            //  Parameters:
            //    LowChan    :first A/D channel of the scan
            //    HighChan   :last A/D channel of the scan
            //    Count      :the total number of A/D samples to collect
            //    Rate       :per channel sampling rate ((samples per second) per channel)
            //    Range      :the gain for the board
            //    FileName   :the filename for the collected data values
            //    Options    :data collection options
            int    Count    = NumPoints;
            string FileName = txtFileName.Text;             //  a full path may be required here
            int    Rate     = 50000;
            int    LowChan  = 0;
            int    HighChan = 1;

            MccDaq.ScanOptions Options = MccDaq.ScanOptions.Default;
            MccDaq.Range       Range   = MccDaq.Range.Bip5Volts;     // set the range

            string DataCount = NumPoints.ToString("0");

            lblAcqStat.Text     = "Collecting " + DataCount + " data points";
            lblShowRate.Text    = Rate.ToString("0");
            lblShowLoChan.Text  = LowChan.ToString("0");
            lblShowHiChan.Text  = HighChan.ToString("0");
            lblShowOptions.Text = Options.ToString();
            lblShowGain.Text    = Range.ToString();
            lblShowFile.Text    = FileName;
            lblShowCount.Text   = Count.ToString("0");
            lblShowPreTrig.Text = "Not Applicable";
            Application.DoEvents();

            //  Collect the values with Collect the values by calling MccDaq.MccBoard.FileAInScan()

            MccDaq.ErrorInfo ULStat = DaqBoard.FileAInScan(LowChan, HighChan, Count, ref Rate, Range, FileName, Options);

            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.BadFileName)
            {
                MessageBox.Show("Enter the name of the file to create in text box.", "Bad File Name", 0);
                cmdStopConvert.Enabled = false;
                cmdStopConvert.Visible = false;
                cmdStartAcq.Enabled    = true;
                cmdStartAcq.Visible    = true;
                txtFileName.Focus();
                return;
            }


            //  show how many data points were collected
            short FileLowChan;
            short FileHighChan;
            int   TotalCount;
            int   PretrigCount;

            ULStat = MccDaq.MccService.FileGetInfo(FileName, out FileLowChan, out FileHighChan, out PretrigCount, out TotalCount, out Rate, out Range);



            lblReadRate.Text    = Rate.ToString("0");
            lblReadLoChan.Text  = FileLowChan.ToString("0");
            lblReadHiChan.Text  = FileHighChan.ToString("0");
            lblReadOptions.Text = Options.ToString();
            lblReadGain.Text    = Range.ToString();
            lblReadFile.Text    = FileName;

            lblReadTotal.Text   = TotalCount.ToString("0");
            lblReadPreTrig.Text = PretrigCount.ToString("0");
        }