public override async Task <byte[]> GetDatasAsync(byte belongAddress, byte masterAddress, string startAddress, int getByteCount) { try { var readRequestOpcInputStruct = new ReadRequestOpcInputStruct(startAddress); var readRequestOpcOutputStruct = await Wrapper.SendReceiveAsync(Wrapper[typeof(ReadRequestOpcProtocal)], readRequestOpcInputStruct) as ReadRequestOpcOutputStruct; return(readRequestOpcOutputStruct?.GetValue); } catch (Exception) { return(null); } }
public override async Task <byte[]> GetDatasAsync(string startAddress, int getByteCount) { try { var split = GetSeperator?.Invoke() ?? '/'; var readRequestOpcInputStruct = new ReadRequestOpcInputStruct(startAddress, split.ToString()); var readRequestOpcOutputStruct = await Wrapper.SendReceiveAsync <ReadRequestOpcOutputStruct>(Wrapper[typeof(ReadRequestOpcProtocal)], readRequestOpcInputStruct); return(readRequestOpcOutputStruct?.GetValue); } catch (Exception) { return(null); } }
/// <summary> /// 获取数据 /// </summary> /// <param name="startAddress">开始地址</param> /// <param name="getByteCount">获取字节数个数</param> /// <returns>接收到的byte数据</returns> public override async Task <byte[]> GetDatasAsync(string startAddress, int getByteCount) { try { var split = GetSeperator?.Invoke() ?? '/'; var readRequestOpcInputStruct = new ReadRequestOpcInputStruct(startAddress.Split('\r'), split); var readRequestOpcOutputStruct = await Wrapper.SendReceiveAsync <ReadRequestOpcOutputStruct>(Wrapper[typeof(ReadRequestOpcProtocal)], readRequestOpcInputStruct); return(readRequestOpcOutputStruct?.GetValue); } catch (Exception e) { Log.Error(e, $"OpcUtility -> GetDatas: {ConnectionString} error"); return(null); } }