Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #3
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            short  err;
            ushort i;
            int    nBufSize;

            ushort[] ChanArray = new ushort[wSelectedChans];
            ushort[] GainArray = new ushort[wSelectedChans];

            dwDataNum = Convert.ToUInt32(TXT_DATACOUNT.Text);

            nBufSize       = sizeof(short) * Convert.ToInt32(dwDataNum) * wSelectedChans;
            m_data_buffer  = Marshal.AllocHGlobal(nBufSize);
            m_data_buffer2 = Marshal.AllocHGlobal(nBufSize);


            // Configure AI Channel
            err = USBDASK.UD_AI_Channel_Config((ushort)Module_Num1, USBDASK.UD_AI_Differential, USBDASK.UD_AI_Differential, USBDASK.UD_AI_Differential, USBDASK.UD_AI_Differential);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_Channel_Config error = " + err.ToString());
                Close();
                return;
            }
            err = USBDASK.UD_AI_Channel_Config((ushort)Module_Num2, USBDASK.UD_AI_Differential, USBDASK.UD_AI_Differential, USBDASK.UD_AI_Differential, USBDASK.UD_AI_Differential);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_Channel_Config error = :" + err.ToString());
                Close();
                return;
            }

            err = USBDASK.UD_AI_Trigger_Config((ushort)Module_Num1, USBDASK.UD_AI_CONVSRC_EXT, USBDASK.UD_AI_TRGMOD_POST, USBDASK.UD_AI_TRGSRC_SOFT, 0, 0, 0, 0);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_Trigger_Config error = " + err.ToString());
                Close();
                return;
            }
            err = USBDASK.UD_AI_Trigger_Config((ushort)Module_Num2, USBDASK.UD_AI_CONVSRC_EXT, USBDASK.UD_AI_TRGMOD_POST, USBDASK.UD_AI_TRGSRC_SOFT, 0, 0, 0, 0);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_Trigger_Config error = :" + err.ToString());
                Close();
                return;
            }

            // Disable double-buffer
            err = USBDASK.UD_AI_AsyncDblBufferMode((ushort)Module_Num1, false);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_AsyncDblBufferMode error = " + err.ToString());
                Close();
                return;
            }
            err = USBDASK.UD_AI_AsyncDblBufferMode((ushort)Module_Num2, false);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_AsyncDblBufferMode error = :" + err.ToString());
                Close();
                return;
            }

            err = USBDASK.UD_AI_EventCallBack_x64((ushort)Module_Num1, 1, USBDASK.AIEnd, m_delegate);
            if (err < 0)
            {
                MessageBox.Show("UD_AI_EventCallBack error = " + err.ToString());
                Close();
                return;
            }

            // Prepare the Channel Gain Queue
            for (i = 0; i < wSelectedChans; i++)
            {
                ChanArray[i] = i;
                GainArray[i] = USBDASK.AD_B_10_V;
            }

            dSamplerate = Convert.ToDouble(TXT_SAMPLERATE.Text);

            err = USBDASK.UD_AI_ContReadMultiChannels((ushort)Module_Num1, wSelectedChans, ChanArray, GainArray, m_data_buffer, dwDataNum * wSelectedChans, dSamplerate, USBDASK.ASYNCH_OP);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_ContReadMultiChannels error = " + err.ToString());
                Close();
                return;
            }
            err = USBDASK.UD_AI_ContReadMultiChannels((ushort)Module_Num2, wSelectedChans, ChanArray, GainArray, m_data_buffer2, dwDataNum * wSelectedChans, dSamplerate, USBDASK.ASYNCH_OP);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_ContReadMultiChannels error = " + err.ToString());
                Close();
                return;
            }

            GPO0Clk();
        }