protected void _Enqueue(IPLCMessage message) { var data = _GetBytes(message as LSRequestMessage); // this.SerialAdaper.Write(data, 0, data.Length); Thread.Sleep(DELAY); }
protected PLCMessageChecker _CheckingOverride(IPLCMessage origin, List <byte> buffer) { try { if (buffer.Count < 6) { return(null); } if (_CheckedHeader(buffer[0])) { byte[] array = buffer.ToArray(); int num = 0; byte b = array[num]; num++; Encoding.ASCII.GetString(array, num, 2); num += 2; Encoding.ASCII.GetString(array, num, 1); num++; Encoding.ASCII.GetString(array, num, 2); num += 2; int num2 = buffer.IndexOf(3); if (num2 < 0) { return(null); } PLCMessageChecker result = null; switch (b) { case 6: result = new PLCMessageChecker(PLCMessageTypes.Ascii, array.Skip(num)); break; case 21: { string @string = Encoding.ASCII.GetString(buffer.ToArray(), num, 4); num += 4; //var err = new ErorrPLC.ErorrPLC(this.GetType().Name, "SerialAdaper.Read" + ", Request error - code:" + @string); result = PLCMessageChecker.Complete; break; } } buffer.RemoveRange(0, (buffer.Count > 7 + num2) ? (7 + num2) : buffer.Count); return(result); } // var err1 = new ErorrPLC.ErorrPLC(this.GetType().Name, "SerialAdaper.Read" + $"Drop Header Octat={buffer[0]:X2}"); buffer.RemoveAt(0); return(null); } catch (Exception ex) { EventscadaException?.Invoke(this.GetType().Name, "Error on " + "SerialAdaper.Read" + ", - " + ex.Message); return(PLCMessageChecker.Complete); } }