using System; using System.IO; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Windows; using Aitex.Core.RT.Log; using Aitex.Core.UI.ControlDataContext; using Aitex.Core.Utilities; using Aitex.Sorter.Common; using VirgoUI.Client.Models.Sys; using MECF.Framework.Common.DataCenter; using OpenSEMI.ClientBase; using OpenSEMI.ClientBase.IO; using ExcelLibrary.SpreadSheet; using MECF.Framework.Common.OperationCenter; using Aitex.Core.Util; using VirgoCommon; using Aitex.Core.Common.DeviceData; using Aitex.Core.RT.SCCore; namespace VirgoUI.Client.Models.PMs { public class LeakCheckViewModel : ModuleUiViewModelBase, ISupportMultipleSystem { #region private int MenuPermission; private bool _isEnableGasLine; public bool IsEnableGasLine { get { return (LeakCheckModeSetPoint == "ChamberAndGasLine" || LeakCheckModeSetPoint == "ChamberAndGasLineAndFAC") && IsLeakCheckEnabled; } set { _isEnableGasLine = value; NotifyOfPropertyChange("IsEnableGasLine"); } } public bool IsLeakCheckEnabled { get { return IsManualMode && !IsLeakCheck; } } [IgnorePropertyChange] public string LeakCheckModeSetPoint { get; set; } [IgnorePropertyChange] public string LeakCheckPumpDownTimeSetPoint { get; set; } [IgnorePropertyChange] public string LeakCheckTimeSetPoint { get; set; } [IgnorePropertyChange] public string LeakRateUpperLimitSetPoint { get; set; } [IgnorePropertyChange] public string LeakCheckFlowScale { get; set; } [Subscription("IoMfc.MfcGas1.IsEnable")] public bool MfcGas1Enable { get; set; } [Subscription("IoMfc.MfcGas2.IsEnable")] public bool MfcGas2Enable { get; set; } [Subscription("IoMfc.MfcGas3.IsEnable")] public bool MfcGas3Enable { get; set; } [Subscription("IoMfc.MfcGas4.IsEnable")] public bool MfcGas4Enable { get; set; } [Subscription("IoMfc.MfcGas5.IsEnable")] public bool MfcGas5Enable { get; set; } private bool _enableGasLine1; public bool EnableGasLine1 { get { return _enableGasLine1; } set { _enableGasLine1 = value; NotifyOfPropertyChange("EnableGasLine1"); } } private bool _enableGasLine2; public bool EnableGasLine2 { get { return _enableGasLine2; } set { _enableGasLine2 = value; NotifyOfPropertyChange("EnableGasLine2"); } } private bool _enableGasLine3; public bool EnableGasLine3 { get { return _enableGasLine3; } set { _enableGasLine3 = value; NotifyOfPropertyChange("EnableGasLine3"); } } private bool _enableGasLine4; public bool EnableGasLine4 { get { return _enableGasLine4; } set { _enableGasLine4 = value; NotifyOfPropertyChange("EnableGasLine4"); } } private bool _enableGasLine5; public bool EnableGasLine5 { get { return _enableGasLine5; } set { _enableGasLine5 = value; NotifyOfPropertyChange("EnableGasLine5"); } } [Subscription(VirgoDevice.ProcessGauge)] public AITPressureMeterData ProcessGauge { get; set; } [Subscription(VirgoDevice.PressureGauge)] public AITPressureMeterData PressureGauge { get; set; } [Subscription(VirgoDevice.ForelineGauge)] public AITPressureMeterData ForelineGauge { get; set; } [Subscription("LeakCheckElapseTime")] public string LeakCheckElapseTime { get; set; } public List LeakCheckResultList { get; set; } [Subscription("IsAutoMode")] public bool IsAutoMode { get; set; } [Subscription(StateData.PMState)] public int PMStatus { get; set; } public string Status { get { return ((PMState)PMStatus).ToString(); } } public string Pressure { get { return ProcessGauge == null ? "0" : ProcessGauge.FeedBack.ToString("F0") + ProcessGauge.Unit; } } public bool IsLeakCheck { get { return (PMState)PMStatus == PMState.LeakCheck; } } public bool IsManualMode { get { return !IsAutoMode; } } public bool IsEnableLeakCheck { get { return !IsAutoMode && (PMState)PMStatus == PMState.Idle; } } public LeakCheckResultItem CurrentLeakCheckResultItem { get; set; } F_TRIG _trigLeakCheckFinished = new F_TRIG(); #endregion public LeakCheckViewModel() { LeakCheckModeSetPoint = LeakCheckMode.ChamberOnly.ToString(); EnableGasLine1 = true; EnableGasLine2 = true; EnableGasLine3 = true; EnableGasLine4 = true; EnableGasLine5 = true; NotifyOfPropertyChange("EnableGasLine1"); NotifyOfPropertyChange("EnableGasLine2"); NotifyOfPropertyChange("EnableGasLine3"); NotifyOfPropertyChange("EnableGasLine4"); NotifyOfPropertyChange("EnableGasLine5"); } protected override void OnInitialize() { base.OnInitialize(); } protected override void OnActivate() { base.OnActivate(); LeakCheckPumpDownTimeSetPoint = QueryDataClient.Instance.Service.GetConfig($"{SystemName}.Pump.LeakCheckPumpingTime").ToString(); LeakCheckTimeSetPoint = QueryDataClient.Instance.Service.GetConfig($"{SystemName}.Pump.LeakCheckWaitTime").ToString(); LeakRateUpperLimitSetPoint = ((float)(double)QueryDataClient.Instance.Service.GetConfig($"{SystemName}.Pump.LeakRate")).ToString(); } public void UpdateLeakCheckResult(string Module) { LeakCheckResultList = QueryDataClient.Instance.Service.GetHistoryLeakCheck(Module); InvokePropertyChanged("LeakCheckResultList"); } protected override void InvokeBeforeUpdateProperty(Dictionary data) { MenuPermission = ClientApp.Instance.GetPermission($"LeakCheck{SystemName}"); if (!MfcGas1Enable) EnableGasLine1 = false; if (!MfcGas2Enable) EnableGasLine2 = false; if (!MfcGas3Enable) EnableGasLine3 = false; if (!MfcGas4Enable) EnableGasLine4 = false; if (!MfcGas5Enable) EnableGasLine5 = false; _trigLeakCheckFinished.CLK = IsLeakCheck; if (_trigLeakCheckFinished.Q) { Application.Current.Dispatcher.Invoke(new Action(() => { UpdateLeakCheckResult(SystemName); })); } } protected override void InvokeAfterUpdateProperty(Dictionary data) { if (CurrentLeakCheckResultItem == null) { UpdateLeakCheckResult(SystemName); ; } } public void LeakCheck() { if (MenuPermission != 3) return; if (!IsLeakCheck) { InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{SystemName}.Pump.LeakCheckPumpingTime", LeakCheckPumpDownTimeSetPoint.ToString()); InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{SystemName}.Pump.LeakCheckWaitTime", LeakCheckTimeSetPoint.ToString()); InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{SystemName}.Pump.LeakRate", LeakRateUpperLimitSetPoint.ToString()); InvokeClient.Instance.Service.DoOperation($"{SystemName}.LeakCheck", new[] { LeakCheckPumpDownTimeSetPoint, LeakCheckTimeSetPoint, LeakCheckModeSetPoint, LeakRateUpperLimitSetPoint, EnableGasLine1.ToString(), EnableGasLine2.ToString(), EnableGasLine3.ToString(), EnableGasLine4.ToString(), EnableGasLine5.ToString(), }); } } public void AbortLeakCheck() { if (MenuPermission != 3) return; if (MessageBox.Show("是否确认停止检漏?", "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes) InvokeClient.Instance.Service.DoOperation($"{SystemName}.Abort"); } public void DeleteLeakCheck() { if (MenuPermission != 3) return; if (CurrentLeakCheckResultItem == null) { MessageBox.Show("请先选择要删除的检漏记录", "JetPlasma", MessageBoxButton.OK); return; } if (MessageBox.Show("是否确认删除当前检漏记录?", "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes) InvokeClient.Instance.Service.DoOperation($"{SystemName}.DeleteLeakCheck", CurrentLeakCheckResultItem.Id); CurrentLeakCheckResultItem = null; } } }