SchedulerDBCallback.cs 11 KB

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