| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508 | using Aitex.Core.RT.SCCore;using Caliburn.Micro;using DocumentFormat.OpenXml.Drawing;using FurnaceUI.Client.Dialog;using MECF.Framework.Common.DataCenter;using MECF.Framework.Common.OperationCenter;using MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig;using MECF.Framework.UI.Client.CenterViews.Dialogs;using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;using MECF.Framework.UI.Client.ClientBase;using OpenSEMI.ClientBase;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Globalization;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;namespace FurnaceUI.Views.Parameter{    public class N2PurgeEditViewModel : ModuleUiViewModelBase    {        public bool IsPermission { get => this.Permission == 3; }        public string TransferRoomVisibleBackGround { get; set; } = "#FF7DABD4";        public string FOUPOpenVisibleBackGround { get; set; } = "#FF7DABD4";        public string O2DetectorVisibleBackGround { get; set; } = "#FF7DABD4";        public string ClampOFFVisibleBackGround { get; set; } = "#FF7DABD4";        public string FurnaceOpenVisibleBackGround { get; set; } = "#FF7DABD4";        public string OperationCheckVisibleBackGround { get; set; } = "#FF7DABD4";        public string O2DensityQuickDownVisibleBackGround { get; set; } = "#FF7DABD4";        public string FoupEnterVisibleBackGround { get; set; } = "#FF7DABD4";        public string WaferChargeVisibleBackGround { get; set; } = "#FF7DABD4";        public string BoatLoadVisibleBackGround { get; set; } = "#FF7DABD4";        public string FoupInhibitAfterVisibleBackGround { get; set; } = "#FF7DABD4";        public string BoatUnloadVisibleBackGround { get; set; } = "#FF7DABD4";        public string BoatUnloadPreVisibleBackGround { get; set; } = "#FF7DABD4";        public string WaferCoolingVisibleBackGround { get; set; } = "#FF7DABD4";        public string WaferDishargeVisibleBackGround { get; set; } = "#FF7DABD4";        public List<ParamBase> ParameterTree { get; set; } = new List<ParamBase>();        public RecipeDataBase CurrentRecipe { get; set; } = new RecipeDataBase();        public ObservableCollection<TempSetData> HeadLst { get; set; } = new ObservableCollection<TempSetData>();        public ObservableCollection<TempSetData> PIDHeadLst { get; set; } = new ObservableCollection<TempSetData>();        private ConfigNode levelOneNode;        public ConfigNode LevelOneNode        {            get { return levelOneNode; }            set { levelOneNode = value; this.NotifyOfPropertyChange(nameof(LevelOneNode)); }        }        private ConfigNode levelTwoNode;        public ConfigNode LevelTwoNode        {            get { return levelTwoNode; }            set { levelTwoNode = value; this.NotifyOfPropertyChange(nameof(LevelTwoNode)); }        }        private List<ConfigItem> currenItems;        public List<ConfigItem> CurrenItems        {            get { return currenItems; }            set { currenItems = value; this.NotifyOfPropertyChange(nameof(CurrenItems)); }        }        private List<ConfigNode> _ConfigNodes = new List<ConfigNode>();        public List<ConfigNode> ConfigNodes        {            get { return _ConfigNodes; }            set { _ConfigNodes = value; NotifyOfPropertyChange("ConfigNodes"); }        }        private string _defaultUnit = "Pa";        public string DefaultUnit        {            get            {                return _defaultUnit;            }            set            {                _defaultUnit = value;                NotifyOfPropertyChange("DefaultUnit");            }        }        private ConfigNode _rootNode;        private string _CurrentNodeName = string.Empty;        private string path;        private string currentValue;        private ObservableCollection<PageValue> valueList { get; set; } = new ObservableCollection<PageValue>();        protected override void OnInitialize()        {            base.OnInitialize();            this.SystemName = "System";            ConfigNodes = SystemConfigProvider.Instance.GetConfigTree(SystemName).SubNodes;            InitTree();            _rootNode = SystemConfigProvider.Instance.GetConfig(true);        }        protected override void OnActivate()        {            base.OnActivate();            DefaultUnit = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.APC.PressureUnit");        }                private void InitTree()        {            var node = SystemConfigProvider.Instance.GetConfigTree(SystemName).SubNodes;            ParameterTree.Add(new ParamBase() { ID = 1, ParentID = 0, Name = "StepTime", ConfigName = "StepTime" });            ParameterTree.Add(new ParamBase() { ID = 2, ParentID = 0, Name = "Temperature" });            {                ParameterTree.Add(new ParamBase() { ID = 21, ParentID = 2, Name = "TempOffset", ConfigName = "TempOffsetTable" });                ParameterTree.Add(new ParamBase() { ID = 22, ParentID = 2, Name = "TempProfile", ConfigName = "TempProfileTable" });                ParameterTree.Add(new ParamBase() { ID = 23, ParentID = 2, Name = "TempStabilize", ConfigName = "TempStabilizeTable" });                ParameterTree.Add(new ParamBase() { ID = 24, ParentID = 2, Name = "TempSetting", ConfigName = "TempSetting" });                ParameterTree.Add(new ParamBase() { ID = 25, ParentID = 2, Name = "TempPIDTable", ConfigName = "TempPIDTable" });            }            //ParameterTree.Add(new ParamBase() { ID = 3, ParentID = 0, Name = "TempSetting", ConfigName = "TempSetting" });            ParameterTree.Add(new ParamBase() { ID = 4, ParentID = 0, Name = "PressureStabilize", ConfigName = "PressureStabilizeTable" });            ParameterTree.Add(new ParamBase() { ID = 5, ParentID = 0, Name = "AlarmWatchTable" });            {                ParameterTree.Add(new ParamBase() { ID = 51, ParentID = 5, Name = "TempAlarm", ConfigName = "AlarmWatchTable.TempAlarmWatch" });                ParameterTree.Add(new ParamBase() { ID = 52, ParentID = 5, Name = "FlowAlarm", ConfigName = "AlarmWatchTable.FlowAlarmWatch" });                ParameterTree.Add(new ParamBase() { ID = 53, ParentID = 5, Name = "PressureAlarm", ConfigName = "AlarmWatchTable.PressureAlarmWatch" });            }            ParameterTree.Add(new ParamBase() { ID = 6, ParentID = 0, Name = "FlowSetting", ConfigName = "FlowSetting" });            {                var MfcItems = ConfigNodes.Where(x => x.Display == "Parameter").FirstOrDefault().SubNodes.Where(y => y.Name == "MFC").FirstOrDefault().SubNodes;                foreach (var item in MfcItems)                {                    var isInstalled = QueryDataClient.Instance.Service.GetConfig($"PM1.MFC.{item.Name}.IsMFCInstalled");                    if (!(bool)isInstalled) continue;                    ParameterTree.Add(new ParamBase()                    {                        ID = 61,                        ParentID = 6,                        Name = SystemConfigProvider.Instance.GetValueByName($"PM1.MFC.{item.Name}.GasName"),                        ConfigName = $"FlowSetting.{item.Name}"                    });                }            }            ParameterTree.Add(new ParamBase() { ID = 7, ParentID = 0, Name = "APCSetting" });            {                ParameterTree.Add(new ParamBase() { ID = 71, ParentID = 7, Name = "Pressure", ConfigName = "APCSetting.Pressure" });                ParameterTree.Add(new ParamBase() { ID = 72, ParentID = 7, Name = "Position", ConfigName = "APCSetting.Position" });            }            ParameterTree.Add(new ParamBase() { ID = 8, ParentID = 0, Name = "LayoutPitch", ConfigName = "LayoutPitch" });            ParameterTree.Add(new ParamBase() { ID = 9, ParentID = 0, Name = "CoolingTime", ConfigName = "CoolTime" });            ParameterTree = this.LoadTreeView(0);        }        private List<ParamBase> LoadTreeView(int id)        {            List<ParamBase> node = ParameterTree.FindAll(s => s.ParentID.Equals(id));            foreach (var item in node)            {                item.Children = LoadTreeView(item.ID);            }            return node;        }        public void HideAllCanvas()        {                  }        public void TreeViewSelectedItemChanged(object obj)        {            valueList.Clear();            LevelOneNode = LevelTwoNode = new ConfigNode();            HideAllCanvas();            var view = GetView() as N2PurgeEditView;            ParamBase para = obj as ParamBase;            string strHeader = "PM1.RecipeEditParameter";            Canvas canvas = null;            LevelOneNode = FindNodeByName(_rootNode, $"{strHeader}.{para.ConfigName}");            LevelTwoNode = LevelOneNode.SubNodes.FirstOrDefault();                       if (canvas == null) return;            canvas.Visibility = Visibility.Visible;            this.GetHeaderConfig();            this.GetPIDHeaderConfig();            if (LevelTwoNode == null)            {                InitItemsCurrentValue(LevelOneNode, false);            }            else            {                InitItemsCurrentValue(LevelTwoNode, true);                ConfigNode subNode = LevelTwoNode.SubNodes.FirstOrDefault();                if (subNode != null) InitItemsCurrentValue(subNode, true);            }        }        private void InitItemsCurrentValue(ConfigNode node, bool initSubItems = true)        {            if (node == null) return;            CurrenItems = node.Items;            _CurrentNodeName = string.IsNullOrEmpty(node.Path) ? node.Name : $"{node.Path}.{node.Name}";            if (CurrenItems == null || CurrenItems.Count <= 0)            {                if (!initSubItems) return;                foreach (var item in node.SubNodes)                {                    InitItemsCurrentValue(item);                }            }            else            {                GetDataOfConfigItems();            }        }        private void GetDataOfConfigItems()        {            if (CurrenItems == null)                return;            for (int i = 0; i < CurrenItems.Count; i++)            {                var isInstalled = QueryDataClient.Instance.Service.GetConfig($"PM1.MFC.{CurrenItems[i].Name}.IsMFCInstalled");                if (isInstalled != null && !(bool)isInstalled)                    CurrenItems[i].Visible = false;                else                    CurrenItems[i].Visible = true;                string key = String.Format("{0}{1}{2}", _CurrentNodeName, ".", CurrenItems[i].Name);                CurrenItems[i].CurrentValue = SystemConfigProvider.Instance.GetValueByName(key);                CurrenItems[i].Path = key;                if (CurrenItems[i].Type == DataType.Bool)                {                    bool value;                    if (bool.TryParse(CurrenItems[i].CurrentValue, out value))                    {                        CurrenItems[i].BoolValue = value;                        CurrenItems[i].CurrentValue = value ? "Yes" : "No";                    }                }                else                    CurrenItems[i].StringValue = CurrenItems[i].CurrentValue;            }        }        public void MenuCommand(object obj, object menuLevel)        {            RadioButton radioButton = obj as RadioButton;            ConfigNode currentNode = null;            switch (menuLevel.ToString())            {                case "LevelOne":                    currentNode = LevelTwoNode = LevelOneNode.SubNodes.Find((x) => x.Name == radioButton.ToolTip.ToString());                    break;                case "LevelTwo":                    currentNode = LevelTwoNode.SubNodes.Find((x) => x.Name == radioButton.ToolTip.ToString());                    break;            }            InitItemsCurrentValue(currentNode);        }        public void SetValue(object obj)        {            var CurrentRecipes = CurrentRecipe;            if (CurrenItems == null || currenItems.Count == 0) return;            ConfigItem item = null;            if (obj is Control)                item = CurrenItems.Find((x) => x.Name == (obj as Control).ToolTip.ToString());            else                item = obj as ConfigItem;            InputDialogViewModel dialog = new InputDialogViewModel();            dialog.Item = item;            dialog.DisplayName = "Set Value";            WindowManager wm = new WindowManager();            bool? bret = wm.ShowDialog(dialog);            if ((bool)bret)            {                item.StringValue = dialog.DialogResult;                //key :System.IsSimulatorMode                 //value: true or false 都是字符串                //input check                string value;                if (item.Type == DataType.Bool)                {                    if (item.StringValue.Equals("Yes", StringComparison.CurrentCultureIgnoreCase))                        item.BoolValue = true;                    else if (item.StringValue.Equals("No", StringComparison.CurrentCultureIgnoreCase))                        item.BoolValue = false;                    else                    {                        DialogBox.ShowWarning("The Value Should be Yes Or No.");                        return;                    }                    value = item.BoolValue.ToString().ToLower();                }                else                {                    if (item.Type == DataType.Int)                    {                        int iValue;                        if (int.TryParse(item.StringValue, out iValue))                        {                            if (!double.IsNaN(item.Max) && !double.IsNaN(item.Min))                            {                                if (iValue > item.Max || iValue < item.Min)                                {                                    DialogBox.ShowWarning(string.Format("The value should be between {0}  and {1}.", ((int)item.Min).ToString(), ((int)item.Max).ToString()));                                    return;                                }                            }                        }                        else                        {                            DialogBox.ShowWarning("Please input valid data.");                            return;                        }                        value = item.StringValue;                    }                    else if (item.Type == DataType.Double)                    {                        double fValue;                        if (double.TryParse(item.StringValue, out fValue))                        {                            if (!double.IsNaN(item.Max) && !double.IsNaN(item.Min))                            {                                if (fValue > item.Max || fValue < item.Min)                                {                                    DialogBox.ShowWarning(string.Format("The value should be between {0}  and {1}.", item.Min.ToString(), item.Max.ToString()));                                    return;                                }                                string[] box = fValue.ToString().Split('.');                                if (box.Length > 1 && box[1].Length > 3)                                {                                    DialogBox.ShowWarning(string.Format("The value should be more than three decimal places"));                                    return;                                }                            }                        }                        else                        {                            DialogBox.ShowWarning("Please input valid data.");                            return;                        }                        value = item.StringValue;                    }                    else                        value = item.StringValue;                }                string key = String.Format("{0}{1}{2}", _CurrentNodeName, ".", item.Name);                if (item.Path.Split('.')[2] == "LayoutPitch")                {                    if (item.Path.Split('.')[3] == "StandardPitch")                    {                        foreach (var current in currenItems.Where(x => x.Description != "StandardPitch"))                        {                            current.CurrentValue = "No";                            InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", current.Path, "false");                        }                    }                    else if (item.Path.Split('.')[3] == "DoublePitch")                    {                        foreach (var current in currenItems.Where(x => x.Description != "DoublePitch"))                        {                            current.CurrentValue = "No";                            InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", current.Path, "false");                        }                    }                    else                    {                        foreach (var current in currenItems.Where(x => x.Description != "TriplePitch"))                        {                            current.CurrentValue = "No";                            InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", current.Path, "false");                        }                    }                }                path = item.Path;                currentValue = value;                valueList.Add(new PageValue() { Path = path, CurrentValue = currentValue });            }        }        public void SaveParameter()        {            foreach (var item in valueList)            {                InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", item.Path, item.CurrentValue);            }        }        public void GetHeaderConfig()        {            HeadLst.Clear();            for (int i = 0; i < 10; i++)            {                if (i % 2 != 0)                {                    var configHeater = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.Heater.Heater{i}.DisplayName");                    TempSetData item = new TempSetData(configHeater);                    item.SetValue.Value = configHeater;                    HeadLst.Add(item);                }            }        }        public void GetPIDHeaderConfig()        {            PIDHeadLst.Clear();            for (int i = 0; i < 10; i++)            {                if (i % 2 != 0)                {                    var configHeater = (string)QueryDataClient.Instance.Service.GetConfig($"PM1.Heater.Heater{i}.DisplayName");                    TempSetData item1 = new TempSetData(configHeater);                    TempSetData item2 = new TempSetData(configHeater);                    TempSetData item3 = new TempSetData(configHeater);                    item1.SetValue.Value = $"{configHeater} P";                    PIDHeadLst.Add(item1);                    item2.SetValue.Value = $"{configHeater} I";                    PIDHeadLst.Add(item2);                    item3.SetValue.Value = $"{configHeater} D";                    PIDHeadLst.Add(item3);                }            }        }        private ConfigNode FindNodeByName(ConfigNode parentNode, string strName)        {            string strCates = strName.Split('.')[0];            ConfigNode node = parentNode.SubNodes.Find((x) => x.Name == strCates);            if (node == null)                return parentNode;            else                return FindNodeByName(node, strName.Replace(strCates + ".", ""));        }        public void N2PurgeParaSelect(string ButtonPara)        {            this.GetType().GetProperty($"{ButtonPara}BackGround").SetValue(this, "#FF7DD486");            UpdataProperty();            N2PurgeSelectDialogViewModel dialog = new N2PurgeSelectDialogViewModel(ButtonPara);            WindowManager wm = new WindowManager();            bool? bret = wm.ShowDialog(dialog);            this.GetType().GetProperty($"{ButtonPara}BackGround").SetValue(this, "#FF7DABD4");            UpdataProperty();            if (!(bool)bret)                return;        }        public void UpdataProperty()        {            NotifyOfPropertyChange("TransferRoomVisibleBackGround");            NotifyOfPropertyChange("FOUPOpenVisibleBackGround");            NotifyOfPropertyChange("O2DetectorVisibleBackGround");            NotifyOfPropertyChange("ClampOFFVisibleBackGround");            NotifyOfPropertyChange("OperationCheckVisibleBackGround");            NotifyOfPropertyChange("O2DensityQuickDownVisibleBackGround");            NotifyOfPropertyChange("FoupEnterVisibleBackGround");            NotifyOfPropertyChange("WaferChargeVisibleBackGround");            NotifyOfPropertyChange("BoatLoadVisibleBackGround");            NotifyOfPropertyChange("FoupInhibitAfterVisibleBackGround");            NotifyOfPropertyChange("BoatUnloadVisibleBackGround");            NotifyOfPropertyChange("BoatUnloadPreVisibleBackGround");            NotifyOfPropertyChange("WaferCoolingVisibleBackGround");            NotifyOfPropertyChange("WaferDishargeVisibleBackGround");        }        protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)        {            base.InvokeAfterUpdateProperty(data);            NotifyOfPropertyChange("TransferRoomVisibleBackGround");        }    }   }
 |