SETMSimulatorServer.cs 3.1 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 CyberX8_Simulator.Devices
  11. {
  12. public class SETMSimulatorServer : SocketDeviceSimulator
  13. {
  14. private readonly Regex _check_load = new Regex(@"CHECK LOAD\s+(\d)+\s+(A|B)\s*");
  15. private readonly Regex _move_arm = new Regex(@"(PLACE|PICK)\s+(\d+)\s+ARM\s+(A|B)\s+(\w{4})\s*");
  16. private readonly Regex _move_wafer = new Regex(@"(PLACE|PICK)\s+(\d+)\s+ARM\s+(A|B)\s*");
  17. private PeriodicJob _HwThread;
  18. public SETMSimulatorServer() : base(1103, -1, "\r", ' ')
  19. {
  20. _HwThread = new PeriodicJob(500, OnSendEvent, "honghuRobot", true);
  21. }
  22. private bool OnSendEvent()
  23. {
  24. return true;
  25. }
  26. protected override void ProcessUnsplitMessage(string str)
  27. {
  28. if (str.Contains("HOME") || str.Contains("GOTO") || str.Contains("XFER") || str.Contains("HALT"))
  29. {
  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. OnWriteMessage(string.Format($"CHECK LOAD"));
  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(2000);
  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(2000);
  68. OnWriteMessage("_RDY");
  69. }
  70. }
  71. }
  72. }