RevtechMatchMockPMC.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. switch (msg)
  46. {
  47. }
  48. Thread.Sleep(200);
  49. sRes += "\n";
  50. OnWriteMessage(sRes);
  51. }
  52. }
  53. }
  54. }