示例#1
0
        private void tmrCheckStatus_Tick(object eventSender, System.EventArgs eventArgs)
        {
            tmrCheckStatus.Stop();

            int   CurIndex;
            int   CurCount;
            short Status;

            MccDaq.ErrorInfo ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.DiFunction);


            lblShowStat.Text  = Status.ToString("0");
            lblShowCount.Text = CurCount.ToString("0");
            lblShowIndex.Text = CurIndex.ToString("0");
            if (Status == MccDaq.MccBoard.Running)
            {
                lblBGStat.Text = "Background operation running";
            }
            else
            {
                lblBGStat.Text = "Background operation idle";
            }

            if ((CurCount == NumPoints || Status == 0) || (Force == 1))
            {
                ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.DiFunction);

                ShowData();
            }
            else
            {
                tmrCheckStatus.Start();
            }
        }
示例#2
0
 private void cmdStop_Click(object sender, System.EventArgs e)
 {
     this.chkAutoRestart.Checked = false;
     DaqBoard.StopBackground(MccDaq.FunctionType.AiFunction);
     // Some devices generate an end of scan event after user
     // explicitly stops background operations, but most do not
     // When stopped manually, handle post-scan tasks here.
     cmdStart.Enabled = true;
     lblStatus.Text   = "IDLE";
 }
示例#3
0
        private void cmdStopConvert_Click(object eventSender, System.EventArgs eventArgs)
        {
            int   CurIndex;
            int   CurCount;
            short Status;

            MccDaq.ErrorInfo ULStat;

            ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.AiFunction);

            cmdStartBgnd.Enabled   = true;
            cmdStartBgnd.Visible   = true;
            cmdStopConvert.Enabled = false;
            cmdStopConvert.Visible = false;
            cmdQuit.Enabled        = true;
            tmrCheckStatus.Enabled = false;

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AiFunction);

            if (Status == MccDaq.MccBoard.Idle)
            {
                lblShowStat.Text = "Idle";
            }
            lblShowCount.Text = CurCount.ToString("D");
            lblShowIndex.Text = CurIndex.ToString("D");
        }
示例#4
0
        // Form overrides dispose to clean up the component list.
        protected override void  Dispose(bool Disposing)
        {
            if (Disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                DaqBoard.StopBackground(MccDaq.FunctionType.AiFunction);
                if (MemHandle != 0)
                {
                    MccDaq.MccService.WinBufFree(MemHandle);
                }
            }
            base.Dispose(Disposing);
        }
示例#5
0
        // Form overrides dispose to clean up the component list.
        protected override void  Dispose(bool Disposing)
        {
            if (Disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                // make sure bacground operation is stopped and all memory
                //  is freed
                DaqBoard.StopBackground(MccDaq.FunctionType.DiFunction);
                if (MemHandle != 0)
                {
                    MccDaq.MccService.WinBufFree(MemHandle);
                }
            }
            base.Dispose(Disposing);
        }
示例#6
0
        // Form overrides dispose to clean up the component list.
        protected override void  Dispose(bool Disposing)
        {
            if (Disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                // make sure the scan has stopped..
                DaqBoard.StopBackground(MccDaq.FunctionType.AiFunction);

                // be sure to free the memory buffer
                if (MemHandle != 0)
                {
                    MccDaq.MccService.WinBufFree(MemHandle);
                }
            }
            base.Dispose(Disposing);
        }
示例#7
0
文件: ULCT03.cs 项目: r4forth/sdkpub
        private void cmdStopRead_Click(object eventSender, System.EventArgs eventArgs)         /* Handles cmdStopRead.Click */
        {
            //  The BACKGROUND operation must be explicitly stopped
            //  Parameters:
            //    FunctionType:counter operation (MccDaq.FunctionType.CtrFunction)
            MccDaq.ErrorInfo ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.CtrFunction);


            //  Free up memory for use by other programs
            ULStat = MccDaq.MccService.WinBufFree(MemHandle);

            MemHandle = 0;

            Application.Exit();
        }
