PMModule.cs 70 KB

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