PMModule.cs 76 KB

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