PMModule.cs 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601
  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}.AUX.SetParameters", (out string reason, int time, object[] param) =>
  557. {
  558. reason = string.Empty;
  559. //Mode参数;Correct Table;PID Table
  560. //"Heater;Parameter\\TempCorrection\\tempCorrect,2,Name2;Parameter\\TempPID\\tempPID,3,Name3"
  561. SetAUXParameters(param);
  562. return true;
  563. });
  564. OP.Subscribe($"{Module}.SetAllMfcVirtualValue", (out string reason, int time, object[] param) =>
  565. {
  566. reason = string.Empty;
  567. var dict = param[0] as Dictionary<string, string>;
  568. foreach (var item in dict)
  569. {
  570. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  571. if (mfc != null)
  572. {
  573. mfc.SetMfcVirtualValue(out reason, 0, new object[] { item.Value });
  574. }
  575. }
  576. return true;
  577. });
  578. OP.Subscribe($"{Module}.SetAllMfcValue", (out string reason, int time, object[] param) =>
  579. {
  580. reason = string.Empty;
  581. var dict = param[0] as Dictionary<string, string>;
  582. foreach (var item in dict)
  583. {
  584. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  585. if (mfc != null)
  586. { mfc.SetMfcValue(out reason, 0, new object[] { item.Value }); }
  587. }
  588. return true;
  589. });
  590. OP.Subscribe($"{Module}.SetAllMfcSetPoint", (out string reason, int time, object[] param) =>
  591. {
  592. reason = string.Empty;
  593. var dict = param[0] as Dictionary<string, string>;
  594. foreach (var item in dict)
  595. {
  596. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  597. if (mfc != null)
  598. { mfc.SetMfcSetPoint(out reason, 0, new object[] { item.Value }); }
  599. }
  600. return true;
  601. });
  602. OP.Subscribe($"{Module}.SetAll{AITValveOperation.GVVirtualTurnValve}", (out string reason, int time, object[] param) =>
  603. {
  604. reason = string.Empty;
  605. var dict = param[0] as Dictionary<string, bool>;
  606. foreach (var item in dict)
  607. {
  608. var valve = _valves.FirstOrDefault(x => x.Name == item.Key);
  609. if (valve != null)
  610. {
  611. valve.InvokeOpenCloseVirtualValve("", new object[] { item.Value });
  612. }
  613. }
  614. return true;
  615. });
  616. OP.Subscribe($"{Module}.SetAll{AITValveOperation.GVTurnValve}", (out string reason, int time, object[] param) =>
  617. {
  618. reason = string.Empty;
  619. var dict = param[0] as Dictionary<string, bool>;
  620. foreach (var item in dict)
  621. {
  622. _valves.FirstOrDefault(x => x.Name == item.Key).InvokeOpenCloseValve("", new object[] { item.Value });
  623. }
  624. return true;
  625. });
  626. OP.Subscribe($"{Name}.SetCREFEnable", (out string reason, int time, object[] param) =>
  627. {
  628. reason = string.Empty;
  629. SetCREFEnable(param);
  630. return true;
  631. });
  632. OP.Subscribe($"{Name}.SetSIREFEnable", (out string reason, int time, object[] param) =>
  633. {
  634. reason = string.Empty;
  635. SetSIREFEnable(param);
  636. return true;
  637. });
  638. InitOtherOP();
  639. }
  640. public void SetTemperatureDetail()
  641. {
  642. }
  643. private void InitFsm()
  644. {
  645. //Error
  646. Transition(STATE.Error, MSG.Reset, FsmReset, STATE.Idle);
  647. AnyStateTransition(MSG.Error, FsmOnError, STATE.Error);
  648. AnyStateTransition(MSG.Disconnected, FsmOnDisconnect, STATE.NotConnected);
  649. EnterExitTransition<STATE, FSM_MSG>(STATE.Error, FsmEnterError, FSM_MSG.NONE, FsmExitError);
  650. Transition(STATE.Idle, MSG.Abort, null, STATE.Idle);
  651. Transition(STATE.Idle, MSG.Reset, null, STATE.Idle);
  652. Transition(STATE.Init, MSG.Reset, null, STATE.Idle);
  653. Transition(STATE.Error, MSG.Abort, null, STATE.Error);
  654. //init
  655. Transition(STATE.Init, MSG.Home, FsmStartHome, STATE.Homing);
  656. AnyStateTransition(MSG.ToInit, FsmToInit, STATE.Init);
  657. //not connected
  658. Transition(STATE.NotConnected, MSG.Connected, null, STATE.Init);
  659. //Home
  660. EnterExitTransition((int)STATE.Homing, FsmEnterHome, (int)FSM_MSG.NONE, FsmExitHome);
  661. Transition(STATE.Error, MSG.Home, FsmStartHome, STATE.Homing);
  662. Transition(STATE.Idle, MSG.Home, FsmStartHome, STATE.Homing);
  663. Transition(STATE.Homing, FSM_MSG.TIMER, FsmMonitorHomeTask, STATE.Idle);
  664. Transition(STATE.Homing, MSG.Error, null, STATE.Init);
  665. Transition(STATE.Homing, MSG.Abort, FsmAbortTask, STATE.Init);
  666. //PrepareTransfer
  667. Transition(STATE.Idle, MSG.PrepareTransfer, FsmStartPrepareTransfer, STATE.PrepareTransfer);
  668. Transition(STATE.PrepareTransfer, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  669. Transition(STATE.PrepareTransfer, MSG.Abort, FsmAbortTask, STATE.Idle);
  670. //PostTransfer
  671. Transition(STATE.InTransfer, MSG.PostTransfer, FsmStartPostTransfer, STATE.PostTransfer);
  672. Transition(STATE.Idle, MSG.PostTransfer, FsmStartPostTransfer, STATE.PostTransfer);
  673. Transition(STATE.PostTransfer, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  674. Transition(STATE.PostTransfer, MSG.Abort, FsmAbortTask, STATE.Idle);
  675. //online
  676. Transition(STATE.Idle, MSG.SetOnline, FsmStartSetOnline, STATE.Idle);
  677. Transition(STATE.Idle, MSG.SetOffline, FsmStartSetOffline, STATE.Idle);
  678. //Leak check
  679. Transition(STATE.Idle, MSG.LeakCheck, FsmStartLeakCheck, STATE.LeakCheck);
  680. Transition(STATE.LeakCheck, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  681. Transition(STATE.LeakCheck, MSG.Abort, FsmAbortTask, STATE.Idle);
  682. EnterExitTransition<STATE, FSM_MSG>(STATE.LeakCheck, FsmEnterLeakCheck, FSM_MSG.NONE, FsmExitLeakCheck);
  683. //open SlitValve
  684. Transition(STATE.Idle, MSG.OpenSlitValve, FsmStartOpenSlitValve, STATE.OpenSlitValve);
  685. Transition(STATE.OpenSlitValve, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  686. Transition(STATE.OpenSlitValve, MSG.Abort, FsmAbortTask, STATE.Idle);
  687. //close SlitValve
  688. Transition(STATE.Idle, MSG.CloseSlitValve, FsmStartCloseSlitValve, STATE.CloseSlitValve);
  689. Transition(STATE.CloseSlitValve, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  690. Transition(STATE.CloseSlitValve, MSG.Abort, FsmAbortTask, STATE.Idle);
  691. //PreProcess
  692. Transition(STATE.Process, MSG.RunIdleRecipe, FsmStartIdleRecipePreProcess, STATE.PreProcess);
  693. Transition(STATE.Process, MSG.RunOtherRecipe, FsmStartOtherRecipePreProcess, STATE.PreProcess);
  694. Transition(STATE.Idle, MSG.RunOtherRecipe, FsmStartOtherRecipePreProcess, STATE.PreProcess);
  695. Transition(STATE.Idle, MSG.SelectRecipe, FsmSelectRecipe, STATE.Idle);
  696. Transition(STATE.Idle, MSG.RunRecipe, FsmStartPreProcess, STATE.PreProcess);
  697. Transition(STATE.PreProcess, FSM_MSG.TIMER, FsmMonitorTask, STATE.PreProcess);
  698. Transition(STATE.PreProcess, MSG.Abort, FsmAbortTask, STATE.Idle);
  699. Transition(STATE.PreProcess, MSG.RecipeAbort, FsmAbortTask, STATE.Idle);
  700. //Process
  701. Transition(STATE.PreProcess, MSG.Process, FsmStartProcess, STATE.Process);
  702. Transition(STATE.Idle, MSG.AlarmConditionJumpStep, FsmStartAlarmConditionJumpStep, STATE.Process);
  703. Transition(STATE.Process, FSM_MSG.TIMER, FsmMonitorTask, STATE.Process);
  704. Transition(STATE.Process, MSG.Abort, FsmAbortTask, STATE.Idle);
  705. Transition(STATE.Process, MSG.EndIdleRecipe, null, STATE.Idle);
  706. EnterExitTransition<STATE, FSM_MSG>(STATE.Process, FsmEnterProcess, FSM_MSG.NONE, FsmExitProcess);
  707. Transition(STATE.Paused, FSM_MSG.TIMER, FsmMonitorTask, STATE.Paused);
  708. Transition(STATE.Paused, MSG.Continue, FsmStartContinue, STATE.Process);
  709. Transition(STATE.Paused, MSG.Error, null, STATE.Paused);
  710. Transition(STATE.Paused, MSG.Abort, FsmAbortTask, STATE.Idle);
  711. //Transition(STATE.Paused, MSG.Error, null, STATE.Paused);
  712. Transition(STATE.Process, MSG.RecipeSkipStep, FsmSkipStep, STATE.Process);
  713. Transition(STATE.Process, MSG.RecipeJumpStep, FsmJumpStep, STATE.Process);
  714. Transition(STATE.Process, MSG.RecipePause, FsmRecipePause, STATE.Process);
  715. Transition(STATE.Process, MSG.RecipeContinue, FsmRecipeContinue, STATE.Process);
  716. Transition(STATE.Process, MSG.RecipeAbort, FsmRecipeAbort, STATE.Process);
  717. //PostProcess
  718. Transition(STATE.Process, MSG.PostProcess, FsmStartPostProcess, STATE.PostProcess);
  719. Transition(STATE.PostProcess, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  720. Transition(STATE.PostProcess, MSG.Abort, FsmAbortTask, STATE.Idle);
  721. EnterExitTransition<STATE, FSM_MSG>(STATE.PostProcess, null, FSM_MSG.NONE, ExitPostProcess);
  722. //MFC Calibration
  723. Transition(STATE.Idle, MSG.StartMFCCalibration, FsmStartMFCCalibration, STATE.MFCCali);
  724. Transition(STATE.MFCCali, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  725. Transition(STATE.MFCCali, MSG.Abort, FsmAbortTask, STATE.Idle);
  726. }
  727. private bool FsmToInit(object[] param)
  728. {
  729. return true;
  730. }
  731. private bool FsmExitError(object[] param)
  732. {
  733. return true;
  734. }
  735. private bool FsmEnterError(object[] param)
  736. {
  737. if (OnEnterError != null)
  738. OnEnterError(Module);
  739. if (IsOnline)
  740. {
  741. //EV.PostWarningLog(Module, $"{Module}");
  742. }
  743. return true;
  744. }
  745. private bool FsmStartPostTransfer(object[] param)
  746. {
  747. _postTransferRoutine.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]));
  748. Result ret = StartRoutine(_postTransferRoutine);
  749. if (ret == Result.FAIL || ret == Result.DONE)
  750. return false;
  751. return ret == Result.RUN;
  752. }
  753. private bool FsmStartPrepareTransfer(object[] param)
  754. {
  755. _prepareTransferRoutine.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]));
  756. Result ret = StartRoutine(_prepareTransferRoutine);
  757. if (ret == Result.FAIL || ret == Result.DONE)
  758. return false;
  759. return ret == Result.RUN;
  760. }
  761. private bool FsmStartSetOffline(object[] param)
  762. {
  763. IsOnline = false;
  764. return true;
  765. }
  766. private bool FsmStartSetOnline(object[] param)
  767. {
  768. IsOnline = true;
  769. return true;
  770. }
  771. private bool FsmStartLeakCheck(object[] param)
  772. {
  773. _leakCheckRoutine.Init((int)param[0], (int)param[1], (string)param[2], (bool[])param[3]);
  774. Result ret = StartRoutine(_leakCheckRoutine);
  775. if (ret == Result.FAIL || ret == Result.DONE)
  776. return false;
  777. return ret == Result.RUN;
  778. }
  779. private bool FsmEnterLeakCheck(object[] param)
  780. {
  781. return true;
  782. }
  783. private bool FsmExitLeakCheck(object[] param)
  784. {
  785. //ChamberProcessPressureGauge.UnsetTuning();
  786. return true;
  787. }
  788. private bool FsmStartOpenSlitValve(object[] param)
  789. {
  790. return true;
  791. }
  792. private bool FsmStartCloseSlitValve(object[] param)
  793. {
  794. return true;
  795. }
  796. private bool FsmSelectRecipe(object[] param)
  797. {
  798. return true;
  799. }
  800. private bool FsmStartPreProcess(object[] param)
  801. {
  802. _recipeRunningInfo.RecipeName = (string)param[0];
  803. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, "Process"))
  804. {
  805. PreprocessStartFailedWarning.Set($"Load process recipe {_recipeRunningInfo.RecipeName} failed, {reason}");
  806. return false;
  807. }
  808. if (recipeSteps == null || recipeSteps.Count == 0)
  809. {
  810. PreprocessStartFailedWarning.Set($"Process recipe {_recipeRunningInfo.RecipeName} is empty");
  811. return false;
  812. }
  813. string abortRecipeName = SC.ContainsItem("System.Recipe.Abort Recipe") ? SC.GetStringValue("System.Recipe.Abort Recipe") : string.Empty;
  814. if (string.IsNullOrEmpty(abortRecipeName))
  815. {
  816. PreprocessStartFailedWarning.Set($"Load abort recipe failed, recipe file is null");
  817. return false;
  818. }
  819. SC.SetItemValueFromString("PM1.ProcessRecipe", _recipeRunningInfo.RecipeName);
  820. if (!IsJobProcess)
  821. Singleton<EquipmentManager>.Instance.CreatePj((string)param[0]);
  822. _preprocessRoutine.Init((string)param[0]);
  823. Result ret = StartRoutine(_preprocessRoutine);
  824. if (ret == Result.FAIL || ret == Result.DONE)
  825. return false;
  826. if (!IsJobProcess)
  827. SensorPROCManualOK.Value = true;
  828. return ret == Result.RUN;
  829. }
  830. private bool FsmStartOtherRecipePreProcess(object[] param)
  831. {
  832. Singleton<EquipmentManager>.Instance.EndPj("AbnormalEnd");
  833. _processRoutine?.Abort();
  834. IsWait = false;
  835. IsJobProcess = false;
  836. _recipeRunningInfo.RecipeName = param[0].ToString();
  837. var recipeType = param[1].ToString();
  838. var tableID = 1;
  839. if (param.Length > 2)
  840. int.TryParse(param[2].ToString(), out tableID);
  841. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, recipeType, tableID))
  842. {
  843. PreprocessStartFailedWarning.Set($"Load {recipeType} recipe {_recipeRunningInfo.RecipeName} failed {reason}");
  844. return false;
  845. }
  846. if (recipeSteps == null || recipeSteps.Count == 0)
  847. {
  848. PreprocessStartFailedWarning.Set($"{recipeType} recipe {_recipeRunningInfo.RecipeName} is empty");
  849. return false;
  850. }
  851. if (!IsJobProcess)
  852. Singleton<EquipmentManager>.Instance.CreatePj(_recipeRunningInfo.RecipeName);
  853. _preprocessRoutine.Init(_recipeRunningInfo.RecipeName, false);
  854. RecipeRunningInfo.MainRecipeName = _recipeRunningInfo.RecipeName;
  855. RecipeRunningInfo.Head = recipeHead;
  856. RecipeRunningInfo.RecipeStepList = recipeSteps;
  857. Result ret = StartRoutine(_preprocessRoutine);
  858. if (ret == Result.FAIL || ret == Result.DONE)
  859. return false;
  860. if (!IsJobProcess)
  861. SensorPROCManualOK.Value = true;
  862. return ret == Result.RUN;
  863. }
  864. private bool FsmStartIdleRecipePreProcess(object[] param)
  865. {
  866. if (!CheckBoatState())
  867. {
  868. PreprocessStartFailedWarning.Set($"boat is not ready");
  869. return false;
  870. }
  871. _recipeRunningInfo.RecipeName = SC.ContainsItem("System.Recipe.Idle Recipe") ? SC.GetStringValue("System.Recipe.Idle Recipe") : string.Empty;
  872. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, "Idle"))
  873. {
  874. PreprocessStartFailedWarning.Set($"Load idle recipe {_recipeRunningInfo.RecipeName} failed {reason}");
  875. return false;
  876. }
  877. if (recipeSteps == null || recipeSteps.Count == 0)
  878. {
  879. PreprocessStartFailedWarning.Set($"Process recipe {_recipeRunningInfo.RecipeName} is empty");
  880. return false;
  881. }
  882. if (!IsJobProcess)
  883. Singleton<EquipmentManager>.Instance.CreatePj(_recipeRunningInfo.RecipeName);
  884. _preprocessRoutine.Init(_recipeRunningInfo.RecipeName, false);
  885. RecipeRunningInfo.MainRecipeName = _recipeRunningInfo.RecipeName;
  886. RecipeRunningInfo.Head = recipeHead;
  887. RecipeRunningInfo.RecipeStepList = recipeSteps;
  888. Result ret = StartRoutine(_preprocessRoutine);
  889. if (ret == Result.FAIL || ret == Result.DONE)
  890. return false;
  891. if (!IsJobProcess)
  892. SensorPROCManualOK.Value = true;
  893. return ret == Result.RUN;
  894. }
  895. private bool FsmStartProcess(object[] param)
  896. {
  897. Result ret = StartRoutine(_processRoutine);
  898. if (ret == Result.FAIL || ret == Result.DONE)
  899. return false;
  900. if (ret == Result.RUN && !IsJobProcess)
  901. Singleton<EquipmentManager>.Instance.StartPj();
  902. return ret == Result.RUN;
  903. }
  904. private bool FsmStartAlarmConditionJumpStep(object[] param)
  905. {
  906. if (param != null && param.Length > 0)
  907. {
  908. int.TryParse(param[0].ToString(), out int jumpStep);
  909. _processRoutine.AlarmConditionJumpStep = jumpStep;
  910. Result ret = StartRoutine(_processRoutine);
  911. if (ret == Result.FAIL || ret == Result.DONE)
  912. return false;
  913. return ret == Result.RUN;
  914. }
  915. return false;
  916. }
  917. private bool FsmEnterProcess(object[] param)
  918. {
  919. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  920. {
  921. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  922. continue;
  923. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.InProcess);
  924. }
  925. _processTimer.Restart();
  926. return true;
  927. }
  928. private bool FsmExitProcess(object[] param)
  929. {
  930. _processRoutine.ExitProcess();
  931. if (!IsJobProcess && !_processRoutine.IsExecuteAbort)//非jobprocess需要recipe结束也需要更新数据库
  932. {
  933. var firstPjId = Singleton<EquipmentManager>.Instance.GetFirstPJId();
  934. Singleton<EquipmentManager>.Instance.EndPj();
  935. _processRoutine.UpdateProcessDataPJid(firstPjId);
  936. }
  937. //_statWaferCount.Increase();
  938. //_statProcessTime.Increase((int)(_processTimer.ElapsedMilliseconds/1000));
  939. _isPrepareProcess = true;
  940. IsJobProcess = false;
  941. SensorPROCManualOK.Value = false;
  942. //if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "StandbyStep")
  943. //{
  944. // StringProcessFlowState = ProcessFlowState.Standby.ToString();
  945. // _recipeRunningInfo.StepName = "Standby";
  946. // var standbyStep = _recipeRunningInfo.RecipeStepList.Where(x => x.StepName == "Standby").FirstOrDefault();
  947. // if (standbyStep != null)
  948. // {
  949. // EV.PostInfoLog(Module, $"Recipe {_recipeRunningInfo.RecipeName} complete excute standby step");
  950. // foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  951. // {
  952. // if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out string reason, standbyStep.RecipeCommands[recipeCmd]))
  953. // {
  954. // if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  955. // {
  956. // if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  957. // {
  958. // reason = $"Can not execute {recipeCmd}, {reason}";
  959. // return false;
  960. // }
  961. // else
  962. // {
  963. // OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  964. // }
  965. // }
  966. // else
  967. // {
  968. // OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  969. // }
  970. // }
  971. // else
  972. // {
  973. // OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  974. // }
  975. // }
  976. // }
  977. // _isStandbyStep = true;
  978. // IsExcuteIdleRecipe = false;
  979. //}
  980. //else if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "IdleRecipe")
  981. //{
  982. // if (!IsExcuteIdleRecipe)
  983. // {
  984. // PostMsg((int)MSG.RunIdleRecipe);
  985. // IsExcuteIdleRecipe = true;
  986. // }
  987. // else
  988. // {
  989. // IsExcuteIdleRecipe = false;
  990. // _isStandbyStep = false;
  991. // }
  992. //}
  993. //else
  994. //{
  995. // IsExcuteIdleRecipe = false;
  996. // _isStandbyStep = false;
  997. //}
  998. return true;
  999. }
  1000. public string GetN2PurgeModeEnumByStr(string str)
  1001. {
  1002. if ((str == N2PurgeModeEnum.ATMMode.ToString()) || (str == N2PurgeModeEnum.ATMMode.ToDescription()) || (str.StartsWith("ATM")))
  1003. {
  1004. return N2PurgeModeEnum.ATMMode.ToString();
  1005. }
  1006. if ((str == N2PurgeModeEnum.N2PurgeMode.ToString()) || (str == N2PurgeModeEnum.N2PurgeMode.ToDescription()) || (str.StartsWith("N2")))
  1007. {
  1008. return N2PurgeModeEnum.N2PurgeMode.ToString();
  1009. }
  1010. return N2PurgeModeEnum.ManualMode.ToString();
  1011. }
  1012. private bool FsmStartContinue(object[] param)
  1013. {
  1014. return true;
  1015. }
  1016. private bool FsmSkipStep(object[] param)
  1017. {
  1018. _processRoutine.SkipCurrentRecipeStep();
  1019. return true;
  1020. }
  1021. private bool FsmJumpStep(object[] param)
  1022. {
  1023. int.TryParse(param[0].ToString(), out int stepNumber);
  1024. _processRoutine.JumpCurrentRecipeStep(stepNumber, param[1].ToString());
  1025. return true;
  1026. }
  1027. private bool FsmRecipePause(object[] param)
  1028. {
  1029. _processRoutine.PauseRecipe();
  1030. return true;
  1031. }
  1032. private bool FsmRecipeContinue(object[] param)
  1033. {
  1034. _processRoutine.ContinueRecipe();
  1035. return true;
  1036. }
  1037. private bool FsmRecipeAbort(object[] param)
  1038. {
  1039. Singleton<EquipmentManager>.Instance.EndPj("Recipe Abort");
  1040. _processRoutine.Abort();
  1041. IsWait = false;
  1042. IsJobProcess = false;
  1043. var recipeName = _recipeRunningInfo.Head.AbortRecipe;
  1044. var reason = "";
  1045. if (!File.Exists($"{PathManager.GetRecipeDir()}\\{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\Abort\\{recipeName}.rcp") ||
  1046. !RecipeParser.Parse(recipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out reason, "Abort"))
  1047. {
  1048. recipeName = SC.GetStringValue("System.Recipe.Abort Recipe");
  1049. if (!File.Exists($"{PathManager.GetRecipeDir()}\\{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\Abort\\{recipeName}.rcp") ||
  1050. !RecipeParser.Parse(SC.GetStringValue("System.Recipe.Abort Recipe"), ModuleName.PM1.ToString(), out recipeHead, out recipeSteps, out reason, "Abort"))
  1051. {
  1052. PostMsg(MSG.Error);
  1053. ExecuteAbortRecipeFailAlarm.Set($"Load abort recipe {recipeName} failed, {reason}");
  1054. return false;
  1055. }
  1056. }
  1057. RecipeRunningInfo.MainRecipeName = recipeName;
  1058. RecipeRunningInfo.Head = recipeHead;
  1059. RecipeRunningInfo.RecipeStepList = recipeSteps;
  1060. Result ret = StartRoutine(_processRoutine);
  1061. if (ret == Result.FAIL || ret == Result.DONE)
  1062. return false;
  1063. return ret == Result.RUN;
  1064. }
  1065. private bool FsmStartPostProcess(object[] param)
  1066. {
  1067. Result ret = StartRoutine(_postprocessRoutine);
  1068. if (ret == Result.FAIL || ret == Result.DONE)
  1069. return false;
  1070. return ret == Result.RUN;
  1071. }
  1072. private bool ExitPostProcess(object[] param)
  1073. {
  1074. return true;
  1075. }
  1076. private bool FsmStartMFCCalibration(object[] param)
  1077. {
  1078. return true;
  1079. }
  1080. private bool FsmOnDisconnect(object[] param)
  1081. {
  1082. if (FsmState == (int)STATE.Error)
  1083. {
  1084. return false;
  1085. }
  1086. return true;
  1087. }
  1088. private bool FsmOnError(object[] param)
  1089. {
  1090. if (FsmState == (int)STATE.Error)
  1091. {
  1092. return false;
  1093. }
  1094. if ((FsmState == (int)STATE.Process) || (FsmState == (int)STATE.PreProcess) || (FsmState == (int)STATE.PostProcess))
  1095. {
  1096. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  1097. {
  1098. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  1099. continue;
  1100. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.Failed);
  1101. }
  1102. _processRoutine.Abort();
  1103. _postprocessRoutine.Abort();
  1104. _preprocessRoutine.Abort();
  1105. IsWait = false;
  1106. }
  1107. return true;
  1108. }
  1109. private bool FsmReset(object[] param)
  1110. {
  1111. if (!_isInit)
  1112. {
  1113. PostMsg(MSG.ToInit);
  1114. return false;
  1115. }
  1116. foreach (var device in _allModuleDevice)
  1117. {
  1118. if (device.HasAlarm)
  1119. {
  1120. CheckHasAlarmWarning.Set($"{device.Name} has error");
  1121. }
  1122. }
  1123. if (CheckHasAlarm())
  1124. return false;
  1125. return true;
  1126. }
  1127. private bool FsmStartHome(object[] param)
  1128. {
  1129. //if (!CheckIsConnected())
  1130. //{
  1131. // PostMsg(MSG.Disconnected);
  1132. // return false;
  1133. //}
  1134. if (CheckHasAlarm())
  1135. {
  1136. CheckHasAlarmWarning.Set($"There exist active alarm, reset error before continue the initialization");
  1137. PostMsg(MSG.Error);
  1138. return false;
  1139. }
  1140. Result ret = StartRoutine(_homeRoutine);
  1141. if (ret == Result.FAIL || ret == Result.DONE)
  1142. return false;
  1143. _isInit = false;
  1144. return ret == Result.RUN;
  1145. }
  1146. private bool FsmExitHome(object[] param)
  1147. {
  1148. return true;
  1149. }
  1150. private bool FsmEnterHome(object[] param)
  1151. {
  1152. return true;
  1153. }
  1154. private bool FsmAbortTask(object[] param)
  1155. {
  1156. AbortRoutine();
  1157. _isPrepareProcess = true;
  1158. return true;
  1159. }
  1160. private bool FsmMonitorHomeTask(object[] param)
  1161. {
  1162. Result ret = MonitorRoutine();
  1163. if (ret == Result.FAIL)
  1164. {
  1165. PostMsg(MSG.Error);
  1166. return false;
  1167. }
  1168. if (ret == Result.DONE)
  1169. {
  1170. _isInit = true;
  1171. return true;
  1172. }
  1173. return false;
  1174. }
  1175. private bool FsmMonitorTask(object[] param)
  1176. {
  1177. Result ret = MonitorRoutine();
  1178. if (ret == Result.FAIL)
  1179. {
  1180. PostMsg(MSG.Error);
  1181. return false;
  1182. }
  1183. if (ret == Result.DONE && FsmState == (int)STATE.PreProcess)
  1184. {
  1185. PostMsg(MSG.Process);
  1186. return true;
  1187. }
  1188. if (ret == Result.DONE && FsmState == (int)STATE.Process)
  1189. {
  1190. PostMsg(MSG.PostProcess);
  1191. return true;
  1192. }
  1193. if (ret == Result.DONE && IsExcuteIdleRecipe && FsmState == (int)STATE.PostProcess)
  1194. {
  1195. PostMsg(MSG.RunIdleRecipe);
  1196. return true;
  1197. }
  1198. return ret == Result.DONE;
  1199. }
  1200. #region Service functions
  1201. public override bool Home(out string reason)
  1202. {
  1203. CheckToPostMessage((int)MSG.Home);
  1204. reason = string.Empty;
  1205. return true;
  1206. }
  1207. public override void Reset()
  1208. {
  1209. ResetAUXTrig();
  1210. if (!IsProcessing)
  1211. CheckToPostMessage((int)MSG.Reset);
  1212. }
  1213. public override bool PrepareTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1214. {
  1215. CheckToPostMessage((int)MSG.PrepareTransfer, transferType.ToString());
  1216. reason = string.Empty;
  1217. return true;
  1218. }
  1219. public override bool TransferHandoff(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1220. {
  1221. reason = string.Empty;
  1222. return true;
  1223. }
  1224. public override bool PostTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1225. {
  1226. CheckToPostMessage((int)MSG.PostTransfer, transferType.ToString());
  1227. reason = string.Empty;
  1228. return true;
  1229. }
  1230. public override bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1231. {
  1232. reason = string.Empty;
  1233. var boat = Singleton<EquipmentManager>.Instance.Modules[ModuleName.Boat] as BoatModule;
  1234. if (!boat.IsBoatElevatorAtHomePosition)
  1235. {
  1236. reason = "Boat z axis is not at home position";
  1237. return false;
  1238. }
  1239. if (!boat.IsBoatRotationAtHomePosition)
  1240. {
  1241. reason = "Boat r axis is not at home position";
  1242. return false;
  1243. }
  1244. return true;
  1245. }
  1246. public override void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1247. {
  1248. //if (FsmState == (int)STATE.InTransfer)
  1249. // CheckToPostMessage(MSG.Transfer)
  1250. }
  1251. public override void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1252. {
  1253. //if (FsmState == (int)STATE.InTransfer)
  1254. // CheckToPostMessage(MSG.Transfer)
  1255. }
  1256. public override bool Process(string recipeName, bool isCleanRecipe, bool withWafer, out string reason)
  1257. {
  1258. _recipeRunningInfo.RecipeName = recipeName;
  1259. _isPrepareProcess = false;
  1260. _isStandbyStep = false;
  1261. IsJobProcess = true;
  1262. IsExcuteIdleRecipe = false;
  1263. CheckToPostMessage((int)MSG.RunRecipe, recipeName);
  1264. reason = string.Empty;
  1265. return true;
  1266. }
  1267. public override bool Standby(string recipeName, out string reason)
  1268. {
  1269. reason = string.Empty;
  1270. _recipeRunningInfo.RecipeName = recipeName;
  1271. _recipeRunningInfo.MainRecipeName = recipeName;
  1272. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out reason, "Process"))
  1273. {
  1274. reason = $"Load process recipe {_recipeRunningInfo.RecipeName} failed, {reason}";
  1275. return false;
  1276. }
  1277. if (recipeSteps == null || recipeSteps.Count == 0)
  1278. {
  1279. reason = $"Process recipe {_recipeRunningInfo.RecipeName} is empty";
  1280. return false;
  1281. }
  1282. _isStandbyStep = true;
  1283. var standbyStep = recipeSteps.Where(x => x.StepName == "Standby").FirstOrDefault();
  1284. if (standbyStep != null)
  1285. {
  1286. StringProcessFlowState = ProcessFlowState.Standby.ToString();
  1287. _recipeRunningInfo.StepName = "Standby";
  1288. EV.PostInfoLog(Module, $"pj job excute recipe {recipeName} standby step");
  1289. foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  1290. {
  1291. if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1292. {
  1293. if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1294. {
  1295. if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1296. {
  1297. reason = $"Can not execute {recipeCmd}, {reason}";
  1298. return false;
  1299. }
  1300. else
  1301. {
  1302. OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1303. }
  1304. }
  1305. else
  1306. {
  1307. OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1308. }
  1309. }
  1310. else
  1311. {
  1312. OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1313. }
  1314. }
  1315. }
  1316. return true;
  1317. }
  1318. public void EndIdleRecipe()
  1319. {
  1320. CheckToPostMessage((int)MSG.EndIdleRecipe);
  1321. }
  1322. private double GetNewShowTime()
  1323. {
  1324. return GetWaitTime() + _recipeRunningInfo.HoldTime;
  1325. }
  1326. private double GetWaitTime()
  1327. {
  1328. if (StringFsmStatus == "Idle")
  1329. {
  1330. _waitTimer.Reset();
  1331. }
  1332. if (IsWait)
  1333. {
  1334. _waitTimer.Start();
  1335. }
  1336. else
  1337. {
  1338. _waitTimer.Stop();
  1339. }
  1340. return _waitTimer.ElapsedMilliseconds / 1000;
  1341. }
  1342. }
  1343. #endregion
  1344. }