PMModule.cs 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using Aitex.Core.Common;
  6. using Aitex.Core.RT.DataCenter;
  7. using Aitex.Core.RT.Device;
  8. using Aitex.Core.RT.Device.Unit;
  9. using Aitex.Core.RT.Event;
  10. using Aitex.Core.RT.Fsm;
  11. using Aitex.Core.RT.OperationCenter;
  12. using Aitex.Core.RT.Routine;
  13. using Aitex.Core.RT.SCCore;
  14. using Aitex.Core.Util;
  15. using Aitex.Core.Utilities;
  16. using Aitex.Sorter.Common;
  17. using MECF.Framework.Common.Alarms;
  18. using MECF.Framework.Common.DataCenter;
  19. using MECF.Framework.Common.Equipment;
  20. using MECF.Framework.Common.Schedulers;
  21. using MECF.Framework.Common.SubstrateTrackings;
  22. using FurnaceRT.Equipments.PMs.RecipeExecutions;
  23. using FurnaceRT.Equipments.PMs.Routines;
  24. using FurnaceRT.Equipments.Systems;
  25. using Process = FurnaceRT.Equipments.PMs.RecipeExecutions.Process;
  26. using Aitex.Core.Common.DeviceData;
  27. using FurnaceRT.Devices;
  28. using FurnaceRT.Modules.PMs;
  29. using MECF.Framework.Common.Device.Bases;
  30. using Aitex.Core.RT.Log;
  31. using FurnaceRT.Equipments.Boats;
  32. using MECF.Framework.Common.Event;
  33. using System.IO;
  34. using Aitex.Common.Util;
  35. using static Aitex.Core.Common.DeviceData.AITConfigData;
  36. using MECF.Framework.Common.CommonData.SorterDefines;
  37. using MECF.Framework.Common.Utilities;
  38. using System.Windows.Documents;
  39. using MECF.Framework.Common.CommonData.EnumData;
  40. using MECF.Framework.Common.CommonData;
  41. using System.ServiceModel;
  42. using FabConnect.SecsGemInterface.Application.Objects.ObjectService;
  43. using DocumentFormat.OpenXml.Packaging;
  44. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  45. using FurnaceRT.Equipments.Schedulers;
  46. using FabConnect.SecsGemInterface.Common;
  47. using MECF.Framework.Common.FAServices;
  48. namespace FurnaceRT.Equipments.PMs
  49. {
  50. public partial class PMModule : PMModuleBase, IRecipeExecutor
  51. {
  52. public enum STATE
  53. {
  54. NotInstall,
  55. NotConnected,
  56. Init,
  57. Idle,
  58. Homing,
  59. OpenSlitValve,
  60. CloseSlitValve,
  61. Error,
  62. PrepareTransfer,
  63. PostTransfer,
  64. PreProcess,
  65. PostProcess,
  66. Process,
  67. LeakCheck,
  68. MFCCali,
  69. Paused,
  70. InTransfer,
  71. }
  72. public enum MSG
  73. {
  74. Home,
  75. Connected,
  76. Disconnected,
  77. Transfer,
  78. PrepareTransfer,
  79. PostTransfer,
  80. Reset,
  81. Abort,
  82. Error,
  83. EndIdleRecipe,
  84. OpenSlitValve,
  85. CloseSlitValve,
  86. SelectRecipe,
  87. RunRecipe,
  88. RunIdleRecipe,
  89. RunOtherRecipe,
  90. RecipeSkipStep,
  91. RecipeJumpStep,
  92. RecipePause,
  93. RecipeContinue,
  94. RecipeAbort,
  95. Continue,
  96. SetOnline,
  97. SetOffline,
  98. PostProcess,
  99. Process,
  100. AlarmConditionJumpStep,
  101. LeakCheck,
  102. ToInit,
  103. StartMFCCalibration,
  104. }
  105. public enum ProcessFlowState
  106. {
  107. None,
  108. Idle,
  109. Standby,
  110. Ready,
  111. Run,
  112. End,
  113. Abort,
  114. }
  115. public override bool IsInit
  116. {
  117. get { return FsmState == (int)STATE.Init; }
  118. }
  119. public bool IsBusy
  120. {
  121. get { return !IsInit && !IsError && !IsReady; }
  122. }
  123. public bool IsProcessing
  124. {
  125. get { return FsmState == (int)STATE.Process; }
  126. }
  127. public override bool IsReady
  128. {
  129. get { return FsmState == (int)STATE.Idle && CheckAllMessageProcessed(); }
  130. }
  131. public override bool IsError
  132. {
  133. get
  134. {
  135. return _alarmNumber != 0;
  136. }
  137. }
  138. public event Action<string> OnEnterError;
  139. private PMHomeRoutine _homeRoutine;
  140. private PMLeakCheckRoutine _leakCheckRoutine;
  141. private PreProcess _preprocessRoutine;
  142. private Process _processRoutine;
  143. private PostProcess _postprocessRoutine;
  144. private PMPrepareTransferRoutine _prepareTransferRoutine;
  145. private PMPostTransferRoutine _postTransferRoutine;
  146. private ModuleName _module;
  147. private RecipeRunningInfo _recipeRunningInfo = new RecipeRunningInfo();
  148. private bool _isInit = true;
  149. private bool _isPrepareProcess = true;
  150. private bool _isStandbyStep;
  151. private StatsData _statTubeCleanNumber;
  152. private StatsData _statTubeCleanTime;
  153. private StatsData _statTubeCleanThick;
  154. private StatsData _statBoatCleanNumber;
  155. private StatsData _statBoatCleanTime;
  156. private StatsData _statBoatCleanThick;
  157. private StatsData _statForkCleanNumber;
  158. private StatsData _statForkCleanTime;
  159. private StatsData _statForkCleanThick;
  160. private Stopwatch _processTimer = new Stopwatch();
  161. public List<IoValve> ValveLists = new List<IoValve>();
  162. public List<IoFlowMeter> FlowmeterLists = new List<IoFlowMeter>();
  163. private bool _isExternalSensorConditionBypass;
  164. private bool _isTempStabilizeConditionBypass;
  165. private bool _isPressureStabilizeConditionBypass;
  166. private bool _isReachTempConditionBypass;
  167. private bool _isReachPressureConditionBypass;
  168. private bool _isFinishAutoProfileConditionBypass;
  169. private SerializableDictionary<string, bool> _conditionCheckDic = new SerializableDictionary<string, bool>();
  170. private Dictionary<string, string> _conditionCheckItemDic = new Dictionary<string, string>();
  171. private Stopwatch _waitTimer = new Stopwatch();
  172. public string StringProcessFlowState { get; set; } = ProcessFlowState.Standby.ToString();
  173. public bool IsExcuteRoutineFailed { get; set; }
  174. public bool IsJobProcess { get; private set; }
  175. public string EditRecipeName { get; set; } = string.Empty;
  176. public string EditRecipeStepName { get; set; } = string.Empty;
  177. public bool IsExcuteIdleRecipe { get; set; }
  178. public string ToolType { get; set; }
  179. public PMModule(ModuleName module) : base(SC.GetValue<int>($"Boat.SlotCount"))
  180. {
  181. _module = module;
  182. Module = module.ToString();
  183. Name = module.ToString();
  184. EnumLoop<STATE>.ForEach((item) =>
  185. {
  186. MapState((int)item, item.ToString());
  187. });
  188. EnumLoop<MSG>.ForEach((item) =>
  189. {
  190. MapMessage((int)item, item.ToString());
  191. });
  192. EnableFsm(1, STATE.Idle);
  193. }
  194. public override bool Initialize()
  195. {
  196. IsOnline = true;
  197. InitRoutine();
  198. InitDevice();
  199. InitAUX();
  200. InitInterlock();
  201. InitFsm();
  202. InitOp();
  203. InitData();
  204. InitLeakCheckData();
  205. InitStats();
  206. InitAlarmEvent();
  207. InitScheduleMaintenance();
  208. InitAlarmConditionChecker();
  209. Singleton<EventManager>.Instance.OnAlarmEvent += Instance_OnAlarmEvent;
  210. ToolType = SC.GetStringValue("System.SetUp.ToolType");
  211. #region bufferpurge重启下发
  212. var isEnable = SC.GetValue<bool>("BufferPurge.IsEnable");
  213. if (isEnable)
  214. {
  215. var sequence = SC.GetStringValue("BufferPurge.OperationOrder")?.Split(';');
  216. string[] names = SC.GetStringValue("BufferPurge.NameList")?.Split(';');
  217. if (sequence?.Length > 0 && names?.Length > 0)
  218. {
  219. List<PurgeParameter> purge = new List<PurgeParameter>();
  220. foreach (string p in sequence)
  221. {
  222. if (string.IsNullOrWhiteSpace(p)) continue;//Purge1,0,Time(10),Open;
  223. var step = p.Trim().Split(',');
  224. if (step.Length == 4)
  225. {
  226. if (string.IsNullOrEmpty(step[0])) continue;//name
  227. if (names.Contains(step[0]))
  228. {
  229. var index = step[2].IndexOf('(') + 1;
  230. int.TryParse(step[2].Substring(index, step[2].Length - index - 1), out int time);//仅考虑时间
  231. purge.Add(
  232. new PurgeParameter() { Name = step[0], TimeString = $"{time / 3600:00}:{time % 3600 / 60:00}:{time % 60:00}", IsClose = step[3].ToLower() == "close", IsOpen = step[3].ToLower() == "open" });
  233. }
  234. }
  235. }
  236. SetBufferPurge(purge);
  237. }
  238. }
  239. #endregion
  240. return base.Initialize();
  241. }
  242. private void Instance_OnAlarmEvent(EventItem item)
  243. {
  244. if (item != null && item.Level == EventLevel.Alarm && (item.Source == Name || item.Source == Module))
  245. {
  246. var alarm = item as AlarmEventItem;
  247. DEVICE.GetDevice<SignalTowerBase>("System.SignalTower")?.Reset();
  248. LOG.Write($"{item.Source} {item.EventEnum} {item.Description}\n");
  249. //PostMsg(MSG.Error);
  250. }
  251. }
  252. private void InitRoutine()
  253. {
  254. _homeRoutine = new PMHomeRoutine(ModuleHelper.Converter(Module), this);
  255. _leakCheckRoutine = new PMLeakCheckRoutine(ModuleHelper.Converter(Module), this);
  256. _preprocessRoutine = new PreProcess(ModuleHelper.Converter(Module), this);
  257. _processRoutine = new Process(ModuleHelper.Converter(Module), this);
  258. _postprocessRoutine = new PostProcess(ModuleHelper.Converter(Module), this);
  259. _prepareTransferRoutine = new PMPrepareTransferRoutine(Module, this);
  260. _postTransferRoutine = new PMPostTransferRoutine(Module, this);
  261. }
  262. public bool GetRunningModeIsDebug()
  263. {
  264. if (SC.ContainsItem("System.RunningMode"))
  265. {
  266. return SC.GetStringValue("System.RunningMode") == ConfigEnum.Debug.ToString();
  267. }
  268. return true;
  269. }
  270. private void InitData()
  271. {
  272. DATA.Subscribe($"{Module}.IsError", () => IsError);
  273. DATA.Subscribe($"{Module}.IsProcessing", () => IsProcessing);
  274. DATA.Subscribe($"{Module}.Status", () => StringFsmStatus);
  275. DATA.Subscribe($"{Module}.IsOnline", () => IsOnline);
  276. DATA.Subscribe($"{Module}.RunningModeIsDebug", () => GetRunningModeIsDebug());
  277. DATA.Subscribe($"{Module}.EnableMinics", () => SC.ContainsItem("Minics.EnableMinics") ? SC.GetValue<bool>("Minics.EnableMinics") : false);
  278. //DATA.Subscribe($"{Module}.WaferSize", () => WaferManager.Instance.GetWaferSize(_module, 0).ToString());
  279. DATA.Subscribe($"{Module}.IsInMaintainMode", () => !IsOnline);
  280. //DATA.Subscribe($"{Name}.LeakCheckElapseTime", () =>
  281. //{
  282. // if (FsmState == (int)STATE.LeakCheck)
  283. // return _leakCheckRoutine.ElapsedTime;
  284. // return 0;
  285. //});
  286. DATA.Subscribe($"{Name}.ChamberPressure", () => ChamberPressure);
  287. //DATA.Subscribe($"{Name}.VAC1", () => _vac1);
  288. //DATA.Subscribe($"{Name}.VAC2", () => _vac2);
  289. //DATA.Subscribe($"{Name}.VAC3", () => _vac3);
  290. DATA.Subscribe($"{Name}.MainRecipeName", () => _recipeRunningInfo.MainRecipeName);
  291. DATA.Subscribe($"{Name}.SelectedRecipeName", () => _recipeRunningInfo.RecipeName);
  292. DATA.Subscribe($"{Name}.ProcessSubRecipe", () => _recipeRunningInfo.SubRecipeName);
  293. DATA.Subscribe($"{Name}.ProcessSubRecipeTable", () => _recipeRunningInfo.SubRecipeTable);
  294. DATA.Subscribe($"{Name}.ProcessAbortRecipe", () => _recipeRunningInfo.AbortRecipeName);
  295. DATA.Subscribe($"{Name}.AbortRecipeName", () => _recipeRunningInfo.RecipeName);
  296. DATA.Subscribe($"{Name}.SubRecipeCurrentLoopCount", () => _recipeRunningInfo.SubRecipeCurrentLoopCount);
  297. DATA.Subscribe($"{Name}.SubRecipeLoopCount", () => _recipeRunningInfo.SubRecipeLoopCount);
  298. DATA.Subscribe($"{Name}.IsExecuteSubRecipe", () => _processRoutine.IsSubReciep);
  299. DATA.Subscribe($"{Name}.RecipeBeginTime", () => _recipeRunningInfo.BeginTime);
  300. DATA.Subscribe($"{Name}.RecipeStepNumber", () => _recipeRunningInfo.StepNumber);
  301. DATA.Subscribe($"{Name}.RecipeNextStepName", () => _recipeRunningInfo.NextStepName);
  302. DATA.Subscribe($"{Name}.RecipeStepName", () => _recipeRunningInfo.StepName);
  303. DATA.Subscribe($"{Name}.RecipeStepElapseTime", () => _recipeRunningInfo.StepElapseTime);
  304. DATA.Subscribe($"{Name}.RecipeStepTime", () => _recipeRunningInfo.StepTime);
  305. DATA.Subscribe($"{Name}.RecipeTotalElapseTime", () => _recipeRunningInfo.TotalElapseTime);
  306. DATA.Subscribe($"{Name}.RecipeTotalTime", () => _recipeRunningInfo.TotalTime);
  307. DATA.Subscribe($"{Name}.RecipeHoldTime", () => _recipeRunningInfo.HoldTime);
  308. DATA.Subscribe($"{Name}.RecipeHold", () => IsPaused);//按了hold按键
  309. DATA.Subscribe($"{Name}.RecipeHolded", () => IsHolded);//按了hold按键之后,当前step执行完了
  310. DATA.Subscribe($"{Name}.RecipeWait", () => IsWait);//等待wait条件的结束
  311. DATA.Subscribe($"{Name}.NewShowTime", () => GetNewShowTime());
  312. DATA.Subscribe($"{Name}.ExecRecipeType", () => _recipeRunningInfo.ExecRecipeType);
  313. DATA.Subscribe($"{Name}.LoopCountSet", () => _recipeRunningInfo.LoopCountSet);
  314. DATA.Subscribe($"{Name}.LoopCountCurrent", () => _recipeRunningInfo.LoopCountCurrent);
  315. DATA.Subscribe($"{Name}.IsLooping", () => _recipeRunningInfo.IsLooping);
  316. DATA.Subscribe("ProcessFlow.Status", () => StringProcessFlowState);
  317. DATA.Subscribe($"{Name}.ConditionCheck", () => _conditionCheckDic);
  318. //DATA.Subscribe($"{Name}.LZoneHeaterData", () => Heater2.DeviceData.IsLspModeFeedBack ? Heater2.DeviceData : Heater1.DeviceData);
  319. //DATA.Subscribe($"{Name}.CLZoneHeaterData", () => Heater4.DeviceData.IsLspModeFeedBack ? Heater4.DeviceData : Heater3.DeviceData);
  320. //DATA.Subscribe($"{Name}.CZoneHeaterData", () => Heater6.DeviceData.IsLspModeFeedBack ? Heater6.DeviceData : Heater5.DeviceData);
  321. //DATA.Subscribe($"{Name}.CUZoneHeaterData", () => Heater8.DeviceData.IsLspModeFeedBack ? Heater8.DeviceData : Heater7.DeviceData);
  322. //DATA.Subscribe($"{Name}.UZoneHeaterData", () => Heater10.DeviceData.IsLspModeFeedBack ? Heater10.DeviceData : Heater9.DeviceData);
  323. SensorRecipeOK = new AITSensorData()
  324. {
  325. DeviceName = "SensorRecipeOK",
  326. DeviceSchematicId = "SensorRecipe",
  327. DisplayName = "SensorRecipe",
  328. Value = false,
  329. };
  330. DATA.Subscribe($"{Module}.{SensorRecipeOK.DeviceName}", () => SensorRecipeOK);
  331. SensorPROCManualOK = new AITSensorData()
  332. {
  333. DeviceName = "SensorPROCManualOK",
  334. DeviceSchematicId = "PROCManual",
  335. DisplayName = "PROCManual",
  336. Value = false,
  337. };
  338. DATA.Subscribe($"{Module}.{SensorPROCManualOK.DeviceName}", () => SensorPROCManualOK);
  339. DATA.Subscribe($"{Module}.EditRecipeName", () => EditRecipeName);
  340. DATA.Subscribe($"{Module}.EditRecipeStepName", () => EditRecipeStepName);
  341. DATA.Subscribe($"{Module}.HTR1Enable", () => IsHTR1Enable);
  342. DATA.Subscribe($"{Module}.HTR2Enable", () => IsHTR2Enable);
  343. DATA.Subscribe($"{Module}.HTR3Enable", () => IsHTR3Enable);
  344. DATA.Subscribe($"{Module}.IsDPROn", () => _isDPROn);
  345. DATA.Subscribe($"{Module}.IsCEXHOn", () => TrigCEXHON?.Value);
  346. DATA.Subscribe($"{Module}.IsF2ClnOn", () =>
  347. {
  348. return IsF2ClnOn;
  349. });
  350. DATA.Subscribe($"{Module}.IsHFClnOn", () =>
  351. {
  352. return IsHFClnOn;
  353. });
  354. DATA.Subscribe($"{Module}.IsDEPOOn", () => TrigDEPOSW != null ? TrigDEPOSW.Value : false);
  355. DATA.Subscribe($"{Module}.IsCREFOn", () => TrigCREFON != null ? TrigCREFON.Value : false);
  356. DATA.Subscribe($"{Module}.IsSIREFOn", () => TrigSIREFON != null ? TrigSIREFON.Value : false);
  357. DATA.Subscribe($"{Module}.MFCList", () =>
  358. {
  359. List<AITMfcData> aITMfcDataList = new List<AITMfcData>();
  360. var mfcs = DEVICE.GetDevice<PMs.Devices.IoMFC>();
  361. if (mfcs != null)
  362. {
  363. foreach (var item in mfcs)
  364. {
  365. if (item == null) continue;
  366. if (item.IsMFCInstalled)
  367. {
  368. aITMfcDataList.Add(item.DeviceData);
  369. }
  370. }
  371. }
  372. return aITMfcDataList;
  373. });
  374. InitScheduleData();
  375. FDCSubscribe();
  376. InitOtherData();
  377. InitN2PurgeData();
  378. }
  379. private void InitStats()
  380. {
  381. _statTubeCleanNumber = new StatsData($"{Module}.Tube Clean Number", "Tube clean number", 0);
  382. _statTubeCleanTime = new StatsData($"{Module}.Tube Clean Time", "Tube clean time(Min)", 0);
  383. _statTubeCleanThick = new StatsData($"{Module}.Tube Clean thick", "Tube clean thick(nm)", 0);
  384. _statBoatCleanNumber = new StatsData($"{Module}.Boat Clean Number", "Boat clean number", 0);
  385. _statBoatCleanTime = new StatsData($"{Module}.Boat Clean Time", "Boat clean time(Min)", 0);
  386. _statBoatCleanThick = new StatsData($"{Module}.Boat Clean thick", "Boat clean thick(nm)", 0);
  387. _statForkCleanNumber = new StatsData($"{Module}.Fork Clean Number", "Fork clean number", 0);
  388. _statForkCleanTime = new StatsData($"{Module}.Fork Clean Time", "Fork clean time(Min)", 0);
  389. _statBoatCleanThick = new StatsData($"{Module}.Boat Clean thick", "Boat clean thick(nm)", 0);
  390. _statForkCleanThick = new StatsData($"{Module}.Fork Clean thick", "Fork clean thick", 0);
  391. }
  392. private void InitOp()
  393. {
  394. OP.Subscribe($"{Module}.Home", (string cmd, object[] args) =>
  395. {
  396. if (!(Singleton<EquipmentManager>.Instance.Modules[ModuleName.WaferRobot] as IModuleDevice).IsReady)
  397. {
  398. TubeHomeFailedWarning.Set($"Wafer Robot is not in ilde state, init failed.");
  399. return false;
  400. }
  401. return CheckToPostMessage((int)MSG.Home);
  402. });
  403. OP.Subscribe($"{Module}.Reset", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Reset));
  404. OP.Subscribe($"{Module}.Abort", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Abort));
  405. OP.Subscribe($"{Module}.PutOnline", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SetOnline));
  406. OP.Subscribe($"{Module}.PutOffline", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SetOffline));
  407. OP.Subscribe($"{Name}.SelectRecipe", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SelectRecipe, args[0]));
  408. OP.Subscribe($"{Name}.RunRecipe", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RunRecipe, (string)args[0]));
  409. OP.Subscribe($"{Name}.RecipeSkipStep", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeSkipStep));
  410. OP.Subscribe($"{Name}.RecipeJumpStep", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeJumpStep, args[0], args[1]));
  411. OP.Subscribe($"{Name}.RecipePause", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipePause));
  412. OP.Subscribe($"{Name}.RecipeContinue", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeContinue));
  413. OP.Subscribe($"{Name}.RecipeAbort", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeAbort));
  414. OP.Subscribe($"{Name}.RecipeIdle", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RunIdleRecipe));
  415. OP.Subscribe($"{Name}.LeakCheck", (string cmd, object[] args) => CheckToPostMessage((int)MSG.LeakCheck, args[0], args[1], args[2], args[3]));
  416. OP.Subscribe($"{Name}.Wait", (string cmd, object[] args) =>
  417. {
  418. IsWait = !IsWait;
  419. return true;
  420. });
  421. OP.Subscribe($"{Module}.AlarmAction", (string cmd, object[] args) =>
  422. {
  423. Enum.TryParse(args[0].ToString(), out AlarmAction alarmAction);
  424. string eventName = null;
  425. if (args.Length > 1)
  426. eventName = args[1].ToString();
  427. if (eventName != null)
  428. {
  429. EV.ClearAlarmEvent(eventName);
  430. var item = _triggeredAlarmList.FirstOrDefault(x => x.EventEnum == eventName);
  431. if (item != null)
  432. {
  433. item.Reset();
  434. _triggeredAlarmList.Remove(item);
  435. }
  436. if (item != null)
  437. {
  438. switch (alarmAction)
  439. {
  440. case AlarmAction.Retry:
  441. {
  442. CheckToPostMessage((int)item.RetryMessage, item.RetryMessageParas);
  443. }
  444. break;
  445. case AlarmAction.Abort:
  446. {
  447. CheckToPostMessage((int)MSG.Abort);
  448. }
  449. break;
  450. case AlarmAction.Clear:
  451. {
  452. int alarmCount = 0;
  453. var alarms = EV.GetAlarmEvent();
  454. foreach (var alarm in alarms)
  455. {
  456. if (alarm.Level == EventLevel.Alarm && alarm.Source == Name)
  457. alarmCount++;
  458. }
  459. if (alarmCount == 0 && !IsProcessing)
  460. {
  461. CheckToPostMessage((int)MSG.Reset);
  462. _alarmNumber = 0;
  463. }
  464. }
  465. break;
  466. case AlarmAction.Continue:
  467. {
  468. int alarmCount = 0;
  469. var alarms = EV.GetAlarmEvent();
  470. foreach (var alarm in alarms)
  471. {
  472. if (alarm.Level == EventLevel.Alarm && alarm.Source == Name)
  473. alarmCount++;
  474. }
  475. if (alarmCount == 0)
  476. CheckToPostMessage((int)MSG.Reset);
  477. }
  478. break;
  479. case AlarmAction.ClearAll:
  480. ResetAUXTrig();
  481. break;
  482. }
  483. }
  484. }
  485. return true;
  486. });
  487. OP.Subscribe($"{Name}.SetConditionCheck", SetConditionCheck);
  488. OP.Subscribe($"{Name}.SetBoatZAxisMotion", SetBoatZAxisMotion);
  489. OP.Subscribe($"{Name}.SetBoatRAxisMotion", SetBoatRAxisMotion);
  490. OP.Subscribe($"{Name}.SetAutoShutterUp", SetAutoShutterUp);
  491. OP.Subscribe($"{Name}.SetAutoShutterOpen", SetAutoShutterOpen);
  492. OP.Subscribe($"{Name}.SetAutoShutterRotateOpen", SetAutoShutterRotateOpen);
  493. OP.Subscribe($"{Name}.BypassStandbyFactor", SeBypassStandbyFactor);
  494. OP.Subscribe($"{Name}.SetCommand", SetCommand);
  495. OP.Subscribe($"{Name}.SetN2PurgeMode", SetN2PurgeMode);
  496. OP.Subscribe($"{Name}.SetAllFFUPower", (out string reason, int time, object[] param) =>
  497. {
  498. reason = string.Empty;
  499. SetAllFFUPower(param);
  500. return true;
  501. });
  502. //OP.Subscribe($"{Name}.SetTemperatureDetail",)
  503. OP.Subscribe($"{Name}.SetSensorRecipeOK", SetSensorRecipeOK);
  504. OP.Subscribe($"{Name}.SetSensorPROCManualOK", SetSensorPROCManualOK);
  505. OP.Subscribe($"{Name}.SetEditRecipeName", SetEditRecipeName);
  506. OP.Subscribe($"{Name}.SetEditRecipeStepName", SetEditRecipeStepName);
  507. OP.Subscribe($"{Name}.Heater.SetParameters", (out string reason, int time, object[] param) =>
  508. {
  509. reason = string.Empty;
  510. //Mode参数;Correct Table;PID Table
  511. //"Heater;Parameter\\TempCorrection\\tempCorrect,2,Name2;Parameter\\TempPID\\tempPID,3,Name3"
  512. SetHeaterControlParameters(param);
  513. return true;
  514. });
  515. OP.Subscribe($"{Name}.Heater.SetPID", (out string reason, int time, object[] param) =>
  516. {
  517. reason = string.Empty;
  518. SetHeaterPIDParameters(param[0].ToString());
  519. return true;
  520. });
  521. OP.Subscribe($"{Name}.Heater.SetCorrect", (out string reason, int time, object[] param) =>
  522. {
  523. reason = string.Empty;
  524. SetHeaterCorrectParameters(param[0].ToString());
  525. return true;
  526. });
  527. //Recipe
  528. OP.Subscribe($"{Name}.SetBoatMotion", (out string reason, int time, object[] param) =>
  529. {
  530. reason = string.Empty;
  531. SetBoatMotion(param);
  532. return true;
  533. });
  534. //Recipe
  535. OP.Subscribe($"{Name}.SetValves", (out string reason, int time, object[] param) =>
  536. {
  537. reason = string.Empty;
  538. SetValves(param);
  539. return true;
  540. });
  541. //Recipe
  542. OP.Subscribe($"{Name}.SetAlarmConditionTable", (out string reason, int time, object[] param) =>
  543. {
  544. reason = string.Empty;
  545. SetAlarmConditionTable(param);
  546. return true;
  547. });
  548. //manual
  549. OP.Subscribe($"{Name}.SetAlarmConditionParameter", (out string reason, int time, object[] param) =>
  550. {
  551. reason = string.Empty;
  552. InitAlarmCondition(param[0].ToString());
  553. SetAlarmConditionTable(new object[1] { param[1] });
  554. return true;
  555. });
  556. OP.Subscribe($"{Name}.SetBoatManualMotion", (out string reason, int time, object[] param) =>
  557. {
  558. reason = string.Empty;
  559. SetBoatManualMotion(param);
  560. return true;
  561. });
  562. OP.Subscribe($"{Name}.SetBWREnable", (out string reason, int time, object[] param) =>
  563. {
  564. reason = string.Empty;
  565. SetBWREnable(param);
  566. return true;
  567. });
  568. OP.Subscribe($"{Name}.SetF2ClnEnable", (out string reason, int time, object[] param) =>
  569. {
  570. reason = string.Empty;
  571. SetF2ClnEnable(param);
  572. return true;
  573. });
  574. OP.Subscribe($"{Name}.SetHFClnEnable", (out string reason, int time, object[] param) =>
  575. {
  576. reason = string.Empty;
  577. SetHFClnEnable(param);
  578. return true;
  579. });
  580. OP.Subscribe($"{Name}.SetDEPOEnable", (out string reason, int time, object[] param) =>
  581. {
  582. reason = string.Empty;
  583. SetDEPOEnable(param);
  584. return true;
  585. });
  586. OP.Subscribe($"{Name}.SetHTR1Enable", (out string reason, int time, object[] param) =>
  587. {
  588. reason = string.Empty;
  589. SetHTR1Enable(param);
  590. return true;
  591. });
  592. OP.Subscribe($"{Name}.SetHTR2Enable", (out string reason, int time, object[] param) =>
  593. {
  594. reason = string.Empty;
  595. SetHTR2Enable(param);
  596. return true;
  597. });
  598. OP.Subscribe($"{Name}.SetHTR3Enable", (out string reason, int time, object[] param) =>
  599. {
  600. reason = string.Empty;
  601. SetHTR3Enable(param);
  602. return true;
  603. });
  604. OP.Subscribe($"{Name}.SetCEXHEnable", (out string reason, int time, object[] param) =>
  605. {
  606. reason = string.Empty;
  607. SetCEXHEnable(param);
  608. return true;
  609. });
  610. OP.Subscribe($"{Name}.AUX.SetParameters", (out string reason, int time, object[] param) =>
  611. {
  612. reason = string.Empty;
  613. //Mode参数;Correct Table;PID Table
  614. //"Heater;Parameter\\TempCorrection\\tempCorrect,2,Name2;Parameter\\TempPID\\tempPID,3,Name3"
  615. SetAUXParameters(param);
  616. return true;
  617. });
  618. OP.Subscribe($"{Module}.SetAllMfcVirtualValue", (out string reason, int time, object[] param) =>
  619. {
  620. reason = string.Empty;
  621. var dict = param[0] as Dictionary<string, string>;
  622. foreach (var item in dict)
  623. {
  624. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  625. if (mfc != null)
  626. {
  627. mfc.SetMfcVirtualValue(out reason, 0, new object[] { item.Value });
  628. }
  629. }
  630. return true;
  631. });
  632. OP.Subscribe($"{Module}.SetAllMfcValue", (out string reason, int time, object[] param) =>
  633. {
  634. reason = string.Empty;
  635. var dict = param[0] as Dictionary<string, string>;
  636. foreach (var item in dict)
  637. {
  638. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  639. if (mfc != null)
  640. { mfc.SetMfcValue(out reason, 0, new object[] { item.Value }); }
  641. }
  642. return true;
  643. });
  644. OP.Subscribe($"{Module}.SetAllMfcSetPoint", (out string reason, int time, object[] param) =>
  645. {
  646. reason = string.Empty;
  647. var dict = param[0] as Dictionary<string, string>;
  648. foreach (var item in dict)
  649. {
  650. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  651. if (mfc != null)
  652. { mfc.SetMfcSetPoint(out reason, 0, new object[] { item.Value }); }
  653. }
  654. return true;
  655. });
  656. OP.Subscribe($"{Module}.SetAll{AITValveOperation.GVVirtualTurnValve}", (out string reason, int time, object[] param) =>
  657. {
  658. reason = string.Empty;
  659. var dict = param[0] as Dictionary<string, bool>;
  660. foreach (var item in dict)
  661. {
  662. var valve = _valves.FirstOrDefault(x => x.Name == item.Key);
  663. if (valve != null)
  664. {
  665. valve.InvokeOpenCloseVirtualValve("", new object[] { item.Value });
  666. }
  667. }
  668. return true;
  669. });
  670. OP.Subscribe($"{Module}.SetAll{AITValveOperation.GVTurnValve}", (out string reason, int time, object[] param) =>
  671. {
  672. reason = string.Empty;
  673. var dict = param[0] as Dictionary<string, bool>;
  674. foreach (var item in dict)
  675. {
  676. _valves.FirstOrDefault(x => x.Name == item.Key).InvokeOpenCloseValve("", new object[] { item.Value });
  677. }
  678. return true;
  679. });
  680. OP.Subscribe($"{Name}.SetCREFEnable", (out string reason, int time, object[] param) =>
  681. {
  682. reason = string.Empty;
  683. SetCREFEnable(param);
  684. return true;
  685. });
  686. OP.Subscribe($"{Name}.SetSIREFEnable", (out string reason, int time, object[] param) =>
  687. {
  688. reason = string.Empty;
  689. SetHREFEnable(param);
  690. return true;
  691. });
  692. OP.Subscribe($"{Name}.SetBufferPurge", (out string reason, int time, object[] param) =>
  693. {
  694. reason = string.Empty;
  695. if (param.Length > 0 && param[0] is List<PurgeParameter> purge)
  696. {
  697. reason = SetBufferPurge(purge);
  698. if (!string.IsNullOrEmpty(reason)) return false;
  699. SC.SetItemValue("BufferPurge.OperationOrder", $"{purge[0].Name},{purge[0].Speed},Time({purge[0].Time}),{(purge[0].IsOpen ? "Open" : (purge[0].IsClose ? "Close" : ""))}");
  700. }
  701. return true;
  702. });
  703. InitOtherOP();
  704. }
  705. private string SetBufferPurge(List<PurgeParameter> purge)
  706. {
  707. string reason = string.Empty;
  708. if (TrigBufferPurgeTime == null || TrigBufferN2PurageEN == null) { reason = "TrigBufferPurgeTime/TrigBufferN2PurageEN is null"; }
  709. if (purge[0].IsOpen || purge[0].IsClose)
  710. {
  711. if (TrigBufferPurgeTime.SetAOTrigger(purge[0].Time, out reason))
  712. {
  713. TrigBufferN2PurageEN.SetTrigger(purge[0].IsOpen, out reason);
  714. }
  715. }
  716. return reason;
  717. }
  718. public void SetTemperatureDetail()
  719. {
  720. }
  721. private void InitFsm()
  722. {
  723. //Error
  724. Transition(STATE.Error, MSG.Reset, FsmReset, STATE.Idle);
  725. AnyStateTransition(MSG.Error, FsmOnError, STATE.Error);
  726. AnyStateTransition(MSG.Disconnected, FsmOnDisconnect, STATE.NotConnected);
  727. EnterExitTransition<STATE, FSM_MSG>(STATE.Error, FsmEnterError, FSM_MSG.NONE, FsmExitError);
  728. Transition(STATE.Idle, MSG.Abort, null, STATE.Idle);
  729. Transition(STATE.Idle, MSG.Reset, null, STATE.Idle);
  730. Transition(STATE.Init, MSG.Reset, null, STATE.Idle);
  731. Transition(STATE.Error, MSG.Abort, null, STATE.Error);
  732. //init
  733. Transition(STATE.Init, MSG.Home, FsmStartHome, STATE.Homing);
  734. AnyStateTransition(MSG.ToInit, FsmToInit, STATE.Init);
  735. //not connected
  736. Transition(STATE.NotConnected, MSG.Connected, null, STATE.Init);
  737. //Home
  738. EnterExitTransition((int)STATE.Homing, FsmEnterHome, (int)FSM_MSG.NONE, FsmExitHome);
  739. Transition(STATE.Error, MSG.Home, FsmStartHome, STATE.Homing);
  740. Transition(STATE.Idle, MSG.Home, FsmStartHome, STATE.Homing);
  741. Transition(STATE.Homing, FSM_MSG.TIMER, FsmMonitorHomeTask, STATE.Idle);
  742. Transition(STATE.Homing, MSG.Error, null, STATE.Init);
  743. Transition(STATE.Homing, MSG.Abort, FsmAbortTask, STATE.Init);
  744. //PrepareTransfer
  745. Transition(STATE.Idle, MSG.PrepareTransfer, FsmStartPrepareTransfer, STATE.PrepareTransfer);
  746. Transition(STATE.PrepareTransfer, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  747. Transition(STATE.PrepareTransfer, MSG.Abort, FsmAbortTask, STATE.Idle);
  748. //PostTransfer
  749. Transition(STATE.InTransfer, MSG.PostTransfer, FsmStartPostTransfer, STATE.PostTransfer);
  750. Transition(STATE.Idle, MSG.PostTransfer, FsmStartPostTransfer, STATE.PostTransfer);
  751. Transition(STATE.PostTransfer, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  752. Transition(STATE.PostTransfer, MSG.Abort, FsmAbortTask, STATE.Idle);
  753. //online
  754. Transition(STATE.Idle, MSG.SetOnline, FsmStartSetOnline, STATE.Idle);
  755. Transition(STATE.Idle, MSG.SetOffline, FsmStartSetOffline, STATE.Idle);
  756. //Leak check
  757. Transition(STATE.Idle, MSG.LeakCheck, FsmStartLeakCheck, STATE.LeakCheck);
  758. Transition(STATE.LeakCheck, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  759. Transition(STATE.LeakCheck, MSG.Abort, FsmAbortTask, STATE.Idle);
  760. EnterExitTransition<STATE, FSM_MSG>(STATE.LeakCheck, FsmEnterLeakCheck, FSM_MSG.NONE, FsmExitLeakCheck);
  761. //open SlitValve
  762. Transition(STATE.Idle, MSG.OpenSlitValve, FsmStartOpenSlitValve, STATE.OpenSlitValve);
  763. Transition(STATE.OpenSlitValve, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  764. Transition(STATE.OpenSlitValve, MSG.Abort, FsmAbortTask, STATE.Idle);
  765. //close SlitValve
  766. Transition(STATE.Idle, MSG.CloseSlitValve, FsmStartCloseSlitValve, STATE.CloseSlitValve);
  767. Transition(STATE.CloseSlitValve, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  768. Transition(STATE.CloseSlitValve, MSG.Abort, FsmAbortTask, STATE.Idle);
  769. //PreProcess
  770. Transition(STATE.Process, MSG.RunIdleRecipe, FsmStartIdleRecipePreProcess, STATE.PreProcess);
  771. Transition(STATE.Process, MSG.RunOtherRecipe, FsmStartOtherRecipePreProcess, STATE.PreProcess);
  772. Transition(STATE.Idle, MSG.RunOtherRecipe, FsmStartOtherRecipePreProcess, STATE.PreProcess);
  773. Transition(STATE.Idle, MSG.SelectRecipe, FsmSelectRecipe, STATE.Idle);
  774. Transition(STATE.Idle, MSG.RunRecipe, FsmStartPreProcess, STATE.PreProcess);
  775. Transition(STATE.PreProcess, FSM_MSG.TIMER, FsmMonitorTask, STATE.PreProcess);
  776. Transition(STATE.PreProcess, MSG.Abort, FsmAbortTask, STATE.Idle);
  777. Transition(STATE.PreProcess, MSG.RecipeAbort, FsmAbortTask, STATE.Idle);
  778. //Process
  779. Transition(STATE.PreProcess, MSG.Process, FsmStartProcess, STATE.Process);
  780. Transition(STATE.Idle, MSG.AlarmConditionJumpStep, FsmStartAlarmConditionJumpStep, STATE.Process);
  781. Transition(STATE.Process, FSM_MSG.TIMER, FsmMonitorTask, STATE.Process);
  782. Transition(STATE.Process, MSG.Abort, FsmAbortTask, STATE.Idle);
  783. Transition(STATE.Process, MSG.EndIdleRecipe, null, STATE.Idle);
  784. EnterExitTransition<STATE, FSM_MSG>(STATE.Process, FsmEnterProcess, FSM_MSG.NONE, FsmExitProcess);
  785. Transition(STATE.Paused, FSM_MSG.TIMER, FsmMonitorTask, STATE.Paused);
  786. Transition(STATE.Paused, MSG.Continue, FsmStartContinue, STATE.Process);
  787. Transition(STATE.Paused, MSG.Error, null, STATE.Paused);
  788. Transition(STATE.Paused, MSG.Abort, FsmAbortTask, STATE.Idle);
  789. //Transition(STATE.Paused, MSG.Error, null, STATE.Paused);
  790. Transition(STATE.Process, MSG.RecipeSkipStep, FsmSkipStep, STATE.Process);
  791. Transition(STATE.Process, MSG.RecipeJumpStep, FsmJumpStep, STATE.Process);
  792. Transition(STATE.Process, MSG.RecipePause, FsmRecipePause, STATE.Process);
  793. Transition(STATE.Process, MSG.RecipeContinue, FsmRecipeContinue, STATE.Process);
  794. Transition(STATE.Process, MSG.RecipeAbort, FsmRecipeAbort, STATE.Process);
  795. //PostProcess
  796. Transition(STATE.Process, MSG.PostProcess, FsmStartPostProcess, STATE.PostProcess);
  797. Transition(STATE.PostProcess, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  798. Transition(STATE.PostProcess, MSG.Abort, FsmAbortTask, STATE.Idle);
  799. EnterExitTransition<STATE, FSM_MSG>(STATE.PostProcess, null, FSM_MSG.NONE, ExitPostProcess);
  800. //MFC Calibration
  801. Transition(STATE.Idle, MSG.StartMFCCalibration, FsmStartMFCCalibration, STATE.MFCCali);
  802. Transition(STATE.MFCCali, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  803. Transition(STATE.MFCCali, MSG.Abort, FsmAbortTask, STATE.Idle);
  804. }
  805. private bool FsmToInit(object[] param)
  806. {
  807. return true;
  808. }
  809. private bool FsmExitError(object[] param)
  810. {
  811. return true;
  812. }
  813. private bool FsmEnterError(object[] param)
  814. {
  815. if (OnEnterError != null)
  816. OnEnterError(Module);
  817. if (IsOnline)
  818. {
  819. //EV.PostWarningLog(Module, $"{Module}");
  820. }
  821. return true;
  822. }
  823. private bool FsmStartPostTransfer(object[] param)
  824. {
  825. _postTransferRoutine.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]));
  826. Result ret = StartRoutine(_postTransferRoutine);
  827. if (ret == Result.FAIL || ret == Result.DONE)
  828. return false;
  829. return ret == Result.RUN;
  830. }
  831. private bool FsmStartPrepareTransfer(object[] param)
  832. {
  833. _prepareTransferRoutine.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]));
  834. Result ret = StartRoutine(_prepareTransferRoutine);
  835. if (ret == Result.FAIL || ret == Result.DONE)
  836. return false;
  837. return ret == Result.RUN;
  838. }
  839. private bool FsmStartSetOffline(object[] param)
  840. {
  841. IsOnline = false;
  842. return true;
  843. }
  844. private bool FsmStartSetOnline(object[] param)
  845. {
  846. IsOnline = true;
  847. return true;
  848. }
  849. private bool FsmStartLeakCheck(object[] param)
  850. {
  851. _leakCheckRoutine.Init((int)param[0], (int)param[1], (string)param[2], (bool[])param[3]);
  852. Result ret = StartRoutine(_leakCheckRoutine);
  853. if (ret == Result.FAIL || ret == Result.DONE)
  854. return false;
  855. return ret == Result.RUN;
  856. }
  857. private bool FsmEnterLeakCheck(object[] param)
  858. {
  859. return true;
  860. }
  861. private bool FsmExitLeakCheck(object[] param)
  862. {
  863. //ChamberProcessPressureGauge.UnsetTuning();
  864. return true;
  865. }
  866. private bool FsmStartOpenSlitValve(object[] param)
  867. {
  868. return true;
  869. }
  870. private bool FsmStartCloseSlitValve(object[] param)
  871. {
  872. return true;
  873. }
  874. private bool FsmSelectRecipe(object[] param)
  875. {
  876. return true;
  877. }
  878. private bool FsmStartPreProcess(object[] param)
  879. {
  880. _recipeRunningInfo.RecipeName = (string)param[0];
  881. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, "Process"))
  882. {
  883. PreprocessStartFailedWarning.Set($"Load process recipe {_recipeRunningInfo.RecipeName} failed, {reason}");
  884. return false;
  885. }
  886. if (recipeSteps == null || recipeSteps.Count == 0)
  887. {
  888. PreprocessStartFailedWarning.Set($"Process recipe {_recipeRunningInfo.RecipeName} is empty");
  889. return false;
  890. }
  891. string abortRecipeName = SC.ContainsItem("System.Recipe.Abort Recipe") ? SC.GetStringValue("System.Recipe.Abort Recipe") : string.Empty;
  892. if (string.IsNullOrEmpty(abortRecipeName))
  893. {
  894. PreprocessStartFailedWarning.Set($"Load abort recipe failed, recipe file is null");
  895. return false;
  896. }
  897. SC.SetItemValueFromString("PM1.ProcessRecipe", _recipeRunningInfo.RecipeName);
  898. if (!IsJobProcess)
  899. Singleton<EquipmentManager>.Instance.CreatePj((string)param[0]);
  900. RecipeExecEntryEnumValue = RecipeExecEntryEnum.MaintenanceJobTrigger;
  901. _preprocessRoutine.Init((string)param[0]);
  902. Result ret = StartRoutine(_preprocessRoutine);
  903. if (ret == Result.FAIL || ret == Result.DONE)
  904. return false;
  905. if (!IsJobProcess)
  906. SensorPROCManualOK.Value = true;
  907. return ret == Result.RUN;
  908. }
  909. private bool FsmStartOtherRecipePreProcess(object[] param)
  910. {
  911. Singleton<EquipmentManager>.Instance.EndPj("AbnormalEnd");
  912. _processRoutine?.Abort();
  913. IsWait = false;
  914. IsJobProcess = false;
  915. _recipeRunningInfo.RecipeName = param[0].ToString();
  916. var recipeType = param[1].ToString();
  917. var tableID = 1;
  918. if (param.Length > 2)
  919. int.TryParse(param[2].ToString(), out tableID);
  920. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, recipeType, tableID))
  921. {
  922. PreprocessStartFailedWarning.Set($"Load {recipeType} recipe {_recipeRunningInfo.RecipeName} failed {reason}");
  923. return false;
  924. }
  925. if (recipeSteps == null || recipeSteps.Count == 0)
  926. {
  927. PreprocessStartFailedWarning.Set($"{recipeType} recipe {_recipeRunningInfo.RecipeName} is empty");
  928. return false;
  929. }
  930. if (!IsJobProcess)
  931. Singleton<EquipmentManager>.Instance.CreatePj(_recipeRunningInfo.RecipeName);
  932. _preprocessRoutine.Init(_recipeRunningInfo.RecipeName, false);
  933. RecipeRunningInfo.MainRecipeName = _recipeRunningInfo.RecipeName;
  934. RecipeRunningInfo.Head = recipeHead;
  935. RecipeRunningInfo.RecipeStepList = recipeSteps;
  936. RecipeRunningInfo.RecipeName = _recipeRunningInfo.RecipeName;
  937. RecipeRunningInfo.ExecRecipeType = recipeSteps.Count > 0 ? recipeSteps[0].RecipeType : string.Empty;
  938. Result ret = StartRoutine(_preprocessRoutine);
  939. if (ret == Result.FAIL || ret == Result.DONE)
  940. return false;
  941. if (!IsJobProcess)
  942. SensorPROCManualOK.Value = true;
  943. return ret == Result.RUN;
  944. }
  945. private bool FsmStartIdleRecipePreProcess(object[] param)
  946. {
  947. if (!CheckBoatState())
  948. {
  949. PreprocessStartFailedWarning.Set($"boat is not ready");
  950. return false;
  951. }
  952. Singleton<EquipmentManager>.Instance.EndPj("AbnormalEnd");
  953. _recipeRunningInfo.RecipeName = SC.ContainsItem("System.Recipe.Idle Recipe") ? SC.GetStringValue("System.Recipe.Idle Recipe") : string.Empty;
  954. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, "Idle"))
  955. {
  956. PreprocessStartFailedWarning.Set($"Load idle recipe {_recipeRunningInfo.RecipeName} failed {reason}");
  957. return false;
  958. }
  959. if (recipeSteps == null || recipeSteps.Count == 0)
  960. {
  961. PreprocessStartFailedWarning.Set($"Process recipe {_recipeRunningInfo.RecipeName} is empty");
  962. return false;
  963. }
  964. if (!IsJobProcess)
  965. Singleton<EquipmentManager>.Instance.CreatePj(_recipeRunningInfo.RecipeName);
  966. _preprocessRoutine.Init(_recipeRunningInfo.RecipeName, false);
  967. RecipeRunningInfo.MainRecipeName = _recipeRunningInfo.RecipeName;
  968. RecipeRunningInfo.Head = recipeHead;
  969. RecipeRunningInfo.RecipeStepList = recipeSteps;
  970. RecipeRunningInfo.RecipeName = _recipeRunningInfo.RecipeName;
  971. RecipeRunningInfo.ExecRecipeType = recipeSteps.Count > 0 ? recipeSteps[0].RecipeType : string.Empty;
  972. RecipeExecEntryEnumValue = RecipeExecEntryEnum.IdleRecipeTrigger;
  973. Result ret = StartRoutine(_preprocessRoutine);
  974. if (ret == Result.FAIL || ret == Result.DONE)
  975. return false;
  976. if (!IsJobProcess)
  977. SensorPROCManualOK.Value = true;
  978. return ret == Result.RUN;
  979. }
  980. private bool FsmStartProcess(object[] param)
  981. {
  982. Result ret = StartRoutine(_processRoutine);
  983. if (ret == Result.FAIL || ret == Result.DONE)
  984. return false;
  985. if (ret == Result.RUN && !IsJobProcess)
  986. Singleton<EquipmentManager>.Instance.StartPj();
  987. return ret == Result.RUN;
  988. }
  989. private bool FsmStartAlarmConditionJumpStep(object[] param)
  990. {
  991. if (param != null && param.Length > 0)
  992. {
  993. int.TryParse(param[0].ToString(), out int jumpStep);
  994. _processRoutine.AlarmConditionJumpStep = jumpStep;
  995. Result ret = StartRoutine(_processRoutine);
  996. if (ret == Result.FAIL || ret == Result.DONE)
  997. return false;
  998. return ret == Result.RUN;
  999. }
  1000. return false;
  1001. }
  1002. private bool FsmEnterProcess(object[] param)
  1003. {
  1004. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  1005. {
  1006. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  1007. continue;
  1008. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.InProcess);
  1009. }
  1010. _processTimer.Restart();
  1011. return true;
  1012. }
  1013. private bool FsmExitProcess(object[] param)
  1014. {
  1015. _processRoutine.ExitProcess();
  1016. if (!IsJobProcess && !_processRoutine.IsExecuteAbort)//非jobprocess需要recipe结束也需要更新数据库
  1017. {
  1018. var firstPjId = Singleton<EquipmentManager>.Instance.GetFirstPJId();
  1019. Singleton<EquipmentManager>.Instance.EndPj();
  1020. }
  1021. //_statWaferCount.Increase();
  1022. //_statProcessTime.Increase((int)(_processTimer.ElapsedMilliseconds/1000));
  1023. _isPrepareProcess = true;
  1024. IsJobProcess = false;
  1025. SensorPROCManualOK.Value = false;
  1026. //if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "StandbyStep")
  1027. //{
  1028. // StringProcessFlowState = ProcessFlowState.Standby.ToString();
  1029. // _recipeRunningInfo.StepName = "Standby";
  1030. // var standbyStep = _recipeRunningInfo.RecipeStepList.Where(x => x.StepName == "Standby").FirstOrDefault();
  1031. // if (standbyStep != null)
  1032. // {
  1033. // EV.PostInfoLog(Module, $"Recipe {_recipeRunningInfo.RecipeName} complete excute standby step");
  1034. // foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  1035. // {
  1036. // if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out string reason, standbyStep.RecipeCommands[recipeCmd]))
  1037. // {
  1038. // if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1039. // {
  1040. // if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1041. // {
  1042. // reason = $"Can not execute {recipeCmd}, {reason}";
  1043. // return false;
  1044. // }
  1045. // else
  1046. // {
  1047. // OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1048. // }
  1049. // }
  1050. // else
  1051. // {
  1052. // OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1053. // }
  1054. // }
  1055. // else
  1056. // {
  1057. // OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1058. // }
  1059. // }
  1060. // }
  1061. // _isStandbyStep = true;
  1062. // IsExcuteIdleRecipe = false;
  1063. //}
  1064. //else if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "IdleRecipe")
  1065. //{
  1066. // if (!IsExcuteIdleRecipe)
  1067. // {
  1068. // PostMsg((int)MSG.RunIdleRecipe);
  1069. // IsExcuteIdleRecipe = true;
  1070. // }
  1071. // else
  1072. // {
  1073. // IsExcuteIdleRecipe = false;
  1074. // _isStandbyStep = false;
  1075. // }
  1076. //}
  1077. //else
  1078. //{
  1079. // IsExcuteIdleRecipe = false;
  1080. // _isStandbyStep = false;
  1081. //}
  1082. return true;
  1083. }
  1084. private bool FsmStartContinue(object[] param)
  1085. {
  1086. return true;
  1087. }
  1088. private bool FsmSkipStep(object[] param)
  1089. {
  1090. _processRoutine.SkipCurrentRecipeStep();
  1091. return true;
  1092. }
  1093. private bool FsmJumpStep(object[] param)
  1094. {
  1095. int.TryParse(param[0].ToString(), out int stepNumber);
  1096. _processRoutine.JumpCurrentRecipeStep(stepNumber, param[1].ToString());
  1097. return true;
  1098. }
  1099. private bool FsmRecipePause(object[] param)
  1100. {
  1101. _processRoutine.PauseRecipe();
  1102. return true;
  1103. }
  1104. private bool FsmRecipeContinue(object[] param)
  1105. {
  1106. _processRoutine.ContinueRecipe();
  1107. return true;
  1108. }
  1109. private bool FsmRecipeAbort(object[] param)
  1110. {
  1111. Singleton<EquipmentManager>.Instance.EndPj("AbnormalEnd");
  1112. var firstPjId = Singleton<EquipmentManager>.Instance.GetFirstPJId();
  1113. _processRoutine.UpdateProcessDataPJid(firstPjId);
  1114. _processRoutine.Abort();
  1115. IsWait = false;
  1116. IsJobProcess = false;
  1117. var recipeName = _recipeRunningInfo.Head.AbortRecipe;
  1118. var reason = "";
  1119. if (!File.Exists($"{PathManager.GetRecipeDir()}\\{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\Abort\\{recipeName}.rcp") ||
  1120. !RecipeParser.Parse(recipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out reason, "Abort"))
  1121. {
  1122. recipeName = SC.GetStringValue("System.Recipe.Abort Recipe");
  1123. if (!File.Exists($"{PathManager.GetRecipeDir()}\\{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\Abort\\{recipeName}.rcp") ||
  1124. !RecipeParser.Parse(SC.GetStringValue("System.Recipe.Abort Recipe"), ModuleName.PM1.ToString(), out recipeHead, out recipeSteps, out reason, "Abort"))
  1125. {
  1126. PostMsg(MSG.Error);
  1127. ExecuteAbortRecipeFailAlarm.Set($"Load abort recipe {recipeName} failed, {reason}");
  1128. return false;
  1129. }
  1130. }
  1131. var recipeType = recipeSteps.Count > 0 ? recipeSteps[0].RecipeType : string.Empty;
  1132. var recipeTable = "";
  1133. if (!string.IsNullOrEmpty(_recipeRunningInfo.Head.AbortRecipe))
  1134. {
  1135. var currectStep = _recipeRunningInfo.RecipeStepList[_processRoutine._currentStepNumber];
  1136. if (string.IsNullOrEmpty(currectStep.AbortRecipeTableInfo))
  1137. {
  1138. if (!RecipeParser.ParseTables(_recipeRunningInfo.Head.AbortRecipe, Module, out var recipeData, out reason, "Abort"))
  1139. {
  1140. ExecuteAbortRecipeFailAlarm.Set($"Load abort recipe {recipeName} failed, {reason}");
  1141. return false;
  1142. }
  1143. else
  1144. {
  1145. recipeTable = recipeData.FirstOrDefault().Key.ToString();
  1146. }
  1147. }
  1148. else
  1149. {
  1150. recipeTable = currectStep.AbortRecipeTableInfo.Split(':').FirstOrDefault();
  1151. }
  1152. }
  1153. else
  1154. {
  1155. if (!RecipeParser.ParseTables(SC.GetStringValue("System.Recipe.Abort Recipe"), Module, out var recipeData, out reason, "Abort"))
  1156. {
  1157. ExecuteAbortRecipeFailAlarm.Set($"Load abort recipe {recipeName} failed, {reason}");
  1158. return false;
  1159. }
  1160. else
  1161. {
  1162. recipeTable = recipeData.FirstOrDefault().Key.ToString();
  1163. }
  1164. }
  1165. RecipeExecEntryEnumValue = RecipeExecEntryEnum.AbortRecipeTrigger;
  1166. CheckToPostMessage((int)MSG.RunOtherRecipe, recipeName, recipeType, recipeTable);
  1167. return true;
  1168. }
  1169. private bool FsmStartPostProcess(object[] param)
  1170. {
  1171. Result ret = StartRoutine(_postprocessRoutine);
  1172. if (ret == Result.FAIL || ret == Result.DONE)
  1173. return false;
  1174. return ret == Result.RUN;
  1175. }
  1176. private bool ExitPostProcess(object[] param)
  1177. {
  1178. return true;
  1179. }
  1180. private bool FsmStartMFCCalibration(object[] param)
  1181. {
  1182. return true;
  1183. }
  1184. private bool FsmOnDisconnect(object[] param)
  1185. {
  1186. if (FsmState == (int)STATE.Error)
  1187. {
  1188. return false;
  1189. }
  1190. return true;
  1191. }
  1192. private bool FsmOnError(object[] param)
  1193. {
  1194. if (FsmState == (int)STATE.Error)
  1195. {
  1196. return false;
  1197. }
  1198. if ((FsmState == (int)STATE.Process) || (FsmState == (int)STATE.PreProcess) || (FsmState == (int)STATE.PostProcess))
  1199. {
  1200. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  1201. {
  1202. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  1203. continue;
  1204. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.Failed);
  1205. }
  1206. _processRoutine.Abort();
  1207. _postprocessRoutine.Abort();
  1208. _preprocessRoutine.Abort();
  1209. IsWait = false;
  1210. }
  1211. return true;
  1212. }
  1213. private bool FsmReset(object[] param)
  1214. {
  1215. if (!_isInit)
  1216. {
  1217. PostMsg(MSG.ToInit);
  1218. return false;
  1219. }
  1220. foreach (var device in _allModuleDevice)
  1221. {
  1222. if (device.HasAlarm)
  1223. {
  1224. CheckHasAlarmWarning.Set($"{device.Name} has error");
  1225. }
  1226. }
  1227. if (CheckHasAlarm())
  1228. return false;
  1229. return true;
  1230. }
  1231. private bool FsmStartHome(object[] param)
  1232. {
  1233. //if (!CheckIsConnected())
  1234. //{
  1235. // PostMsg(MSG.Disconnected);
  1236. // return false;
  1237. //}
  1238. if (CheckHasAlarm())
  1239. {
  1240. CheckHasAlarmWarning.Set($"There exist active alarm, reset error before continue the initialization");
  1241. PostMsg(MSG.Error);
  1242. return false;
  1243. }
  1244. Result ret = StartRoutine(_homeRoutine);
  1245. if (ret == Result.FAIL || ret == Result.DONE)
  1246. return false;
  1247. _isInit = false;
  1248. return ret == Result.RUN;
  1249. }
  1250. private bool FsmExitHome(object[] param)
  1251. {
  1252. return true;
  1253. }
  1254. private bool FsmEnterHome(object[] param)
  1255. {
  1256. return true;
  1257. }
  1258. private bool FsmAbortTask(object[] param)
  1259. {
  1260. AbortRoutine();
  1261. _isPrepareProcess = true;
  1262. return true;
  1263. }
  1264. private bool FsmMonitorHomeTask(object[] param)
  1265. {
  1266. Result ret = MonitorRoutine();
  1267. if (ret == Result.FAIL)
  1268. {
  1269. PostMsg(MSG.Error);
  1270. return false;
  1271. }
  1272. if (ret == Result.DONE)
  1273. {
  1274. _isInit = true;
  1275. return true;
  1276. }
  1277. return false;
  1278. }
  1279. private bool FsmMonitorTask(object[] param)
  1280. {
  1281. Result ret = MonitorRoutine();
  1282. if (ret == Result.FAIL)
  1283. {
  1284. PostMsg(MSG.Error);
  1285. return false;
  1286. }
  1287. if (ret == Result.DONE && FsmState == (int)STATE.PreProcess)
  1288. {
  1289. PostMsg(MSG.Process);
  1290. return true;
  1291. }
  1292. if (ret == Result.DONE && FsmState == (int)STATE.Process)
  1293. {
  1294. PostMsg(MSG.PostProcess);
  1295. return true;
  1296. }
  1297. if (ret == Result.DONE && IsExcuteIdleRecipe && FsmState == (int)STATE.PostProcess)
  1298. {
  1299. PostMsg(MSG.RunIdleRecipe);
  1300. return true;
  1301. }
  1302. return ret == Result.DONE;
  1303. }
  1304. #region Service functions
  1305. public override bool Home(out string reason)
  1306. {
  1307. CheckToPostMessage((int)MSG.Home);
  1308. reason = string.Empty;
  1309. return true;
  1310. }
  1311. public override void Reset()
  1312. {
  1313. ResetAUXTrig();
  1314. if (!IsProcessing)
  1315. CheckToPostMessage((int)MSG.Reset);
  1316. }
  1317. public override bool PrepareTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1318. {
  1319. CheckToPostMessage((int)MSG.PrepareTransfer, transferType.ToString());
  1320. reason = string.Empty;
  1321. return true;
  1322. }
  1323. public override bool TransferHandoff(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1324. {
  1325. reason = string.Empty;
  1326. return true;
  1327. }
  1328. public override bool PostTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1329. {
  1330. CheckToPostMessage((int)MSG.PostTransfer, transferType.ToString());
  1331. reason = string.Empty;
  1332. return true;
  1333. }
  1334. public override bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1335. {
  1336. reason = string.Empty;
  1337. var boat = Singleton<EquipmentManager>.Instance.Modules[ModuleName.Boat] as BoatModule;
  1338. if (!boat.IsBoatElevatorAtHomePosition)
  1339. {
  1340. reason = "Boat z axis is not at home position";
  1341. return false;
  1342. }
  1343. if (!boat.IsBoatRotationAtHomePosition)
  1344. {
  1345. reason = "Boat r axis is not at home position";
  1346. return false;
  1347. }
  1348. return true;
  1349. }
  1350. public override void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1351. {
  1352. //if (FsmState == (int)STATE.InTransfer)
  1353. // CheckToPostMessage(MSG.Transfer)
  1354. }
  1355. public override void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1356. {
  1357. //if (FsmState == (int)STATE.InTransfer)
  1358. // CheckToPostMessage(MSG.Transfer)
  1359. }
  1360. public override bool Process(string recipeName, bool isCleanRecipe, bool withWafer, out string reason)
  1361. {
  1362. _recipeRunningInfo.RecipeName = recipeName;
  1363. _isPrepareProcess = false;
  1364. _isStandbyStep = false;
  1365. IsJobProcess = true;
  1366. IsExcuteIdleRecipe = false;
  1367. CheckToPostMessage((int)MSG.RunRecipe, recipeName);
  1368. reason = string.Empty;
  1369. return true;
  1370. }
  1371. public override bool Standby(string recipeName, out string reason)
  1372. {
  1373. reason = string.Empty;
  1374. _recipeRunningInfo.RecipeName = recipeName;
  1375. _recipeRunningInfo.MainRecipeName = recipeName;
  1376. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out reason, "Process"))
  1377. {
  1378. reason = $"Load process recipe {_recipeRunningInfo.RecipeName} failed, {reason}";
  1379. return false;
  1380. }
  1381. if (recipeSteps == null || recipeSteps.Count == 0)
  1382. {
  1383. reason = $"Process recipe {_recipeRunningInfo.RecipeName} is empty";
  1384. return false;
  1385. }
  1386. _isStandbyStep = true;
  1387. var standbyStep = recipeSteps.Where(x => x.StepName == "Standby").FirstOrDefault();
  1388. if (standbyStep != null)
  1389. {
  1390. StringProcessFlowState = ProcessFlowState.Standby.ToString();
  1391. _recipeRunningInfo.StepName = "Standby";
  1392. EV.PostInfoLog(Module, $"pj job excute recipe {recipeName} standby step");
  1393. foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  1394. {
  1395. if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1396. {
  1397. if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1398. {
  1399. if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1400. {
  1401. reason = $"Can not execute {recipeCmd}, {reason}";
  1402. return false;
  1403. }
  1404. else
  1405. {
  1406. OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1407. }
  1408. }
  1409. else
  1410. {
  1411. OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1412. }
  1413. }
  1414. else
  1415. {
  1416. OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1417. }
  1418. }
  1419. }
  1420. return true;
  1421. }
  1422. public void EndIdleRecipe()
  1423. {
  1424. CheckToPostMessage((int)MSG.EndIdleRecipe);
  1425. }
  1426. private double GetNewShowTime()
  1427. {
  1428. return GetWaitTime() + _recipeRunningInfo.HoldTime;
  1429. }
  1430. private double GetWaitTime()
  1431. {
  1432. if (StringFsmStatus == "Idle")
  1433. {
  1434. _waitTimer.Reset();
  1435. }
  1436. if (IsWait)
  1437. {
  1438. _waitTimer.Start();
  1439. }
  1440. else
  1441. {
  1442. _waitTimer.Stop();
  1443. }
  1444. return _waitTimer.ElapsedMilliseconds / 1000;
  1445. }
  1446. #region
  1447. #region
  1448. private string _processRecipeStepName = "";
  1449. private string _subRecipeStepName = "";
  1450. private string _subRecipeStepNumber = "";
  1451. private string _currentFilmThickness = "";
  1452. private string _dryClearCount = "";
  1453. /// <summary>
  1454. /// 更新FDC采集的数据
  1455. /// </summary>
  1456. /// <param name="isSub"></param>
  1457. /// <param name="stepName"></param>
  1458. /// <param name="stepNo"></param>
  1459. public void SetFDCRecipeStepName(bool isSub, string stepName, string stepNo = "")
  1460. {
  1461. if (isSub)
  1462. {
  1463. _subRecipeStepName = stepName;
  1464. _subRecipeStepNumber = stepNo;
  1465. }
  1466. else
  1467. {
  1468. _processRecipeStepName = stepName;
  1469. _subRecipeStepName = string.Empty;
  1470. _subRecipeStepNumber = string.Empty;
  1471. }
  1472. }
  1473. #endregion
  1474. public void ResetFDCRecipeStepName()
  1475. {
  1476. _subRecipeStepName = "";
  1477. _subRecipeStepNumber = "";
  1478. _processRecipeStepName = "";
  1479. }
  1480. public void SetCurrentFilmThickness(float value)
  1481. {
  1482. _currentFilmThickness = value.ToString();
  1483. }
  1484. public void SetDryClearCount(float value)
  1485. {
  1486. _dryClearCount = value.ToString();
  1487. }
  1488. public void FDCSubscribe()
  1489. {
  1490. DATA.Subscribe($"DryClearCount", () => _dryClearCount);
  1491. DATA.Subscribe($"BoatCurrentFilmThickness", () => _currentFilmThickness);
  1492. DATA.Subscribe($"ProcessRecipeStepName", () => _processRecipeStepName);
  1493. DATA.Subscribe($"SubRecipeStepName", () => _subRecipeStepName);
  1494. DATA.Subscribe($"SubRecipeStepNumber", () => _subRecipeStepNumber);
  1495. }
  1496. #endregion
  1497. #region
  1498. public void CarrierOutStart(CarrierInfo carrier)
  1499. {
  1500. List<string> crids = CarrierManager.Instance.GetBufferMaterialInfo();
  1501. SECsDataItem BufferMaterialInfos = new SECsDataItem(SECsFormat.List);
  1502. SECsDataItem BufferMaterialInfo = new SECsDataItem(SECsFormat.List);
  1503. foreach (var _id in crids)
  1504. {
  1505. BufferMaterialInfo = new SECsDataItem(SECsFormat.List);
  1506. BufferMaterialInfo.Add("StockerName", _id.Split(';')[0], SECsFormat.Ascii);
  1507. BufferMaterialInfo.Add("StockerCarrierID", _id.Split(';')[1].Replace("emptyid", ""), SECsFormat.Ascii);
  1508. BufferMaterialInfos.Add(BufferMaterialInfo);
  1509. }
  1510. if (carrier != null)
  1511. {
  1512. EV.Notify(UniversalEvents.CarrierOutStart, new SerializableDictionary<string, object>()
  1513. {
  1514. {DataVariables.Usage, carrier.CarrierType.ToString()},
  1515. {DataVariables.CarrierID, carrier.CarrierId},
  1516. {DataVariables.BufferCapacitiyList, GetBufferCapacitiyList()},
  1517. {DataVariables.BufferMaterialInfo, BufferMaterialInfos},
  1518. });
  1519. }
  1520. }
  1521. private SECsDataItem GetBufferCapacitiyList()
  1522. {
  1523. SECsDataItem bufinfo = new SECsDataItem(SECsFormat.List);
  1524. bufinfo.Add("BUFPara", "Partition1");
  1525. bufinfo.Add("BUFPara", "General");
  1526. int emptyStocker = 0;
  1527. int totalStocker = 0;
  1528. foreach (var key in Singleton<EquipmentManager>.Instance.Modules.Keys)
  1529. {
  1530. if (ModuleHelper.IsStocker(key))
  1531. totalStocker++;
  1532. if (ModuleHelper.IsStocker(key) && CarrierManager.Instance.CheckNoCarrier(key, 0))
  1533. {
  1534. var has = false;
  1535. foreach (var key1 in Singleton<EquipmentManager>.Instance.Modules.Keys)
  1536. {
  1537. if (CarrierManager.Instance.CheckHasCarrier(key1, 0) && CarrierManager.Instance.GetCarrier(key1, 0).InternalModuleName == key)
  1538. {
  1539. has = true;
  1540. break;
  1541. }
  1542. }
  1543. if (has)
  1544. continue;
  1545. emptyStocker++;
  1546. }
  1547. }
  1548. bufinfo.Add("BUFPara", emptyStocker, SECsFormat.U1);
  1549. bufinfo.Add("BUFPara", totalStocker, SECsFormat.U1);
  1550. int unallocatedPartitionCapacity = 0;
  1551. List<ModuleName> checkList = new List<ModuleName>()
  1552. {
  1553. ModuleName.LP1,
  1554. ModuleName.LP2,
  1555. ModuleName.FIMS1,
  1556. ModuleName.FIMS2,
  1557. };
  1558. foreach (var module in checkList)
  1559. {
  1560. if (CarrierManager.Instance.CheckHasCarrier(module, 0))
  1561. unallocatedPartitionCapacity++;
  1562. }
  1563. bufinfo.Add("BUFPara", unallocatedPartitionCapacity, SECsFormat.U1);
  1564. return bufinfo;
  1565. }
  1566. public void CarrierOutEnd(CarrierInfo carrier)
  1567. {
  1568. List<string> crids = CarrierManager.Instance.GetBufferMaterialInfo();
  1569. SECsDataItem BufferMaterialInfos = new SECsDataItem(SECsFormat.List);
  1570. SECsDataItem BufferMaterialInfo = new SECsDataItem(SECsFormat.List);
  1571. foreach (var _id in crids)
  1572. {
  1573. BufferMaterialInfo = new SECsDataItem(SECsFormat.List);
  1574. BufferMaterialInfo.Add("StockerName", _id.Split(';')[0], SECsFormat.Ascii);
  1575. BufferMaterialInfo.Add("StockerCarrierID", _id.Split(';')[1].Replace("emptyid", ""), SECsFormat.Ascii);
  1576. BufferMaterialInfos.Add(BufferMaterialInfo);
  1577. }
  1578. if (carrier != null)
  1579. {
  1580. EV.Notify(UniversalEvents.CarrierOutEnd, new SerializableDictionary<string, object>()
  1581. {
  1582. {DataVariables.Usage, carrier.CarrierType.ToString()},
  1583. {DataVariables.BufferCapacitiyList, GetBufferCapacitiyList()},
  1584. {DataVariables.BufferMaterialInfo, BufferMaterialInfos},
  1585. {DataVariables.CarrierID, carrier.CarrierId},
  1586. });
  1587. }
  1588. }
  1589. #endregion
  1590. }
  1591. #endregion
  1592. }