Ejemplo n.º 1
0
        // Added on 2018/2/27 Ming-Yen
        private void btnGPO0_Click(object sender, EventArgs e)
        {
            short err;

            // 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
            if (btnGPO0.Text == "GPO0 2MHz OFF")
            {
                err = USBDASK.UD_GPTC_Control((ushort)Module_Num1, 0, USBDASK.IntENABLE, 1);
                if (err < 0)
                {
                    MessageBox.Show(string.Format("UD_GPTC_Control IntENABLE Error: {0}", err));
                    return;
                }
                btnGPO0.Text = "GPO0 2MHz ON";
            }
            else
            {
                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;
                }
                btnGPO0.Text = "GPO0 2MHz OFF";
            }
        }
Ejemplo n.º 2
0
        private void GPO0Close()
        {
            short err;

            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;
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            short err;

            m_delegate = new CallbackDelegate(Callback);
            gr         = pbxDisplay.CreateGraphics();

            blackBrush = new SolidBrush(Color.Black);
            // Create rectangle.
            PanelRect = new Rectangle(0, 0, pbxDisplay.Width, pbxDisplay.Height);


            TXT_SAMPLERATE.Text = dSamplerate.ToString();
            TXT_DATACOUNT.Text  = dwDataNum.ToString();
            Module_Num1         = USBDASK.UD_Register_Card(USBDASK.USB_1210, 0);
            if (Module_Num1 < 0)
            {
                MessageBox.Show("Register card Fail, Code:" + Module_Num1.ToString());
                Close();
                return;
            }
            Module_Num2 = USBDASK.UD_Register_Card(USBDASK.USB_1210, 1);
            if (Module_Num2 < 0)
            {
                MessageBox.Show("Register card Fail, Code:" + Module_Num2.ToString());
                Close();
                return;
            }

            tbxYup.Text          = "10V";
            tbxYdown.Text        = "-10V";
            textYZero.Text       = "0V";
            pbxDisplay.BackColor = Color.Black;

            err = USBDASK.UD_DIO_Config((ushort)Module_Num1, USBDASK.GPTC0_GPO1, USBDASK.GPTC2_GPO3);
            if (err != USBDASK.NoError)
            {
                MessageBox.Show("UD_DIO_Config error = :" + err.ToString());
                Close();
                return;
            }

            err = USBDASK.UD_GPTC_Setup_N((ushort)Module_Num1, 0, USBDASK.ContGatedPulseGen, USBDASK.GPTC_GATE_SRC_Int, 0x00, 40, 40, 1);
            if (err < 0)
            {
                MessageBox.Show(string.Format("UD_GPTC_Setup_N Error: {0}", err));
                return;
            }
            err = USBDASK.UD_GPTC_Control((ushort)Module_Num1, 0, USBDASK.IntUpDnCTR, 0);
            if (err < 0)
            {
                MessageBox.Show(string.Format("UD_GPTC_Control IntUpDnCTR Error: {0}", err));
                return;
            }

            // Added on 2018/2/27 Ming-Yen
            USBDASK.UD_GPTC_Control((ushort)Module_Num1, 0, USBDASK.IntGate, 1);
            if (err < 0)
            {
                MessageBox.Show(string.Format("UD_GPTC_Control IntGate Error: {0}", err));
                return;
            }
            // 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;
            }
            btnGPO0.Text = "GPO0 2MHz OFF";
        }