PMModule.cs 62 KB

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