123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- 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<NoReadyPolicy>(device, out result))
- {
- return false;
- }
- if (!Check<NoInitCompletedPolicy>(device, out result))
- {
- return false;
- }
- if (!Check<NoOriginCompletedPolicy>(device, out result))
- {
- return false;
- }
- if (!Check<VacPolicy>(device, out result))
- {
- return false;
- }
- if (!Check<EMSPolicy>(device, out result))
- {
- return false;
- }
- if (!Check<ErrorPolicy>(device, out result))
- {
- return false;
- }
- if (!Check<BusyPolicy>(device, out result))
- {
- return false;
- }
- if (!Check<HoldPolicy>(device, out result))
- {
- return false;
- }
- if (!Check<MaintenancePolicy>(device, out result))
- {
- return false;
- }
- if (!Check<LinkPolicy>(device, out result))
- {
- return false;
- }
- if (!Check<ArmExtendPolicy>(device, out result))
- {
- return false;
- }
- if (!Check<PowerDownPolicy>(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<EfemEntity>.Instance.EfemDevice.Grip(ModuleName.Robot, arm, out result))
- {
- return false;
- }
- }
- else
- {
- if (!Singleton<EfemEntity>.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<Robot>(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<NoReadyPolicy>(device, out result))
- {
- return false;
- }
- if (args[0].StartsWith("ARM"))
- {
- Hand arm = Hand.Blade2;
- Robot robot = DEVICE.GetDevice<Robot>(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<Robot>(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;
- }
- }
- }
|