private void timeupEx() { if (bOpen) { int errcode = Advantech.Digital_ReadByteFromPort(DeviceHandle, short.Parse(Public.GetXmlValue("PCLPort")), out DiValue); UpdateLED(); } }
private bool getPCLA() { bool ret = false; short MaxEntries = 9; int i; int ii; string tempStr; int tempNum; try { int errcode = Advantech.GetDeviceList(out devlistarray, ref outEntries); if (errcode != 0) { MessageBox.Show("获取设备列表失败,错误代码:" + errcode.ToString()); } else { errcode = Advantech.DRV_DeviceGetNumOfList(ref MaxEntries); if (errcode != 0) { MessageBox.Show("获取设备数,错误代码:" + errcode.ToString()); } else { for (i = 0; i < MaxEntries; i++) { tempStr = ""; tempStr = devlistarray.Devices[i].szDeviceName; MessageBox.Show(tempStr); string pzDevice = Public.GetXmlValue("type");//获取设备类型 tempNum = tempStr.IndexOf(pzDevice); if (tempNum != -1) { gnNumOfSubdevices = devlistarray.Devices[i].nNumOfSubdevices; if (gnNumOfSubdevices > MaxDev) { gnNumOfSubdevices = MaxDev; } if (gnNumOfSubdevices == 0) { dwDeviceNum = devlistarray.Devices[i].dwDeviceNum; errcode = Advantech.DRV_DeviceOpen(dwDeviceNum, ref DeviceHandle); if (errcode != 0) { MessageBox.Show("打开设备失败,错误代码:" + errcode.ToString()); } else { ret = true; bOpen = true; } //PCLDevice.ptDevGetFeatures.buffer = &lpDevFeatures; } } else { MessageBox.Show("没有安装PCL-730"); ret = false; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(ret); }