PMModule.cs 71 KB

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