SchedulerDBCallback.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Aitex.Core.Common;
  7. using Aitex.Core.RT.SCCore;
  8. using MECF.Framework.Common.DBCore;
  9. using MECF.Framework.Common.Equipment;
  10. using MECF.Framework.Common.Jobs;
  11. using MECF.Framework.Common.SubstrateTrackings;
  12. using FurnaceRT.Equipments.PMs.RecipeExecutions;
  13. using Aitex.Core.RT.Log;
  14. using FurnaceRT.Equipments.PMs;
  15. using MECF.Framework.Common.CommonData.EnumData;
  16. using MECF.Framework.Common.DataCenter;
  17. using Aitex.Core.Util;
  18. namespace FurnaceRT.Equipments.Schedulers
  19. {
  20. class SchedulerDBCallback : ISchedulerDBCallback
  21. {
  22. private ProcessJobInfo _processJobInfo;
  23. public void LotCreated(ControlJobInfo cj)
  24. {
  25. if (string.IsNullOrEmpty(cj.Module))
  26. return;
  27. ModuleName module = ModuleHelper.Converter(cj.Module);
  28. Guid carrierGuid = CarrierManager.Instance.GetCarrier(cj.Module).InnerId;
  29. LotDataRecorder.StartLot(cj.LotInnerId.ToString(), carrierGuid.ToString(), "", cj.LotName, cj.Module, cj.Module, cj.LotWafers.Count);
  30. foreach (var waferInfo in cj.LotWafers)
  31. {
  32. LotDataRecorder.InsertLotWafer(cj.LotInnerId.ToString(), waferInfo.InnerId.ToString());
  33. WaferDataRecorder.SetWaferSequence(waferInfo.InnerId.ToString(), waferInfo.PPID);
  34. }
  35. }
  36. public void LotFinished(ControlJobInfo cj)
  37. {
  38. int unprocessed = 0;
  39. int aborted = 0;
  40. foreach (var waferInfo in cj.LotWafers)
  41. {
  42. if (waferInfo.ProcessState == EnumWaferProcessStatus.Failed)
  43. {
  44. aborted++;
  45. continue;
  46. }
  47. if (waferInfo.ProcessState != EnumWaferProcessStatus.Completed)
  48. {
  49. unprocessed++;
  50. continue;
  51. }
  52. }
  53. LotDataRecorder.EndLot(cj.LotInnerId.ToString(), aborted, unprocessed);
  54. }
  55. public void PjCreated(params object[] objs)
  56. {
  57. var param = (Dictionary<string, object>)objs[0];
  58. string jobName = (string)param["JobRecipe"];
  59. string recipeName = (string)param["ProcessRecipe"];
  60. string layoutName = (string)param["LayoutRecipe"];
  61. string form = (string)param["Form"];
  62. string batchId = "";
  63. if (param.ContainsKey("Batch"))
  64. {
  65. batchId = $"Batch{(string)param["Batch"]}{DateTime.Now.ToString("yyyyMMddHHmmssffff")}";
  66. }
  67. else
  68. {
  69. batchId = DateTime.Now.ToString("yyyyMMddHHmmssffff");
  70. }
  71. _processJobInfo = new ProcessJobInfo();
  72. _processJobInfo.Name = jobName;
  73. _processJobInfo.LotName = jobName;
  74. _processJobInfo.InnerId = Guid.NewGuid();
  75. RecipeParser.LayoutRecipeParse(layoutName, ModuleName.PM1.ToString(), out RecipeLayoutEntityNormal layoutRecipeDataNormal, out RecipeLayoutEntityExpert layoutRecipeDataExpert, out string reason);
  76. string layoutData = String.Join(",", layoutRecipeDataExpert.Items);
  77. JobDataRecorder.CreatePJ(_processJobInfo.InnerId.ToString(), batchId, jobName, recipeName, layoutName, layoutData, form);
  78. }
  79. public void PjCreated(string batch, string jobRecipe, string processRecipe, string layoutRecipe)
  80. {
  81. string batchId = "";
  82. if (!string.IsNullOrEmpty(batch))
  83. {
  84. batchId = $"Batch{batch}{DateTime.Now.ToString("yyyyMMddHHmmssffff")}";
  85. }
  86. else
  87. {
  88. batchId = DateTime.Now.ToString("yyyyMMddHHmmssffff");
  89. }
  90. _processJobInfo = new ProcessJobInfo();
  91. _processJobInfo.Name = jobRecipe;
  92. _processJobInfo.LotName = jobRecipe;
  93. _processJobInfo.InnerId = Guid.NewGuid();
  94. RecipeParser.LayoutRecipeParse(layoutRecipe, ModuleName.PM1.ToString(), out RecipeLayoutEntityNormal layoutRecipeDataNormal, out RecipeLayoutEntityExpert layoutRecipeDataExpert, out string reason);
  95. string layoutData = String.Join(",", layoutRecipeDataExpert.Items);
  96. JobDataRecorder.CreatePJ(_processJobInfo.InnerId.ToString(), batchId, jobRecipe, processRecipe, layoutRecipe, layoutData, "Normal");
  97. }
  98. public void PjCreated(ProcessJobInfo pj)
  99. {
  100. _processJobInfo = new ProcessJobInfo();
  101. _processJobInfo.Name = pj.Name;
  102. _processJobInfo.LotName = pj.LotName;
  103. _processJobInfo.InnerId = pj.InnerId;
  104. _processJobInfo.JobRecipe = pj.JobRecipe;
  105. _processJobInfo.ProcessRecipe = pj.ProcessRecipe;
  106. _processJobInfo.LayoutRecipe = pj.LayoutRecipe;
  107. var batchId = DateTime.Now.ToString("yyyyMMddHHmmssffff");
  108. RecipeParser.LayoutRecipeParse(_processJobInfo.LayoutRecipe, ModuleName.PM1.ToString(),
  109. out RecipeLayoutEntityNormal layoutRecipeDataNormal, out RecipeLayoutEntityExpert layoutRecipeDataExpert, out string reason);
  110. string layoutData = String.Join(",", layoutRecipeDataExpert.Items);
  111. JobDataRecorder.CreatePJ(_processJobInfo.InnerId.ToString(), batchId,
  112. _processJobInfo.JobRecipe, _processJobInfo.ProcessRecipe, _processJobInfo.LayoutRecipe, layoutData, "Normal");
  113. }
  114. public void PjCreated(string processName)
  115. {
  116. string form = "process";
  117. string batchId = $"process{DateTime.Now.ToString("yyyyMMddHHmmssffff")}";
  118. _processJobInfo = new ProcessJobInfo();
  119. _processJobInfo.Name = processName;
  120. _processJobInfo.LotName = processName;
  121. _processJobInfo.InnerId = Guid.NewGuid();
  122. JobDataRecorder.CreatePJ(_processJobInfo.InnerId.ToString(), batchId, "", processName, "", "", form);
  123. }
  124. public void PjStart()
  125. {
  126. JobDataRecorder.StartPJ(_processJobInfo.InnerId.ToString());
  127. }
  128. public void PjUpdated()
  129. {
  130. var wafers = WaferManager.Instance.GetWafers(ModuleName.PM1);
  131. List<string> layoutDatas = new List<string>();
  132. List<string> waferDatas = new List<string>();
  133. //StringBuilder waferData = new StringBuilder();
  134. int waferCount = 0;
  135. for (int i = 0; i < wafers.Length; i++)
  136. {
  137. if (wafers[i].IsEmpty)
  138. {
  139. layoutDatas.Add("");
  140. continue;
  141. }
  142. switch (wafers[i].WaferType)
  143. {
  144. case WaferType.P:
  145. case WaferType.M:
  146. case WaferType.M1:
  147. case WaferType.M2:
  148. case WaferType.SD:
  149. case WaferType.ED:
  150. layoutDatas.Add($"{wafers[i].WaferType}-{wafers[i].LotId}-{wafers[i].WaferOrigin.Replace("Stocker", "")}");
  151. //layoutDatas.Add($"{wafers[i].WaferType}-{wafers[i].WaferOrigin}");
  152. break;
  153. default:
  154. layoutDatas.Add("");
  155. break;
  156. }
  157. waferDatas.Add($"{wafers[i].WaferType}:{wafers[i].WaferOrigin}:{wafers[i].LotId}");
  158. //waferData.Append(wafers[i].WaferType.ToString() + ":");
  159. //waferData.Append(wafers[i].WaferOrigin + ",");
  160. waferCount++;
  161. }
  162. string layoutData = String.Join(",", layoutDatas);
  163. string waferData = String.Join(",", waferDatas);
  164. if(_processJobInfo != null)
  165. JobDataRecorder.UpdatePJ(_processJobInfo.InnerId.ToString(), layoutData, waferData, waferCount);
  166. }
  167. public string GetFirstPJId()
  168. {
  169. if (_processJobInfo != null) return _processJobInfo.InnerId.ToString();
  170. return "";
  171. }
  172. public void PjFinished(string endStatus = "Normal")
  173. {
  174. if (_processJobInfo != null)
  175. JobDataRecorder.EndPJ(_processJobInfo.InnerId.ToString(), endStatus);
  176. }
  177. public void JobCreated(ControlJobInfo cj, ProcessJobInfo pj)
  178. {
  179. List<string> carrierInnerIdLst = new List<string>();
  180. List<string> stockerModuleLst = new List<string>();
  181. List<int> stockerWaferCountLst = new List<int>();
  182. foreach (var s in pj.Stockers)
  183. {
  184. var type = SC.GetStringValue($"System.Stocker.{s.Item1}WaferType");
  185. if (!string.IsNullOrEmpty(type) && (type.Contains("P") || type.Contains("M")))
  186. {
  187. ModuleName module = ModuleHelper.Converter(s.Item1);
  188. var carrier = CarrierManager.Instance.GetCarrier(s.Item1, 0);
  189. if (carrier != null && !carrier.IsEmpty)
  190. {
  191. var waferCount = WaferManager.Instance.GetWafers(module).ToList().Where(x => !x.IsEmpty).Count();
  192. carrierInnerIdLst.Add(carrier.InnerId.ToString());
  193. stockerModuleLst.Add(s.Item1);
  194. stockerWaferCountLst.Add(waferCount);
  195. }
  196. }
  197. }
  198. 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);
  199. }
  200. }
  201. }