123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516 |
- 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 Virgo_DUI.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 Virgo_DCommon;
- using Aitex.Core.Common.DeviceData;
- using Aitex.Core.RT.SCCore;
- namespace Virgo_DUI.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");
- }
- }
- #region GasLine
- public bool IsEnableGas1Line
- {
- get
- {
- bool originalCondition = (LeakCheckModeSetPoint == "ChamberAndGasLine" ||
- LeakCheckModeSetPoint == "ChamberAndGasLineAndFAC") &&
- IsLeakCheckEnabled;
- string configValue = QueryDataClient.Instance.Service.GetConfig($"{SystemName}.MfcGas1.Enable").ToString(); // GasIndex 表示当前气体管路序号(1/2/3/4)
- //string configValue = QueryDataClient.Instance.Service.GetConfig(configKey)?.ToString();
- bool isGasEnabled = bool.TryParse(configValue, out bool result) ? result : false;
- return originalCondition && isGasEnabled;
- }
- set
- {
- _isEnableGasLine = value;
- NotifyOfPropertyChange("IsEnableGasLine");
- }
- }
- public bool IsEnableGas2Line
- {
- get
- {
- bool originalCondition = (LeakCheckModeSetPoint == "ChamberAndGasLine" ||
- LeakCheckModeSetPoint == "ChamberAndGasLineAndFAC") &&
- IsLeakCheckEnabled;
- string configValue = QueryDataClient.Instance.Service.GetConfig($"{SystemName}.MfcGas2.Enable").ToString(); // GasIndex 表示当前气体管路序号(1/2/3/4)
- //string configValue = QueryDataClient.Instance.Service.GetConfig(configKey)?.ToString();
- bool isGasEnabled = bool.TryParse(configValue, out bool result) ? result : false;
- return originalCondition && isGasEnabled;
- }
- set
- {
- _isEnableGasLine = value;
- NotifyOfPropertyChange("IsEnableGasLine");
- }
- }
- public bool IsEnableGas3Line
- {
- get
- {
- bool originalCondition = (LeakCheckModeSetPoint == "ChamberAndGasLine" ||
- LeakCheckModeSetPoint == "ChamberAndGasLineAndFAC") &&
- IsLeakCheckEnabled;
- string configValue = QueryDataClient.Instance.Service.GetConfig($"{SystemName}.MfcGas3.Enable").ToString(); // GasIndex 表示当前气体管路序号(1/2/3/4)
- //string configValue = QueryDataClient.Instance.Service.GetConfig(configKey)?.ToString();
- bool isGasEnabled = bool.TryParse(configValue, out bool result) ? result : false;
- return originalCondition && isGasEnabled;
- }
- set
- {
- _isEnableGasLine = value;
- NotifyOfPropertyChange("IsEnableGasLine");
- }
- }
- public bool IsEnableGas4Line
- {
- get
- {
- bool originalCondition = (LeakCheckModeSetPoint == "ChamberAndGasLine" ||
- LeakCheckModeSetPoint == "ChamberAndGasLineAndFAC") &&
- IsLeakCheckEnabled;
- string configValue = QueryDataClient.Instance.Service.GetConfig($"{SystemName}.MfcGas4.Enable").ToString(); // GasIndex 表示当前气体管路序号(1/2/3/4)
- //string configValue = QueryDataClient.Instance.Service.GetConfig(configKey)?.ToString();
- bool isGasEnabled = bool.TryParse(configValue, out bool result) ? result : false;
- return originalCondition && isGasEnabled;
- }
- set
- {
- _isEnableGasLine = value;
- NotifyOfPropertyChange("IsEnableGasLine");
- }
- }
- public bool IsEnableMasterGasline
- {
- get
- {
- return (LeakCheckModeSetPoint == "ChamberAndGasLine" || LeakCheckModeSetPoint == "ChamberAndGasLineAndFAC") && IsLeakCheckEnabled;
- }
- set
- {
- _isEnableGasLine = value;
- NotifyOfPropertyChange("IsEnableMasterGasline");
- }
- }
- #endregion
- 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");
- }
- }
- private bool _masterGasLineControl;
- public bool MasterGasLineControl
- {
- get => _masterGasLineControl;
- set
- {
- if (_masterGasLineControl == value) return;
- _masterGasLineControl = value;
- // 动态获取各气体管道的配置状态
- bool gas1Enabled = GetGasConfigState("MfcGas1");
- bool gas2Enabled = GetGasConfigState("MfcGas2");
- bool gas3Enabled = GetGasConfigState("MfcGas3");
- bool gas4Enabled = GetGasConfigState("MfcGas4");
- // 仅操作配置启用的管道
- if (gas1Enabled) EnableGasLine1 = value;
- if (gas2Enabled) EnableGasLine2 = value;
- if (gas3Enabled) EnableGasLine3 = value;
- if (gas4Enabled) EnableGasLine4 = value;
- NotifyOfPropertyChange(nameof(MasterGasLineControl));
- }
- }
- private bool GetGasConfigState(string gasName)
- {
- string configKey = $"{SystemName}.{gasName}.Enable";
- string configValue = QueryDataClient.Instance.Service.GetConfig(configKey)?.ToString();
- return bool.TryParse(configValue, out bool result) && result; // 配置无效时默认禁用
- }
- [Subscription(Virgo_DDevice.ProcessGauge)]
- public AITPressureMeterData ProcessGauge { get; set; }
- [Subscription(Virgo_DDevice.PressureGauge)]
- public AITPressureMeterData PressureGauge { get; set; }
- [Subscription(Virgo_DDevice.ForelineGauge)]
- public AITPressureMeterData ForelineGauge { get; set; }
- [Subscription("LeakCheckElapseTime")]
- public string LeakCheckElapseTime
- {
- get;
- set;
- }
- public List<LeakCheckResultItem> 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;
-
- NotifyOfPropertyChange("EnableGasLine1");
- NotifyOfPropertyChange("EnableGasLine2");
- NotifyOfPropertyChange("EnableGasLine3");
- NotifyOfPropertyChange("EnableGasLine4");
- }
- 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<string, object> 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<string, object> 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("Confirm to stop leak detection?", "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
- InvokeClient.Instance.Service.DoOperation($"{SystemName}.Abort");
- }
- public void DeleteLeakCheck()
- {
- if (MenuPermission != 3) return;
- if (CurrentLeakCheckResultItem == null)
- {
- MessageBox.Show("Please select the leak detection record to delete first.", "JetPlasma", MessageBoxButton.OK);
- return;
- }
- if (MessageBox.Show("Confirm to delete the current leak detection record?", "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
- InvokeClient.Instance.Service.DoOperation($"{SystemName}.DeleteLeakCheck", CurrentLeakCheckResultItem.Id);
- CurrentLeakCheckResultItem = null;
- }
- }
- }
|