using Aitex.Core.Common; using Aitex.Core.Common.DeviceData; using Aitex.Core.UI.Dialog; using Aitex.Core.UI.MVVM; using Aitex.Core.Util; using Aitex.Core.Utilities; using Aitex.Sorter.Common; using MECF.Framework.Common.OperationCenter; using System.Collections.Generic; using System.Linq; using System.Windows; using System.Windows.Input; using Aitex.Core.RT.SCCore; using System.Collections.ObjectModel; using Aitex.Sorter.UI.Controls; using Aitex.Sorter.UI.Controls.Common; using MECF.Framework.Common.DataCenter; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.RecipeCenter; namespace Aitex.Sorter.UI.ViewModel { public abstract class OperationMultiLPViewModel : FoupListViewModelBase { public string FoupType { get; set; } #region command public ICommand OperationCommand { get; private set; } public ICommand RecipeSelectCommand { get; private set; } public ICommand RecipeStartCommand { get; private set; } public ICommand RecipePauseCommand { get; private set; } public ICommand RecipeResumeCommand { get; private set; } public ICommand RecipeStopCommand { get; private set; } #endregion #region Subscription [Subscription(ParamName.TranserThroughput, SystemStateModule)] public int TranserThroughput { get; set; } [Subscription(ParamName.TransferCount, SystemStateModule)] public int TransferCount { get; set; } [Subscription(ParamName.CycleCount, SystemStateModule)] public int CycleCount { get; set; } [Subscription(ParamName.TransferTime, SystemStateModule)] public int TransferTime { get; set; } [Subscription(ParamName.TotalCycleCount, SystemStateModule)] public int TotalCycleCount { get; set; } [Subscription(ParamName.TotalWaferCount, SystemStateModule)] public int TotalWaferCount { get; set; } [Subscription(ParamName.RTStatus, SystemStateModule)] public int RoutManagerState { get; set; } [Subscription(ParamName.WaferInfoRobotSlot01, "System")] public WaferInfo RobotWaferInfo1 { get; set; } [Subscription(ParamName.WaferInfoRobotSlot02, "System")] public WaferInfo RobotWaferInfo2 { get; set; } [Subscription(ParamName.ModuleWaferList, DeviceName.Aligner)] public WaferInfo[] AlignerWafers { get; set; } [Subscription(ParamName.ModuleWaferList, DeviceName.LL1)] public WaferInfo[] LLWaferInfos { get; set; } public WaferInfo AlignerWafer { get { if(AlignerWafers!=null) { return AlignerWafers[0]; } else { return null; } } } public WaferInfo Loadlock1Wafer { get { if (LLWaferInfos != null) { return LLWaferInfos[0]; } else { return null; } } } [Subscription(ParamName.AlignerState, DeviceName.Aligner)] public string AlignerState { get; set; } [Subscription(ParamName.RobotState, DeviceName.Robot)] public string RobotState { get; set; } [Subscription("State", DeviceName.Robot)] public string RobotFsmState { get; set; } [Subscription(ParamName.RobotSpeed, DeviceName.Robot)] public string RobotSpeed { get; set; } [Subscription("System.SensorPreAlignerWaferOn.DeviceData")] public AITSensorData SensorPreAlignerWaferOn { get; set; } [Subscription("System.SensorRobotFork2WaferOn.DeviceData")] public AITSensorData SensorRobotFork2WaferOn { get; set; } [Subscription("System.SensorRobotFork1WaferOn.DeviceData")] public AITSensorData SensorRobotFork1WaferOn { get; set; } [Subscription("System.SensorBufferWaferOn.DeviceData")] public AITSensorData SensorBufferWaferOn { get; set; } [Subscription("System.SensorCoolingStageSLOT1WaferON.DeviceData")] public AITSensorData SensorCoolingStageSLOT1WaferON { get; set; } [Subscription("System.SensorCoolingStageSLOT2WaferON.DeviceData")] public AITSensorData SensorCoolingStageSLOT2WaferON { get; set; } [Subscription("System.SensorCoolingStageSLOT3WaferON.DeviceData")] public AITSensorData SensorCoolingStageSLOT3WaferON { get; set; } [Subscription("System.SensorCoolingStageSLOT4WaferON.DeviceData")] public AITSensorData SensorCoolingStageSLOT4WaferON { get; set; } [Subscription("System.SensorCoolingStageSLOT5WaferON.DeviceData")] public AITSensorData SensorCoolingStageSLOT5WaferON { get; set; } [Subscription("System.SensorCoolingStageSLOT6WaferON.DeviceData")] public AITSensorData SensorCoolingStageSLOT6WaferON { get; set; } [Subscription("System.DiffPressure")] public double DiffPressure { get; set; } [Subscription("System.FFURpm")] public double FfuRpm { get; set; } // [Subscription(ParamName.IsAutoMode, SystemStateModule)] //public bool IsAutoMode { get; set; } [Subscription(ParamName.LocalControlJob, SystemStateModule)] public SorterRecipeXml LocalControlJob { get; set; } [Subscription(ParamName.FoupDoorState, DeviceName.LoadportA)] public FoupDoorState LPADoorState { get; set; } [Subscription(ParamName.FoupDoorState, DeviceName.LoadportB)] public FoupDoorState LPBDoorState { get; set; } [Subscription(ParamName.FoupDoorState, DeviceName.LoadportC)] public FoupDoorState LPCDoorState { get; set; } [Subscription(ParamName.FoupDoorState, DeviceName.LoadportD)] public FoupDoorState LPDDoorState { get; set; } [Subscription(ParamName.FoupDoorState, DeviceName.LoadportE)] public FoupDoorState LPEDoorState { get; set; } [Subscription(ParamName.FoupDoorState, DeviceName.LoadportF)] public FoupDoorState LPFDoorState { get; set; } [Subscription(ParamName.FoupClampState, DeviceName.LoadportA)] public FoupClampState FoupAClampState { get; set; } [Subscription(ParamName.FoupClampState, DeviceName.LoadportB)] public FoupClampState FoupBClampState { get; set; } [Subscription(ParamName.FoupClampState, DeviceName.LoadportC)] public FoupClampState FoupCClampState { get; set; } [Subscription(ParamName.FoupClampState, DeviceName.LoadportD)] public FoupClampState FoupDClampState { get; set; } [Subscription(ParamName.FoupClampState, DeviceName.LoadportE)] public FoupClampState FoupEClampState { get; set; } [Subscription(ParamName.FoupClampState, DeviceName.LoadportF)] public FoupClampState FoupFClampState { get; set; } private WaferInfo[] robotWafers; [Subscription(ParamName.ModuleWaferList, DeviceName.Robot)] public WaferInfo[] RobotWafers { get { return robotWafers; } set { robotWafers = value; RobotWafer1 = value[0]; RobotWafer2 = value[1]; } } public WaferInfo RobotWafer1 { get; set; } public WaferInfo RobotWafer2 { get; set; } #endregion #region Logic public Visibility CycleVisibility { get; set; } public string CycleCountDisplay { get { return $"{CycleCount}/{TotalCycleCount}"; } } public bool IsHomeAllButtonEnabled { get { return !IsAutoMode; } } public bool IsAbortHomeAllButtonEnabled { get { switch (RoutManagerState) { case (int)RtState.Init: return false; case (int)RtState.Initializing: case (int)RtState.ManualTransfer: case (int)RtState.Transfer: case (int)RtState.Cycle: case (int)RtState.PrepareCycle: case (int)RtState.PostCycle: case (int)RtState.Reset: case (int)RtState.Processing: case (int)RtState.PostProcess: case (int)RtState.PauseProcess: case (int)RtState.SetSpeed: return true; case (int)RtState.Error: case (int)RtState.Maintenance: return false; case (int)RtState.Idle: return false; default: return false; } } } public bool IsStartCycleButtonEnabled { get { return IsAutoMode; } } public bool IsReturnWaferButtonEnabled { get { return !IsAutoMode; } } public bool IsStopCycleButtonEnabled { get { return IsAutoMode; } } public bool IsManualMode { get { return !IsAutoMode; } } [IgnorePropertyChange] public string SelectedRecipeName { get; set; } public bool IsProcessing { get { return (RtState)RoutManagerState == RtState.PauseProcess || (RtState)RoutManagerState == RtState.Processing; } } public string RtStatus { get { return ((RtState)RoutManagerState).ToString(); } } public bool IsManualButtonEnabled { get { return IsAutoMode; } } public bool IsAutoButtonEnabled { get { return !IsAutoMode; } } public virtual bool IsEnableSelectRecipe { get { return IsAutoMode && !IsProcessing; } } public virtual bool IsEnableStartRecipe { get { return IsAutoMode && !string.IsNullOrEmpty(SelectedRecipeName) && !IsProcessing; } } public bool IsEnablePauseRecipe { get { return true ; ;//IsAutoMode && IsProcessing; } } public bool IsEnableResumeRecipe { get { return true;//IsAutoMode && IsProcessing; } } public bool IsEnableStopRecipe { get { return true; ;//IsAutoMode && IsProcessing; } } #endregion public OperationMultiLPViewModel(int foupCount) : base("OperationViewModal", foupCount) { OperationCommand = new DelegateCommand(Operation); RecipeSelectCommand = new DelegateCommand(SelectRecipe); RecipeStartCommand = new DelegateCommand(StartRecipe); RecipePauseCommand = new DelegateCommand(PauseRecipe); RecipeResumeCommand = new DelegateCommand(ResumeRecipe); RecipeStopCommand = new DelegateCommand(StopRecipe); } private void DeviceOperation(string cmd, object[] param) { InvokeClient.Instance.Service.DoOperation(cmd, param); } void Operation(string param) { InvokeClient.Instance.Service.DoOperation(param); } protected override void InvokeBeforeUpdateProperty(Dictionary data) { base.InvokeBeforeUpdateProperty(data); } #region recipe private void SelectRecipe(object param) { RecipeSelectDialog dialog = new RecipeSelectDialog(RecipeClient.Instance.Service.GetXmlRecipeList(ModuleName.System, false)) { Owner = Application.Current.MainWindow }; var ret = dialog.ShowDialog(); if (ret.HasValue && ret.Value) { SelectedRecipeName = dialog.SelectedRecipe; InvokePropertyChanged("SelectedRecipeName"); InvokeClient.Instance.Service.DoOperation(OperationName.SelectRecipe, SelectedRecipeName); } } private void StartRecipe(object param) { if (string.IsNullOrEmpty(SelectedRecipeName)) { return; } InvokeClient.Instance.Service.DoOperation(OperationName.StartRecipe, SelectedRecipeName); } private void PauseRecipe(object param) { if (MessageBox.Show("Are you sure you want to pause the process?", "Sorter", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { InvokeClient.Instance.Service.DoOperation(OperationName.PauseRecipe); } } private void ResumeRecipe(object param) { if (MessageBox.Show("Are you sure you want to resume the process?", "Sorter", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { InvokeClient.Instance.Service.DoOperation(OperationName.ResumeRecipe); } } private void StopRecipe(object param) { if (MessageBox.Show("Are you sure you want to abort the process?", "Sorter", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { InvokeClient.Instance.Service.DoOperation(OperationName.StopRecipe); } } #endregion } }