示例#8
0
        private void tmrCheckStatus_Tick(object eventSender, System.EventArgs eventArgs)
        {
            int   CurIndex;
            int   CurCount;
            short Status;

            tmrCheckStatus.Stop();

            // Check the current status of the background data collection
            //   Parameters:
            //      Status     :current status of the background data collection
            //      CurCount   :current number of samples collected
            //      CurIndex   :index to the data buffer pointing to the last value transferred
            //      FunctionType: A/D operation (MccDaq.FunctionType.AiFunction)

            MccDaq.ErrorInfo ULStat = DaqBoard.GetStatus
                                          (out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AiFunction);

            //  check if the background operation has finished
            if ((Status == MccDaq.MccBoard.Idle) || (UserTerm == 1))
            {
                lblStatus.Text = "Data collection finished.";

                // the background operation must be explicitly stopped
                ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.AiFunction);

                ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, NumPoints);

                cmdStartConvert.Enabled   = true;
                cmdQuit.Enabled           = true;
                cmdStopBackground.Enabled = false;
                Convert();
            }
            else
            {
                lblStatus.Text = "Background operation in progress.";
                tmrCheckStatus.Start();
            }

            if (UserTerm == 1)
            {
                lblStatus.Text = "Data collection terminated by user.";
                UserTerm       = 0;
            }
        }
        private void tmrCheckStatus_Tick(System.Object eventSender, System.EventArgs eventArgs)
        {
            int FirstPoint;

            MccDaq.ErrorInfo ULStat;
            int   CurIndex;
            int   CurCount;
            short Status;

            tmrCheckStatus.Stop();

            // This timer will check the status of the background data collection

            // Parameters:
            //   BoardNum   :the number used by CB.CFG to describe this board
            //   Status     :current status of the background data collection
            //   CurCount   :current number of samples collected
            //   CurIndex   :index to the data buffer pointing to the start of the
            //                most recently collected scan
            //   FunctionType: A/D operation (AIFUNCTIOM)

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex,
                                        MccDaq.FunctionType.DaqiFunction);

            lblShowCount.Text = CurCount.ToString("D");
            lblShowIndex.Text = CurIndex.ToString("D");

            // Check if the background operation has finished. If it has, then
            // transfer the data from the memory buffer set up by Windows to an
            // array for use by Visual Basic
            // The BACKGROUND operation must be explicitly stopped

            if (Status == MccDaq.MccBoard.Running && UserTerm == 0)
            {
                lblShowStat.Text = "Running";
                ULStat           = DaqBoard.GetStatus(out Status, out CurCount,
                                                      out CurIndex, MccDaq.FunctionType.DaqiFunction);

                lblShowCount.Text = CurCount.ToString("D");
                lblShowIndex.Text = CurIndex.ToString("D");

                FirstPoint = CurIndex;
                if (FirstPoint >= 0)
                {
                    ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, ChanCount);

                    lblADData[0].Text = ADData[0].ToString("D");
                    lblADData[1].Text = ADData[1].ToString("D");
                    lblADData[2].Text = System.Convert.ToString(System.Convert.ToInt32(ADData[2])
                                                                + System.Convert.ToInt32(ADData[3]) * System.Convert.ToInt32(Math.Pow(2, 16)));
                    // 32-bit counter
                }
                tmrCheckStatus.Start();
            }
            else if (Status == MccDaq.MccBoard.Idle || UserTerm == 1)
            {
                lblShowStat.Text = "Idle";
                tmrCheckStatus.Stop();

                ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.DaqiFunction);

                cmdStartBgnd.Enabled   = true;
                cmdStartBgnd.Visible   = true;
                cmdStopConvert.Enabled = false;
                cmdStopConvert.Visible = false;
                cmdQuit.Enabled        = true;
            }
        }
