123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493 |
- using Aitex.Core.UI.Control;
- using Aitex.Core.Util;
- using Caliburn.Micro.Core;
- using DocumentFormat.OpenXml.Drawing;
- using DocumentFormat.OpenXml.Drawing.Diagrams;
- using MECF.Framework.Common.DataCenter;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Jobs;
- using MECF.Framework.Common.Utilities;
- using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
- using MECF.Framework.UI.Client.ClientBase;
- using OpenSEMI.ClientBase.Command;
- using SciChart.Core.Extensions;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics.Eventing.Reader;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Input;
- namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory
- {
- public class ProcessDetailV2ViewModel : ModuleUiViewModelBase
- {
- #region
- [Subscription("Rt.Status")]
- public string RtStatus { get; set; }
- [Subscription("PM1.Status")]
- public string PM1Status { get; set; }
- private int _upperSDNum = 0;
- public int UpperSDNum
- {
- get => _upperSDNum;
- set
- {
- _upperSDNum = value;
- NotifyOfPropertyChange(nameof(UpperSDNum));
- }
- }
- private int _productNum = 0;
- public int ProductNum
- {
- get => _productNum;
- set
- {
- _productNum = value;
- NotifyOfPropertyChange(nameof(ProductNum));
- }
- }
- private int _monitorNum1 = 0;
- public int MonitorNum1
- {
- get => _monitorNum1;
- set
- {
- _monitorNum1 = value;
- NotifyOfPropertyChange(nameof(MonitorNum1));
- }
- }
- private int _monitorNum2 = 0;
- public int MonitorNum2
- {
- get => _monitorNum2;
- set
- {
- _monitorNum2 = value;
- NotifyOfPropertyChange(nameof(MonitorNum2));
- }
- }
- private int _lowerSDNum = 0;
- public int LowerSDNum
- {
- get => _lowerSDNum;
- set
- {
- _lowerSDNum = value;
- NotifyOfPropertyChange(nameof(LowerSDNum));
- }
- }
- private int _selectItemIndex = 0;
- public int SelectItemIndex
- {
- get => _selectItemIndex;
- set
- {
- _selectItemIndex = value;
- NotifyOfPropertyChange(nameof(SelectItemIndex));
- }
- }
- private int _tableCount = 0;
- public int TableCount
- {
- get => _tableCount;
- set
- {
- _tableCount = value;
- NotifyOfPropertyChange(nameof(TableCount));
- }
- }
- private List<string> _boatMapWafers = new List<string>();
- public List<string> BoatMapWafers
- {
- get => _boatMapWafers;
- set
- {
- _boatMapWafers = value;
- NotifyOfPropertyChange(nameof(BoatMapWafers));
- }
- }
- private ProcessDetailV2ViewData _viewData;
- public ProcessDetailV2ViewData ViewData
- {
- get => _viewData;
- set
- {
- _viewData = value;
- NotifyOfPropertyChange(nameof(ViewData));
- }
- }
- private RecipeDataBase _layoutRecipe = new RecipeDataBase();
- public RecipeDataBase LayoutRecipe
- {
- get { return _layoutRecipe; }
- set { _layoutRecipe = value; this.NotifyOfPropertyChange(nameof(LayoutRecipe)); }
- }
- private RecipeDataBase _processRecipe = new RecipeDataBase();
- public RecipeDataBase ProcessRecipe
- {
- get { return _processRecipe; }
- set { _processRecipe = value; this.NotifyOfPropertyChange(nameof(ProcessRecipe)); }
- }
- private ProcessHistoryLot _pJInfo = new ProcessHistoryLot();
- public ProcessHistoryLot PJInfo
- {
- get { return _pJInfo; }
- set { _pJInfo = value; this.NotifyOfPropertyChange(nameof(PJInfo)); }
- }
- private readonly RecipeProvider _recipeProvider = new RecipeProvider();
- private RecipeFormatBuilder _columnBuilder = new RecipeFormatBuilder();
- private string _processPrefix = "Furnace\\Process";
- private string _layoutPrefix = "Furnace\\Layout";
- public ICommand AlarmInformationCommand { get; set; }
- public ICommand EventLoggingCommand { get; set; }
- public ICommand PMCTraceLoggingCommand { get; set; }
- public ICommand VPCommand { get; set; }
- #endregion
- public ProcessDetailV2ViewModel()
- {
- AlarmInformationCommand = new BaseCommand<object>(AlarmInformationMethod);
- EventLoggingCommand = new BaseCommand<object>(EventLoggingMethod);
- PMCTraceLoggingCommand = new BaseCommand<object>(PMCTraceLoggingMethod);
- VPCommand = new BaseCommand<object>(VPMethod);
- }
- private void AlarmInformationMethod(object e) {
- //
- }
- private void EventLoggingMethod(object e) { }
- private void PMCTraceLoggingMethod(object e) { }
- private void VPMethod(object e) { }
- protected override void OnViewLoaded(object _view)
- {
- base.OnViewLoaded(_view);
- ViewData = new ProcessDetailV2ViewData();
- LoadLayoutInfo(PJInfo.LayoutName);
- LoadProcessData();
- if (string.IsNullOrEmpty(PJInfo.LayoutName))
- {
- ViewData.ProcessStartTime = ViewData.PJobStartTime;
- ViewData.ProcessEndTime = ViewData.PJobEndTime;
- }
- }
- private void LoadProcessData()
- {
- var pjStartNoEnd = PJInfo.StartTime != DateTime.MinValue && PJInfo.EndTime == DateTime.MinValue;
- var pjStartAndEnd = PJInfo.StartTime != DateTime.MinValue && PJInfo.EndTime != DateTime.MinValue;
- var hasLayoutRecipe = !string.IsNullOrEmpty(PJInfo.LayoutName);
- string sql = $"SELECT * FROM process_data where (pj_id ='{PJInfo.PjId}')";
- if (string.IsNullOrEmpty(PJInfo.PjId))
- {
- sql = $"SELECT * FROM process_data where (recipe_name ='{PJInfo.RecipeName}' and process_begin_time >= '{PJInfo.StartTime:yyyy/MM/dd HH:mm:ss.fff}' and process_end_time <= '{PJInfo.EndTime:yyyy/MM/dd HH:mm:ss.fff}') order by process_begin_time DESC;";
- }
- DataTable dbData = QueryDataClient.Instance.Service.QueryData(sql);
- string processDataStatus = "";
- if (dbData != null && dbData.Rows.Count > 0)
- {
- ViewData.ProcessStartTime = dbData.Rows[0]["process_begin_time"].ToString();
- ViewData.ProcessEndTime = dbData.Rows[0]["process_end_time"].ToString();
- processDataStatus = dbData.Rows[0]["process_status"].ToString();
- }
- if (pjStartNoEnd)
- {
- ViewData.IsSettingUp = true;
- ViewData.IsProcessComplete = false;
- ViewData.IsProcessing = false;
- }
- if (!string.IsNullOrEmpty(ViewData.ProcessStartTime) && string.IsNullOrEmpty(ViewData.ProcessEndTime))
- {
- ViewData.IsSettingUp = false;
- ViewData.IsProcessComplete = false;
- ViewData.IsProcessing = true;
- }
- if (pjStartAndEnd)
- {
- ViewData.IsSettingUp = false;
- ViewData.IsProcessComplete = true;
- ViewData.IsProcessing = false;
- }
- if (PJInfo.Form == ProcessEndResultEnum.Abort.ToDescription())
- {
- ViewData.ProcessEndResult = ProcessEndResultEnum.Abort.ToDescription();
- return;
- }
- if (PJInfo.Form == ProcessEndResultEnum.Normal.ToDescription() && !string.IsNullOrEmpty(processDataStatus) && processDataStatus == ProcessEndResultEnum.Succeed.ToDescription())
- {
- ViewData.ProcessEndResult = ProcessEndResultEnum.NORMALEND.ToDescription();
- return;
- }
- if (pjStartNoEnd || (PJInfo.Form == ProcessEndResultEnum.Normal.ToDescription() && string.IsNullOrEmpty(processDataStatus)))
- {
- ViewData.ProcessEndResult = ProcessEndResultEnum.NONE.ToDescription();
- return;
- }
- }
- protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
- {
- // RefreshCassetteDataTask();
- }
- private void RefreshCassetteDataTask()
- {
- var wafers = ModuleManager.ModuleInfos[ModuleName.PM1.ToString()].WaferManager.Wafers;
- }
- private void LoadLayoutInfo(string layoutName)
- {
- ViewData.PJobStartTime = PJInfo.StartTime.ToString("yyyy/MM/dd HH:mm:ss.fff");
- ViewData.PJobEndTime = PJInfo.EndTime.ToString("yyyy/MM/dd HH:mm:ss.fff");
- if (string.IsNullOrEmpty(layoutName))
- {
- return;
- }
- _columnBuilder.Build("Layout");
- LayoutRecipe.PrefixPath = _layoutPrefix;
- var recipeContent = _recipeProvider.LoadRecipe(LayoutRecipe.PrefixPath, layoutName);
- //if (string.IsNullOrEmpty(recipeContent))
- //{
- // System.Windows.MessageBox.Show($"{layoutName} is empty, please confirm the file is valid.");
- // return;
- //}
- // LayoutRecipe.InitData(LayoutRecipe.PrefixPath, layoutName, recipeContent, _columnBuilder.Configs, "PM1");
- var waferNumberAll = (int)QueryDataClient.Instance.Service.GetConfig("Boat.SlotCount");
- var cassetteSlotCount = (int)QueryDataClient.Instance.Service.GetConfig("System.CassetteSlotCount");
- List<string> listWafers = QueryDataClient.Instance.Service.GetLayoutRecipeContent(recipeContent, waferNumberAll.ToString(), cassetteSlotCount.ToString());
- BoatMapWafers = listWafers;
- if (null != BoatMapWafers && BoatMapWafers.Count > 0)
- {
- var data = ComputSD(BoatMapWafers);
- ComputWafer(listWafers);
- }
- }
- private void ComputWafer(List<string> listWafers)
- {
- UpperSDNum = listWafers.Where(x => x == "SD").Count();
- LowerSDNum = listWafers.Where(x => x == "FD").Count();
- ProductNum = listWafers.Where(x => x.StartsWith("P")).Count();
- MonitorNum1 = listWafers.Where(x => x == "M1").Count();
- MonitorNum2 = listWafers.Where(x => x == "M2").Count();
- }
- private Tuple<int, int> ComputSD(List<string> dataSource)
- {
- List<string> otherSlot = dataSource.Where(a => a != "SD" && !string.IsNullOrEmpty(a)).ToList().Distinct().ToList();
- if (dataSource == null || dataSource.Count == 0)
- {
- return new Tuple<int, int>(0, 0);
- }
- List<int> minList = new List<int>();
- for (int i = 0; i < dataSource.Count; i++)
- {
- var item = dataSource[i];
- if (otherSlot.Contains(item) && !string.IsNullOrEmpty(item))
- {
- break;
- }
- if (string.IsNullOrEmpty(item))
- {
- continue;
- }
- minList.Add(i);
- }
- dataSource.Reverse();
- List<int> maxList = new List<int>();
- for (int i = 0; i < dataSource.Count; i++)
- {
- var item = dataSource[i];
- if (otherSlot.Contains(item) && !string.IsNullOrEmpty(item))
- {
- break;
- }
- if (string.IsNullOrEmpty(item))
- {
- continue;
- }
- maxList.Add(i);
- }
- return new Tuple<int, int>(minList.Count(), maxList.Count());
- }
- public enum ProcessEndResultEnum
- {
- [Description("NORMAL END")]
- NORMALEND,
- [Description("ABNORMAL END")]
- ABNORMALEND,
- [Description("NONE")]
- NONE,
- [Description("Recipe Abort")]
- Abort,
- [Description("Normal")]
- Normal, [Description("Succeed")]
- Succeed,
- }
- public class ProcessDetailV2ViewData : PropertyChangedBase
- {
- private string _processEndResult;
- public string ProcessEndResult
- {
- get => _processEndResult;
- set
- {
- _processEndResult = value;
- NotifyOfPropertyChange(nameof(ProcessEndResult));
- }
- }
- private string _pJobStartTime = "";
- public string PJobStartTime
- {
- get => _pJobStartTime;
- set
- {
- _pJobStartTime = value;
- NotifyOfPropertyChange(nameof(PJobStartTime));
- }
- }
- public string PJobEndTime
- {
- get => _pJobEndTime;
- set
- {
- _pJobEndTime = value;
- NotifyOfPropertyChange(nameof(PJobEndTime));
- }
- }
- private string _pJobEndTime = "";
- public string ExecREcipeThinckess
- {
- get => _execREcipeThinckess;
- set
- {
- _execREcipeThinckess = value;
- NotifyOfPropertyChange(nameof(ExecREcipeThinckess));
- }
- }
- private string _execREcipeThinckess = "";
- public string ProcessStartTime
- {
- get => _processStartTime;
- set
- {
- _processStartTime = value;
- NotifyOfPropertyChange(nameof(ProcessStartTime));
- }
- }
- private string _processStartTime = "";
- public string ProcessEndTime
- {
- get => _processEndTime;
- set
- {
- _processEndTime = value;
- NotifyOfPropertyChange(nameof(ProcessEndTime));
- }
- }
- private string _processEndTime = "";
- public string CJobId
- {
- get => _cJobId;
- set
- {
- _cJobId = value;
- NotifyOfPropertyChange(nameof(CJobId));
- }
- }
- private string _cJobId = "";
- private List<string> _pCarrierIdList = new List<string>();
- public List<string> PCarrierIdList
- {
- get => _pCarrierIdList;
- set
- {
- _pCarrierIdList = value;
- NotifyOfPropertyChange(nameof(PCarrierIdList));
- }
- }
- private bool _isSettingUp = false;
- public bool IsSettingUp
- {
- get => _isSettingUp;
- set
- {
- _isSettingUp = value;
- NotifyOfPropertyChange(nameof(IsSettingUp));
- }
- }
- private bool _isProcessing = false;
- public bool IsProcessing
- {
- get => _isProcessing;
- set
- {
- _isProcessing = value;
- NotifyOfPropertyChange(nameof(IsProcessing));
- }
- }
- private bool _isProcessComplete = false;
- public bool IsProcessComplete
- {
- get => _isProcessComplete;
- set
- {
- _isProcessComplete = value;
- NotifyOfPropertyChange(nameof(IsProcessComplete));
- }
- }
- }
- }
- }
|