| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 | using System.Collections.Generic;using System.Collections.ObjectModel;using Caliburn.Micro;using MECF.Framework.Common.RecipeCenter;using OpenSEMI.ClientBase;using VirgoUI.Client.Models.Recipe;namespace VirgoUI.Client.Models.Operate.WaferAssociation{    public class WaferAssociationViewModel : BaseModel    {        private WaferAssociationInfo _LP1;        public WaferAssociationInfo LP1        {            get { return _LP1; }            set { _LP1 = value; }        }        private WaferAssociationInfo _LP2;        public WaferAssociationInfo LP2        {            get { return _LP2; }            set { _LP2 = value; }        }        protected override void OnInitialize()        {            base.OnInitialize();            #region test data            LP1 = new WaferAssociationInfo();            LP1.ModuleData = ModuleManager.ModuleInfos["LP1"];                     LP2 = new WaferAssociationInfo();            LP2.ModuleData = ModuleManager.ModuleInfos["LP2"];                           #endregion        }        #region functions        #region Sequence operation        public void SelectSequence(WaferAssociationInfo info)        {            SequenceDialogViewModel dialog = new SequenceDialogViewModel();            dialog.DisplayName = "Select Sequence";                 dialog.Files = new ObservableCollection<FileNode>(RecipeSequenceTreeBuilder.GetFiles(                    RecipeClient.Instance.Service.GetSequenceNameList()                    ));             WindowManager wm = new WindowManager();            bool? bret = wm.ShowDialog(dialog);            if ((bool)bret)            {                info.SequenceName = dialog.DialogResult;            }         }        public void SetSlot(WaferAssociationInfo info)        {            if (InputSlotCheck(info.SlotFrom, info.SlotTo))                AssociateSequence(info, true);        }        public void SkipSlot(WaferAssociationInfo info)        {            if (InputSlotCheck(info.SlotFrom, info.SlotTo))                AssociateSequence(info, false);        }        public void SetAll(WaferAssociationInfo info)        {            info.SlotFrom = 1;            info.SlotTo = 25;            AssociateSequence(info, true);        }        public void DeselectAll(WaferAssociationInfo info)        {            info.SlotFrom = 1;            info.SlotTo = 25;            AssociateSequence(info, false);        }        public void SetSequence(WaferAssociationInfo info, int slotIndex, string seqName)        {            bool flag = string.IsNullOrEmpty(seqName);            AssociateSequence(info, flag, slotIndex - 1);        }        private bool InputSlotCheck(int from, int to)        {            if (from > to)            {                DialogBox.ShowInfo("This index of from slot should be large than the index of to slot.");                return false;            }            if (from < 1 || to > 25)            {                DialogBox.ShowInfo("This input value for from should be between 1 and 25.");                return false;            }            return true;        }        private void AssociateSequence(WaferAssociationInfo info, bool flag, int slot = -1)        {            List<WaferInfo> wafers = info.ModuleData.WaferManager.Wafers;            if (slot >= 0) //by wafer            {                int index = wafers.Count - slot - 1;                if (index < wafers.Count)                {                    if (flag && HasWaferOnSlot(wafers, index))                        wafers[index].SequenceName = info.SequenceName;                    else                        wafers[index].SequenceName = string.Empty;                }            }            else //by from-to            {                for (int i = info.SlotFrom - 1; i < info.SlotTo; i++)                {                    int index = wafers.Count - i - 1;                    if (index < wafers.Count)                    {                        if (flag && HasWaferOnSlot(wafers, index))                            wafers[index].SequenceName = info.SequenceName;                        else                            wafers[index].SequenceName = string.Empty;                    }                }            }        }        private bool HasWaferOnSlot(List<WaferInfo> wafers, int index)        {            if (wafers[index].WaferStatus == 0)                return false;            return true;        }        #endregion        #region Job operation        private bool JobCheck(string jobID)        {            if (jobID.Length == 0)            {                DialogBox.ShowWarning("Please create job first.");                return false;            }            else                return true;        }        public void CreateJob(WaferAssociationInfo info)        {            List<object> param = new List<object>();            param.Add(info.ModuleData.ModuleID);            info.ModuleData.WaferManager.Wafers.ForEach(key => { param.Add(key.SequenceName); });            param.Add(false);    //auto start            //WaferAssociationProvider.Instance.CreateJob(param.ToArray());        }        public void AbortJob(string jobID)        {            if (JobCheck(jobID))                WaferAssociationProvider.Instance.AbortJob(jobID);        }        public void Start(string jobID)        {            if (JobCheck(jobID))                WaferAssociationProvider.Instance.Start(jobID);        }        public void Pause(string jobID)        {            if (JobCheck(jobID))                WaferAssociationProvider.Instance.Pause(jobID);        }        public void Resume(string jobID)        {            if (JobCheck(jobID))                WaferAssociationProvider.Instance.Resume(jobID);        }        public void Stop(string jobID)        {            if (JobCheck(jobID))                WaferAssociationProvider.Instance.Stop(jobID);        }        #endregion        #endregion    }}
 |