| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Beckhoff.AxisProvider;
- using MECF.Framework.Common.RecipeCenter;
- using MECF.Framework.Common.Routine;
- using MECF.Framework.Common.ToolLayout;
- using MECF.Framework.Common.Utilities;
- using PunkHPX8_Core;
- using PunkHPX8_RT.Devices.AXIS;
- using PunkHPX8_RT.Devices.Facilities;
- using PunkHPX8_RT.Devices.PlatingCell;
- using PunkHPX8_RT.Modules.Reservoir;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PunkHPX8_RT.Modules.PlatingCell
- {
- public class PlatingCellRunRecipeRoutine : RoutineBase, IRoutine
- {
- private enum RunRecipeStep
- {
- Delay,
- InterRinse,
- CheckInterRinse,
- Vertical,
- CheckVertical,
- End
- }
- #region 常量
- private const int ALL_DAY_MILLOSECONDS = 24 * 60 * 60 * 1000;
- #endregion
- #region 内部变量
- /// <summary>
- /// recipe
- /// </summary>
- private DepRecipe _recipe;
- /// <summary>
- /// Platingcell device
- /// </summary>
- private PlatingCellDevice _device;
- /// <summary>
- /// Rotation axis
- /// </summary>
- private JetAxisBase _rotationAxis;
- /// <summary>
- ///rotation Provider对象
- /// </summary>
- private BeckhoffProviderAxis _rotationProviderAxis;
- /// cycle次数
- /// </summary>
- private int _cycle;
- /// <summary>
- /// 当前完成的Cycle次数
- /// </summary>
- private int _currentCycle;
- /// <summary>
- /// platingcell entity
- /// </summary>
- private PlatingCellEntity _platingCellEntity;
- /// <summary>
- /// 对应reservoir entity
- /// </summary>
- private ReservoirEntity _reservoirEntity;
- private PlatingCellInterRinseRoutine _interRinseRoutine;
- private PlatingCellVerticalEntity _verticalEntity;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public PlatingCellRunRecipeRoutine(string module) : base(module)
- {
- _interRinseRoutine = new PlatingCellInterRinseRoutine(module);
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual Abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner.Delay(RunRecipeStep.Delay, 5000)
- .Run(RunRecipeStep.InterRinse, () => { return _interRinseRoutine.Start() == RState.Running; })
- .WaitWithStopCondition(RunRecipeStep.CheckInterRinse, () => CommonFunction.CheckRoutineEndState(_interRinseRoutine),
- () => CommonFunction.CheckRoutineStopState(_interRinseRoutine))
- .Run(RunRecipeStep.Vertical, StartVertical)
- .WaitWithStopCondition(RunRecipeStep.CheckVertical, CheckVerticalEnd, CheckVerticalError)
- .End(RunRecipeStep.End, NullFun);
- return Runner.Status;
- }
- /// <summary>
- /// 垂直电机运行(仅示例只做参考)
- /// </summary>
- /// <returns></returns>
- private bool StartVertical()
- {
- double position = 101;
- return _verticalEntity.CheckToPostMessage<PlatingCellVerticalState, PlatingCellVerticalEntity.VerticalMsg>(Aitex.Core.RT.Log.eEvent.INFO_PLATINGCELL,
- Module, (int)PlatingCellVerticalEntity.VerticalMsg.Position, position);
- }
- /// <summary>
- /// 检验垂直电机是否运动完成
- /// </summary>
- /// <returns></returns>
- private bool CheckVerticalEnd()
- {
- return _verticalEntity.IsIdle;
- }
- /// <summary>
- /// 检验垂直是否出现错误
- /// </summary>
- /// <returns></returns>
- private bool CheckVerticalError()
- {
- return _verticalEntity.IsError;
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- _recipe = objs[0] as DepRecipe;
- if (_recipe == null)
- {
- LOG.WriteLog(eEvent.ERR_METAL, Module, "recipe is null");
- return RState.Failed;
- }
- if (objs.Length > 1)
- {
- _cycle = (int)objs[1];
- }
- _device = DEVICE.GetDevice<PlatingCellDevice>(Module);
- _rotationAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Rotation");
- _rotationProviderAxis = BeckhoffAxisProviderManager.Instance.GetAxisProvider($"{Module}.Rotation");
- if (_rotationProviderAxis == null)
- {
- NotifyError(eEvent.ERR_PLATINGCELL, $"{Module}.Rotation Provider is not exist", 0);
- return RState.Failed;
- }
- //获取vertical entity
- string vertical = ModuleMatcherManager.Instance.GetPlatingVerticalByCell(Module);
- _verticalEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellVerticalEntity>(vertical);
- //获取platingcell eneity
- _platingCellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(Module);
- //获取对应reservoir eneity
- string reservoir = ReservoirItemManager.Instance.GetReservoirByPlatingCell(Module);
- _reservoirEntity = Singleton<RouteManager>.Instance.GetModule<ReservoirEntity>(reservoir);
- if (!CheckPreCondition())
- {
- return RState.Failed;
- }
- _currentCycle = 0;
-
- return Runner.Start(Module, "Run Recipe");
- }
- /// <summary>
- /// 检验前置条件
- /// </summary>
- /// <returns></returns>
- private bool CheckPreCondition()
- {
- if (_recipe == null)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Recipe is null");
- return false;
- }
- if (_recipe.DepSteps.Count == 0)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Recipe DepSteps count is 0");
- return false;
- }
- CheckAxisHome();
- CheckFacility();
- CheckModuleAndReservoir();
- return true;
- }
- private bool CheckModuleAndReservoir()
- {
- if (!_platingCellEntity.IsIdle)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"{Module} is not initialized");
- return false;
- }
- if (!_reservoirEntity.IsIdle)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"Releated reseroivr is not initialized");
- return false;
- }
- if (!_reservoirEntity.TemperatureReached)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, $"Releated reseroivr temperature is not reached");
- return false;
- }
- if ("Manual".Equals(_reservoirEntity.PersistentValue.OperatingMode))
- {
- // 要增加又wafer的判定,待修正
- }
- return true;
- }
- /// <summary>
- /// 检查马达是否上电且home
- /// </summary>
- /// <returns></returns>
- private bool CheckAxisHome()
- {
- if (!_rotationAxis.IsSwitchOn)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Rotation Axis is off");
- return false;
- }
- if (!_rotationAxis.IsHomed)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Rotation Axis is not home");
- return false;
- }
- if (!_verticalEntity.IsIdle)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Vertical Axis is not home");
- return false;
- }
- return true;
- }
- /// <summary>
- /// 检查facility
- /// </summary>
- /// <returns></returns>
- private bool CheckFacility()
- {
- SystemFacilities systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
- if (systemFacilities == null)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Facility is null");
- return false;
- }
- if (!systemFacilities.CDAEnable)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Facility CDA is off");
- return false;
- }
- if (!systemFacilities.N2Enable)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Facility N2 is off");
- return false;
- }
- if (!systemFacilities.DIFillEnable)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Facility DIW is off");
- return false;
- }
- if (systemFacilities.FacilitiesDataDic["CDA1Pressure"].IsError || systemFacilities.FacilitiesDataDic["CDA2Pressure"].IsError)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Facility CDA Data is in errro range");
- return false;
- }
- if (systemFacilities.FacilitiesDataDic["Nitrogen1APressure"].IsError ||
- systemFacilities.FacilitiesDataDic["Nitrogen1BPressure"].IsError ||
- systemFacilities.FacilitiesDataDic["Nitrogen2APressure"].IsError ||
- systemFacilities.FacilitiesDataDic["Nitrogen2BPressure"].IsError)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Facility N2 Data is in errro range");
- return false;
- }
- if (systemFacilities.FacilitiesDataDic["DiWaterPressure"].IsError)
- {
- LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Facility Diw Pressure value is in errro range");
- return false;
- }
- return true;
- }
- }
- }
|