예제 #1
0
        public GPIB(int ADDR)        //构造函数
        {
            //ADDR为GPIB设备地址
            try
            {
                li      = new LangInt();                     // Contains all GPIB functions
                c       = new GpibConstants();               // Contains all GPIB global constants
                TIMEOUT = c.T3s;

                Dev = li.ibdev(BDINDEX, ADDR, NO_SECONDARY_ADDR, TIMEOUT, EOTMODE, EOSMODE);         //Get the device handle
                if ((li.ibsta & c.ERR) != 0)
                {
                    throw new System.Exception("Unable to open device!\nibsta:" + li.ibsta + "\nERR:" + c.ERR);
                }


                li.ibclr(Dev);
                if ((li.ibsta & c.ERR) != 0)
                {
                    throw new System.Exception("Unable to clear device!\nibsta:" + li.ibsta + "\nERR:" + c.ERR);
                }
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #2
0
 internal override bool Open()
 {
     if (IsConnected())
     {
         return(true);
     }
     try
     {
         Dev        = li.ibdev(BDINDEX, PRIMARY_ADDR_OF_PPS, NO_SECONDARY_ADDR, TIMEOUT, EOTMODE, EOSMODE);
         bConnected = ((li.ibsta & c.ERR) == 0);
         if (!bConnected)
         {
             MessageBox.Show("GPIB 接口打开失败");
         }
         return(bConnected);
     }
     catch (SystemException ex)
     {
         MessageBox.Show("GPIB 接口打开失败 " + PRIMARY_ADDR_OF_PPS.ToString() + " " + ex.Source + "  " + ex.Message, "GPIBMeasConfig", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
 }