using Aitex.Core.RT.Device; using Aitex.Core.Util; using Aitex.Sorter.Common; using Aitex.Sorter.RT.EFEMs.Servers; using MECF.Framework.Common.Equipment; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot; namespace Aitex.Sorter.RT.EFEMs.Tasks { public class SetClampTask : RobotImp, ITask { public SetClampTask() { HasInfoMessage = false; } public bool Execute(out string result, params string[] args) { if (args.Length < 2) { result = PARAM_NG; return false; } string device = DeviceName.Robot; if (args[1].StartsWith("ALIGN")) device = DeviceName.Aligner; if (!Check(device, out result)) { return false; } if (!Check(device, out result)) { return false; } if (!Check(device, out result)) { return false; } if (!Check(device, out result)) { return false; } if (!Check(device, out result)) { return false; } if (!Check(device, out result)) { return false; } if (!Check(device, out result)) { return false; } if (!Check(device, out result)) { return false; } if (!Check(device, out result)) { return false; } if (!Check(device, out result)) { return false; } if (!Check(device, out result)) { return false; } if (!Check(device, out result)) { return false; } bool isGrip = false; if (args[0] == "ON") { isGrip = true; } else if (args[0] == "OFF") { isGrip = false; } else { result = PARAM_NG; return false; } if (args[1].StartsWith("ARM")) { Hand arm = Hand.Blade2; if (!ParseMoveArm(args[1], out arm) || arm == Hand.Both) { result = PARAM_NG; return false; } if (isGrip) { if (!Singleton.Instance.EfemDevice.Grip(ModuleName.Robot, arm, out result)) { return false; } } else { if (!Singleton.Instance.EfemDevice.Release(ModuleName.Robot, arm, out result)) { return false; } } } else if (args[1].StartsWith("ALIGN")) { AlignerServerModule serverAligner = (AlignerServerModule)GetEntity(device); if (serverAligner != null) { if (isGrip) { if (!serverAligner.Grip(out result)) { return false; } } else { if (!serverAligner.Release(out result)) { return false; } } } } else { result = PARAM_NG; return false; } return true; } public bool? Monitor(out string result, params string[] args) { result = ""; string device = DeviceName.Robot; if (args[1].StartsWith("ALIGN")) device = DeviceName.Aligner; if (args[1].StartsWith("ARM")) { Hand arm = Hand.Blade2; if (!ParseMoveArm(args[1], out arm) || arm == Hand.Both) { result = PARAM_NG; return false; } Robot robot = DEVICE.GetDevice(device); if (robot.Error) { return false; } if (!robot.Moving) { //if (arm == Hand.Blade1) // result = robot.StateBlade1Gripped ? "ON" : "OFF"; //else if (arm == Hand.Blade2) // result = robot.StateBlade2Gripped ? "ON" : "OFF"; return true; } } else if (args[1].StartsWith("ALIGN")) { AlignerServerModule serverAligner = (AlignerServerModule)GetEntity(device); if (serverAligner != null) { if (serverAligner.Error) { return false; } if (!serverAligner.Moving) { return true; } } else { return true; } } else { return true; } return null; } } public class GetClampTask : RobotImp, ITask { public GetClampTask() { } public bool Execute(out string result, params string[] args) { if (args.Length < 1) { result = PARAM_NG; return false; } string device = DeviceName.Robot; if (args[0].StartsWith("ALIGN")) device = DeviceName.Aligner; if (!Check(device, out result)) { return false; } if (args[0].StartsWith("ARM")) { Hand arm = Hand.Blade2; Robot robot = DEVICE.GetDevice(device); if (!ParseMoveArm(args[0], out arm) || arm == Hand.Both) { result = PARAM_NG; return false; } if (!robot.QueryState(out result)) { return false; } } else if (args[0].StartsWith("ALIGN")) { ///??? to be done } else { result = PARAM_NG; return false; } return true; } public bool? Monitor(out string result, params string[] args) { result = string.Empty; string device = DeviceName.Robot; if (args[0].StartsWith("ALIGN")) device = DeviceName.Aligner; if (args[0].StartsWith("ARM")) { Hand arm = Hand.Blade2; if (!ParseMoveArm(args[0], out arm) || arm == Hand.Both) { result = PARAM_NG; return false; } Robot robot = DEVICE.GetDevice(device); if (robot.Error) { return false; } if (!robot.Moving) { if (arm == Hand.Blade1) result = robot.StateBlade1Gripped ? "ON" : "OFF"; else if (arm == Hand.Blade2) result = robot.StateBlade2Gripped ? "ON" : "OFF"; return true; } } else if (args[0].StartsWith("ALIGN")) { AlignerServerModule serverAligner = (AlignerServerModule)GetEntity(device); if (serverAligner != null) { if (serverAligner.Error) { return false; } if (!serverAligner.Moving) { result = serverAligner.IsGripped ? "ON" : "OFF"; return true; } } else { return true; } } else { return true; } return null; } } }