123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.Routine;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.Common.Alarm;
- using MECF.Framework.Common.RecipeCenter;
- using MECF.Framework.Common.Routine;
- using MECF.Framework.Common.Utilities;
- using PunkHPX8_Core;
- using PunkHPX8_RT.Devices.Facilities;
- using PunkHPX8_RT.Devices.PlatingCell;
- using PunkHPX8_RT.Devices.Reservoir;
- using PunkHPX8_RT.Devices.Temperature;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PunkHPX8_RT.Modules.Reservoir
- {
- public class DMReservoirInitializeRoutine : RoutineBase, IRoutine
- {
- private enum InitializeStep
- {
- OpenIsolationValve,
- CAPump,
- CAPumpWait,
- ANPump,
- ANPumpWait,
- CheckFlowWait,
- CellManualCheckFlow,
- CellAutoCheckFlow,
- CheckDiReplen,
- AutoDiReplen,
- AutoCellAutoEnableHED,
- End
- }
- #region 常量
- private const string AUTO = "Auto";
- private const string MANUAL = "Manual";
- private const int ENABLE = 5;
- #endregion
- #region 内部变量
- CAPumpOnRoutine _caPumpOnRoutine;
- ANPumpOnRoutine _anPumpOnRoutine;
- DMReservoirDevice _dmReservoirDevice;
- private ResRecipe _recipe;
- private PlatingCellDevice _platingCellDevices;
- private TemperatureController _temperatureController;
- private double _hedFlowLowLimit;
- private int _autoHedDelay = 0;
- private int _flowFaultHoldOffTime = 1000;
- private double _cellFlowStartLowLimit = 3;
- private double _anFlowStartLowLimit = 0.5;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- public DMReservoirInitializeRoutine(string module) : base(module)
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- _caPumpOnRoutine.Abort();
- _anPumpOnRoutine.Abort();
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner.Run(InitializeStep.OpenIsolationValve, OpenIsolationValve,_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))
- .Delay(InitializeStep.CheckFlowWait, _flowFaultHoldOffTime)
- .RunIf(InitializeStep.CellManualCheckFlow,_dmReservoirDevice.OperationMode == MANUAL,ManualCheckFlow,_delay_1ms)
- .RunIf(InitializeStep.CellAutoCheckFlow,_dmReservoirDevice.OperationMode == AUTO, AutoCheckFlow, _delay_1ms)
- .RunIf(InitializeStep.AutoDiReplen, _recipe.DIReplenEnable || _recipe.ANDIReplenEnable, CheckFacilitiesDiReplenStatus, _delay_1ms)
- .Run(InitializeStep.AutoCellAutoEnableHED, AutoHedOn, _delay_1ms)
- .End(InitializeStep.End, ClearAlarmDataError, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// 打开Isolation valve
- /// </summary>
- /// <returns></returns>
- private bool OpenIsolationValve()
- {
- return _dmReservoirDevice.ANIsolationOn() && _dmReservoirDevice.CAIsolationOn();
- }
- /// <summary>
- /// 检查cell flow 和an flow是否大于配置项
- /// </summary>
- /// <returns></returns>
- private bool ManualCheckFlow()
- {
- //cell flow 校验待完成
- if(_dmReservoirDevice.ReservoirData.AnFlow < _anFlowStartLowLimit)
- {
- _dmReservoirDevice.AnPumpOff();
- _dmReservoirDevice.ANIsolationOff();
- return false;
- }
- return true;
- }
- /// <summary>
- /// 检查cell flow 和an flow是否大于recipe的设定
- /// </summary>
- /// <returns></returns>
- private bool AutoCheckFlow()
- {
- //cell flow 校验待完成
- if (_dmReservoirDevice.ReservoirData.AnFlow < _recipe.ANFlowRateErrorLow)
- {
- return false;
- }
- return true;
- }
- /// <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()
- {
- bool result = _dmReservoirDevice.ReservoirData.CaFlow < _cellFlowStartLowLimit;
- if (result)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, $"CA Flow {_dmReservoirDevice.ReservoirData.CaFlow} is less than CellFlowStartLowLimit{_cellFlowStartLowLimit}");
- return false;
- }
- result = _temperatureController.EnableOperation("", null);
- if (!result)
- {
- return false;
- }
- result = _temperatureController.SetTargetTemperatureOperation("", new object[] { _recipe.TemperatureSetPoint });
- if (!result)
- {
- return false;
- }
- 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>
- /// 清除alarm界面相关的dataerror
- /// </summary>
- private bool ClearAlarmDataError()
- {
- //AlarmListManager.Instance.RemoveDataError(Module);
- //_dmReservoirDevice.ClearErrorLogSet(Module); //清除device里面的ErrorLogSet
- return true;
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- _caPumpOnRoutine = new CAPumpOnRoutine(Module);
- _anPumpOnRoutine = new ANPumpOnRoutine(Module);
- _dmReservoirDevice = DEVICE.GetDevice<DMReservoirDevice>(Module);
- //_dmReservoirDevice.ClearErrorLogSet(Module);
- _platingCellDevices = (PlatingCellDevice)objs[0];
-
- _temperatureController = (TemperatureController)objs[1];
- _recipe = _dmReservoirDevice.Recipe;
- _flowFaultHoldOffTime = SC.GetValue<int>($"PlatingCell.FlowFaultHoldOffTime");
- _cellFlowStartLowLimit = SC.GetValue<double>($"PlatingCell.CellFlowStartLowLimit");
- _anFlowStartLowLimit = SC.GetValue<double>($"PlatingCell.ANFlowStartLowLimit");
- if (!CheckPreCondition())
- {
- return RState.Failed;
- }
- return Runner.Start(Module, "Start D&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;
- }
- if (!CheckFacility())
- {
- return false;
- }
- return true;
- }
- /// <summary>
- /// 检验facility
- /// </summary>
- /// <returns></returns>
- private bool CheckFacility()
- {
- SystemFacilities systemFacilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
- if (systemFacilities != null)
- {
- if (!systemFacilities.HouseChilledWaterEnable)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "HouseChilledWaterEnable is false");
- return false;
- }
- if (!systemFacilities.DIFillEnable)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "DIFillEnable is false");
- return false;
- }
- if (!systemFacilities.DIReplenEnable)
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "DIReplenEnable is false");
- return false;
- }
- }
- else
- {
- LOG.WriteLog(eEvent.ERR_RESERVOIR, Module, "DIReplenEnable is false");
- return false;
- }
- return true;
- }
- }
- }
|