123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- 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");
- }
- }
- }
|