AdTecMatchMock.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Threading;
  3. using MECF.Framework.Simulator.Core.Driver;
  4. namespace EfemDualSimulator.Devices
  5. {
  6. class AdTecMatchMock : SerialPortDeviceSimulator
  7. {
  8. private const string EOF = "\r";
  9. private const char MSG_DELIMITER = '\r';
  10. private const string MOCKUP_PORT = "COM52";
  11. public AdTecMatchMock(string com) : base(com, -1, EOF, MSG_DELIMITER)
  12. {
  13. }
  14. protected override void ProcessUnsplitMessage(string message)
  15. {
  16. if (string.IsNullOrEmpty(message))
  17. throw new ArgumentException("Hardware command message is invalid");
  18. message = message.TrimEnd('\r');
  19. string[] strs = message.Split(MSG_DELIMITER);
  20. string sRes = string.Empty;
  21. if (message.Contains("$APRR"))
  22. {
  23. sRes = "$APRR10E1D5";
  24. }
  25. else
  26. {
  27. sRes = "S34000C0000000000000080020015A273B00700700400005C095210";
  28. }
  29. Thread.Sleep(2 * 1000);
  30. OnWriteMessage(sRes + "\r");
  31. }
  32. }
  33. }