PMModule.cs 60 KB

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