Beispiel #1
0
        private void buttonstop_Click(object sender, EventArgs e)
        {
            buttonstop.Enabled         = false;
            buttonstart.Enabled        = true;
            comboBoxchan.Enabled       = true;
            comboBoxsamplerate.Enabled = true;
            start = false;
            check.Abort();
            daqcontrol.result = USBDASK.UD_AI_AsyncClear(0, out daqcontrol.AccessCnt);
            if (daqcontrol.result < 0)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Falied to perform UD_AI_AsyncClear(), error: " + daqcontrol.result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            daqcontrol.result = USBDASK.UD_Release_Card(0);
            if (daqcontrol.result < 0)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show("Falied to perform UD_Release_Card(), error: " + daqcontrol.result, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            timetofileindex = 0;
            files           = dir.GetFiles("*", SearchOption.TopDirectoryOnly);
            filenames       = files.Select(f => f.Name).ToArray();

            for (int i = 0; i < filenames.Length; i++)
            {
                File.Move(path[0] + filenames[i], path[1] + filenames[i]);
            }
            //File.Move(path[0] + Timetofile.ToString("yyyyMMddHHmmss") + ".txt", path[1] + Timetofile.ToString("yyyyMMddHHmmss") + ".txt");
            // txtWtr.Close();
        }
Beispiel #2
0
        private void btnStop_Click(object sender, EventArgs e)
        {
            short err;
            uint  AccessCnt;

            err = USBDASK.UD_AI_AsyncClear(Module_Num, out AccessCnt);
            btnStart.Enabled = true;
        }
Beispiel #3
0
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            short err;
            uint  AccessCnt;

            // gr.Dispose();

            if (Module_Num1 != -1)
            {
                err = USBDASK.UD_AI_AsyncClear((ushort)Module_Num1, out AccessCnt);
            }


            if (Module_Num2 != -1)
            {
                err = USBDASK.UD_AI_AsyncClear((ushort)Module_Num2, out AccessCnt);
            }


            Marshal.FreeHGlobal(m_data_buffer);
            Marshal.FreeHGlobal(m_data_buffer2);

            // Added on 2018/2/27 Ming-Yen
            // The 80M / 40 = 2MHz Clock will be sent out when IntEnable is set to 1
            // The 80M / 40 = 2MHz Clock will be stopped when IntEnable is set to 0
            err = USBDASK.UD_GPTC_Control((ushort)Module_Num1, 0, USBDASK.IntENABLE, 0);
            if (err < 0)
            {
                MessageBox.Show(string.Format("UD_GPTC_Control IntENABLE Error: {0}", err));
                return;
            }
            // Added on 2018/2/27 Ming-Yen
            err = USBDASK.UD_GPTC_Control((ushort)Module_Num1, 0, USBDASK.IntGate, 0);
            if (err < 0)
            {
                MessageBox.Show(string.Format("UD_GPTC_Control IntGate Error: {0}", err));
                return;
            }
            //btnGPO0.Text = "GPO0 2MHz OFF";

            if (Module_Num1 != -1)
            {
                USBDASK.UD_Release_Card((ushort)Module_Num1);
            }
            if (Module_Num2 != -1)
            {
                USBDASK.UD_Release_Card((ushort)Module_Num2);
            }
        }
Beispiel #4
0
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (start)
            {
                daqcontrol.result = USBDASK.UD_AI_AsyncClear(0, out daqcontrol.AccessCnt);
                daqcontrol.result = USBDASK.UD_Release_Card(0);
            }

            if (txtWtr != null)
            {
                txtWtr.Close();
            }
            if (check.IsAlive)
            {
                if (false == check.Join(200))
                {
                    check.Abort();
                }
            }
        }
Beispiel #5
0
        private void Callback()
        {
            short err;
            uint  dwAccessCnt;

            err = USBDASK.UD_AI_AsyncClear((ushort)Module_Num1, out dwAccessCnt);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_AsyncClear error = " + err.ToString());
                return;
            }

            err = USBDASK.UD_AI_AsyncClear((ushort)Module_Num2, out dwAccessCnt);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_AI_AsyncClear error = " + err.ToString());
                return;
            }
            GPO0Close();
            PlotData();
        }
Beispiel #6
0
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            short err;
            uint  AccessCnt;

            gr.Dispose();

            if (Module_Num != USBDASK.INVALID_CARD_ID)
            {
                err = USBDASK.UD_AI_AsyncClear(Module_Num, out AccessCnt);
            }



            if (alloc == 1)
            {
                Marshal.FreeHGlobal(m_data_buffer);
            }

            if (Module_Num != USBDASK.INVALID_CARD_ID)
            {
                USBDASK.UD_Release_Card(Module_Num);
            }
        }