RevtechMatchMockPMC.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using System.Windows.Documents;
  6. using MECF.Framework.Simulator.Core.Driver;
  7. namespace Venus_Simulator.Devices
  8. {
  9. class RevtechMatchMockPMC : SerialPortDeviceSimulator
  10. {
  11. private const string EOF = "\n";
  12. private const char MSG_DELIMITER = '\n';
  13. private const string MOCKUP_PORT = "COM76";
  14. private List<string> info = new List<string>();
  15. public RevtechMatchMockPMC() : base(MOCKUP_PORT, -1, EOF, MSG_DELIMITER)
  16. {
  17. info.Add("1");//Mode
  18. info.Add("1");
  19. info.Add("1");
  20. info.Add("1");
  21. info.Add("1");
  22. info.Add("1");
  23. info.Add("1");
  24. info.Add("1");
  25. info.Add("20");//C1
  26. info.Add("30");//C2
  27. info.Add("1");
  28. info.Add("1");
  29. info.Add("1");
  30. info.Add("1");
  31. info.Add("1");
  32. }
  33. protected override void ProcessUnsplitMessage(string message)
  34. {
  35. if (string.IsNullOrEmpty(message))
  36. throw new ArgumentException("Hardware command message is invalid");
  37. string sRes = string.Empty;
  38. if (message.Contains(EOF))
  39. {
  40. message = message.Remove(message.Length - 1);
  41. }
  42. string[] msgs = message.Split('\n');
  43. foreach(string msg in msgs)
  44. {
  45. Thread.Sleep(200);
  46. sRes += "\n";
  47. OnWriteMessage(sRes);
  48. }
  49. }
  50. }
  51. }