Ejemplo n.º 1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            short err;
            uint  dwInvCnt;

            // Configure AI Channel
            err = USBDASK.UD_AI_1902_Config(Module_Num, USBDASK.P1902_AI_PseudoDifferential, 0, 0, 0, 0);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_1902_Config error = :" + err.ToString());
                Close();
                return;
            }

            // Enable double-buffer
            err = USBDASK.UD_AI_AsyncDblBufferMode(Module_Num, true);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_AsyncDblBufferMode error = :" + err.ToString());
                Close();
                return;
            }

            dwInvCnt = Convert.ToUInt32(U1902_TIMEBASE / fSampleRate);

            err = USBDASK.UD_AI_1902_CounterInterval(Module_Num, dwInvCnt, dwInvCnt);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_1902_CounterInterval error = :" + err.ToString());
                Close();
                return;
            }
            err = USBDASK.UD_AI_EventCallBack(Module_Num, 1, USBDASK.DBEvent, m_delegate);
            if (err < 0)
            {
                MessageBox.Show("UD_AI_EventCallBack error = :" + err.ToString());
                Close();
                return;
            }

            err = USBDASK.UD_AI_ContReadChannel(Module_Num, 0, USBDASK.AD_B_10_V, m_data_buffer, dwDataNum, fSampleRate, USBDASK.ASYNCH_OP);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_ContReadMultiChannels error = :" + err.ToString());
                Close();
                return;
            }

            //timer1.Enabled = true;
            btnStart.Enabled = false;
        }