using Aitex.Core.Util; using MECF.Framework.Simulator.Core.Driver; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; namespace CyberX8_Simulator.Devices { public class SETMSimulatorServer : SocketDeviceSimulator { private readonly Regex _check_load = new Regex(@"CHECK LOAD\s+(\d)+\s+(A|B)\s*"); private readonly Regex _move_arm = new Regex(@"(PLACE|PICK)\s+(\d+)\s+ARM\s+(A|B)\s+(\w{4})\s*"); private readonly Regex _move_wafer = new Regex(@"(PLACE|PICK)\s+(\d+)\s+ARM\s+(A|B)\s*"); private PeriodicJob _HwThread; public SETMSimulatorServer() : base(1103, -1, "\r", ' ') { _HwThread = new PeriodicJob(500, OnSendEvent, "honghuRobot", true); } private bool OnSendEvent() { return true; } protected override void ProcessUnsplitMessage(string str) { if (str.Contains("HOME") || str.Contains("GOTO") || str.Contains("XFER") || str.Contains("HALT")) { OnWriteMessage("_RDY"); } //if (str.Contains("RQ WAF_CEN DATA")) //{ // string t = new Random().Next(0, 359).ToString().PadLeft(6, '0'); // string r = new Random().Next(0, 50000).ToString().PadLeft(6, '0'); // OnWriteMessage($"WAF_CEN RT 000000 000000 000000 000000 LFT 000000 000000 000000 000000 OFFSET {r} {t}"); // OnWriteMessage("_RDY"); //} if (_check_load.IsMatch(str)) { Match result = _check_load.Match(str); string station = result.Groups[1].Value; string arm = result.Groups[2].Value; //OnWriteMessage(string.Format($"LOAD {arm} OFF")); OnWriteMessage(string.Format($"CHECK LOAD")); } else if (_move_arm.IsMatch(str)) { // @"(PLACE|PICK)\s+(\d+)\s+SLOT\s+(\d+)\s+ARM\s+(A|B)\s+(\w{4})\s+" Match result = _move_arm.Match(str); string operation = result.Groups[1].Value; string station = result.Groups[2].Value; string slot = result.Groups[3].Value; string arm = result.Groups[4].Value; string dir = result.Groups[5].Value; Thread.Sleep(2000); OnWriteMessage("_RDY"); } else if (_move_wafer.IsMatch(str)) { // @"(PLACE|PICK)\s+(\d+)\s+SLOT\s+(\d+)\s+ARM\s+(A|B)\s+" Match result = _move_wafer.Match(str); string operation = result.Groups[1].Value; string station = result.Groups[2].Value; string slot = result.Groups[3].Value; string arm = result.Groups[4].Value; Thread.Sleep(2000); OnWriteMessage("_RDY"); } } } }