PMModule.cs 77 KB

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