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); } }
static GPIBDevice() { li = new LangInt(); // Contains all GPIB functions c = new GpibConstants(); // Contains all GPIB global constants TIMEOUT = c.T300ms; }