public PLCResponseMessage CheckBinaryData(byte[] data) { LSCommandTypes command = Command; if (command == LSCommandTypes.ReqRead || command == LSCommandTypes.ReqReadWithBCC) { return(new LSResponseMessage(PLCMessageTypes.Binary, this, data)); } return(null); }
protected string[] _OnReceivedOverride(byte[] data) { string[] dateString = null; try { if (data == null) { throw new NullReferenceException(); } if (data.Length < 20) { throw new ArgumentException(); } int offset = 0; string @string = Encoding.ASCII.GetString(data, offset, 10); offset += 10; if (!string.IsNullOrEmpty(@string)) { offset += 2; offset++; byte b = data[offset]; offset++; ushort key = BitConverter.ToUInt16(data, offset); offset += 2; BitConverter.ToUInt16(data, offset); offset += 2; offset++; offset++; LSCommandTypes lSCommandTypes = (LSCommandTypes)data[offset]; offset += 2; byte b2 = data[offset]; offset += 2; offset += 2; ushort num2 = Unsigned16(data, offset); offset += 2; switch (lSCommandTypes) { case LSCommandTypes.RspRead: if (num2 == 0) { PLCResponseMessage pLCResponseMessage = Requests[1]?.CheckBinaryData(data.Skip(offset).ToArray()); if (pLCResponseMessage != null) { return(dateString); } } else { EventscadaException?.Invoke(this.GetType().Name, $"Received error code::0x{data[offset]:X2}"); offset++; } break; case LSCommandTypes.RspWrite: if (num2 == 0) { } break; default: throw new NotSupportedException(); } } } catch (Exception ex) { EventscadaException?.Invoke(this.GetType().Name + ", Received date error - ", ex.Message); } return(null); }