123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- using Aitex.Core.Common;
- using Aitex.Core.UI.MVVM;
- using Aitex.Core.Util;
- using Aitex.Core.Utilities;
- using Aitex.Sorter.Common;
- using Aitex.Sorter.UI.Controls;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using System.Windows.Input;
- using MECF.Framework.Common.Equipment;
- namespace Aitex.Sorter.UI.ViewModel
- {
- class RecipeViewModel : UIViewModelBase
- {
- private WaferInfo[] foupAWaferInfo;
- private WaferInfo[] foupBWaferInfo;
- public RecipeViewModel() : base("Recipe")
- {
- WaferTransferCommand = new DelegateCommand<SorterRecipeTransferTableItem>(OnTransfer);
- WaferTransferOptionCommand = new DelegateCommand<WaferTransferOption>(BeforeTransfer);
- RemoveResultCommand = new DelegateCommand<SorterRecipeTransferTableItem>(RemoveResult);
- SourceDestinationCommand = new DelegateCommand<string>(SourceDestinationChanged);
- }
- public void AddNewRecipe(string name)
- {
- CurrentRecipe = new SorterRecipeXml(name);
- UIRecipeManager.Instance.SaveRecipe(name, CurrentRecipe.GetContent());
- Refresh();
- }
- public void LoadRecipe(string name)
- {
- if (name != null)
- {
- CurrentRecipe = new SorterRecipeXml(UIRecipeManager.Instance.LoadRecipe(name), name);
- }
- else
- {
- CurrentRecipe = null;
- }
- }
- public void SaveRecipe()
- {
- if (CurrentRecipe != null)
- {
- CurrentRecipe.SaveContent();
- UIRecipeManager.Instance.SaveRecipe(CurrentRecipe.Name, CurrentRecipe.GetContent());
- }
- }
- public void DeleteRecipe()
- {
- if (CurrentRecipe != null)
- {
- UIRecipeManager.Instance.DeleteRecipe(CurrentRecipe.Name);
- CurrentRecipe = null;
- Refresh();
- }
- }
- public void RenameRecipe(string newName)
- {
- if (CurrentRecipe != null)
- {
- UIRecipeManager.Instance.RenameRecipe(CurrentRecipe.Name, newName);
- LoadRecipe(newName);
- Refresh();
- }
- }
- public void CopyRecipe(string newName)
- {
- if (CurrentRecipe != null)
- {
- UIRecipeManager.Instance.SaveAsRecipe(newName, CurrentRecipe.GetContent());
- LoadRecipe(newName);
- Refresh();
- }
- }
- public void Refresh()
- {
- RecipeList = UIRecipeManager.Instance.GetRecipes();
- }
- private void OnTransfer(SorterRecipeTransferTableItem transferItem)
- {
- CurrentRecipe.TransferItems.Add(transferItem);
- }
- private void BeforeTransfer(WaferTransferOption option)
- {
- if (currentRecipe != null && currentRecipe.RecipeType == SorterRecipeType.TransferNToN)
- {
- option.Align = currentRecipe.IsAlign;
- option.TurnOver = currentRecipe.IsTurnOver;
- option.ReadLaserMarker = currentRecipe.IsReadLaserMarker;
- option.ReadT7Code = currentRecipe.IsReadT7Code;
- option.AlignerAngle = currentRecipe.AlignAngle;
- }
- }
- private void RemoveResult(SorterRecipeTransferTableItem item)
- {
- CurrentRecipe.TransferItems.Remove(item);
- }
- private void SourceDestinationChanged(string param)
- {
- if (currentRecipe != null && currentRecipe.RecipeType == SorterRecipeType.Transfer1To1)
- {
- if (param == "1")
- {
- //currentRecipe.Destination = (currentRecipe.Source == ModuleName.LP1 ? ModuleName.LP2 : ModuleName.LP1);
- }
- else
- {
- //currentRecipe.Source = (currentRecipe.Destination == ModuleName.LP1 ? ModuleName.LP2 : ModuleName.LP1);
- }
- }
- }
- [Subscription(ParamName.WaferInfoFoupA, "System")]
- public WaferInfo[] FoupAWaferInfo
- {
- get
- {
- return foupAWaferInfo;
- }
- set
- {
- for (int i = 0; i < value.Length; i++)
- {
- var wafer = value[i];
- if (wafer.Status != WaferStatus.Empty) wafer.Status = WaferStatus.Dummy;
- UpdateTransferState(wafer, ModuleName.LP1, i);
- }
- foupAWaferInfo = value.Reverse().ToArray();
- }
- }
- [Subscription(ParamName.WaferInfoFoupB, "System")]
- public WaferInfo[] FoupBWaferInfo
- {
- get
- {
- return foupBWaferInfo;
- }
- set
- {
- for (int i = 0; i < value.Length; i++)
- {
- var wafer = value[i];
- if (wafer.Status != WaferStatus.Empty) wafer.Status = WaferStatus.Dummy;
- UpdateTransferState(wafer, ModuleName.LP2, i);
- }
- foupBWaferInfo = value.Reverse().ToArray();
- }
- }
- private IEnumerable<string> recipeList;
- [IgnorePropertyChange]
- public IEnumerable<string> RecipeList
- {
- get
- {
- return recipeList;
- }
- set
- {
- recipeList = value;
- InvokePropertyChanged("RecipeList");
- }
- }
- public ICommand WaferTransferCommand
- {
- get; set;
- }
- public ICommand WaferTransferOptionCommand
- {
- get; set;
- }
- private SorterRecipeXml currentRecipe;
- [IgnorePropertyChange]
- public SorterRecipeXml CurrentRecipe
- {
- get
- {
- return currentRecipe;
- }
- set
- {
- currentRecipe = value;
- InvokePropertyChanged("CurrentRecipe");
- }
- }
- public IDictionary PlaceMode1To1
- {
- get
- {
- return EnumHelper.ToDictionary<SorterRecipePlaceModeTransfer1To1>();
- }
- }
- public IDictionary PlaceModePack
- {
- get
- {
- return EnumHelper.ToDictionary<SorterRecipePlaceModePack>();
- }
- }
- public IDictionary PlaceModeOrder
- {
- get
- {
- return EnumHelper.ToDictionary<SorterRecipePlaceModeOrder>();
- }
- }
- public ICommand RemoveResultCommand
- {
- get; set;
- }
- public ICommand SourceDestinationCommand
- {
- get;set;
- }
- private void UpdateTransferState(WaferInfo wafer, ModuleName station, int slot)
- {
- if (CurrentRecipe != null && currentRecipe.TransferItems != null)
- {
- var sourceItem = currentRecipe.TransferItems.FirstOrDefault(x => x.SourceStation == station && x.SourceSlot == slot);
- if (sourceItem != null)
- {
- wafer.IsSource = true;
- }
- var destinationItem = currentRecipe.TransferItems.FirstOrDefault(x => x.DestinationStation == station && x.DestinationSlot == slot);
- if (destinationItem != null)
- {
- wafer.IsDestination = true;
- }
- }
- }
- }
- }
|