using Aitex.Core.RT.Routine; using CyberX8_Core; using CyberX8_RT.Devices.EFEM; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.Routine; using MECF.Framework.Common.Schedulers; using MECF.Framework.Common.Utilities; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CyberX8_RT.Modules.EFEM { public class RobotCycleMoveRoutine : RoutineBase, IRoutine { private enum CycleStep { LoopStart, LoopRun, LoopCheck, LoopEnd, End } private EfemPickRoutine _efemPickRoutine; private EfemPlaceRoutine _efemPlaceRoutine; private EFEMAlignRoutine _efemAlignRoutine; private IRoutine _currentRoutine; private List _moveActionQueue; /// /// 构建函数 /// /// public RobotCycleMoveRoutine(EfemBase efem) : base(ModuleName.EfemRobot.ToString()) { _efemPickRoutine = new EfemPickRoutine(efem); _efemPlaceRoutine = new EfemPlaceRoutine(efem); _efemAlignRoutine = new EFEMAlignRoutine(efem); } /// /// 中止 /// public void Abort() { Runner.Stop("Manual abort"); } /// /// 中止 /// /// public RState Monitor() { Runner.LoopStart(CycleStep.LoopStart, "start efem cycle action", _moveActionQueue.Count, NullFun, _delay_1ms) .LoopRun(CycleStep.LoopRun, RunAction, _delay_1ms) .LoopRunWithStopStatus(CycleStep.LoopCheck, () => CommonFunction.CheckRoutineEndState(_currentRoutine), () => CommonFunction.CheckRoutineStopState(_currentRoutine)) .LoopEnd(CycleStep.LoopEnd, NullFun, _delay_1ms) .End(CycleStep.End, NullFun, _delay_1ms); return Runner.Status; } private bool RunAction() { EfemCycleAction action = _moveActionQueue[Runner.LoopCounter]; switch(action.Action) { case "Pick": Queue moveItems = new Queue(); moveItems.Enqueue((MoveItem)action.Parameter); _currentRoutine = _efemPickRoutine; return _efemPickRoutine.Start(moveItems) == RState.Running; case "Place": Queue placeMoveItems = new Queue(); placeMoveItems.Enqueue((MoveItem)action.Parameter); _currentRoutine= _efemPlaceRoutine; return _efemPlaceRoutine.Start(placeMoveItems) == RState.Running; case "Align": _currentRoutine = _efemAlignRoutine; object[] alignerParamater = new object[3];//初始化Align参数 alignerParamater[0] = ModuleName.Aligner1; alignerParamater[1] = 0; alignerParamater[2] = action.Parameter; return _efemAlignRoutine.Start(alignerParamater) ==RState.Running; } return false; } /// /// 启动 /// /// /// public RState Start(params object[] objs) { _moveActionQueue = (List)objs[0]; return Runner.Start(Module, "Robot Cycle move"); } } }