PMModule.cs 63 KB

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