PMModule.cs 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591
  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}.IsCEXHOn", () => _isCEXHOn);
  300. DATA.Subscribe($"{Module}.IsF2ClnOn", () =>
  301. {
  302. return IsF2ClnOn;
  303. });
  304. DATA.Subscribe($"{Module}.IsHFClnOn", () =>
  305. {
  306. return IsHFClnOn;
  307. });
  308. DATA.Subscribe($"{Module}.IsDEPOOn", () => TrigDEPOSW != null ? TrigDEPOSW.Value : false);
  309. DATA.Subscribe($"{Module}.IsCREFOn", () => TrigCREFON != null ? TrigCREFON.Value : false);
  310. DATA.Subscribe($"{Module}.IsSIREFOn", () => TrigSIREFON != null ? TrigSIREFON.Value : false);
  311. DATA.Subscribe($"{Module}.MFCList", () =>
  312. {
  313. List<AITMfcData> aITMfcDataList = new List<AITMfcData>();
  314. var mfcs = DEVICE.GetDevice<PMs.Devices.IoMFC>();
  315. if (mfcs != null)
  316. {
  317. foreach (var item in mfcs)
  318. {
  319. if (item == null) continue;
  320. if (item.IsMFCInstalled)
  321. {
  322. aITMfcDataList.Add(item.DeviceData);
  323. }
  324. }
  325. }
  326. return aITMfcDataList;
  327. });
  328. InitOtherData();
  329. InitN2PurgeData();
  330. }
  331. private void InitStats()
  332. {
  333. _statTubeCleanNumber = new StatsData($"{Module}.Tube Clean Number", "Tube clean number", 0);
  334. _statTubeCleanTime = new StatsData($"{Module}.Tube Clean Time", "Tube clean time(Min)", 0);
  335. _statTubeCleanThick = new StatsData($"{Module}.Tube Clean thick", "Tube clean thick(nm)", 0);
  336. _statBoatCleanNumber = new StatsData($"{Module}.Boat Clean Number", "Boat clean number", 0);
  337. _statBoatCleanTime = new StatsData($"{Module}.Boat Clean Time", "Boat clean time(Min)", 0);
  338. _statBoatCleanThick = new StatsData($"{Module}.Boat Clean thick", "Boat clean thick(nm)", 0);
  339. _statForkCleanNumber = new StatsData($"{Module}.Fork Clean Number", "Fork clean number", 0);
  340. _statForkCleanTime = new StatsData($"{Module}.Fork Clean Time", "Fork clean time(Min)", 0);
  341. _statBoatCleanThick = new StatsData($"{Module}.Boat Clean thick", "Boat clean thick(nm)", 0);
  342. _statForkCleanThick = new StatsData($"{Module}.Fork Clean thick", "Fork clean thick", 0);
  343. }
  344. private void InitOp()
  345. {
  346. OP.Subscribe($"{Module}.Home", (string cmd, object[] args) =>
  347. {
  348. if (!(Singleton<EquipmentManager>.Instance.Modules[ModuleName.WaferRobot] as IModuleDevice).IsReady)
  349. {
  350. TubeHomeFailedWarning.Set($"Wafer Robot is not in ilde state, init failed.");
  351. return false;
  352. }
  353. return CheckToPostMessage((int)MSG.Home);
  354. });
  355. OP.Subscribe($"{Module}.Reset", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Reset));
  356. OP.Subscribe($"{Module}.Abort", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Abort));
  357. OP.Subscribe($"{Module}.PutOnline", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SetOnline));
  358. OP.Subscribe($"{Module}.PutOffline", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SetOffline));
  359. OP.Subscribe($"{Name}.SelectRecipe", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SelectRecipe, args[0]));
  360. OP.Subscribe($"{Name}.RunRecipe", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RunRecipe, (string)args[0]));
  361. OP.Subscribe($"{Name}.RecipeSkipStep", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeSkipStep));
  362. OP.Subscribe($"{Name}.RecipeJumpStep", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeJumpStep, args[0], args[1]));
  363. OP.Subscribe($"{Name}.RecipePause", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipePause));
  364. OP.Subscribe($"{Name}.RecipeContinue", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeContinue));
  365. OP.Subscribe($"{Name}.RecipeAbort", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeAbort));
  366. OP.Subscribe($"{Name}.RecipeIdle", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RunIdleRecipe));
  367. OP.Subscribe($"{Name}.LeakCheck", (string cmd, object[] args) => CheckToPostMessage((int)MSG.LeakCheck, args[0], args[1], args[2], args[3]));
  368. OP.Subscribe($"{Name}.Wait", (string cmd, object[] args) =>
  369. {
  370. IsWait = !IsWait;
  371. return true;
  372. });
  373. OP.Subscribe($"{Module}.AlarmAction", (string cmd, object[] args) =>
  374. {
  375. Enum.TryParse(args[0].ToString(), out AlarmAction alarmAction);
  376. string eventName = null;
  377. if (args.Length > 1)
  378. eventName = args[1].ToString();
  379. if (eventName != null)
  380. {
  381. EV.ClearAlarmEvent(eventName);
  382. var item = _triggeredAlarmList.FirstOrDefault(x => x.EventEnum == eventName);
  383. if (item != null)
  384. {
  385. item.Reset();
  386. _triggeredAlarmList.Remove(item);
  387. }
  388. if (item != null)
  389. {
  390. switch (alarmAction)
  391. {
  392. case AlarmAction.Retry:
  393. {
  394. CheckToPostMessage((int)item.RetryMessage, item.RetryMessageParas);
  395. }
  396. break;
  397. case AlarmAction.Abort:
  398. {
  399. CheckToPostMessage((int)MSG.Abort);
  400. }
  401. break;
  402. case AlarmAction.Clear:
  403. {
  404. int alarmCount = 0;
  405. var alarms = EV.GetAlarmEvent();
  406. foreach (var alarm in alarms)
  407. {
  408. if (alarm.Level == EventLevel.Alarm && alarm.Source == Name)
  409. alarmCount++;
  410. }
  411. if (alarmCount == 0 && !IsProcessing)
  412. {
  413. CheckToPostMessage((int)MSG.Reset);
  414. _alarmNumber = 0;
  415. }
  416. }
  417. break;
  418. case AlarmAction.Continue:
  419. {
  420. int alarmCount = 0;
  421. var alarms = EV.GetAlarmEvent();
  422. foreach (var alarm in alarms)
  423. {
  424. if (alarm.Level == EventLevel.Alarm && alarm.Source == Name)
  425. alarmCount++;
  426. }
  427. if (alarmCount == 0)
  428. CheckToPostMessage((int)MSG.Reset);
  429. }
  430. break;
  431. case AlarmAction.ClearAll:
  432. ResetAUXTrig();
  433. break;
  434. }
  435. }
  436. }
  437. return true;
  438. });
  439. OP.Subscribe($"{Name}.SetConditionCheck", SetConditionCheck);
  440. OP.Subscribe($"{Name}.SetBoatZAxisMotion", SetBoatZAxisMotion);
  441. OP.Subscribe($"{Name}.SetBoatRAxisMotion", SetBoatRAxisMotion);
  442. OP.Subscribe($"{Name}.SetAutoShutterUp", SetAutoShutterUp);
  443. OP.Subscribe($"{Name}.SetAutoShutterOpen", SetAutoShutterOpen);
  444. OP.Subscribe($"{Name}.SetAutoShutterRotateOpen", SetAutoShutterRotateOpen);
  445. OP.Subscribe($"{Name}.BypassStandbyFactor", SeBypassStandbyFactor);
  446. OP.Subscribe($"{Name}.SetCommand", SetCommand);
  447. OP.Subscribe($"{Name}.SetN2PurgeMode", SetN2PurgeMode);
  448. //OP.Subscribe($"{Name}.SetTemperatureDetail",)
  449. OP.Subscribe($"{Name}.SetSensorRecipeOK", SetSensorRecipeOK);
  450. OP.Subscribe($"{Name}.SetSensorPROCManualOK", SetSensorPROCManualOK);
  451. OP.Subscribe($"{Name}.SetEditRecipeName", SetEditRecipeName);
  452. OP.Subscribe($"{Name}.SetEditRecipeStepName", SetEditRecipeStepName);
  453. OP.Subscribe($"{Name}.Heater.SetParameters", (out string reason, int time, object[] param) =>
  454. {
  455. reason = string.Empty;
  456. //Mode参数;Correct Table;PID Table
  457. //"Heater;Parameter\\TempCorrection\\tempCorrect,2,Name2;Parameter\\TempPID\\tempPID,3,Name3"
  458. SetHeaterControlParameters(param);
  459. return true;
  460. });
  461. OP.Subscribe($"{Name}.Heater.SetPID", (out string reason, int time, object[] param) =>
  462. {
  463. reason = string.Empty;
  464. SetHeaterPIDParameters(param[0].ToString());
  465. return true;
  466. });
  467. OP.Subscribe($"{Name}.Heater.SetCorrect", (out string reason, int time, object[] param) =>
  468. {
  469. reason = string.Empty;
  470. SetHeaterCorrectParameters(param[0].ToString());
  471. return true;
  472. });
  473. //Recipe
  474. OP.Subscribe($"{Name}.SetBoatMotion", (out string reason, int time, object[] param) =>
  475. {
  476. reason = string.Empty;
  477. SetBoatMotion(param);
  478. return true;
  479. });
  480. //Recipe
  481. OP.Subscribe($"{Name}.SetValves", (out string reason, int time, object[] param) =>
  482. {
  483. reason = string.Empty;
  484. SetValves(param);
  485. return true;
  486. });
  487. //Recipe
  488. OP.Subscribe($"{Name}.SetAlarmConditionTable", (out string reason, int time, object[] param) =>
  489. {
  490. reason = string.Empty;
  491. SetAlarmConditionTable(param);
  492. return true;
  493. });
  494. //manual
  495. OP.Subscribe($"{Name}.SetAlarmConditionParameter", (out string reason, int time, object[] param) =>
  496. {
  497. reason = string.Empty;
  498. InitAlarmCondition(param[0].ToString());
  499. SetAlarmConditionTable(new object[1] { param[1] });
  500. return true;
  501. });
  502. OP.Subscribe($"{Name}.SetBoatManualMotion", (out string reason, int time, object[] param) =>
  503. {
  504. reason = string.Empty;
  505. SetBoatManualMotion(param);
  506. return true;
  507. });
  508. OP.Subscribe($"{Name}.SetCEXHEnable", (out string reason, int time, object[] param) =>
  509. {
  510. reason = string.Empty;
  511. SetCEXHEnable(param);
  512. return true;
  513. });
  514. OP.Subscribe($"{Name}.SetF2ClnEnable", (out string reason, int time, object[] param) =>
  515. {
  516. reason = string.Empty;
  517. SetF2ClnEnable(param);
  518. return true;
  519. });
  520. OP.Subscribe($"{Name}.SetHFClnEnable", (out string reason, int time, object[] param) =>
  521. {
  522. reason = string.Empty;
  523. SetHFClnEnable(param);
  524. return true;
  525. });
  526. OP.Subscribe($"{Name}.SetDEPOEnable", (out string reason, int time, object[] param) =>
  527. {
  528. reason = string.Empty;
  529. SetDEPOEnable(param);
  530. return true;
  531. });
  532. OP.Subscribe($"{Name}.SetHTR1Enable", (out string reason, int time, object[] param) =>
  533. {
  534. reason = string.Empty;
  535. SetHTR1Enable(param);
  536. return true;
  537. });
  538. OP.Subscribe($"{Name}.SetHTR2Enable", (out string reason, int time, object[] param) =>
  539. {
  540. reason = string.Empty;
  541. SetHTR2Enable(param);
  542. return true;
  543. });
  544. OP.Subscribe($"{Name}.SetHTR3Enable", (out string reason, int time, object[] param) =>
  545. {
  546. reason = string.Empty;
  547. SetHTR3Enable(param);
  548. return true;
  549. });
  550. OP.Subscribe($"{Name}.AUX.SetParameters", (out string reason, int time, object[] param) =>
  551. {
  552. reason = string.Empty;
  553. //Mode参数;Correct Table;PID Table
  554. //"Heater;Parameter\\TempCorrection\\tempCorrect,2,Name2;Parameter\\TempPID\\tempPID,3,Name3"
  555. SetAUXParameters(param);
  556. return true;
  557. });
  558. OP.Subscribe($"{Module}.SetAllMfcVirtualValue", (out string reason, int time, object[] param) =>
  559. {
  560. reason = string.Empty;
  561. var dict = param[0] as Dictionary<string, string>;
  562. foreach (var item in dict)
  563. {
  564. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  565. if (mfc != null)
  566. {
  567. mfc.SetMfcVirtualValue(out reason, 0, new object[] { item.Value });
  568. }
  569. }
  570. return true;
  571. });
  572. OP.Subscribe($"{Module}.SetAllMfcValue", (out string reason, int time, object[] param) =>
  573. {
  574. reason = string.Empty;
  575. var dict = param[0] as Dictionary<string, string>;
  576. foreach (var item in dict)
  577. {
  578. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  579. if (mfc != null)
  580. { mfc.SetMfcValue(out reason, 0, new object[] { item.Value }); }
  581. }
  582. return true;
  583. });
  584. OP.Subscribe($"{Module}.SetAllMfcSetPoint", (out string reason, int time, object[] param) =>
  585. {
  586. reason = string.Empty;
  587. var dict = param[0] as Dictionary<string, string>;
  588. foreach (var item in dict)
  589. {
  590. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  591. if (mfc != null)
  592. { mfc.SetMfcSetPoint(out reason, 0, new object[] { item.Value }); }
  593. }
  594. return true;
  595. });
  596. OP.Subscribe($"{Module}.SetAll{AITValveOperation.GVVirtualTurnValve}", (out string reason, int time, object[] param) =>
  597. {
  598. reason = string.Empty;
  599. var dict = param[0] as Dictionary<string, bool>;
  600. foreach (var item in dict)
  601. {
  602. var valve = _valves.FirstOrDefault(x => x.Name == item.Key);
  603. if (valve != null)
  604. {
  605. valve.InvokeOpenCloseVirtualValve("", new object[] { item.Value });
  606. }
  607. }
  608. return true;
  609. });
  610. OP.Subscribe($"{Module}.SetAll{AITValveOperation.GVTurnValve}", (out string reason, int time, object[] param) =>
  611. {
  612. reason = string.Empty;
  613. var dict = param[0] as Dictionary<string, bool>;
  614. foreach (var item in dict)
  615. {
  616. _valves.FirstOrDefault(x => x.Name == item.Key).InvokeOpenCloseValve("", new object[] { item.Value });
  617. }
  618. return true;
  619. });
  620. OP.Subscribe($"{Name}.SetCREFEnable", (out string reason, int time, object[] param) =>
  621. {
  622. reason = string.Empty;
  623. SetCREFEnable(param);
  624. return true;
  625. });
  626. OP.Subscribe($"{Name}.SetSIREFEnable", (out string reason, int time, object[] param) =>
  627. {
  628. reason = string.Empty;
  629. SetSIREFEnable(param);
  630. return true;
  631. });
  632. InitOtherOP();
  633. }
  634. public void SetTemperatureDetail()
  635. {
  636. }
  637. private void InitFsm()
  638. {
  639. //Error
  640. Transition(STATE.Error, MSG.Reset, FsmReset, STATE.Idle);
  641. AnyStateTransition(MSG.Error, FsmOnError, STATE.Error);
  642. AnyStateTransition(MSG.Disconnected, FsmOnDisconnect, STATE.NotConnected);
  643. EnterExitTransition<STATE, FSM_MSG>(STATE.Error, FsmEnterError, FSM_MSG.NONE, FsmExitError);
  644. Transition(STATE.Idle, MSG.Abort, null, STATE.Idle);
  645. Transition(STATE.Idle, MSG.Reset, null, STATE.Idle);
  646. Transition(STATE.Init, MSG.Reset, null, STATE.Idle);
  647. Transition(STATE.Error, MSG.Abort, null, STATE.Error);
  648. //init
  649. Transition(STATE.Init, MSG.Home, FsmStartHome, STATE.Homing);
  650. AnyStateTransition(MSG.ToInit, FsmToInit, STATE.Init);
  651. //not connected
  652. Transition(STATE.NotConnected, MSG.Connected, null, STATE.Init);
  653. //Home
  654. EnterExitTransition((int)STATE.Homing, FsmEnterHome, (int)FSM_MSG.NONE, FsmExitHome);
  655. Transition(STATE.Error, MSG.Home, FsmStartHome, STATE.Homing);
  656. Transition(STATE.Idle, MSG.Home, FsmStartHome, STATE.Homing);
  657. Transition(STATE.Homing, FSM_MSG.TIMER, FsmMonitorHomeTask, STATE.Idle);
  658. Transition(STATE.Homing, MSG.Error, null, STATE.Init);
  659. Transition(STATE.Homing, MSG.Abort, FsmAbortTask, STATE.Init);
  660. //PrepareTransfer
  661. Transition(STATE.Idle, MSG.PrepareTransfer, FsmStartPrepareTransfer, STATE.PrepareTransfer);
  662. Transition(STATE.PrepareTransfer, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  663. Transition(STATE.PrepareTransfer, MSG.Abort, FsmAbortTask, STATE.Idle);
  664. //PostTransfer
  665. Transition(STATE.InTransfer, MSG.PostTransfer, FsmStartPostTransfer, STATE.PostTransfer);
  666. Transition(STATE.Idle, MSG.PostTransfer, FsmStartPostTransfer, STATE.PostTransfer);
  667. Transition(STATE.PostTransfer, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  668. Transition(STATE.PostTransfer, MSG.Abort, FsmAbortTask, STATE.Idle);
  669. //online
  670. Transition(STATE.Idle, MSG.SetOnline, FsmStartSetOnline, STATE.Idle);
  671. Transition(STATE.Idle, MSG.SetOffline, FsmStartSetOffline, STATE.Idle);
  672. //Leak check
  673. Transition(STATE.Idle, MSG.LeakCheck, FsmStartLeakCheck, STATE.LeakCheck);
  674. Transition(STATE.LeakCheck, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  675. Transition(STATE.LeakCheck, MSG.Abort, FsmAbortTask, STATE.Idle);
  676. EnterExitTransition<STATE, FSM_MSG>(STATE.LeakCheck, FsmEnterLeakCheck, FSM_MSG.NONE, FsmExitLeakCheck);
  677. //open SlitValve
  678. Transition(STATE.Idle, MSG.OpenSlitValve, FsmStartOpenSlitValve, STATE.OpenSlitValve);
  679. Transition(STATE.OpenSlitValve, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  680. Transition(STATE.OpenSlitValve, MSG.Abort, FsmAbortTask, STATE.Idle);
  681. //close SlitValve
  682. Transition(STATE.Idle, MSG.CloseSlitValve, FsmStartCloseSlitValve, STATE.CloseSlitValve);
  683. Transition(STATE.CloseSlitValve, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  684. Transition(STATE.CloseSlitValve, MSG.Abort, FsmAbortTask, STATE.Idle);
  685. //PreProcess
  686. Transition(STATE.Process, MSG.RunIdleRecipe, FsmStartIdleRecipePreProcess, STATE.PreProcess);
  687. Transition(STATE.Process, MSG.RunOtherRecipe, FsmStartOtherRecipePreProcess, STATE.PreProcess);
  688. Transition(STATE.Idle, MSG.RunOtherRecipe, FsmStartOtherRecipePreProcess, STATE.PreProcess);
  689. Transition(STATE.Idle, MSG.SelectRecipe, FsmSelectRecipe, STATE.Idle);
  690. Transition(STATE.Idle, MSG.RunRecipe, FsmStartPreProcess, STATE.PreProcess);
  691. Transition(STATE.PreProcess, FSM_MSG.TIMER, FsmMonitorTask, STATE.PreProcess);
  692. Transition(STATE.PreProcess, MSG.Abort, FsmAbortTask, STATE.Idle);
  693. Transition(STATE.PreProcess, MSG.RecipeAbort, FsmAbortTask, STATE.Idle);
  694. //Process
  695. Transition(STATE.PreProcess, MSG.Process, FsmStartProcess, STATE.Process);
  696. Transition(STATE.Idle, MSG.AlarmConditionJumpStep, FsmStartAlarmConditionJumpStep, STATE.Process);
  697. Transition(STATE.Process, FSM_MSG.TIMER, FsmMonitorTask, STATE.Process);
  698. Transition(STATE.Process, MSG.Abort, FsmAbortTask, STATE.Idle);
  699. Transition(STATE.Process, MSG.EndIdleRecipe, null, STATE.Idle);
  700. EnterExitTransition<STATE, FSM_MSG>(STATE.Process, FsmEnterProcess, FSM_MSG.NONE, FsmExitProcess);
  701. Transition(STATE.Paused, FSM_MSG.TIMER, FsmMonitorTask, STATE.Paused);
  702. Transition(STATE.Paused, MSG.Continue, FsmStartContinue, STATE.Process);
  703. Transition(STATE.Paused, MSG.Error, null, STATE.Paused);
  704. Transition(STATE.Paused, MSG.Abort, FsmAbortTask, STATE.Idle);
  705. //Transition(STATE.Paused, MSG.Error, null, STATE.Paused);
  706. Transition(STATE.Process, MSG.RecipeSkipStep, FsmSkipStep, STATE.Process);
  707. Transition(STATE.Process, MSG.RecipeJumpStep, FsmJumpStep, STATE.Process);
  708. Transition(STATE.Process, MSG.RecipePause, FsmRecipePause, STATE.Process);
  709. Transition(STATE.Process, MSG.RecipeContinue, FsmRecipeContinue, STATE.Process);
  710. Transition(STATE.Process, MSG.RecipeAbort, FsmRecipeAbort, STATE.Process);
  711. //PostProcess
  712. Transition(STATE.Process, MSG.PostProcess, FsmStartPostProcess, STATE.PostProcess);
  713. Transition(STATE.PostProcess, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  714. Transition(STATE.PostProcess, MSG.Abort, FsmAbortTask, STATE.Idle);
  715. EnterExitTransition<STATE, FSM_MSG>(STATE.PostProcess, null, FSM_MSG.NONE, ExitPostProcess);
  716. //MFC Calibration
  717. Transition(STATE.Idle, MSG.StartMFCCalibration, FsmStartMFCCalibration, STATE.MFCCali);
  718. Transition(STATE.MFCCali, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  719. Transition(STATE.MFCCali, MSG.Abort, FsmAbortTask, STATE.Idle);
  720. }
  721. private bool FsmToInit(object[] param)
  722. {
  723. return true;
  724. }
  725. private bool FsmExitError(object[] param)
  726. {
  727. return true;
  728. }
  729. private bool FsmEnterError(object[] param)
  730. {
  731. if (OnEnterError != null)
  732. OnEnterError(Module);
  733. if (IsOnline)
  734. {
  735. //EV.PostWarningLog(Module, $"{Module}");
  736. }
  737. return true;
  738. }
  739. private bool FsmStartPostTransfer(object[] param)
  740. {
  741. _postTransferRoutine.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]));
  742. Result ret = StartRoutine(_postTransferRoutine);
  743. if (ret == Result.FAIL || ret == Result.DONE)
  744. return false;
  745. return ret == Result.RUN;
  746. }
  747. private bool FsmStartPrepareTransfer(object[] param)
  748. {
  749. _prepareTransferRoutine.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]));
  750. Result ret = StartRoutine(_prepareTransferRoutine);
  751. if (ret == Result.FAIL || ret == Result.DONE)
  752. return false;
  753. return ret == Result.RUN;
  754. }
  755. private bool FsmStartSetOffline(object[] param)
  756. {
  757. IsOnline = false;
  758. return true;
  759. }
  760. private bool FsmStartSetOnline(object[] param)
  761. {
  762. IsOnline = true;
  763. return true;
  764. }
  765. private bool FsmStartLeakCheck(object[] param)
  766. {
  767. _leakCheckRoutine.Init((int)param[0], (int)param[1], (string)param[2], (bool[])param[3]);
  768. Result ret = StartRoutine(_leakCheckRoutine);
  769. if (ret == Result.FAIL || ret == Result.DONE)
  770. return false;
  771. return ret == Result.RUN;
  772. }
  773. private bool FsmEnterLeakCheck(object[] param)
  774. {
  775. return true;
  776. }
  777. private bool FsmExitLeakCheck(object[] param)
  778. {
  779. //ChamberProcessPressureGauge.UnsetTuning();
  780. return true;
  781. }
  782. private bool FsmStartOpenSlitValve(object[] param)
  783. {
  784. return true;
  785. }
  786. private bool FsmStartCloseSlitValve(object[] param)
  787. {
  788. return true;
  789. }
  790. private bool FsmSelectRecipe(object[] param)
  791. {
  792. return true;
  793. }
  794. private bool FsmStartPreProcess(object[] param)
  795. {
  796. _recipeRunningInfo.RecipeName = (string)param[0];
  797. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, "Process"))
  798. {
  799. PreprocessStartFailedWarning.Set($"Load process recipe {_recipeRunningInfo.RecipeName} failed, {reason}");
  800. return false;
  801. }
  802. if (recipeSteps == null || recipeSteps.Count == 0)
  803. {
  804. PreprocessStartFailedWarning.Set($"Process recipe {_recipeRunningInfo.RecipeName} is empty");
  805. return false;
  806. }
  807. string abortRecipeName = SC.ContainsItem("System.Recipe.Abort Recipe") ? SC.GetStringValue("System.Recipe.Abort Recipe") : string.Empty;
  808. if (string.IsNullOrEmpty(abortRecipeName))
  809. {
  810. PreprocessStartFailedWarning.Set($"Load abort recipe failed, recipe file is null");
  811. return false;
  812. }
  813. SC.SetItemValueFromString("PM1.ProcessRecipe", _recipeRunningInfo.RecipeName);
  814. if (!IsJobProcess)
  815. Singleton<EquipmentManager>.Instance.CreatePj((string)param[0]);
  816. _preprocessRoutine.Init((string)param[0]);
  817. Result ret = StartRoutine(_preprocessRoutine);
  818. if (ret == Result.FAIL || ret == Result.DONE)
  819. return false;
  820. if (!IsJobProcess)
  821. SensorPROCManualOK.Value = true;
  822. return ret == Result.RUN;
  823. }
  824. private bool FsmStartOtherRecipePreProcess(object[] param)
  825. {
  826. _recipeRunningInfo.RecipeName = param[0].ToString();
  827. var recipeType = param[1].ToString();
  828. var tableID = 1;
  829. if (param.Length > 2)
  830. int.TryParse(param[2].ToString(), out tableID);
  831. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, recipeType, tableID))
  832. {
  833. PreprocessStartFailedWarning.Set($"Load {recipeType} recipe {_recipeRunningInfo.RecipeName} failed {reason}");
  834. return false;
  835. }
  836. if (recipeSteps == null || recipeSteps.Count == 0)
  837. {
  838. PreprocessStartFailedWarning.Set($"{recipeType} recipe {_recipeRunningInfo.RecipeName} is empty");
  839. return false;
  840. }
  841. if (!IsJobProcess)
  842. Singleton<EquipmentManager>.Instance.CreatePj(_recipeRunningInfo.RecipeName);
  843. _preprocessRoutine.Init(_recipeRunningInfo.RecipeName, false);
  844. RecipeRunningInfo.MainRecipeName = _recipeRunningInfo.RecipeName;
  845. RecipeRunningInfo.Head = recipeHead;
  846. RecipeRunningInfo.RecipeStepList = recipeSteps;
  847. Result ret = StartRoutine(_preprocessRoutine);
  848. if (ret == Result.FAIL || ret == Result.DONE)
  849. return false;
  850. if (!IsJobProcess)
  851. SensorPROCManualOK.Value = true;
  852. return ret == Result.RUN;
  853. }
  854. private bool FsmStartIdleRecipePreProcess(object[] param)
  855. {
  856. if (!CheckBoatState())
  857. {
  858. PreprocessStartFailedWarning.Set($"boat is not ready");
  859. return false;
  860. }
  861. _recipeRunningInfo.RecipeName = SC.ContainsItem("System.Recipe.Idle Recipe") ? SC.GetStringValue("System.Recipe.Idle Recipe") : string.Empty;
  862. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, "Idle"))
  863. {
  864. PreprocessStartFailedWarning.Set($"Load idle recipe {_recipeRunningInfo.RecipeName} failed {reason}");
  865. return false;
  866. }
  867. if (recipeSteps == null || recipeSteps.Count == 0)
  868. {
  869. PreprocessStartFailedWarning.Set($"Process recipe {_recipeRunningInfo.RecipeName} is empty");
  870. return false;
  871. }
  872. if (!IsJobProcess)
  873. Singleton<EquipmentManager>.Instance.CreatePj(_recipeRunningInfo.RecipeName);
  874. _preprocessRoutine.Init(_recipeRunningInfo.RecipeName, false);
  875. RecipeRunningInfo.MainRecipeName = _recipeRunningInfo.RecipeName;
  876. RecipeRunningInfo.Head = recipeHead;
  877. RecipeRunningInfo.RecipeStepList = recipeSteps;
  878. Result ret = StartRoutine(_preprocessRoutine);
  879. if (ret == Result.FAIL || ret == Result.DONE)
  880. return false;
  881. if (!IsJobProcess)
  882. SensorPROCManualOK.Value = true;
  883. return ret == Result.RUN;
  884. }
  885. private bool FsmStartProcess(object[] param)
  886. {
  887. Result ret = StartRoutine(_processRoutine);
  888. if (ret == Result.FAIL || ret == Result.DONE)
  889. return false;
  890. if (ret == Result.RUN && !IsJobProcess)
  891. Singleton<EquipmentManager>.Instance.StartPj();
  892. return ret == Result.RUN;
  893. }
  894. private bool FsmStartAlarmConditionJumpStep(object[] param)
  895. {
  896. if (param != null && param.Length > 0)
  897. {
  898. int.TryParse(param[0].ToString(), out int jumpStep);
  899. _processRoutine.AlarmConditionJumpStep = jumpStep;
  900. Result ret = StartRoutine(_processRoutine);
  901. if (ret == Result.FAIL || ret == Result.DONE)
  902. return false;
  903. return ret == Result.RUN;
  904. }
  905. return false;
  906. }
  907. private bool FsmEnterProcess(object[] param)
  908. {
  909. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  910. {
  911. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  912. continue;
  913. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.InProcess);
  914. }
  915. _processTimer.Restart();
  916. return true;
  917. }
  918. private bool FsmExitProcess(object[] param)
  919. {
  920. _processRoutine.ExitProcess();
  921. if (!IsJobProcess && !_processRoutine.IsExecuteAbort)//非jobprocess需要recipe结束也需要更新数据库
  922. {
  923. var firstPjId = Singleton<EquipmentManager>.Instance.GetFirstPJId();
  924. Singleton<EquipmentManager>.Instance.EndPj();
  925. _processRoutine.UpdateProcessDataPJid(firstPjId);
  926. }
  927. //_statWaferCount.Increase();
  928. //_statProcessTime.Increase((int)(_processTimer.ElapsedMilliseconds/1000));
  929. _isPrepareProcess = true;
  930. IsJobProcess = false;
  931. SensorPROCManualOK.Value = false;
  932. //if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "StandbyStep")
  933. //{
  934. // StringProcessFlowState = ProcessFlowState.Standby.ToString();
  935. // _recipeRunningInfo.StepName = "Standby";
  936. // var standbyStep = _recipeRunningInfo.RecipeStepList.Where(x => x.StepName == "Standby").FirstOrDefault();
  937. // if (standbyStep != null)
  938. // {
  939. // EV.PostInfoLog(Module, $"Recipe {_recipeRunningInfo.RecipeName} complete excute standby step");
  940. // foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  941. // {
  942. // if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out string reason, standbyStep.RecipeCommands[recipeCmd]))
  943. // {
  944. // if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  945. // {
  946. // if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  947. // {
  948. // reason = $"Can not execute {recipeCmd}, {reason}";
  949. // return false;
  950. // }
  951. // else
  952. // {
  953. // OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  954. // }
  955. // }
  956. // else
  957. // {
  958. // OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  959. // }
  960. // }
  961. // else
  962. // {
  963. // OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  964. // }
  965. // }
  966. // }
  967. // _isStandbyStep = true;
  968. // IsExcuteIdleRecipe = false;
  969. //}
  970. //else if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "IdleRecipe")
  971. //{
  972. // if (!IsExcuteIdleRecipe)
  973. // {
  974. // PostMsg((int)MSG.RunIdleRecipe);
  975. // IsExcuteIdleRecipe = true;
  976. // }
  977. // else
  978. // {
  979. // IsExcuteIdleRecipe = false;
  980. // _isStandbyStep = false;
  981. // }
  982. //}
  983. //else
  984. //{
  985. // IsExcuteIdleRecipe = false;
  986. // _isStandbyStep = false;
  987. //}
  988. return true;
  989. }
  990. public string GetN2PurgeModeEnumByStr(string str)
  991. {
  992. if ((str == N2PurgeModeEnum.ATMMode.ToString()) || (str == N2PurgeModeEnum.ATMMode.ToDescription()) || (str.StartsWith("ATM")))
  993. {
  994. return N2PurgeModeEnum.ATMMode.ToString();
  995. }
  996. if ((str == N2PurgeModeEnum.N2PurgeMode.ToString()) || (str == N2PurgeModeEnum.N2PurgeMode.ToDescription()) || (str.StartsWith("N2")))
  997. {
  998. return N2PurgeModeEnum.N2PurgeMode.ToString();
  999. }
  1000. return N2PurgeModeEnum.ManualMode.ToString();
  1001. }
  1002. private bool FsmStartContinue(object[] param)
  1003. {
  1004. return true;
  1005. }
  1006. private bool FsmSkipStep(object[] param)
  1007. {
  1008. _processRoutine.SkipCurrentRecipeStep();
  1009. return true;
  1010. }
  1011. private bool FsmJumpStep(object[] param)
  1012. {
  1013. int.TryParse(param[0].ToString(), out int stepNumber);
  1014. _processRoutine.JumpCurrentRecipeStep(stepNumber, param[1].ToString());
  1015. return true;
  1016. }
  1017. private bool FsmRecipePause(object[] param)
  1018. {
  1019. _processRoutine.PauseRecipe();
  1020. return true;
  1021. }
  1022. private bool FsmRecipeContinue(object[] param)
  1023. {
  1024. _processRoutine.ContinueRecipe();
  1025. return true;
  1026. }
  1027. private bool FsmRecipeAbort(object[] param)
  1028. {
  1029. Singleton<EquipmentManager>.Instance.EndPj("Recipe Abort");
  1030. _processRoutine.Abort();
  1031. IsWait = false;
  1032. IsJobProcess = false;
  1033. var recipeName = _recipeRunningInfo.Head.AbortRecipe;
  1034. var reason = "";
  1035. if (!File.Exists($"{PathManager.GetRecipeDir()}\\{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\Abort\\{recipeName}.rcp") ||
  1036. !RecipeParser.Parse(recipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out reason, "Abort"))
  1037. {
  1038. recipeName = SC.GetStringValue("System.Recipe.Abort Recipe");
  1039. if (!File.Exists($"{PathManager.GetRecipeDir()}\\{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\Abort\\{recipeName}.rcp") ||
  1040. !RecipeParser.Parse(SC.GetStringValue("System.Recipe.Abort Recipe"), ModuleName.PM1.ToString(), out recipeHead, out recipeSteps, out reason, "Abort"))
  1041. {
  1042. PostMsg(MSG.Error);
  1043. ExecuteAbortRecipeFailAlarm.Set($"Load abort recipe {recipeName} failed, {reason}");
  1044. return false;
  1045. }
  1046. }
  1047. RecipeRunningInfo.MainRecipeName = recipeName;
  1048. RecipeRunningInfo.Head = recipeHead;
  1049. RecipeRunningInfo.RecipeStepList = recipeSteps;
  1050. Result ret = StartRoutine(_processRoutine);
  1051. if (ret == Result.FAIL || ret == Result.DONE)
  1052. return false;
  1053. return ret == Result.RUN;
  1054. }
  1055. private bool FsmStartPostProcess(object[] param)
  1056. {
  1057. Result ret = StartRoutine(_postprocessRoutine);
  1058. if (ret == Result.FAIL || ret == Result.DONE)
  1059. return false;
  1060. return ret == Result.RUN;
  1061. }
  1062. private bool ExitPostProcess(object[] param)
  1063. {
  1064. return true;
  1065. }
  1066. private bool FsmStartMFCCalibration(object[] param)
  1067. {
  1068. return true;
  1069. }
  1070. private bool FsmOnDisconnect(object[] param)
  1071. {
  1072. if (FsmState == (int)STATE.Error)
  1073. {
  1074. return false;
  1075. }
  1076. return true;
  1077. }
  1078. private bool FsmOnError(object[] param)
  1079. {
  1080. if (FsmState == (int)STATE.Error)
  1081. {
  1082. return false;
  1083. }
  1084. if ((FsmState == (int)STATE.Process) || (FsmState == (int)STATE.PreProcess) || (FsmState == (int)STATE.PostProcess))
  1085. {
  1086. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  1087. {
  1088. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  1089. continue;
  1090. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.Failed);
  1091. }
  1092. _processRoutine.Abort();
  1093. _postprocessRoutine.Abort();
  1094. _preprocessRoutine.Abort();
  1095. IsWait = false;
  1096. }
  1097. return true;
  1098. }
  1099. private bool FsmReset(object[] param)
  1100. {
  1101. if (!_isInit)
  1102. {
  1103. PostMsg(MSG.ToInit);
  1104. return false;
  1105. }
  1106. foreach (var device in _allModuleDevice)
  1107. {
  1108. if (device.HasAlarm)
  1109. {
  1110. CheckHasAlarmWarning.Set($"{device.Name} has error");
  1111. }
  1112. }
  1113. if (CheckHasAlarm())
  1114. return false;
  1115. return true;
  1116. }
  1117. private bool FsmStartHome(object[] param)
  1118. {
  1119. //if (!CheckIsConnected())
  1120. //{
  1121. // PostMsg(MSG.Disconnected);
  1122. // return false;
  1123. //}
  1124. if (CheckHasAlarm())
  1125. {
  1126. CheckHasAlarmWarning.Set($"There exist active alarm, reset error before continue the initialization");
  1127. PostMsg(MSG.Error);
  1128. return false;
  1129. }
  1130. Result ret = StartRoutine(_homeRoutine);
  1131. if (ret == Result.FAIL || ret == Result.DONE)
  1132. return false;
  1133. _isInit = false;
  1134. return ret == Result.RUN;
  1135. }
  1136. private bool FsmExitHome(object[] param)
  1137. {
  1138. return true;
  1139. }
  1140. private bool FsmEnterHome(object[] param)
  1141. {
  1142. return true;
  1143. }
  1144. private bool FsmAbortTask(object[] param)
  1145. {
  1146. AbortRoutine();
  1147. _isPrepareProcess = true;
  1148. return true;
  1149. }
  1150. private bool FsmMonitorHomeTask(object[] param)
  1151. {
  1152. Result ret = MonitorRoutine();
  1153. if (ret == Result.FAIL)
  1154. {
  1155. PostMsg(MSG.Error);
  1156. return false;
  1157. }
  1158. if (ret == Result.DONE)
  1159. {
  1160. _isInit = true;
  1161. return true;
  1162. }
  1163. return false;
  1164. }
  1165. private bool FsmMonitorTask(object[] param)
  1166. {
  1167. Result ret = MonitorRoutine();
  1168. if (ret == Result.FAIL)
  1169. {
  1170. PostMsg(MSG.Error);
  1171. return false;
  1172. }
  1173. if (ret == Result.DONE && FsmState == (int)STATE.PreProcess)
  1174. {
  1175. PostMsg(MSG.Process);
  1176. return true;
  1177. }
  1178. if (ret == Result.DONE && FsmState == (int)STATE.Process)
  1179. {
  1180. PostMsg(MSG.PostProcess);
  1181. return true;
  1182. }
  1183. if (ret == Result.DONE && IsExcuteIdleRecipe && FsmState == (int)STATE.PostProcess)
  1184. {
  1185. PostMsg(MSG.RunIdleRecipe);
  1186. return true;
  1187. }
  1188. return ret == Result.DONE;
  1189. }
  1190. #region Service functions
  1191. public override bool Home(out string reason)
  1192. {
  1193. CheckToPostMessage((int)MSG.Home);
  1194. reason = string.Empty;
  1195. return true;
  1196. }
  1197. public override void Reset()
  1198. {
  1199. ResetAUXTrig();
  1200. if (!IsProcessing)
  1201. CheckToPostMessage((int)MSG.Reset);
  1202. }
  1203. public override bool PrepareTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1204. {
  1205. CheckToPostMessage((int)MSG.PrepareTransfer, transferType.ToString());
  1206. reason = string.Empty;
  1207. return true;
  1208. }
  1209. public override bool TransferHandoff(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1210. {
  1211. reason = string.Empty;
  1212. return true;
  1213. }
  1214. public override bool PostTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1215. {
  1216. CheckToPostMessage((int)MSG.PostTransfer, transferType.ToString());
  1217. reason = string.Empty;
  1218. return true;
  1219. }
  1220. public override bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1221. {
  1222. reason = string.Empty;
  1223. var boat = Singleton<EquipmentManager>.Instance.Modules[ModuleName.Boat] as BoatModule;
  1224. if (!boat.IsBoatElevatorAtHomePosition)
  1225. {
  1226. reason = "Boat z axis is not at home position";
  1227. return false;
  1228. }
  1229. if (!boat.IsBoatRotationAtHomePosition)
  1230. {
  1231. reason = "Boat r axis is not at home position";
  1232. return false;
  1233. }
  1234. return true;
  1235. }
  1236. public override void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1237. {
  1238. //if (FsmState == (int)STATE.InTransfer)
  1239. // CheckToPostMessage(MSG.Transfer)
  1240. }
  1241. public override void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1242. {
  1243. //if (FsmState == (int)STATE.InTransfer)
  1244. // CheckToPostMessage(MSG.Transfer)
  1245. }
  1246. public override bool Process(string recipeName, bool isCleanRecipe, bool withWafer, out string reason)
  1247. {
  1248. _recipeRunningInfo.RecipeName = recipeName;
  1249. _isPrepareProcess = false;
  1250. _isStandbyStep = false;
  1251. IsJobProcess = true;
  1252. IsExcuteIdleRecipe = false;
  1253. CheckToPostMessage((int)MSG.RunRecipe, recipeName);
  1254. reason = string.Empty;
  1255. return true;
  1256. }
  1257. public override bool Standby(string recipeName, out string reason)
  1258. {
  1259. reason = string.Empty;
  1260. _recipeRunningInfo.RecipeName = recipeName;
  1261. _recipeRunningInfo.MainRecipeName = recipeName;
  1262. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out reason, "Process"))
  1263. {
  1264. reason = $"Load process recipe {_recipeRunningInfo.RecipeName} failed, {reason}";
  1265. return false;
  1266. }
  1267. if (recipeSteps == null || recipeSteps.Count == 0)
  1268. {
  1269. reason = $"Process recipe {_recipeRunningInfo.RecipeName} is empty";
  1270. return false;
  1271. }
  1272. _isStandbyStep = true;
  1273. var standbyStep = recipeSteps.Where(x => x.StepName == "Standby").FirstOrDefault();
  1274. if (standbyStep != null)
  1275. {
  1276. StringProcessFlowState = ProcessFlowState.Standby.ToString();
  1277. _recipeRunningInfo.StepName = "Standby";
  1278. EV.PostInfoLog(Module, $"pj job excute recipe {recipeName} standby step");
  1279. foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  1280. {
  1281. if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1282. {
  1283. if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1284. {
  1285. if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1286. {
  1287. reason = $"Can not execute {recipeCmd}, {reason}";
  1288. return false;
  1289. }
  1290. else
  1291. {
  1292. OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1293. }
  1294. }
  1295. else
  1296. {
  1297. OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1298. }
  1299. }
  1300. else
  1301. {
  1302. OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1303. }
  1304. }
  1305. }
  1306. return true;
  1307. }
  1308. public void EndIdleRecipe()
  1309. {
  1310. CheckToPostMessage((int)MSG.EndIdleRecipe);
  1311. }
  1312. private double GetNewShowTime()
  1313. {
  1314. return GetWaitTime() + _recipeRunningInfo.HoldTime;
  1315. }
  1316. private double GetWaitTime()
  1317. {
  1318. if (StringFsmStatus == "Idle")
  1319. {
  1320. _waitTimer.Reset();
  1321. }
  1322. if (IsWait)
  1323. {
  1324. _waitTimer.Start();
  1325. }
  1326. else
  1327. {
  1328. _waitTimer.Stop();
  1329. }
  1330. return _waitTimer.ElapsedMilliseconds / 1000;
  1331. }
  1332. }
  1333. #endregion
  1334. }