PMModule.cs 63 KB

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