|
@@ -0,0 +1,185 @@
|
|
|
+using Aitex.Core.RT.Device;
|
|
|
+using Aitex.Core.RT.Log;
|
|
|
+using Aitex.Core.RT.Routine;
|
|
|
+using Aitex.Core.Util;
|
|
|
+using MECF.Framework.Common.Routine;
|
|
|
+using MECF.Framework.Common.ToolLayout;
|
|
|
+using PunkHPX8_Core;
|
|
|
+using PunkHPX8_RT.Devices.AXIS;
|
|
|
+using PunkHPX8_RT.Devices.Facilities;
|
|
|
+using PunkHPX8_RT.Devices.VpwCell;
|
|
|
+using PunkHPX8_RT.Devices.VpwMain;
|
|
|
+using PunkHPX8_RT.Modules.VpwMain;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace PunkHPX8_RT.Modules.VpwCelMain
|
|
|
+{
|
|
|
+ public class VpwSimpleHomeRoutine : RoutineBase, IRoutine
|
|
|
+ {
|
|
|
+ private enum VpwSimpleHomeStep
|
|
|
+ {
|
|
|
+ CheckPreCondition,
|
|
|
+ ChamberUp,
|
|
|
+ HomeAllRotation,
|
|
|
+ CheckAllRotationHome,
|
|
|
+ ChamberDown,
|
|
|
+ End
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 常量
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 内部变量
|
|
|
+ /// <summary>
|
|
|
+ /// Cell device集合
|
|
|
+ /// </summary>
|
|
|
+ private List<VpwCellDevice> _vpwCellDevices = new List<VpwCellDevice>();
|
|
|
+ /// <summary>
|
|
|
+ /// Main Device
|
|
|
+ /// </summary>
|
|
|
+ private VpwMainDevice _mainDevice;
|
|
|
+ /// <summary>
|
|
|
+ /// 用于处理没有被dissable的vpwcell
|
|
|
+ /// </summary>
|
|
|
+ private List<VpwCellDevice> _cellLst = new List<VpwCellDevice>();
|
|
|
+ /// <summary>
|
|
|
+ /// vpw cell rotation列表
|
|
|
+ /// </summary>
|
|
|
+ private List<JetAxisBase> _rotationAxis = new List<JetAxisBase>();
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 构造函数
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="module"></param>
|
|
|
+ public VpwSimpleHomeRoutine(string module) : base(module)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 中止
|
|
|
+ /// </summary>
|
|
|
+ public void Abort()
|
|
|
+ {
|
|
|
+ Runner.Stop("Vpw Simple Home abort");
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 监控
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public RState Monitor()
|
|
|
+ {
|
|
|
+ Runner.Run(VpwSimpleHomeStep.CheckPreCondition, CheckPreCondition, _delay_1ms)
|
|
|
+ .Run(VpwSimpleHomeStep.ChamberUp, _mainDevice.ChamberUp, CheckChamberClosed, _delay_1s)
|
|
|
+ .Run(VpwSimpleHomeStep.HomeAllRotation, HomeAllRotation,_delay_1s)
|
|
|
+ .WaitWithStopCondition(VpwSimpleHomeStep.CheckAllRotationHome, CheckAllRotationHomed, CheckRotationHomeFailed)
|
|
|
+ .Run(VpwSimpleHomeStep.ChamberDown, _mainDevice.ChamberDown, CheckChamberOpened, _delay_1s)
|
|
|
+ .End(VpwSimpleHomeStep.End, NullFun, _delay_1ms);
|
|
|
+ return Runner.Status;
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool CheckPreCondition()
|
|
|
+ {
|
|
|
+ //SystemFacilities systemFacility = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
|
|
|
+ //if (systemFacility == null)
|
|
|
+ //{
|
|
|
+ // LOG.WriteLog(eEvent.ERR_VPW, Module, "Facility is null");
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ private bool HomeAllRotation()
|
|
|
+ {
|
|
|
+ bool result = true;
|
|
|
+ foreach (var axis in _rotationAxis)
|
|
|
+ {
|
|
|
+ result &= axis.Home();
|
|
|
+ if (result == false)
|
|
|
+ {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private bool CheckAllRotationHomed()
|
|
|
+ {
|
|
|
+ bool result = true;
|
|
|
+ foreach (var axis in _rotationAxis)
|
|
|
+ {
|
|
|
+ bool condition = axis.IsHomed && axis.Status == RState.End;
|
|
|
+ result &= condition;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ private bool CheckRotationHomeFailed()
|
|
|
+ {
|
|
|
+ bool result = false;
|
|
|
+ foreach (var axis in _rotationAxis)
|
|
|
+ {
|
|
|
+ bool condition = axis.Status == RState.Failed;
|
|
|
+ result |= condition;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 检验Chamber关闭
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool CheckChamberClosed()
|
|
|
+ {
|
|
|
+ return _mainDevice.CommonData.ChamberClosed && !_mainDevice.CommonData.ChamberOpened;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 检验Chamber打开
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ private bool CheckChamberOpened()
|
|
|
+ {
|
|
|
+ return !_mainDevice.CommonData.ChamberClosed && _mainDevice.CommonData.ChamberOpened;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 启动
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="objs"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public RState Start(params object[] objs)
|
|
|
+ {
|
|
|
+ _rotationAxis.Clear();
|
|
|
+ _vpwCellDevices.Clear();
|
|
|
+ _cellLst.Clear();
|
|
|
+ VpwMainItem vpwMainItem = VpwMainItemManager.Instance.GetItem(Module.ToString());
|
|
|
+ if (vpwMainItem == null || vpwMainItem.VpwCells == null)
|
|
|
+ {
|
|
|
+ return RState.Failed;
|
|
|
+ }
|
|
|
+ foreach (var item in vpwMainItem.VpwCells)
|
|
|
+ {
|
|
|
+ VpwCellDevice cellDevice = DEVICE.GetDevice<VpwCellDevice>(item.ModuleName);
|
|
|
+ _vpwCellDevices.Add(cellDevice);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ foreach (var device in _vpwCellDevices)
|
|
|
+ {
|
|
|
+ VpwCellEntity vpwCellEntity = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(device.Module);
|
|
|
+ if (vpwCellEntity.IsAuto || vpwCellEntity.IsManual)
|
|
|
+ {
|
|
|
+ _cellLst.Add(device);
|
|
|
+
|
|
|
+ JetAxisBase axis = DEVICE.GetDevice<JetAxisBase>($"{device.Module}.Rotation");
|
|
|
+ _rotationAxis.Add(axis);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ _mainDevice = DEVICE.GetDevice<VpwMainDevice>(Module.ToString());
|
|
|
+ return Runner.Start(Module, "VPW Simple Home");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|