| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- 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
- /// <summary>
- /// Platingcell device
- /// </summary>
- private PlatingCellDevice _device;
- /// <summary>
- /// vertical axis entity
- /// </summary>
- private PlatingCellVerticalEntity _verticalEntity;
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public PlatingCellUnloadRoutine(string module) : base(module)
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// vertical 运行
- /// </summary>
- /// <param name="positionName"></param> 目标位置名称
- /// <param name="offset"></param> 偏移量
- /// <returns></returns>
- private bool StartVertical(string positionName)
- {
- return _verticalEntity.CheckToPostMessage<PlatingCellVerticalState, PlatingCellVerticalEntity.VerticalMsg>(Aitex.Core.RT.Log.eEvent.INFO_PLATINGCELL,
- Module, (int)PlatingCellVerticalEntity.VerticalMsg.Position, positionName,0);
- }
- /// <summary>
- /// 检验垂直电机是否运动完成
- /// </summary>
- /// <returns></returns>
- private bool CheckVerticalEnd()
- {
- return _verticalEntity.IsIdle;
- }
- /// <summary>
- /// 检验垂直是否出现错误
- /// </summary>
- /// <returns></returns>
- private bool CheckVerticalError()
- {
- return _verticalEntity.IsError;
- }
- /// <summary>
- /// 检查ClamShell是否Open
- /// </summary>
- /// <returns></returns>
- private bool CheckClamShellOpen()
- {
- return _device.PlatingCellDeviceData.ClamShellOpened;
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- _device = DEVICE.GetDevice<PlatingCellDevice>(Module);
- //获取vertical entity
- string vertical = ModuleMatcherManager.Instance.GetPlatingVerticalByCell(Module);
- _verticalEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellVerticalEntity>(vertical);
- return Runner.Start(Module, "start unload");
- }
- }
- }
|