/// <summary> /// 随机读取 /// </summary> /// <param name="szDevice"></param> /// <param name="size"></param> /// <param name="lData"></param> /// <returns></returns> public bool ReadDeviceRandom(string szDevice, int size, out int[] lData) { lock (this) { lData = new int[size]; try { int result = actUtlType.ReadDeviceRandom(szDevice, size, out lData[0]); if (0 == result) { message = "随即读取PLC地址" + szDevice + "\n" + size + "位成功"; return(true); } else { message = "随即读取PLC地址" + szDevice + "\n" + size + "失败,错误代码:\n" + (uint)result; return(false); } } catch (Exception ex) { _isOpen = false; message = "error:\n" + ex.Message; return(false); } finally { Console.WriteLine(message); } } }