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;
        }
Ejemplo n.º 2
0
        private void Configuredaq()
        {
            daqcontrol.result = USBDASK.UD_AI_2405_Chan_Config(0, daqcontrol.Chconfig, daqcontrol.Chconfig, daqcontrol.Chconfig, daqcontrol.Chconfig);
            if (daqcontrol.result != USBDASK.NoError)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Falied to perform UD_AI_2405_Chan_Config(), error: " + daqcontrol.result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }
            daqcontrol.result = USBDASK.UD_AI_2405_Trig_Config(0, USBDASK.P2405_AI_CONVSRC_INT, USBDASK.UD_AI_TRGMOD_POST, 0, 0, 0, 0, 0);
            if (daqcontrol.result != USBDASK.NoError)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Falied to perform UD_AI_2405_Trig_Config(), error: " + daqcontrol.result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            daqcontrol.result = USBDASK.UD_AI_AsyncDblBufferMode(0, true);
            if (daqcontrol.result != USBDASK.NoError)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Falied to perform UD_AI_AsyncDblBufferMode(), error: " + daqcontrol.result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }
            daqcontrol.result = USBDASK.UD_AI_EventCallBack(0, 1 /*add*/, USBDASK.DBEvent /*EventType*/, ai_buf_ready_cbdel);
            if (daqcontrol.result != USBDASK.NoError)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Falied to perform UD_AI_EventCallBack(), error: " + daqcontrol.result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }
            daqcontrol.result = USBDASK.UD_AI_ContReadMultiChannels(0, (ushort)daqcontrol.numbchans, daqcontrol.ai_chans, daqcontrol.ai_chans_range, daqcontrol.airowdata, daqcontrol.allchanlength * 2, daqcontrol.samplerate, USBDASK.ASYNCH_OP);
            if (daqcontrol.result != USBDASK.NoError)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Falied to perform UD_AI_ContReadMultiChannels(), error: " + daqcontrol.result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }
            Time       = DateTime.Now;
            Timetofile = Time;
        }