private void refreshDevList() { cbbSerialList.Items.Clear(); //получаем список серийных номеров X502.DevRec[] pci_devrecs; X502.DevRec[] usb_devrecs; Int32 res = L502.GetDevRecordsList(out pci_devrecs, 0); res = E502.UsbGetDevRecordsList(out usb_devrecs, 0); devrecs = new X502.DevRec[pci_devrecs.Length + usb_devrecs.Length]; pci_devrecs.CopyTo(devrecs, 0); usb_devrecs.CopyTo(devrecs, pci_devrecs.Length); /* заполняем полученные серийные номера в ComboBox */ for (int i = 0; i < devrecs.Length; i++) { cbbSerialList.Items.Add(devrecs[i].DevName + ", " + devrecs[i].Serial); } if (devrecs.Length > 0) { cbbSerialList.SelectedIndex = 0; } updateControls(); }
void LFATAL(string _msg, lpcie.Errs _err) { if (_err != 0) { throw (new Exception(_msg + " " + L502.GetErrorString(_err))); } }
public LCard502(LCard502Pars _pars, DOnPr _OnPr = null) { if (_OnPr != null) { OnPr += _OnPr; } LastError = null; /* создаем описатель модуля */ hnd = new L502(); string serial = FindSerial(_pars.DevNum); if (serial == null) { throw (new Exception("LCard502.LCard502: Ошибка: Устройство не найдено: " + _pars.DevNum.ToString())); } pr("LCard502 create"); // lpcie.Errs res; /* устанавливаем связь по выбранному серийному номеру */ lpcie.Errs res = hnd.Open(serial); if (res != 0) { throw (new Exception(L502.GetErrorString(res) + " Ошибка открытия модуля")); } /* получаем информацию о модуле */ L502.Info devinfo = hnd.DevInfo; }
bool CheckError(lpcie.Errs _err) { if (_err == 0) { return(false); } LastError = L502.GetErrorString(_err); return(true); }
public void Dispose() { if (hnd == null) { return; } hnd.Close(); // память освободится диспетчером мусора, т.к. нет больше ссылок hnd = null; }
string FindSerial(int _devNum) { String[] serials; Int32 res = L502.GetSerialList(out serials, 0); if (res <= 0) { throw (new Exception("LCard502.FindSerial: Ошибка: не могу получить список плат")); } if (_devNum >= serials.Length) { return(null); } return(serials[_devNum]); }