TMSimulatorServer.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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(_check_load.IsMatch(str))
  32. {
  33. Match result = _check_load.Match(str);
  34. string station = result.Groups[1].Value;
  35. string arm = result.Groups[2].Value;
  36. OnWriteMessage(string.Format($"LOAD {arm} OFF"));
  37. }
  38. else if(_move_arm.IsMatch(str))
  39. {
  40. // @"(PLACE|PICK)\s+(\d+)\s+SLOT\s+(\d+)\s+ARM\s+(A|B)\s+(\w{4})\s+"
  41. Match result = _move_arm.Match(str);
  42. string operation = result.Groups[1].Value;
  43. string station = result.Groups[2].Value;
  44. string slot = result.Groups[3].Value;
  45. string arm = result.Groups[4].Value;
  46. string dir = result.Groups[5].Value;
  47. Thread.Sleep(5000);
  48. OnWriteMessage("_RDY");
  49. }
  50. else if(_move_wafer.IsMatch(str))
  51. {
  52. // @"(PLACE|PICK)\s+(\d+)\s+SLOT\s+(\d+)\s+ARM\s+(A|B)\s+"
  53. Match result = _move_wafer.Match(str);
  54. string operation = result.Groups[1].Value;
  55. string station = result.Groups[2].Value;
  56. string slot = result.Groups[3].Value;
  57. string arm = result.Groups[4].Value;
  58. Thread.Sleep(5000);
  59. OnWriteMessage("_RDY");
  60. }
  61. }
  62. }
  63. }