private void ComboBox_ChooseDriver_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                captureDriver = new CaptureDriver((CaptureDriver.EnumDriverName)comboBox_ChooseDriver.SelectedItem);

                hDevice = captureDriver.OpenDevice(0);
                captureDriver.CAL(hDevice);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            addata = new Int32[600000];

            textBox_do.Text = "0";
            textBox_da.Text = "0";
        }
示例#2
0
 public CaptureCard(int captureCardID, CaptureDriver captureDriver)
 {
     this.CaptureCardID = captureCardID;
     this.CaptureDriver = captureDriver;
 }
示例#3
0
 public CaptureCard(int captureCardID, string captureDriverName)
 {
     this.CaptureCardID = captureCardID;
     this.CaptureDriver = new CaptureDriver((EnumDriverName)Enum.Parse(typeof(EnumDriverName), captureDriverName));
 }
示例#4
0
        /// <summary>
        /// 传感器数据读取线程的主函数
        /// </summary>
        public static void GetCaptureDataThread()
        {
            IntPtr hDevice;

            Int32[]       addata;
            CaptureDriver captureDriver;

            #region 加载驱动
            captureDriver = new CaptureDriver((CaptureDriver.EnumDriverName)Enum.Parse(typeof(CaptureDriver.EnumDriverName), "AC6623SIM"));
            hDevice       = captureDriver.OpenDevice(0);
            captureDriver.CAL(hDevice);
            #endregion

            addata = new Int32[600000]; //采样数据
            #region 线程一直读取板卡的AD采样信息
            while (ThreadStatue)
            {
                foreach (Sensor aSensor in allSensorsList)
                {
                    string str;

                    captureDriver.TAD(hDevice, 0, 14, 2, 0, 0, 0, 0, 0, 0, 100);
                    for (int m = 0; m < 1000; m++)
                    {
                        for (int n = 0; n < 1000; n++)
                        {
                            ;;
                        }
                    }

                    if (captureDriver.TAD_Poll(hDevice) < 0)
                    {
                        //timer1.Enabled = false;
                        captureDriver.TAD_Stop(hDevice);
                        //listBox_ad.Items.Add("ad fifo over!!!");
                    }
                    else
                    {
                        //read空值则报错
                        if (captureDriver.TAD_Read(hDevice, captureDriver.TAD_Poll(hDevice), ref addata) == -1)
                        {
                            //listBox_ad.Items.Add("ad fifo over!!!");
                        }
                        else
                        {
                            //listBox_ad.Items.Clear();//清空数据
                            for (Int16 i = 0; i < 15; i++)
                            {
                                str = Convert.ToString(((addata[i]) - 2048) * 5000 / 2048); //  (0..4096分度) = ( -5 .. +5 V 电压)
                                                                                            //  int j = str.IndexOf('.');//
                                                                                            //      j = j + 3;
                                                                                            //    str = str.Substring(0, j);//
                                str = str + " mv";
                                //listBox_ad.Items.Add(str);//写入数据
                            }
                        }
                    }

                    captureDriver.TAD_Stop(hDevice);

                    Thread.Sleep(10);
                }
                //for (int i = 0; i < 10; i++)
                //{
                //    Console.WriteLine("ThreadProc: {0}", i);
                //    // Yield the rest of the time slice.
                //    Thread.Sleep(10);
                //}
            }
            Console.WriteLine("Thread stop.");
            #endregion
        }