using Aitex.Core.RT.Device; using Aitex.Core.RT.Routine; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; using MECF.Framework.Common.RecipeCenter; using MECF.Framework.Common.Routine; using MECF.Framework.Common.Utilities; using PunkHPX8_Core; using PunkHPX8_RT.Devices.AXIS; using PunkHPX8_RT.Devices.PlatingCell; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace PunkHPX8_RT.Modules.PlatingCell { public class PlatingCellUnloadRoutine : RoutineBase, IRoutine { private enum RunRecipeStep { VerticalGotoLoad, CheckVerticalGotoLoad, ClamShellOpen, End } #region 常量 #endregion /// /// Platingcell device /// private PlatingCellDevice _device; /// /// vertical axis entity /// private PlatingCellVerticalEntity _verticalEntity; /// /// 构造函数 /// /// public PlatingCellUnloadRoutine(string module) : base(module) { } /// /// 中止 /// public void Abort() { Runner.Stop("Manual Abort"); } /// /// 监控 /// /// public RState Monitor() { Runner.Run(RunRecipeStep.VerticalGotoLoad, () => StartVertical("Load"), _delay_1ms) .WaitWithStopCondition(RunRecipeStep.CheckVerticalGotoLoad, CheckVerticalEnd, CheckVerticalError) .Run(RunRecipeStep.ClamShellOpen, () => _device.ClamShellOpen(), CheckClamShellOpen, _delay_1s) .End(RunRecipeStep.End, NullFun); return Runner.Status; } /// /// vertical 运行 /// /// 目标位置名称 /// 偏移量 /// private bool StartVertical(string positionName) { return _verticalEntity.CheckToPostMessage(Aitex.Core.RT.Log.eEvent.INFO_PLATINGCELL, Module, (int)PlatingCellVerticalEntity.VerticalMsg.Position, positionName,0); } /// /// 检验垂直电机是否运动完成 /// /// private bool CheckVerticalEnd() { return _verticalEntity.IsIdle; } /// /// 检验垂直是否出现错误 /// /// private bool CheckVerticalError() { return _verticalEntity.IsError; } /// /// 检查ClamShell是否Open /// /// private bool CheckClamShellOpen() { return _device.PlatingCellDeviceData.ClamShellOpened; } /// /// 启动 /// /// /// public RState Start(params object[] objs) { _device = DEVICE.GetDevice(Module); //获取vertical entity string vertical = ModuleMatcherManager.Instance.GetPlatingVerticalByCell(Module); _verticalEntity = Singleton.Instance.GetModule(vertical); return Runner.Start(Module, "start unload"); } } }