TMSimulatorServer.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. Thread.Sleep(1500);
  30. OnWriteMessage("_RDY");
  31. }
  32. if (str.Contains("RQ WAF_CEN DATA"))
  33. {
  34. Thread.Sleep(1500);
  35. string t = new Random().Next(0, 359).ToString().PadLeft(6, '0');
  36. string r = new Random().Next(0, 50000).ToString().PadLeft(6, '0');
  37. OnWriteMessage($"WAF_CEN RT 000000 000000 000000 000000 LFT 000000 000000 000000 000000 OFFSET {r} {t}");
  38. OnWriteMessage("_RDY");
  39. }
  40. if (_check_load.IsMatch(str))
  41. {
  42. Match result = _check_load.Match(str);
  43. string station = result.Groups[1].Value;
  44. string arm = result.Groups[2].Value;
  45. OnWriteMessage(string.Format($"LOAD {arm} OFF"));
  46. }
  47. else if(_move_arm.IsMatch(str))
  48. {
  49. // @"(PLACE|PICK)\s+(\d+)\s+SLOT\s+(\d+)\s+ARM\s+(A|B)\s+(\w{4})\s+"
  50. Match result = _move_arm.Match(str);
  51. string operation = result.Groups[1].Value;
  52. string station = result.Groups[2].Value;
  53. string slot = result.Groups[3].Value;
  54. string arm = result.Groups[4].Value;
  55. string dir = result.Groups[5].Value;
  56. Thread.Sleep(5000);
  57. OnWriteMessage("_RDY");
  58. }
  59. else if(_move_wafer.IsMatch(str))
  60. {
  61. // @"(PLACE|PICK)\s+(\d+)\s+SLOT\s+(\d+)\s+ARM\s+(A|B)\s+"
  62. Match result = _move_wafer.Match(str);
  63. string operation = result.Groups[1].Value;
  64. string station = result.Groups[2].Value;
  65. string slot = result.Groups[3].Value;
  66. string arm = result.Groups[4].Value;
  67. Thread.Sleep(5000);
  68. OnWriteMessage("_RDY");
  69. }
  70. }
  71. }
  72. }