VPASimulator.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using MECF.Framework.Simulator.Core.Driver;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. namespace Venus_Simulator.Devices
  10. {
  11. public class VPASimulator : SerialPortDeviceSimulator
  12. {
  13. private const string EOF = "\r";
  14. private const char MSG_DELIMITER = ' ';
  15. private const string VPA_Port = "COM159";
  16. public VPASimulator() : base(VPA_Port, -1, EOF, MSG_DELIMITER)
  17. {
  18. }
  19. protected override void ProcessUnsplitMessage(string message)
  20. {
  21. if (string.IsNullOrEmpty(message))
  22. throw new ArgumentException("Hardware command message is invalid");
  23. Thread.Sleep(3000);
  24. if (message == "RSLT\r")
  25. {
  26. OnWriteMessage("DATA 0000 1230 01000 01000 Y" + EOF);
  27. Thread.Sleep(500);
  28. }
  29. OnWriteMessage("_RDY" + EOF);
  30. }
  31. }
  32. }