MsgCutter.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Edge.Core.Processor;using Edge.Core.IndustryStandardInterface.Pump;
  2. using Edge.Core.Parser.BinaryParser.Util;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using Edge.Core.Processor.Communicator;
  10. namespace SimpleScanner
  11. {
  12. public class MsgCutter : IMessageCutter<byte[]>
  13. {
  14. public byte[] Message { get; private set; }
  15. public event EventHandler OnMessageCut;
  16. public event EventHandler<MessageCutterInvalidMessageReadEventArg> OnInvalidMessageRead;
  17. //static ILog innerLogger = log4net.LogManager.GetLogger("StateMachine");
  18. static NLog.Logger innerLogger = NLog.LogManager.LoadConfiguration("nlog.config").GetLogger("Communicator");
  19. private string loggerAppendix = "SimpleScanner msgCutter";
  20. private readonly List<byte> buffer = new List<byte>();
  21. public MsgCutter()
  22. {
  23. }
  24. public void Feed(byte[] next)
  25. {
  26. this.Message = next;
  27. var safe = this.OnMessageCut;
  28. safe?.Invoke(this, null);
  29. }
  30. }
  31. }