using Aitex.Core.RT.SCCore; using Aitex.Core.Util; 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 OxyPlot; using OxyPlot.Axes; using OxyPlot.Series; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Globalization; using System.Linq; using System.Text; using System.Threading; 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 ParameterTree { get; set; } = new List(); public RecipeDataBase CurrentRecipe { get; set; } = new RecipeDataBase(); public ObservableCollection HeadLst { get; set; } = new ObservableCollection(); public ObservableCollection PIDHeadLst { get; set; } = new ObservableCollection(); 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 currenItems; public List CurrenItems { get { return currenItems; } set { currenItems = value; this.NotifyOfPropertyChange(nameof(CurrenItems)); } } private List _ConfigNodes = new List(); public List 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 valueList { get; set; } = new ObservableCollection(); private PlotModel o2Model; public PlotModel O2Model { get { return o2Model; } set { o2Model = value; NotifyOfPropertyChange("O2Model"); } } private PlotModel n2Model; public PlotModel N2Model { get { return n2Model; } set { n2Model = value; NotifyOfPropertyChange("N2Model"); } } [Subscription("PM1.ConcentrationO2.Value")] public double ConcentrationO2Value { get; set; } [Subscription("PM1.MFC51.Feedback")] public double MFC51Feedback { get; set; } [Subscription("PM1.MFM57.Feedback")] public double MFM57Feedback { get; set; } 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"); GetO2ModelSpline(); GetN2ModelSpline(); } public void GetO2ModelSpline() { var tmp = new PlotModel { }; tmp.Axes.Add(new DateTimeAxis() { StringFormat = "HH:mm:ss", IsZoomEnabled = false, IsPanEnabled = false, IntervalType = DateTimeIntervalType.Seconds }); tmp.Series.Add(new LineSeries { Color = OxyColors.Blue, MarkerType = MarkerType.Circle, }); this.O2Model = tmp; Task.Run(() => { while (true) { var date = DateTime.Now; tmp.Axes[0].Maximum = DateTimeAxis.ToDouble(date.AddSeconds(1)); var lineSer = this.O2Model.Series[0] as LineSeries; lineSer.Points.Add(new OxyPlot.DataPoint(DateTimeAxis.ToDouble(date), ConcentrationO2Value)); if (lineSer.Points.Count > 30) { lineSer.Points.RemoveAt(0); } tmp.InvalidatePlot(true); Thread.Sleep(1000); } }); } public void GetN2ModelSpline() { var tmp = new PlotModel { }; tmp.Axes.Add(new DateTimeAxis() { StringFormat = "HH:mm:ss", IsZoomEnabled = false, IsPanEnabled = false, IntervalType = DateTimeIntervalType.Seconds }); tmp.Series.Add(new LineSeries { Color = OxyColors.Blue, MarkerType = MarkerType.Circle, }); this.N2Model = tmp; Task.Run(() => { while (true) { var date = DateTime.Now; tmp.Axes[0].Maximum = DateTimeAxis.ToDouble(date.AddSeconds(1)); var lineSer = this.N2Model.Series[0] as LineSeries; var pointValue = MFC51Feedback + MFM57Feedback; lineSer.Points.Add(new OxyPlot.DataPoint(DateTimeAxis.ToDouble(date), pointValue)); if (lineSer.Points.Count > 30) { lineSer.Points.RemoveAt(0); } tmp.InvalidatePlot(true); Thread.Sleep(1000); } }); } 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 LoadTreeView(int id) { List 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 data) { base.InvokeAfterUpdateProperty(data); NotifyOfPropertyChange("TransferRoomVisibleBackGround"); } } }