PMModule.cs 69 KB

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