SETMSimulatorServer.cs 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using Aitex.Core.Util;
  2. using MECF.Framework.Simulator.Core.Driver;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. namespace Venus_Simulator.Devices
  11. {
  12. public class SETMSimulatorServer : SocketDeviceSimulator
  13. {
  14. private readonly Regex _check_load = new Regex(@"CHECK LOAD\s+(\d)+\s+(A|B)\s*");
  15. private readonly Regex _move_arm = new Regex(@"(PLACE|PICK)\s+(\d+)\s+ARM\s+(A|B)\s+(\w{4})\s*");
  16. private readonly Regex _move_wafer = new Regex(@"(PLACE|PICK)\s+(\d+)\s+ARM\s+(A|B)\s*");
  17. private readonly Regex _rq_arm = new Regex(@"(RQ)\s+(LOAD)\s+(ARM)\s*");
  18. private PeriodicJob _HwThread;
  19. public SETMSimulatorServer() : base(1103, -1, "\n", ' ')
  20. {
  21. _HwThread = new PeriodicJob(500, OnSendEvent, "honghuRobot", true);
  22. }
  23. private bool OnSendEvent()
  24. {
  25. return true;
  26. }
  27. protected override void ProcessUnsplitMessage(string str)
  28. {
  29. if (str.Contains("HOME") || str.Contains("GOTO") || str.Contains("XFER") || str.Contains("HALT"))
  30. {
  31. OnWriteMessage("_RDY");
  32. }
  33. if (_rq_arm.IsMatch(str))
  34. {
  35. //OnWriteMessage(string.Format($"LOAD {arm} OFF"));
  36. //OnWriteMessage(string.Format($"CHECK LOAD"));
  37. OnWriteMessage("_RDY");
  38. }
  39. //if (str.Contains("RQ WAF_CEN DATA"))
  40. //{
  41. // string t = new Random().Next(0, 359).ToString().PadLeft(6, '0');
  42. // string r = new Random().Next(0, 50000).ToString().PadLeft(6, '0');
  43. // OnWriteMessage($"WAF_CEN RT 000000 000000 000000 000000 LFT 000000 000000 000000 000000 OFFSET {r} {t}");
  44. // OnWriteMessage("_RDY");
  45. //}
  46. if (_check_load.IsMatch(str))
  47. {
  48. Match result = _check_load.Match(str);
  49. string station = result.Groups[1].Value;
  50. string arm = result.Groups[2].Value;
  51. //OnWriteMessage(string.Format($"LOAD {arm} OFF"));
  52. //OnWriteMessage(string.Format($"CHECK LOAD"));
  53. OnWriteMessage("_RDY");
  54. }
  55. else if (_move_arm.IsMatch(str))
  56. {
  57. // @"(PLACE|PICK)\s+(\d+)\s+SLOT\s+(\d+)\s+ARM\s+(A|B)\s+(\w{4})\s+"
  58. Match result = _move_arm.Match(str);
  59. string operation = result.Groups[1].Value;
  60. string station = result.Groups[2].Value;
  61. string slot = result.Groups[3].Value;
  62. string arm = result.Groups[4].Value;
  63. string dir = result.Groups[5].Value;
  64. Thread.Sleep(7000);
  65. OnWriteMessage("_RDY");
  66. }
  67. else if (_move_wafer.IsMatch(str))
  68. {
  69. // @"(PLACE|PICK)\s+(\d+)\s+SLOT\s+(\d+)\s+ARM\s+(A|B)\s+"
  70. Match result = _move_wafer.Match(str);
  71. string operation = result.Groups[1].Value;
  72. string station = result.Groups[2].Value;
  73. string slot = result.Groups[3].Value;
  74. string arm = result.Groups[4].Value;
  75. Thread.Sleep(7000);
  76. OnWriteMessage("_RDY");
  77. }
  78. }
  79. }
  80. }