PMModule.cs 63 KB

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