internal override void ClearInBuffer() { if (IsConnected()) { li.ibclr(Dev); } }
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); } }
//read data form device public string GPIBrd(int buffersize) { try { li.ibrd(Dev, out ValueStr, buffersize); li.ibclr(Dev); return(ValueStr); } catch (System.Exception Ex) { throw new Exception("Error: " + Ex.Message + //error Name "ibsta = " + li.ibsta + //ibsta "iberr = " + li.iberr + //iberr ErrorMnemonic[li.iberr]); //error code } }