示例#10
0
        static void Main(string[] args)
        {
            System.ConsoleKeyInfo cki = new System.ConsoleKeyInfo();
            MccDaq.ErrorInfo      RetVal;

            int  BoardNum       = 0;
            int  DeviceChannels = 0;
            int  Rate           = FREQ;
            bool ReadLower      = true;

            BoardNum = GetBoardNum(DEVICE);

            if (BoardNum == -1)
            {
                Console.WriteLine("No USB-{0} detected!", DEVICE);
                cki = Console.ReadKey();
            }
            else
            {
                MccBoard daq = new MccDaq.MccBoard(BoardNum);

                daq.BoardConfig.GetNumAdChans(out DeviceChannels);

                if (DeviceChannels > 8)
                {
                    Console.WriteLine("Single-Ended Channels");
                }
                else
                {
                    Console.WriteLine("Differentially-Ended Channels");
                }


                IntPtr buffer = MccService.ScaledWinBufAllocEx(BUFFERSIZE);

                if (buffer == IntPtr.Zero)
                {
                    Console.WriteLine("Bad Handle");
                    return;
                }

                short[] chArray = new short[CHANCOUNT]; //configuration array for channel numbers
                Range[] chRange = new Range[CHANCOUNT]; //configuration array for input ranges

                chArray[0] = 0;
                chArray[1] = 1;
                chArray[2] = 2;
                chArray[3] = 3;

                chRange[0] = Range.Bip10Volts;
                chRange[1] = Range.Bip10Volts;
                chRange[2] = Range.Bip10Volts;
                chRange[3] = Range.Bip10Volts;

                RetVal = daq.ALoadQueue(chArray, chRange, CHANCOUNT);
                IsError(RetVal);

                //setup the acquisiton
                RetVal = daq.AInScan(FIRSTCHANNEL,
                                     LASTCHANNEL,
                                     BUFFERSIZE,
                                     ref Rate,
                                     Range.Bip10Volts,
                                     buffer,
                                     ScanOptions.Background | ScanOptions.ScaleData | ScanOptions.Continuous
                                     );
                IsError(RetVal);

                fStream = new StreamWriter(@"C:\Users\Public\Documents\DataFile1608G.asc");
                CreateFileHeaders(chArray); //writes basic info to the beginning of the file

                int   Count = 0;
                int   Index = 0;
                short daqStatus;

                double[] theArray = new double[BUFFERSIZE];



                //Loop until key press
                do
                {
                    RetVal = daq.GetStatus(out daqStatus, out Count, out Index, FunctionType.AiFunction);
                    if ((Index >= HALFBUFFSIZE) & ReadLower) //check for 50% more data
                    {
                        //get lower half of buffer - ScaledWinBufToArray returns engineering units
                        RetVal = MccService.ScaledWinBufToArray(buffer, theArray, 0, HALFBUFFSIZE);
                        IsError(RetVal);

                        DisplayData(theArray, HALFBUFFSIZE / CHANCOUNT);
                        ReadLower = false; //flag that controls the next read
                    }
                    else if ((Index < HALFBUFFSIZE) & !ReadLower)
                    {
                        //get the upper half  - ScaledWinBufToArray returns engineering units
                        RetVal = MccService.ScaledWinBufToArray(buffer, theArray, HALFBUFFSIZE, HALFBUFFSIZE);
                        IsError(RetVal);

                        DisplayData(theArray, HALFBUFFSIZE / CHANCOUNT);
                        ReadLower = true;//flag that controls the next read
                    }
                } while (!Console.KeyAvailable);

                cki = Console.ReadKey();

                //flush any buffered data out to disk
                fStream.Close();

                //stop the  acquisition
                RetVal = daq.StopBackground(FunctionType.AiFunction);

                //free up memory
                MccService.WinBufFreeEx(buffer);

                WaitForKey();
            }
        }
示例#11
0
        private void tmrCheckStatus_Tick(object eventSender, System.EventArgs eventArgs)
        {
            int j;
            int i;

            MccDaq.ErrorInfo ULStat;
            int   CurIndex;
            int   CurCount;
            short Status;

            tmrCheckStatus.Stop();

            //  This timer will check the status of the background data collection

            //  Parameters:
            //    Status     :current status of the background data collection
            //    CurCount   :current number of samples collected
            //    CurIndex   :index to the data buffer pointing to the start of the
            //                most recently collected scan
            //    FunctionType: A/D operation (AiFunction)

            ULStat = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AiFunction);

            lblShowCount.Text = CurCount.ToString("D");
            lblShowIndex.Text = CurIndex.ToString("D");

            //  Check if the background operation has finished. If it has, then
            //  transfer the data from the memory buffer set up by Windows to an
            //  array for use by Visual this program
            //  The background operation must be explicitly stopped

            if ((Status == MccDaq.MccBoard.Running) && (UserTerm == 0))
            {
                lblShowStat.Text = "Running";
                tmrCheckStatus.Start();
            }
            else if ((Status == MccDaq.MccBoard.Idle) || (UserTerm == 1))
            {
                lblShowStat.Text = "Idle";
                ULStat           = DaqBoard.GetStatus(out Status, out CurCount, out CurIndex, MccDaq.FunctionType.AiFunction);

                lblShowCount.Text      = CurCount.ToString("D");
                lblShowIndex.Text      = CurIndex.ToString("D");
                tmrCheckStatus.Enabled = false;

                if (ADResolution > 16)
                {
                    ULStat = MccDaq.MccService.WinBufToArray32(MemHandle, ADData32, FirstPoint, NumPoints);

                    for (i = 0; i <= HighChan; ++i)
                    {
                        lblADData[i].Text = ADData32[i].ToString("D");
                    }
                }
                else
                {
                    ULStat = MccDaq.MccService.WinBufToArray(MemHandle, ADData, FirstPoint, NumPoints);

                    for (i = 0; i <= HighChan; ++i)
                    {
                        lblADData[i].Text = ADData[i].ToString("D");
                    }
                }

                for (j = HighChan + 1; j <= 7; ++j)
                {
                    lblADData[j].Text = "";
                }

                // always call StopBackground upon completion...
                ULStat = DaqBoard.StopBackground(MccDaq.FunctionType.AiFunction);

                cmdStartBgnd.Enabled   = true;
                cmdStartBgnd.Visible   = true;
                cmdStopConvert.Enabled = false;
                cmdStopConvert.Visible = false;
                cmdQuit.Enabled        = true;
            }
        }