PMModule.cs 69 KB

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