PMModule.cs 59 KB

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