|
@@ -0,0 +1,256 @@
|
|
|
+using MECF.Framework.Common.DataCenter;
|
|
|
+using MECF.Framework.Common.OperationCenter;
|
|
|
+using Prism.Commands;
|
|
|
+using Prism.Mvvm;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
+using System.Linq;
|
|
|
+using System.Windows.Threading;
|
|
|
+using Venus_Core;
|
|
|
+using Venus_MainPages.Unity;
|
|
|
+
|
|
|
+namespace Venus_MainPages.ViewModels
|
|
|
+{
|
|
|
+ public class CleanRecipeViewModel : BindableBase
|
|
|
+ {
|
|
|
+ #region 私有字段
|
|
|
+ private string m_ModuleName;
|
|
|
+ private PMState m_PMCurrentState;
|
|
|
+ private bool m_IsEnableCleanRecipe;
|
|
|
+ private int m_IdleDuringTimeCount;
|
|
|
+ private TimeSpan m_IdleDuringTime;
|
|
|
+ private List<string> m_CurrentModuleRecipes = new List<string>();
|
|
|
+ private string m_SelectedCleanRecipe;
|
|
|
+ private string m_CleanRecipeSetpoint;
|
|
|
+ private int m_IdleCleanTimeSetpoint;
|
|
|
+ private string m_IdleCleanModeSetpoint;
|
|
|
+ private int m_IdleCleanWaferCountSetpoint;
|
|
|
+ private string m_CleanRecipeFeedback;
|
|
|
+ private int m_IdleCleanTimeFeedback;
|
|
|
+ private int m_IdleCleanWaferCountFeedback;
|
|
|
+ private string m_IdleCleanModeFeedback;
|
|
|
+
|
|
|
+ private List<string> m_RtConfigKeys = new List<string>();
|
|
|
+ private Dictionary<string, object> m_RtConfigValues;
|
|
|
+ private List<string> m_IdleCleanModes = new List<string>();
|
|
|
+
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 属性
|
|
|
+ public string ModuleName
|
|
|
+ {
|
|
|
+ get { return m_ModuleName; }
|
|
|
+ set { m_ModuleName = value; }
|
|
|
+ }
|
|
|
+ public PMState PMCurrentState
|
|
|
+ {
|
|
|
+ get { return m_PMCurrentState; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+
|
|
|
+ m_PMCurrentState = value;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ public bool IsEnableCleanRecipe
|
|
|
+ {
|
|
|
+ get { return m_IsEnableCleanRecipe; }
|
|
|
+ set { SetProperty(ref m_IsEnableCleanRecipe, value); }
|
|
|
+ }
|
|
|
+ public TimeSpan IdleDuringTime
|
|
|
+ {
|
|
|
+ get { return m_IdleDuringTime; }
|
|
|
+ set { SetProperty(ref m_IdleDuringTime, value); }
|
|
|
+ }
|
|
|
+ public List<string> CurrentModuleRecipes
|
|
|
+ {
|
|
|
+ get { return m_CurrentModuleRecipes; }
|
|
|
+ set { SetProperty(ref m_CurrentModuleRecipes, value); }
|
|
|
+
|
|
|
+ }
|
|
|
+ public string SelectedCleanRecipe
|
|
|
+ {
|
|
|
+ get { return m_SelectedCleanRecipe; }
|
|
|
+ set { SetProperty(ref m_SelectedCleanRecipe, value); }
|
|
|
+ }
|
|
|
+ public string CleanRecipeSetpoint
|
|
|
+ {
|
|
|
+ get { return m_CleanRecipeSetpoint; }
|
|
|
+ set { SetProperty(ref m_CleanRecipeSetpoint, value); }
|
|
|
+ }
|
|
|
+ public int IdleCleanTimeSetpoint
|
|
|
+ {
|
|
|
+ get { return m_IdleCleanTimeSetpoint; }
|
|
|
+ set { SetProperty(ref m_IdleCleanTimeSetpoint, value); }
|
|
|
+ }
|
|
|
+ public int IdleCleanWaferCountSetpoint
|
|
|
+ {
|
|
|
+ get { return m_IdleCleanWaferCountSetpoint; }
|
|
|
+ set { SetProperty(ref m_IdleCleanWaferCountSetpoint, value); }
|
|
|
+ }
|
|
|
+ public string CleanRecipeFeedback
|
|
|
+ {
|
|
|
+ get { return m_CleanRecipeFeedback; }
|
|
|
+ set { SetProperty(ref m_CleanRecipeFeedback, value); }
|
|
|
+ }
|
|
|
+ public int IdleCleanTimeFeedback
|
|
|
+ {
|
|
|
+ get { return m_IdleCleanTimeFeedback; }
|
|
|
+ set { SetProperty(ref m_IdleCleanTimeFeedback, value); }
|
|
|
+ }
|
|
|
+ public int IdleCleanWaferCountFeedback
|
|
|
+ {
|
|
|
+ get { return m_IdleCleanWaferCountFeedback; }
|
|
|
+ set { SetProperty(ref m_IdleCleanWaferCountFeedback, value); }
|
|
|
+ }
|
|
|
+ public Dictionary<string, object> RtConfigValues
|
|
|
+ {
|
|
|
+ get { return m_RtConfigValues; }
|
|
|
+ set { SetProperty(ref m_RtConfigValues, value); }
|
|
|
+ }
|
|
|
+ public string IdleCleanModeSetpoint
|
|
|
+ {
|
|
|
+ get { return m_IdleCleanModeSetpoint; }
|
|
|
+ set { SetProperty(ref m_IdleCleanModeSetpoint, value); }
|
|
|
+ }
|
|
|
+ public string IdleCleanModeFeedback
|
|
|
+ {
|
|
|
+ get { return m_IdleCleanModeFeedback; }
|
|
|
+ set { SetProperty(ref m_IdleCleanModeFeedback, value); }
|
|
|
+ }
|
|
|
+ public List<string> IdleCleanModes
|
|
|
+ {
|
|
|
+ get { return m_IdleCleanModes; }
|
|
|
+ set { SetProperty(ref m_IdleCleanModes, value); }
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 命令
|
|
|
+ private DelegateCommand<object> _EnableCleanRecipeCommand;
|
|
|
+ public DelegateCommand<object> EnableCleanRecipeCommand =>
|
|
|
+ _EnableCleanRecipeCommand ?? (_EnableCleanRecipeCommand = new DelegateCommand<object>(OnEnableCleanRecipe));
|
|
|
+
|
|
|
+ private DelegateCommand _LoadRecipeCommand;
|
|
|
+ public DelegateCommand LoadRecipeCommand =>
|
|
|
+ _LoadRecipeCommand ?? (_LoadRecipeCommand = new DelegateCommand(OnLoadRecipe));
|
|
|
+
|
|
|
+ private DelegateCommand<object> _SetCommand;
|
|
|
+ public DelegateCommand<object> SetCommand =>
|
|
|
+ _SetCommand ?? (_SetCommand = new DelegateCommand<object>(OnSet));
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 构造函数
|
|
|
+ public CleanRecipeViewModel()
|
|
|
+ {
|
|
|
+ DispatcherTimer timer = new DispatcherTimer();
|
|
|
+ timer.Interval = TimeSpan.FromSeconds(0.5);
|
|
|
+ timer.Tick += Timer_Tick;
|
|
|
+ timer.Start();
|
|
|
+
|
|
|
+ IdleCleanModes.Add("Disable");
|
|
|
+ IdleCleanModes.Add("IdleTime");
|
|
|
+ IdleCleanModes.Add("WaferCount");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 方法
|
|
|
+ private void Timer_Tick(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ var pmstate = QueryDataClient.Instance.Service.GetData($"{ModuleName}.FsmState");
|
|
|
+ PMCurrentState = (PMState)Enum.Parse(typeof(PMState), pmstate.ToString());
|
|
|
+ if (PMCurrentState != PMState.Idle)
|
|
|
+ {
|
|
|
+ m_IdleDuringTimeCount = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_IdleDuringTimeCount += 1;
|
|
|
+ }
|
|
|
+ IdleDuringTime = new System.TimeSpan(0, 0, m_IdleDuringTimeCount);
|
|
|
+ RtConfigValues = QueryDataClient.Instance.Service.PollConfig(m_RtConfigKeys);
|
|
|
+ CleanRecipeFeedback = CommonFunction.GetValue<string>(RtConfigValues, $"{ModuleName}.IdleClean.IdleCleanRecipe");
|
|
|
+ IdleCleanTimeFeedback = CommonFunction.GetValue<int>(RtConfigValues, $"{ModuleName}.IdleClean.IdleCleanTime");
|
|
|
+ IdleCleanWaferCountFeedback = CommonFunction.GetValue<int>(RtConfigValues, $"{ModuleName}.IdleClean.IdleCleanWaferCount");
|
|
|
+
|
|
|
+ IdleCleanModeFeedback=ModeConver( CommonFunction.GetValue<string>(RtConfigValues, $"{ModuleName}.IdleClean.Option"));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ private void OnEnableCleanRecipe(object obj)
|
|
|
+ {
|
|
|
+ if (obj.ToString() == "true")
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (obj.ToString() == "false")
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void OnLoadRecipe()
|
|
|
+ {
|
|
|
+ CurrentModuleRecipes = CommonFunction.GetFilesNames(Path.Combine(QueryDataClient.Instance.Service.GetData("GetRTPath").ToString(), "Recipes", ModuleName, "Clean")).ToList<string>();
|
|
|
+ }
|
|
|
+ public void addConfigKeys()
|
|
|
+ {
|
|
|
+ m_RtConfigKeys.Add($"{ModuleName}.IdleClean.IdleCleanRecipe");
|
|
|
+ m_RtConfigKeys.Add($"{ModuleName}.IdleClean.IdleCleanTime");
|
|
|
+ m_RtConfigKeys.Add($"{ModuleName}.IdleClean.IdleCleanWaferCount");
|
|
|
+ m_RtConfigKeys.Add($"{ModuleName}.IdleClean.Option");
|
|
|
+
|
|
|
+ }
|
|
|
+ private void OnSet(object obj)
|
|
|
+ {
|
|
|
+ switch (obj.ToString())
|
|
|
+ {
|
|
|
+ case "0":
|
|
|
+ InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{ModuleName}.IdleClean.IdleCleanRecipe", CleanRecipeSetpoint);
|
|
|
+ break;
|
|
|
+ case "1":
|
|
|
+ InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{ModuleName}.IdleClean.IdleCleanTime", IdleCleanTimeSetpoint.ToString());
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{ModuleName}.IdleClean.IdleCleanWaferCount", IdleCleanWaferCountSetpoint.ToString());
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ if (IdleCleanModeSetpoint == "Disable")
|
|
|
+ {
|
|
|
+ InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{ModuleName}.IdleClean.Option", "0");
|
|
|
+ }
|
|
|
+ else if (IdleCleanModeSetpoint == "IdleTime")
|
|
|
+ {
|
|
|
+ InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{ModuleName}.IdleClean.Option", "1");
|
|
|
+ }
|
|
|
+ else if (IdleCleanModeSetpoint == "WaferCount")
|
|
|
+ {
|
|
|
+ InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{ModuleName}.IdleClean.Option", "2");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private string ModeConver(string str)
|
|
|
+ {
|
|
|
+ if (str == "0")
|
|
|
+ {
|
|
|
+ return "Disable";
|
|
|
+ }
|
|
|
+ else if (str == "1")
|
|
|
+ {
|
|
|
+ return "IdleTime";
|
|
|
+ }
|
|
|
+ else if (str == "2")
|
|
|
+ {
|
|
|
+ return "WaferCount";
|
|
|
+ }
|
|
|
+ return "Error";
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+}
|