| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391 | 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<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;            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<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;        }    }}
 |