SETMSimulatorServer.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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*");
  15. //private readonly Regex _check_load = new Regex(@"CHECK LOAD\s+(\d+)\s+ARM\s+(A|B)\s*");
  16. private readonly Regex _move_arm = new Regex(@"(PLACE|PICK)\s+(\d+)\s*");
  17. private readonly Regex _move_wafer = new Regex(@"(PLACE|PICK)\s+(\d+)\s*");
  18. private PeriodicJob _HwThread;
  19. public SETMSimulatorServer() : base(1103, -1, "\r", ' ')
  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 (str.Contains("RQ WAF_CEN DATA"))
  34. //{
  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. OnWriteMessage(string.Format($"CHECK LOAD"));
  47. }
  48. else if (_move_arm.IsMatch(str))
  49. {
  50. // @"(PLACE|PICK)\s+(\d+)\s+SLOT\s+(\d+)\s+ARM\s+(A|B)\s+(\w{4})\s+"
  51. Match result = _move_arm.Match(str);
  52. string operation = result.Groups[1].Value;
  53. string station = result.Groups[2].Value;
  54. string slot = result.Groups[3].Value;
  55. string arm = result.Groups[4].Value;
  56. string dir = result.Groups[5].Value;
  57. Thread.Sleep(2000);
  58. OnWriteMessage("_RDY");
  59. }
  60. else if (_move_wafer.IsMatch(str))
  61. {
  62. // @"(PLACE|PICK)\s+(\d+)\s+SLOT\s+(\d+)\s+ARM\s+(A|B)\s+"
  63. Match result = _move_wafer.Match(str);
  64. string operation = result.Groups[1].Value;
  65. string station = result.Groups[2].Value;
  66. string slot = result.Groups[3].Value;
  67. string arm = result.Groups[4].Value;
  68. Thread.Sleep(2000);
  69. OnWriteMessage("_RDY");
  70. }
  71. }
  72. }
  73. }