123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- 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 PunkHPX8_Core;
- using PunkHPX8_RT.Devices.VpwCell;
- using PunkHPX8_RT.Devices.VpwMain;
- using SecsGem.Core.ItemModel;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PunkHPX8_RT.Modules.VpwMain
- {
- public class VPWHomeRoutine : RoutineBase, IRoutine
- {
- private enum HomeStep
- {
- ChameberUp,
- OpenCellDrainValve,
- End
- }
- #region 常量
- #endregion
- #region 内部变量
- /// <summary>
- /// Cell device集合
- /// </summary>
- private List<VpwCellDevice> _vpwCellDevices;
- /// <summary>
- /// Main Device
- /// </summary>
- private VpwMainDevice _mainDevice;
- /// <summary>
- /// cell集合
- /// </summary>
- private List<VpwCellDevice> _cellLst=new List<VpwCellDevice>();
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="module"></param>
- /// <param name="device"></param>
- public VPWHomeRoutine(string module) : base(module)
- {
- }
- /// <summary>
- /// 中止
- /// </summary>
- public void Abort()
- {
- Runner.Stop("Manual abort");
- }
- /// <summary>
- /// 监控
- /// </summary>
- /// <returns></returns>
- public RState Monitor()
- {
- Runner.Run(HomeStep.ChameberUp, _mainDevice.ChamberUp, CheckChamberClosed, _delay_1s)
- .Run(HomeStep.OpenCellDrainValve, OpenCellDrainValve, CheckCellDrainValveStatus, _delay_2s)
- .End(HomeStep.End,NullFun, _delay_1ms);
- return Runner.Status;
- }
- /// <summary>
- /// 检验Chamber关闭
- /// </summary>
- /// <returns></returns>
- private bool CheckChamberClosed()
- {
- return _mainDevice.CommonData.ChamberClosed && !_mainDevice.CommonData.ChamberOpened;
- }
- /// <summary>
- /// 打开所有cell valve
- /// </summary>
- /// <returns></returns>
- private bool OpenCellDrainValve()
- {
- foreach(var device in _vpwCellDevices)
- {
- VpwCellEntity vpwCellEntity = Singleton<RouteManager>.Instance.GetModule<VpwCellEntity>(device.Module);
- if (vpwCellEntity.IsAuto||vpwCellEntity.IsManual)
- {
- _cellLst.Add(device);
- bool result= device.DrainValveOn();
- if (!result)
- {
- LOG.WriteLog(eEvent.ERR_VPWMAIN, Module, $"{device.Module} open drain valve failed");
- CloseCellDrainValve();
- return false;
- }
- }
- }
- return true;
- }
- /// <summary>
- /// 检验Cell Drain状态
- /// </summary>
- /// <returns></returns>
- private bool CheckCellDrainValveStatus()
- {
- foreach (var item in _cellLst)
- {
- bool result = item.CommonData.DrainValve;
- if (!result)
- {
- LOG.WriteLog(eEvent.ERR_VPWMAIN, Module, $"{item.Module} drain valve is not opened");
- CloseCellDrainValve();
- return false;
- }
- }
- return true;
- }
- /// <summary>
- /// 关闭所有cell的Drain valve
- /// </summary>
- private void CloseCellDrainValve()
- {
- foreach (var item in _cellLst)
- {
- item.DrainValveOff();
- }
- }
- /// <summary>
- /// 启动
- /// </summary>
- /// <param name="objs"></param>
- /// <returns></returns>
- public RState Start(params object[] objs)
- {
- List<VpwCellDevice> lstDevice = (List<VpwCellDevice>)objs[0];
- _vpwCellDevices.Clear();
- _cellLst.Clear();
- for (int i = 0; i < lstDevice.Count; i++)
- {
- _vpwCellDevices.Add(lstDevice[i]);
- }
- _mainDevice = DEVICE.GetDevice<VpwMainDevice>(Module.ToString());
- return Runner.Start(Module,"VPW Home");
- }
- }
- }
|