TMSimulatorServer.cs 2.9 KB

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