TMSimulatorServer.cs 3.0 KB

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