SchedulerDBCallback.cs 10 KB

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