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 MECF.Framework.Common.DataCenter; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.RecipeCenter; namespace Aitex.Sorter.UI.ViewModel { class Operation4LPViewModel : UIViewModelBase { private WaferInfo[] foupAWaferInfo; private WaferInfo[] foupBWaferInfo; private WaferInfo[] foupCWaferInfo; private WaferInfo[] foupDWaferInfo; #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.TotalWaferCount, SystemStateModule)] public int TotalWaferCount { get; set; } [Subscription(ParamName.RTStatus, SystemStateModule)] public int RoutManagerState { get; set; } [Subscription(ParamName.WaferInfoFoupA, "System")] public WaferInfo[] FoupAWaferInfo { get { return foupAWaferInfo; } set { foupAWaferInfo = value.Reverse().ToArray(); } } [Subscription(ParamName.WaferInfoFoupB, "System")] public WaferInfo[] FoupBWaferInfo { get { return foupBWaferInfo; } set { foupBWaferInfo = value.Reverse().ToArray(); } } [Subscription(ParamName.WaferInfoFoupC, "System")] public WaferInfo[] FoupCWaferInfo { get { return foupCWaferInfo; } set { foupCWaferInfo = value.Reverse().ToArray(); } } [Subscription(ParamName.WaferInfoFoupD, "System")] public WaferInfo[] FoupDWaferInfo { get { return foupDWaferInfo; } set { foupDWaferInfo = value.Reverse().ToArray(); } } [Subscription(ParamName.WaferInfoRobotSlot01, "System")] public WaferInfo RobotWaferInfo1 { get; set; } [Subscription(ParamName.WaferInfoRobotSlot02, "System")] public WaferInfo RobotWaferInfo2 { get; set; } [Subscription(ParamName.WaferInfoRobotAligner01, "System")] public WaferInfo AlignerWaferInfo { get; set; } [Subscription(ParamName.LoadportState, DeviceName.LoadportA)] public string LoadportAState { get; set; } [Subscription(ParamName.LoadportState, DeviceName.LoadportB)] public string LoadportBState { get; set; } [Subscription(ParamName.LoadportState, DeviceName.LoadportC)] public string LoadportCState { get; set; } [Subscription(ParamName.LoadportState, DeviceName.LoadportD)] public string LoadportDState { get; set; } [Subscription(ParamName.AlignerState, DeviceName.Aligner)] public string AlignerState { get; set; } [Subscription(ParamName.RobotState, DeviceName.Robot)] public string RobotState { get; set; } [Subscription(ParamName.FoupID, DeviceName.RFIDReaderA)] public string FoupAID { get; set; } [Subscription(ParamName.FoupID, DeviceName.RFIDReaderB)] public string FoupBID { get; set; } [Subscription(ParamName.FoupID, DeviceName.RFIDReaderC)] public string FoupCID { get; set; } [Subscription(ParamName.FoupID, DeviceName.RFIDReaderD)] public string FoupDID { get; set; } [Subscription(ParamName.RobotSpeed, DeviceName.Robot)] public string RobotSpeed { get; set; } [Subscription(ParamName.CassetteState, DeviceName.LoadportA)] public LoadportCassetteState LPACassetteState { get; set; } [Subscription(ParamName.CassetteState, DeviceName.LoadportB)] public LoadportCassetteState LPBCassetteState { get; set; } [Subscription(ParamName.CassetteState, DeviceName.LoadportC)] public LoadportCassetteState LPCCassetteState { get; set; } [Subscription(ParamName.CassetteState, DeviceName.LoadportD)] public LoadportCassetteState LPDCassetteState { get; set; } [Subscription(DeviceName.SensorPreAlignerWaferOn, SystemDeviceModule)] public AITSensorData SensorPreAlignerWaferOn { get; set; } [Subscription(DeviceName.SensorRobotFork2WaferOn, SystemDeviceModule)] public AITSensorData SensorRobotFork2WaferOn { get; set; } [Subscription(DeviceName.SensorRobotFork1WaferOn, SystemDeviceModule)] public AITSensorData SensorRobotFork1WaferOn { get; set; } public ICommand LoadPortACommand { get; set; } public ICommand LoadPortBCommand { get; set; } public ICommand LoadPortCCommand { get; set; } public ICommand LoadPortDCommand { 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.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; } #endregion #region Logic public Visibility CycleVisibility { get; set; } public bool IsHomeAllButtonEnabled { get { return !IsAutoMode; } } public bool IsAbortHomeAllButtonEnabled { get { return !IsAutoMode; } } 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 bool IsEnableSelectRecipe { get { return IsAutoMode && !IsProcessing; } } public bool IsEnableStartRecipe { get { return IsAutoMode && !string.IsNullOrEmpty(SelectedRecipeName) && !IsProcessing; } } public bool IsEnablePauseRecipe { get { return IsAutoMode && IsProcessing; } } public bool IsEnableResumeRecipe { get { return IsAutoMode && IsProcessing; } } public bool IsEnableStopRecipe { get { return IsAutoMode && IsProcessing; } } #endregion public Operation4LPViewModel() : base("OperationViewModal") { OperationCommand = new DelegateCommand(Operation); LoadPortACommand = new DelegateCommand(DoLoadPortACmd, x => { bool result = (LoadportAState == DeviceState.Idle.ToString()); if (result) { switch (x) { case OperationName.ReadFoupID: result = (LPACassetteState == LoadportCassetteState.Normal && FoupAClampState!= FoupClampState.Close); break; case OperationName.LoadFoup: result = (FoupAClampState == FoupClampState.Close && LPADoorState != FoupDoorState.Open); break; case OperationName.UnloadFoup: result = (LPACassetteState == LoadportCassetteState.Normal && FoupAClampState == FoupClampState.Close); break; default: result = false; break; } } return result; }); LoadPortBCommand = new DelegateCommand(DoLoadPortBCmd, x => { bool result = (LoadportBState == DeviceState.Idle.ToString()); if (result) { switch (x) { case OperationName.ReadFoupID: result = (LPBCassetteState == LoadportCassetteState.Normal && FoupBClampState == FoupClampState.Open); break; case OperationName.LoadFoup: result = (FoupBClampState == FoupClampState.Close && LPBDoorState == FoupDoorState.Close); break; case OperationName.UnloadFoup: result = (LPBCassetteState == LoadportCassetteState.Normal && FoupBClampState== FoupClampState.Close); break; default: result = false; break; } } return result; }); LoadPortCCommand = new DelegateCommand(DoLoadPortCCmd, x => { bool result = (LoadportCState == DeviceState.Idle.ToString()); if (result) { switch (x) { case OperationName.ReadFoupID: result = (LPCCassetteState == LoadportCassetteState.Normal && FoupCClampState == FoupClampState.Open); break; case OperationName.LoadFoup: result = (FoupCClampState == FoupClampState.Close && LPCDoorState == FoupDoorState.Close); break; case OperationName.UnloadFoup: result = (LPCCassetteState == LoadportCassetteState.Normal && FoupCClampState == FoupClampState.Close); break; default: result = false; break; } } return result; }); LoadPortDCommand = new DelegateCommand(DoLoadPortDCmd, x => { bool result = (LoadportDState == DeviceState.Idle.ToString()); if (result) { switch (x) { case OperationName.ReadFoupID: result = (LPDCassetteState == LoadportCassetteState.Normal && FoupDClampState == FoupClampState.Open); break; case OperationName.LoadFoup: result = (FoupDClampState == FoupClampState.Close && LPDDoorState == FoupDoorState.Close); break; case OperationName.UnloadFoup: result = (LPDCassetteState == LoadportCassetteState.Normal && FoupDClampState == FoupClampState.Close); break; default: result = false; break; } } return result; }); RecipeSelectCommand = new DelegateCommand(SelectRecipe); RecipeStartCommand = new DelegateCommand(StartRecipe); RecipePauseCommand = new DelegateCommand(PauseRecipe); RecipeResumeCommand = new DelegateCommand(ResumeRecipe); RecipeStopCommand = new DelegateCommand(StopRecipe); } private void DoLoadPortACmd(string cmd) { var deviceName = ModuleName.LP1; var param = new object[] { deviceName }; DeviceOperation(cmd, param); } private void DoLoadPortBCmd(string cmd) { var deviceName = ModuleName.LP2; var param = new object[] { deviceName }; DeviceOperation(cmd, param); } private void DoLoadPortCCmd(string cmd) { var deviceName = ModuleName.LP3; var param = new object[] { deviceName }; DeviceOperation(cmd, param); } private void DoLoadPortDCmd(string cmd) { var deviceName = ModuleName.LP4; var param = new object[] { deviceName }; DeviceOperation(cmd, param); } 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) { CycleVisibility = ((bool) QueryDataClient.Instance.Service.GetConfig(SorterCommon.ScPathName.Process_CycleEnable) )? Visibility.Visible : Visibility.Hidden; //data[UIKey(UnitName.LoadportA.ToString(), ParamName.FoupDoorState)] = FoupDoorState.Close; } #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 SelectLDULDRecipe(object param) { RecipeSelectDialog dialog = new RecipeSelectDialog(RecipeClient.Instance.Service.GetXmlRecipeList(ModuleName.LDULD, 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 stop the process?", "Sorter", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { InvokeClient.Instance.Service.DoOperation(OperationName.StopRecipe); } } #endregion } }