using MECF.Framework.Common.DataCenter; using MECF.Framework.UI.Client.CenterViews.Editors.Recipe; using MECF.Framework.UI.Client.CenterViews.Editors.Sequence; using OpenSEMI.ClientBase; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using FurnaceUI.Models; using FurnaceUI.Views.Recipes; using ProcessTypeFileItem = MECF.Framework.UI.Client.CenterViews.Editors.Recipe.ProcessTypeFileItem; namespace FurnaceUI.Views.Editors { public class RecipeAlarmActionSubViewModel : FurnaceUIViewModelBase { public ObservableCollection FileListByProcessType { get; set; } public ObservableCollection ChamberType { get; set; } public int ChamberTypeIndexSelection { get; set; } private RecipeProvider _recipeProvider = new RecipeProvider(); private ObservableCollection _stepList = new ObservableCollection(); public ObservableCollection StepList { get => _stepList; set { _stepList = value; NotifyOfPropertyChange("StepList"); } } private int _alarmTableNo; public int AlarmTableNo { get => _alarmTableNo; set { _alarmTableNo = value; NotifyOfPropertyChange("AlarmTableNo"); } } private int _alarmGroupNo; public int AlarmGroupNo { get => _alarmGroupNo; set { _alarmGroupNo = value; NotifyOfPropertyChange("AlarmGroupNo"); } } private string _alarmType; public string AlarmType { get => _alarmType; set { _alarmType = value; NotifyOfPropertyChange("AlarmType"); } } private string _alarmDetails; public string AlarmDetails { get => _alarmDetails; set { _alarmDetails = value; NotifyOfPropertyChange("AlarmDetails"); } } private Visibility _abortRecipeVisibility; public Visibility AbortRecipeVisibility { get => _abortRecipeVisibility; set { _abortRecipeVisibility = value; NotifyOfPropertyChange("AbortRecipeVisibility"); } } private Visibility _jumpStepVisibility; public Visibility JumpStepVisibility { get => _jumpStepVisibility; set { _jumpStepVisibility = value; NotifyOfPropertyChange("JumpStepVisibility"); } } public string CurrentStepName { get; set; } public string SelectedStepName { get; set; } public string AbortRecipeName { get; set; } private bool _isCheckJumpAbortRecipe; public bool IsCheckJumpAbortRecipe { get => _isCheckJumpAbortRecipe; set { _isCheckJumpAbortRecipe = value; NotifyOfPropertyChange(nameof(IsCheckJumpAbortRecipe)); } } private bool _isCheckJumpStep; public bool IsCheckJumpStep { get => _isCheckJumpStep; set { _isCheckJumpStep = value; NotifyOfPropertyChange(nameof(IsCheckJumpStep)); } } private bool _isCheckJumpStepCancelLoop; public bool IsCheckJumpStepCancelLoop { get => _isCheckJumpStepCancelLoop; set { _isCheckJumpStepCancelLoop = value; NotifyOfPropertyChange(nameof(IsCheckJumpStepCancelLoop)); } } private bool _isCheckAbort; public bool IsCheckAbort { get => _isCheckAbort; set { _isCheckAbort = value; NotifyOfPropertyChange(nameof(IsCheckAbort)); } } private bool _isCheckHold; public bool IsCheckHold { get => _isCheckHold; set { _isCheckHold = value; NotifyOfPropertyChange(nameof(IsCheckHold)); } } private bool _isCheckIgnoreAlarm; public bool IsCheckIgnoreAlarm { get => _isCheckIgnoreAlarm; set { _isCheckIgnoreAlarm = value; NotifyOfPropertyChange(nameof(IsCheckIgnoreAlarm)); } } protected override void OnInitialize() { base.OnInitialize(); } private void ShowControl(string alarmType) { AbortRecipeVisibility = Visibility.Hidden; JumpStepVisibility = Visibility.Hidden; switch (alarmType) { case "Jump Abort Recipe": AbortRecipeVisibility = Visibility.Visible; break; case "Jump Step": JumpStepVisibility = Visibility.Visible; break; case "Jump Step(Cancel Call Loop)": JumpStepVisibility = Visibility.Visible; break; case "Abort": break; case "Hold": break; case "Ignore Alarm": break; default: break; } } public void SelectStep(object step) { if (step is Step) { if (AlarmType == "Jump Step") { AlarmDetails = $"Jump Step/{((Step)step).Name}"; SelectedStepName = ((Step)step).Name; } else if (AlarmType == "Jump Step(Cancel Call Loop)") { AlarmDetails = $"Jump Step(Cancel Call Loop)/{((Step)step).Name}"; SelectedStepName = ((Step)step).Name; } } } public void TreeSelectChanged(object abortRecipeName) { if (abortRecipeName is FileNode) { AlarmDetails = $"Abort Recipe/{((FileNode)abortRecipeName).Name}"; AbortRecipeName = ((FileNode)abortRecipeName).Name; } } public void SelectAlarmGroupCommand(string alarmType) { AlarmType = alarmType; switch (alarmType) { case "Jump Abort Recipe": AlarmDetails = @"Abort Recipe/"; break; case "Jump Step": AlarmDetails = @"Jump Step/"; break; case "Jump Step(Cancel Call Loop)": AlarmDetails = @"Jump Step(Cancel Call Loop)/"; break; case "Abort": AlarmDetails = ""; break; case "Hold": AlarmDetails = ""; break; case "Ignore Alarm": AlarmDetails = ""; break; default: break; } SelectedStepName = ""; AbortRecipeName = ""; ShowControl(alarmType); } protected override void OnViewLoaded(object view) { base.OnViewLoaded(view); GetAbortRecipeFileList(); switch (AlarmType) { case "Jump Abort Recipe": IsCheckJumpAbortRecipe = true; break; case "Jump Step": IsCheckJumpStep = true; break; case "Jump Step(Cancel Call Loop)": IsCheckJumpStepCancelLoop = true; break; case "Abort": IsCheckAbort = true; break; case "Hold": IsCheckHold = true; break; case "Ignore Alarm": IsCheckIgnoreAlarm = true; break; default: IsCheckIgnoreAlarm = true; break; } ShowControl(AlarmType); } private void GetAbortRecipeFileList() { var processType = "Abort"; var chamberType = QueryDataClient.Instance.Service.GetConfig("System.Recipe.SupportedChamberType"); if (chamberType == null) { ChamberType = new ObservableCollection() { "Default" }; } else { ChamberType = new ObservableCollection(((string)(chamberType)).Split(',')); } ChamberTypeIndexSelection = 0; ObservableCollection typeFileList = new ObservableCollection(); string[] recipeProcessType = ((string)processType).Split(','); for (int i = 0; i < recipeProcessType.Length; i++) { var prefix = $"{ChamberType[ChamberTypeIndexSelection]}\\{recipeProcessType[i]}"; var recipes = _recipeProvider.GetXmlRecipeList(prefix); FileListByProcessType = RecipeSequenceTreeBuilder.BuildFileNode(prefix, "", false, recipes)[0].Files; } } public void SaveCmd() { if (AlarmType == "Jump Step" || AlarmType == "Jump Step(Cancel Call Loop)") { if (string.IsNullOrEmpty(SelectedStepName)) { DialogBox.ShowWarning("Jump Step is empty!"); return; } if (SelectedStepName == CurrentStepName) { DialogBox.ShowWarning($"Jump Step cannot be the same as {CurrentStepName}!"); return; } } if (AlarmType == "Jump Abort Recipe") { if (string.IsNullOrEmpty(AbortRecipeName)) { DialogBox.ShowWarning("Abort Recipe Name is empty!"); return; } } ((Window)GetView()).DialogResult = true; } public void CloseCmd() { ((Window)GetView()).DialogResult = false; } } }