123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- using Aitex.Core.RT.Routine;
- using MECF.Framework.Common.Routine;
- using MECF.Framework.Common.Utilities;
- using CyberX8_Core;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using CyberX8_RT.Devices.Reservoir;
- using Aitex.Core.RT.Device;
- using MECF.Framework.Common.RecipeCenter;
- using Aitex.Core.RT.Log;
- using CyberX8_RT.Devices.PowerSupplier;
- using CyberX8_RT.Devices.Temperature;
- using CyberX8_RT.Devices.Metal;
- using Aitex.Core.RT.SCCore;
- using CyberX8_RT.Devices.Facilities;
- namespace CyberX8_RT.Modules.Reservoir
- {
- public class CompactEmbranceInitializeRoutine : RoutineBase, IRoutine
- {
- private enum InitializeStep
- {
- AutoDiReplen,
- CAPump,
- CAPumpWait,
- ANPump,
- ANPumpWait,
- ManualCellDisableHED,
- AutoCellAutoEnableHED,
- AutoCellAutoEnableHEDDelay,
- AutoCellAutoEnableHEDCheck,
- AutoCellAutoCheckPowerSupplier,
- AutoCellAutoLinmotReset,
- AutoCellAutoLinmotResetCheck,
- CellWSUnclamp,
- End
- }
- #region 常量
- private const string AUTO = "Auto";
- private const string MANUAL = "Manual";
- private const int ENABLE = 5;
- #endregion
- #region 内部变量
- CAPumpOnRoutine _caPumpOnRoutine;
- ANPumpOnRoutine _anPumpOnRoutine;
- CompactMembranReservoirDevice _reservoirDevice;
- private ResRecipe _recipe;
- private List<CompactMembranMetalDevice> _metalDevices = new List<CompactMembranMetalDevice>();
- private TemperatureController _temperatureController;
- private double _hedFlowLowLimit;
- private int _autoHedDelay = 0;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public CompactEmbranceInitializeRoutine(string module) : base(module)
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- _caPumpOnRoutine.Abort();
- _anPumpOnRoutine.Abort();
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner.RunIf(InitializeStep.AutoDiReplen,_recipe.DIReplenEnable||_recipe.ANDIReplenEnable,CheckFacilitiesDiReplenStatus,_delay_1ms)
- .Run(InitializeStep.CAPump, () => { return _caPumpOnRoutine.Start() == RState.Running; }, _delay_1s)
- .WaitWithStopCondition(InitializeStep.CAPumpWait, () => CommonFunction.CheckRoutineEndState(_caPumpOnRoutine), () => CommonFunction.CheckRoutineStopState(_caPumpOnRoutine))
- .Run(InitializeStep.ANPump, () => { return _anPumpOnRoutine.Start() == RState.Running; }, _delay_1ms)
- .WaitWithStopCondition(InitializeStep.ANPumpWait, () => CommonFunction.CheckRoutineEndState(_anPumpOnRoutine), () => CommonFunction.CheckRoutineStopState(_anPumpOnRoutine))
- //Manual cell Bypass同时Enable HED
- .Run(InitializeStep.AutoCellAutoEnableHED, AutoHedOn, _delay_1ms)
- .Delay(InitializeStep.AutoCellAutoEnableHEDDelay, _autoHedDelay)
- .Run(InitializeStep.AutoCellAutoEnableHEDCheck, AutoHedSuccess, _delay_1ms)
- //检验PowerSupplier通信
- .Run(InitializeStep.AutoCellAutoCheckPowerSupplier, AutoMetalsPowerSupplierCommuncationStatus, _delay_1ms)
- //Cell Linmot Reset
- .RunIf(InitializeStep.AutoCellAutoLinmotReset, _reservoirDevice.OperationMode == AUTO, AutoMetalResetLinmot, _delay_1ms)
- .WaitWithStopCondition(InitializeStep.AutoCellAutoLinmotResetCheck, CheckAutoMetalResetStatus, CheckAutoMetalResetStopStatus)
- //Cell Unclamp
- .Run(InitializeStep.CellWSUnclamp, MetalsWHUnclampOn, _delay_1ms)
- .End(InitializeStep.End, NullFun, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// 检验总Di有没有开
- /// </summary>
- /// <returns></returns>
- private bool CheckFacilitiesDiReplenStatus()
- {
- SystemFacilities systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
- if (systemFacilities != null)
- {
- bool result= systemFacilities.DIReplenEnable;
- if (!result)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Facilities DiReplen is disable");
- }
- return result;
- }
- return false;
- }
- /// <summary>
- /// 启用HED
- /// </summary>
- /// <returns></returns>
- private bool EnableHED()
- {
- return _temperatureController.EnableOperation("", null);
- }
- /// <summary>
- /// 检验所有Metal处于Manual
- /// </summary>
- /// <returns></returns>
- private bool CheckAutoAndAllMetalAuto()
- {
- if (_reservoirDevice.OperationMode != AUTO)
- {
- return false;
- }
- for (int i = 0; i < _metalDevices.Count; i++)
- {
- CompactMembranMetalDevice hotMetalDevice = _metalDevices[i];
- if (hotMetalDevice.OperationMode != AUTO)
- {
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 自动HED On
- /// </summary>
- /// <returns></returns>
- private bool AutoHedOn()
- {
- double hedFlow = _reservoirDevice.ReservoirData.CAHedFlow;
- bool result = hedFlow > _hedFlowLowLimit;
- if (!result)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"HED Flow {hedFlow} is less than {_hedFlowLowLimit}");
- return false;
- }
- _autoHedDelay = _delay_2s;
- _temperatureController.EnableOperation("", null);
- _temperatureController.SetTargetTemperatureOperation("", new object[] { _recipe.TemperatureSetPoint });
- return true;
- }
- /// <summary>
- /// 检验Hed是否成功
- /// </summary>
- /// <returns></returns>
- private bool AutoHedSuccess()
- {
- if (_temperatureController.TemperatureData.ControlOperationModel == 0)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Temperature control is disable");
- return false;
- }
- if (Math.Abs(_recipe.TemperatureSetPoint - _temperatureController.TemperatureData.TargetTemperature) >= 0.1 * _recipe.TemperatureSetPoint)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"recipe temperature {_recipe.TemperatureSetPoint} is not match temperature target point {_temperatureController.TemperatureData.TargetTemperature}");
- return false;
- }
- return true;
- }
- /// <summary>
- /// 检验Metal A/B PowerSupplier通信状态
- /// </summary>
- /// <returns></returns>
- private bool AutoMetalsPowerSupplierCommuncationStatus()
- {
- for (int i = 0; i < _metalDevices.Count; i++)
- {
- CompactMembranMetalDevice hotMetalDevice = _metalDevices[i];
- if (hotMetalDevice.IsAuto)
- {
- if (hotMetalDevice.SideAPowerSupplier == null)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Side A PowerSupplier is null");
- return false;
- }
- if (hotMetalDevice.SideBPowerSupplier == null)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Side B PowerSupplier is null");
- return false;
- }
- if (!hotMetalDevice.SideAPowerSupplier.IsConnected)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Side A PowerSupplier {hotMetalDevice.SideAPowerSupplier.Name} is not connected");
- return false;
- }
- if (!hotMetalDevice.SideBPowerSupplier.IsConnected)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"Side B PowerSupplier {hotMetalDevice.SideBPowerSupplier.Name} is not connected");
- return false;
- }
- }
- }
- return true;
- }
- /// <summary>
- /// Auto Metal reset linmot
- /// </summary>
- /// <returns></returns>
- private bool AutoMetalResetLinmot()
- {
- for (int i = 0; i < _metalDevices.Count; i++)
- {
- CompactMembranMetalDevice hotMetalDevice = _metalDevices[i];
- if (hotMetalDevice.OperationMode == AUTO)
- {
- bool result = hotMetalDevice.ResetLinmot();
- if (!result)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Reset linmot error");
- return false;
- }
- }
- }
- return true;
- }
- /// <summary>
- /// Auto Metal reset linmot
- /// </summary>
- /// <returns></returns>
- private bool CheckAutoMetalResetStatus()
- {
- if (_reservoirDevice.OperationMode == MANUAL)
- {
- return true;
- }
- for (int i = 0; i < _metalDevices.Count; i++)
- {
- CompactMembranMetalDevice metalDevice = _metalDevices[i];
- if (metalDevice.OperationMode == AUTO)
- {
- bool result = metalDevice.CheckLinmotRoutineEnd();
- if (!result)
- {
- return false;
- }
- }
- }
- return true;
- }
- /// <summary>
- /// Auto Metal reset linmot
- /// </summary>
- /// <returns></returns>
- private bool CheckAutoMetalResetStopStatus()
- {
- if (_reservoirDevice.OperationMode == MANUAL)
- {
- return false;
- }
- for (int i = 0; i < _metalDevices.Count; i++)
- {
- CompactMembranMetalDevice hotMetalDevice = _metalDevices[i];
- if (hotMetalDevice.OperationMode == AUTO)
- {
- bool result = hotMetalDevice.CheckLinmotRoutineError();
- if (result)
- {
- return true;
- }
- }
- }
- return false;
- }
- /// Metal WS Unclamp
- /// </summary>
- /// <returns></returns>
- private bool MetalsWHUnclampOn()
- {
- for (int i = 0; i < _metalDevices.Count; i++)
- {
- CompactMembranMetalDevice hotMetalDevice = _metalDevices[i];
- if (hotMetalDevice != null && !hotMetalDevice.IsDisable)
- {
- bool result = hotMetalDevice.WaferHolderUnclampOn("", null);
- if (!result)
- {
- return false;
- }
- }
- }
- _reservoirDevice.InitializeCrossDose(true);
- return true;
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- _caPumpOnRoutine = new CAPumpOnRoutine(Module);
- _anPumpOnRoutine = new ANPumpOnRoutine(Module);
- _reservoirDevice = DEVICE.GetDevice<CompactMembranReservoirDevice>(Module);
- List<MetalCellDevice> lstDevice = (List<MetalCellDevice>)objs[0];
- _metalDevices.Clear();
- for (int i = 0; i < lstDevice.Count; i++)
- {
- _metalDevices.Add((CompactMembranMetalDevice)lstDevice[i]);
- }
- _temperatureController = (TemperatureController)objs[1];
- _recipe = _reservoirDevice.Recipe;
- _autoHedDelay = 0;
- _hedFlowLowLimit = SC.GetValue<double>($"Reservoir.{Module}.HEDFlowLowLimit");
- if (!CheckPreCondition())
- {
- return RState.Failed;
- }
- _reservoirDevice.InitializeCrossDose(false);
- return Runner.Start(Module, "Start C&M Initialize");
- }
- /// <summary>
- /// 检验前置条件
- /// </summary>
- /// <returns></returns>
- private bool CheckPreCondition()
- {
- if (_recipe == null)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "recipe is null");
- return false;
- }
- if (!_temperatureController.IsConnected)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "Temperature is not connected");
- return false;
- }
- return true;
- }
- }
- }
|