Esempio n. 1
0
        private void connectM_Click(object sender, EventArgs e)
        {
            if (mIsOpen == 1)
            {
                timerSend.Enabled = false;
                DllAdapte.VCI_CloseDevice(mDevType, mDevInd);
                mIsOpen = 0;
            }
            else
            {
                uint ret = DllAdapte.VCI_OpenDevice(mDevType, mDevInd, 0);

                if (ret <= 0)
                {
                    MessageBox.Show("打开设备失败,请检查设备类型和设备索引号是否正确", "错误",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                else
                {
                    AddListBoxItem("设备连接成功。");
                }

                mIsOpen = 1;
                InitCanAll();
            }

            connectM.Text     = mIsOpen == 1 ? "断开" : "连接";
            connectBtn.Text   = connectM.Text;
            timer_rec.Enabled = mIsOpen == 1 ? true : false;
        }
Esempio n. 2
0
 //主窗口关闭处理函数
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (mIsOpen == 1)
     {
         DllAdapte.VCI_CloseDevice(mDevType, mDevInd);
     }
 }