예제 #1
0
        private void btnMulti_Click(object sender, EventArgs e)
        {
            int nGpibAddr = 0;
            int error     = 0;

            nGpibAddr = (Int32)multiNum.Value;
            string strResource = "GPIB0::" + nGpibAddr + "::INSTR"; // GPIB1 to GPIB0 changed 16.09.03 by msq

            if (btnMulti.Text == "打开")                              //用户要连接万用表   //changed 16.09.03 by msq
            {
                error = Multimeter_Driver.Connect_Multimeter(strResource);
                if (error < 0)
                {
                    CCommonFuncs.ShowHintInfor(eHintInfoType.error, "万用表连接失败!");
                    btnMulti.Text = "打开";
                }
                else
                {
                    btnMulti.Text = "关闭";
                }
            }
            else//断开万用表
            {
                Multimeter_Driver.Close();
                btnMulti.Text = "打开";
            }
        }
예제 #2
0
        /******************************************************************************************
         * 函数原型:ConnectSpecificInstrument(string strInstruName,string resourceName)
         * 函数功能:根据输入的仪器名进行连接。连接后的句柄存储在相应的句柄参数中
         * 输入参数:strInstruName,仪器名字;resourceName,资源名字,用于VISA连接
         * 输出参数:
         * 创 建 者:yzx
         * 创建日期:2016.7.27
         * 修改说明:
         * */
        public static int ConnectSpecificInstrument(string strInstruName, string resourceName)
        {
            int error = 0;

            if (strInstruName == "电源")
            {
                if (CGloabal.g_InstrPowerModule.nHandle == 0)
                {
                    error = Power_Driver.Init(resourceName, ref CGloabal.g_InstrPowerModule.nHandle, strError);
                    if (error < 0)
                    {
                        CGloabal.g_InstrPowerModule.bInternet = false;
                        CCommonFuncs.ShowHintInfor(eHintInfoType.error, CGloabal.g_InstrPowerModule.strInstruName + "连接失败");
                    }
                    else
                    {
                        CGloabal.g_InstrPowerModule.bInternet = true;
                    }
                }
                else
                {
                    CCommonFuncs.ShowHintInfor(eHintInfoType.hint, CGloabal.g_InstrPowerModule.strInstruName + "已经处于连接状态");
                }
            }
            else if (strInstruName == "示波器")
            {
                if (CGloabal.g_InstrScopeModule.nHandle == 0)
                {
                    error = Oscilloscope_Driver.Init(resourceName, ref CGloabal.g_InstrScopeModule.nHandle, ref strError);
                    if (error < 0)
                    {
                        CGloabal.g_InstrScopeModule.bInternet = false;
                        CCommonFuncs.ShowHintInfor(eHintInfoType.error, CGloabal.g_InstrScopeModule.strInstruName + "连接失败");
                    }
                    else
                    {
                        CGloabal.g_InstrScopeModule.bInternet = true;
                    }
                }
                else
                {
                    CCommonFuncs.ShowHintInfor(eHintInfoType.hint, CGloabal.g_InstrScopeModule.strInstruName + "已经处于连接状态");
                }
            }
            else if (strInstruName == "万用表")
            {
                if (CGloabal.g_InstrMultimeterModule.nHandle == 0)
                {
                    error = Multimeter_Driver.Connect_Multimeter(resourceName);
                    if (error < 0)
                    {
                        CGloabal.g_InstrPowerModule.bInternet = false;
                        CCommonFuncs.ShowHintInfor(eHintInfoType.error, CGloabal.g_InstrMultimeterModule.strInstruName + "连接失败");
                    }
                    else
                    {
                        CGloabal.g_InstrPowerModule.bInternet = true;
                    }
                }
                else
                {
                    CCommonFuncs.ShowHintInfor(eHintInfoType.hint, CGloabal.g_InstrPowerModule.strInstruName + "已经处于连接状态");
                }
            }
            else
            {
                CCommonFuncs.ShowHintInfor(eHintInfoType.error, "错误的仪器名");
                return(-1);
            }

            return(error);
        }