PMModule.cs 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517
  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. Singleton<EquipmentManager>.Instance.EndPj();
  893. //_statWaferCount.Increase();
  894. //_statProcessTime.Increase((int)(_processTimer.ElapsedMilliseconds/1000));
  895. _isPrepareProcess = true;
  896. IsJobProcess = false;
  897. SensorPROCManualOK.Value = false;
  898. //if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "StandbyStep")
  899. //{
  900. // StringProcessFlowState = ProcessFlowState.Standby.ToString();
  901. // _recipeRunningInfo.StepName = "Standby";
  902. // var standbyStep = _recipeRunningInfo.RecipeStepList.Where(x => x.StepName == "Standby").FirstOrDefault();
  903. // if (standbyStep != null)
  904. // {
  905. // EV.PostInfoLog(Module, $"Recipe {_recipeRunningInfo.RecipeName} complete excute standby step");
  906. // foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  907. // {
  908. // if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out string reason, standbyStep.RecipeCommands[recipeCmd]))
  909. // {
  910. // if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  911. // {
  912. // if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  913. // {
  914. // reason = $"Can not execute {recipeCmd}, {reason}";
  915. // return false;
  916. // }
  917. // else
  918. // {
  919. // OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  920. // }
  921. // }
  922. // else
  923. // {
  924. // OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  925. // }
  926. // }
  927. // else
  928. // {
  929. // OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  930. // }
  931. // }
  932. // }
  933. // _isStandbyStep = true;
  934. // IsExcuteIdleRecipe = false;
  935. //}
  936. //else if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "IdleRecipe")
  937. //{
  938. // if (!IsExcuteIdleRecipe)
  939. // {
  940. // PostMsg((int)MSG.RunIdleRecipe);
  941. // IsExcuteIdleRecipe = true;
  942. // }
  943. // else
  944. // {
  945. // IsExcuteIdleRecipe = false;
  946. // _isStandbyStep = false;
  947. // }
  948. //}
  949. //else
  950. //{
  951. // IsExcuteIdleRecipe = false;
  952. // _isStandbyStep = false;
  953. //}
  954. return true;
  955. }
  956. private bool FsmStartContinue(object[] param)
  957. {
  958. return true;
  959. }
  960. private bool FsmSkipStep(object[] param)
  961. {
  962. _processRoutine.SkipCurrentRecipeStep();
  963. return true;
  964. }
  965. private bool FsmJumpStep(object[] param)
  966. {
  967. int.TryParse(param[0].ToString(), out int stepNumber);
  968. _processRoutine.JumpCurrentRecipeStep(stepNumber, param[1].ToString());
  969. return true;
  970. }
  971. private bool FsmRecipePause(object[] param)
  972. {
  973. _processRoutine.PauseRecipe();
  974. return true;
  975. }
  976. private bool FsmRecipeContinue(object[] param)
  977. {
  978. _processRoutine.ContinueRecipe();
  979. return true;
  980. }
  981. private bool FsmRecipeAbort(object[] param)
  982. {
  983. Singleton<EquipmentManager>.Instance.EndPj("Recipe Abort");
  984. _processRoutine.Abort();
  985. IsWait = false;
  986. return true;
  987. }
  988. private bool FsmStartPostProcess(object[] param)
  989. {
  990. Result ret = StartRoutine(_postprocessRoutine);
  991. if (ret == Result.FAIL || ret == Result.DONE)
  992. return false;
  993. return ret == Result.RUN;
  994. }
  995. private bool ExitPostProcess(object[] param)
  996. {
  997. return true;
  998. }
  999. private bool FsmStartMFCCalibration(object[] param)
  1000. {
  1001. return true;
  1002. }
  1003. private bool FsmOnDisconnect(object[] param)
  1004. {
  1005. if (FsmState == (int)STATE.Error)
  1006. {
  1007. return false;
  1008. }
  1009. return true;
  1010. }
  1011. private bool FsmOnError(object[] param)
  1012. {
  1013. if (FsmState == (int)STATE.Error)
  1014. {
  1015. return false;
  1016. }
  1017. if ((FsmState == (int)STATE.Process) || (FsmState == (int)STATE.PreProcess) || (FsmState == (int)STATE.PostProcess))
  1018. {
  1019. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  1020. {
  1021. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  1022. continue;
  1023. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.Failed);
  1024. }
  1025. _processRoutine.Abort();
  1026. _postprocessRoutine.Abort();
  1027. _preprocessRoutine.Abort();
  1028. IsWait = false;
  1029. }
  1030. return true;
  1031. }
  1032. private bool FsmReset(object[] param)
  1033. {
  1034. if (!_isInit)
  1035. {
  1036. PostMsg(MSG.ToInit);
  1037. return false;
  1038. }
  1039. foreach (var device in _allModuleDevice)
  1040. {
  1041. if (device.HasAlarm)
  1042. {
  1043. CheckHasAlarmWarning.Set($"{device.Name} has error");
  1044. }
  1045. }
  1046. if (CheckHasAlarm())
  1047. return false;
  1048. return true;
  1049. }
  1050. private bool FsmStartHome(object[] param)
  1051. {
  1052. //if (!CheckIsConnected())
  1053. //{
  1054. // PostMsg(MSG.Disconnected);
  1055. // return false;
  1056. //}
  1057. if (CheckHasAlarm())
  1058. {
  1059. CheckHasAlarmWarning.Set($"There exist active alarm, reset error before continue the initialization");
  1060. PostMsg(MSG.Error);
  1061. return false;
  1062. }
  1063. Result ret = StartRoutine(_homeRoutine);
  1064. if (ret == Result.FAIL || ret == Result.DONE)
  1065. return false;
  1066. _isInit = false;
  1067. return ret == Result.RUN;
  1068. }
  1069. private bool FsmExitHome(object[] param)
  1070. {
  1071. return true;
  1072. }
  1073. private bool FsmEnterHome(object[] param)
  1074. {
  1075. return true;
  1076. }
  1077. private bool FsmAbortTask(object[] param)
  1078. {
  1079. AbortRoutine();
  1080. _isPrepareProcess = true;
  1081. return true;
  1082. }
  1083. private bool FsmMonitorHomeTask(object[] param)
  1084. {
  1085. Result ret = MonitorRoutine();
  1086. if (ret == Result.FAIL)
  1087. {
  1088. PostMsg(MSG.Error);
  1089. return false;
  1090. }
  1091. if (ret == Result.DONE)
  1092. {
  1093. _isInit = true;
  1094. return true;
  1095. }
  1096. return false;
  1097. }
  1098. private bool FsmMonitorTask(object[] param)
  1099. {
  1100. Result ret = MonitorRoutine();
  1101. if (ret == Result.FAIL)
  1102. {
  1103. PostMsg(MSG.Error);
  1104. return false;
  1105. }
  1106. if (ret == Result.DONE && FsmState == (int)STATE.PreProcess)
  1107. {
  1108. PostMsg(MSG.Process);
  1109. return true;
  1110. }
  1111. if (ret == Result.DONE && FsmState == (int)STATE.Process)
  1112. {
  1113. PostMsg(MSG.PostProcess);
  1114. return true;
  1115. }
  1116. if (ret == Result.DONE && IsExcuteIdleRecipe && FsmState == (int)STATE.PostProcess)
  1117. {
  1118. PostMsg(MSG.RunIdleRecipe);
  1119. return true;
  1120. }
  1121. return ret == Result.DONE;
  1122. }
  1123. #region Service functions
  1124. public override bool Home(out string reason)
  1125. {
  1126. CheckToPostMessage((int)MSG.Home);
  1127. reason = string.Empty;
  1128. return true;
  1129. }
  1130. public override void Reset()
  1131. {
  1132. ResetAUXTrig();
  1133. if (!IsProcessing)
  1134. CheckToPostMessage((int)MSG.Reset);
  1135. }
  1136. public override bool PrepareTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1137. {
  1138. CheckToPostMessage((int)MSG.PrepareTransfer, transferType.ToString());
  1139. reason = string.Empty;
  1140. return true;
  1141. }
  1142. public override bool TransferHandoff(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1143. {
  1144. reason = string.Empty;
  1145. return true;
  1146. }
  1147. public override bool PostTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1148. {
  1149. CheckToPostMessage((int)MSG.PostTransfer, transferType.ToString());
  1150. reason = string.Empty;
  1151. return true;
  1152. }
  1153. public override bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1154. {
  1155. reason = string.Empty;
  1156. var boat = Singleton<EquipmentManager>.Instance.Modules[ModuleName.Boat] as BoatModule;
  1157. if (!boat.IsBoatElevatorAtHomePosition)
  1158. {
  1159. reason = "Boat z axis is not at home position";
  1160. return false;
  1161. }
  1162. if (!boat.IsBoatRotationAtHomePosition)
  1163. {
  1164. reason = "Boat r axis is not at home position";
  1165. return false;
  1166. }
  1167. return true;
  1168. }
  1169. public override void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1170. {
  1171. //if (FsmState == (int)STATE.InTransfer)
  1172. // CheckToPostMessage(MSG.Transfer)
  1173. }
  1174. public override void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1175. {
  1176. //if (FsmState == (int)STATE.InTransfer)
  1177. // CheckToPostMessage(MSG.Transfer)
  1178. }
  1179. public override bool Process(string recipeName, bool isCleanRecipe, bool withWafer, out string reason)
  1180. {
  1181. _recipeRunningInfo.RecipeName = recipeName;
  1182. _isPrepareProcess = false;
  1183. _isStandbyStep = false;
  1184. IsJobProcess = true;
  1185. IsExcuteIdleRecipe = false;
  1186. CheckToPostMessage((int)MSG.RunRecipe, recipeName);
  1187. reason = string.Empty;
  1188. return true;
  1189. }
  1190. public override bool Standby(string recipeName, out string reason)
  1191. {
  1192. reason = string.Empty;
  1193. _recipeRunningInfo.RecipeName = recipeName;
  1194. _recipeRunningInfo.MainRecipeName = recipeName;
  1195. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out reason, "Process"))
  1196. {
  1197. reason = $"Load process recipe {_recipeRunningInfo.RecipeName} failed, {reason}";
  1198. return false;
  1199. }
  1200. if (recipeSteps == null || recipeSteps.Count == 0)
  1201. {
  1202. reason = $"Process recipe {_recipeRunningInfo.RecipeName} is empty";
  1203. return false;
  1204. }
  1205. _isStandbyStep = true;
  1206. var standbyStep = recipeSteps.Where(x => x.StepName == "Standby").FirstOrDefault();
  1207. if (standbyStep != null)
  1208. {
  1209. StringProcessFlowState = ProcessFlowState.Standby.ToString();
  1210. _recipeRunningInfo.StepName = "Standby";
  1211. EV.PostInfoLog(Module, $"pj job excute recipe {recipeName} standby step");
  1212. foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  1213. {
  1214. if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1215. {
  1216. if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1217. {
  1218. if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1219. {
  1220. reason = $"Can not execute {recipeCmd}, {reason}";
  1221. return false;
  1222. }
  1223. else
  1224. {
  1225. OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1226. }
  1227. }
  1228. else
  1229. {
  1230. OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1231. }
  1232. }
  1233. else
  1234. {
  1235. OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1236. }
  1237. }
  1238. }
  1239. return true;
  1240. }
  1241. public void EndIdleRecipe()
  1242. {
  1243. CheckToPostMessage((int)MSG.EndIdleRecipe);
  1244. }
  1245. private double GetNewShowTime()
  1246. {
  1247. return GetWaitTime() + _recipeRunningInfo.HoldTime;
  1248. }
  1249. private double GetWaitTime()
  1250. {
  1251. if (StringFsmStatus=="Idle")
  1252. {
  1253. _waitTimer.Reset();
  1254. }
  1255. if (IsWait)
  1256. {
  1257. _waitTimer.Start();
  1258. }
  1259. else
  1260. {
  1261. _waitTimer.Stop();
  1262. }
  1263. return _waitTimer.ElapsedMilliseconds / 1000;
  1264. }
  1265. }
  1266. #endregion
  1267. }