您好,欢迎来到叨叨游戏网。
搜索
您的当前位置:首页C#——GPIB连接仪器

C#——GPIB连接仪器

来源:叨叨游戏网

button21是一个连接的按钮。

uicombox3是一个多端口的选择下拉栏,因为这个文章是关于GPIB的所以uicombox3其实是可以成一个textbox的。

需要引用Ivi.Visa,Ivi.Visa.Interop

Ivi.Visa.Interop.FormattedIO488 ioobj = new Ivi.Visa.Interop.FormattedIO488();
Ivi.Visa.Interop.ResourceManager rm = new Ivi.Visa.Interop.ResourceManager();
private void button21_Click(object sender, EventArgs e)
        {
            try
            {
                if (uiComboBox3.Text == "GPIB")
                {
                    // ioDmm.IO = (IMessage)grm.Open("GPIB0::19::INSTR", AccessMode.NO_LOCK, 2000, "");
                    string resourceName = "GPIB0::" + uiTextBox14.Text + "::INSTR";
                    Class1.XHYresourceName = resourceName;
                    //var visa = GlobalResourceManager.Open(resourceName) as IMessageBasedSession;
                    ioobj.IO = (Ivi.Visa.Interop.IMessage)rm.Open(resourceName, Ivi.Visa.Interop.AccessMode.NO_LOCK, 0, "");
                    ioobj.WriteString("*IDN?\n");
                    string res0 = ioobj.ReadString();
                    uiTextBox15.Text = res0;
                    string[] str1 = res0.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);//str1[0]=厂家,str1[1]=型号,str1[2]=序列号。
                    MessageBox.Show("仪器连接成功");
                }
            }
            catch (SystemException ex)
            {
                MessageBox.Show("仪器连接失败");
                // ioDmm.IO = null;
                return;
            }
        }

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- gamedaodao.net 版权所有 湘ICP备2024080961号-6

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务