123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Aitex.Core.Common;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.Common.DBCore;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.Jobs;
- using MECF.Framework.Common.SubstrateTrackings;
- using FurnaceRT.Equipments.PMs.RecipeExecutions;
- using Aitex.Core.RT.Log;
- namespace FurnaceRT.Equipments.Schedulers
- {
- class SchedulerDBCallback : ISchedulerDBCallback
- {
- private ProcessJobInfo _processJobInfo;
- public void LotCreated(ControlJobInfo cj)
- {
- if (string.IsNullOrEmpty(cj.Module))
- return;
- ModuleName module = ModuleHelper.Converter(cj.Module);
- Guid carrierGuid = CarrierManager.Instance.GetCarrier(cj.Module).InnerId;
- LotDataRecorder.StartLot(cj.LotInnerId.ToString(), carrierGuid.ToString(), "", cj.LotName, cj.Module, cj.Module, cj.LotWafers.Count);
- foreach (var waferInfo in cj.LotWafers)
- {
- LotDataRecorder.InsertLotWafer(cj.LotInnerId.ToString(), waferInfo.InnerId.ToString());
- WaferDataRecorder.SetWaferSequence(waferInfo.InnerId.ToString(), waferInfo.PPID);
- }
- }
- public void LotFinished(ControlJobInfo cj)
- {
- int unprocessed = 0;
- int aborted = 0;
- foreach (var waferInfo in cj.LotWafers)
- {
- if (waferInfo.ProcessState == EnumWaferProcessStatus.Failed)
- {
- aborted++;
- continue;
- }
- if (waferInfo.ProcessState != EnumWaferProcessStatus.Completed)
- {
- unprocessed++;
- continue;
- }
- }
- LotDataRecorder.EndLot(cj.LotInnerId.ToString(), aborted, unprocessed);
- }
- public void PjCreated(params object[] objs)
- {
- var param = (Dictionary<string, object>)objs[0];
- string jobName = (string)param["JobRecipe"];
- string recipeName = (string)param["ProcessRecipe"];
- string layoutName = (string)param["LayoutRecipe"];
- string form = (string)param["Form"];
- string batchId = "";
- if (param.ContainsKey("Batch"))
- {
- batchId = $"Batch{(string)param["Batch"]}{DateTime.Now.ToString("yyyyMMddHHmmssffff")}";
- }
- else
- {
- batchId = DateTime.Now.ToString("yyyyMMddHHmmssffff");
- }
- _processJobInfo = new ProcessJobInfo();
- _processJobInfo.Name = jobName;
- _processJobInfo.LotName = jobName;
- _processJobInfo.InnerId = Guid.NewGuid();
- RecipeParser.LayoutRecipeParse(layoutName, ModuleName.PM1.ToString(), out RecipeLayoutEntityNormal layoutRecipeDataNormal, out RecipeLayoutEntityExpert layoutRecipeDataExpert, out string reason);
- string layoutData = String.Join(",", layoutRecipeDataExpert.Items);
- JobDataRecorder.CreatePJ(_processJobInfo.InnerId.ToString(), batchId, jobName, recipeName, layoutName, layoutData, form);
- }
- public void PjCreated(string batch, string jobRecipe, string processRecipe, string layoutRecipe)
- {
- string batchId = "";
- if (!string.IsNullOrEmpty(batch))
- {
- batchId = $"Batch{batch}{DateTime.Now.ToString("yyyyMMddHHmmssffff")}";
- }
- else
- {
- batchId = DateTime.Now.ToString("yyyyMMddHHmmssffff");
- }
- _processJobInfo = new ProcessJobInfo();
- _processJobInfo.Name = jobRecipe;
- _processJobInfo.LotName = jobRecipe;
- _processJobInfo.InnerId = Guid.NewGuid();
- RecipeParser.LayoutRecipeParse(layoutRecipe, ModuleName.PM1.ToString(), out RecipeLayoutEntityNormal layoutRecipeDataNormal, out RecipeLayoutEntityExpert layoutRecipeDataExpert, out string reason);
- string layoutData = String.Join(",", layoutRecipeDataExpert.Items);
- JobDataRecorder.CreatePJ(_processJobInfo.InnerId.ToString(), batchId, jobRecipe, processRecipe, layoutRecipe, layoutData, "Normal");
- }
- public void PjCreated(ProcessJobInfo pj)
- {
- _processJobInfo = new ProcessJobInfo();
- _processJobInfo.Name = pj.Name;
- _processJobInfo.LotName = pj.LotName;
- _processJobInfo.InnerId = pj.InnerId;
- _processJobInfo.JobRecipe = pj.JobRecipe;
- _processJobInfo.ProcessRecipe = pj.ProcessRecipe;
- _processJobInfo.LayoutRecipe = pj.LayoutRecipe;
- var batchId = DateTime.Now.ToString("yyyyMMddHHmmssffff");
- RecipeParser.LayoutRecipeParse(_processJobInfo.LayoutRecipe, ModuleName.PM1.ToString(),
- out RecipeLayoutEntityNormal layoutRecipeDataNormal, out RecipeLayoutEntityExpert layoutRecipeDataExpert, out string reason);
- string layoutData = String.Join(",", layoutRecipeDataExpert.Items);
- JobDataRecorder.CreatePJ(_processJobInfo.InnerId.ToString(), batchId,
- _processJobInfo.JobRecipe, _processJobInfo.ProcessRecipe, _processJobInfo.LayoutRecipe, layoutData, "Normal");
- }
- public void PjCreated(string processName)
- {
- string form = "process";
- string batchId = $"process{DateTime.Now.ToString("yyyyMMddHHmmssffff")}";
- _processJobInfo = new ProcessJobInfo();
- _processJobInfo.Name = processName;
- _processJobInfo.LotName = processName;
- _processJobInfo.InnerId = Guid.NewGuid();
- JobDataRecorder.CreatePJ(_processJobInfo.InnerId.ToString(), batchId, "", processName, "", "", form);
- }
- public void PjStart()
- {
- JobDataRecorder.StartPJ(_processJobInfo.InnerId.ToString());
- }
- public void PjUpdated()
- {
- var wafers = WaferManager.Instance.GetWafers(ModuleName.PM1);
- List<string> layoutDatas = new List<string>();
- List<string> waferDatas = new List<string>();
- //StringBuilder waferData = new StringBuilder();
- int waferCount = 0;
- for (int i = 0; i < wafers.Length; i++)
- {
- if (wafers[i].IsEmpty)
- {
- layoutDatas.Add("");
- continue;
- }
- switch (wafers[i].WaferType)
- {
- case WaferType.P:
- case WaferType.M:
- case WaferType.M1:
- case WaferType.M2:
- case WaferType.SD:
- case WaferType.ED:
- layoutDatas.Add($"{wafers[i].WaferType}-{wafers[i].LotId}-{wafers[i].WaferOrigin.Replace("Stocker", "")}");
- //layoutDatas.Add($"{wafers[i].WaferType}-{wafers[i].WaferOrigin}");
- break;
- default:
- layoutDatas.Add("");
- break;
- }
- waferDatas.Add($"{wafers[i].WaferType}:{wafers[i].WaferOrigin}:{wafers[i].LotId}");
- //waferData.Append(wafers[i].WaferType.ToString() + ":");
- //waferData.Append(wafers[i].WaferOrigin + ",");
- waferCount++;
- }
- string layoutData = String.Join(",", layoutDatas);
- string waferData = String.Join(",", waferDatas);
- if(_processJobInfo != null)
- JobDataRecorder.UpdatePJ(_processJobInfo.InnerId.ToString(), layoutData, waferData, waferCount);
- }
- public string GetFirstPJId()
- {
- if (_processJobInfo != null) return _processJobInfo.InnerId.ToString();
- return "";
- }
- public void PjFinished(string endStatus = "Normal")
- {
- if (_processJobInfo != null)
- JobDataRecorder.EndPJ(_processJobInfo.InnerId.ToString(), endStatus);
- }
- public void JobCreated(ControlJobInfo cj, ProcessJobInfo pj)
- {
- List<string> carrierInnerIdLst = new List<string>();
- List<string> stockerModuleLst = new List<string>();
- List<int> stockerWaferCountLst = new List<int>();
- foreach (var s in pj.Stockers)
- {
- var type = SC.GetStringValue($"System.Stocker.{s.Item1}WaferType");
- if (!string.IsNullOrEmpty(type) && (type.Contains("P") || type.Contains("M")))
- {
- ModuleName module = ModuleHelper.Converter(s.Item1);
- var carrier = CarrierManager.Instance.GetCarrier(s.Item1, 0);
- if (carrier != null && !carrier.IsEmpty)
- {
- var waferCount = WaferManager.Instance.GetWafers(module).ToList().Where(x => !x.IsEmpty).Count();
- carrierInnerIdLst.Add(carrier.InnerId.ToString());
- stockerModuleLst.Add(s.Item1);
- stockerWaferCountLst.Add(waferCount);
- }
- }
- }
- JobDataRecorder.StartPJ(pj.InnerId.ToString(), string.Join(";", carrierInnerIdLst), cj.InnerId.ToString(), cj.LotName, pj.Name, string.Join(";", stockerModuleLst), string.Join(";", stockerModuleLst), stockerWaferCountLst.Sum(), pj.JobRecipe);
- }
- }
- }
|