PMModule.cs 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898
  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($"{Name}.RemainTimeToEnterCooling", () => _recipeRunningInfo.RemainTimeExcludeEndStep-_recipeRunningInfo.TotalElapseTime,SubscriptionAttribute.FLAG.IgnoreSaveDB);
  330. DATA.Subscribe("ProcessFlow.Status", () => StringProcessFlowState);
  331. DATA.Subscribe($"{Name}.ConditionCheck", () => _conditionCheckDic);
  332. //DATA.Subscribe($"{Name}.LZoneHeaterData", () => Heater2.DeviceData.IsLspModeFeedBack ? Heater2.DeviceData : Heater1.DeviceData);
  333. //DATA.Subscribe($"{Name}.CLZoneHeaterData", () => Heater4.DeviceData.IsLspModeFeedBack ? Heater4.DeviceData : Heater3.DeviceData);
  334. //DATA.Subscribe($"{Name}.CZoneHeaterData", () => Heater6.DeviceData.IsLspModeFeedBack ? Heater6.DeviceData : Heater5.DeviceData);
  335. //DATA.Subscribe($"{Name}.CUZoneHeaterData", () => Heater8.DeviceData.IsLspModeFeedBack ? Heater8.DeviceData : Heater7.DeviceData);
  336. //DATA.Subscribe($"{Name}.UZoneHeaterData", () => Heater10.DeviceData.IsLspModeFeedBack ? Heater10.DeviceData : Heater9.DeviceData);
  337. SensorRecipeOK = new AITSensorData()
  338. {
  339. DeviceName = "SensorRecipeOK",
  340. DeviceSchematicId = "SensorRecipe",
  341. DisplayName = "SensorRecipe",
  342. Value = false,
  343. };
  344. DATA.Subscribe($"{Module}.{SensorRecipeOK.DeviceName}", () => SensorRecipeOK);
  345. SensorPROCManualOK = new AITSensorData()
  346. {
  347. DeviceName = "SensorPROCManualOK",
  348. DeviceSchematicId = "PROCManual",
  349. DisplayName = "PROCManual",
  350. Value = false,
  351. };
  352. DATA.Subscribe($"{Module}.{SensorPROCManualOK.DeviceName}", () => SensorPROCManualOK);
  353. DATA.Subscribe($"{Module}.EditRecipeName", () => EditRecipeName);
  354. DATA.Subscribe($"{Module}.EditRecipeStepName", () => EditRecipeStepName);
  355. DATA.Subscribe($"{Module}.HTR1Enable", () => IsHTR1Enable);
  356. DATA.Subscribe($"{Module}.HTR2Enable", () => IsHTR2Enable);
  357. DATA.Subscribe($"{Module}.HTR3Enable", () => IsHTR3Enable);
  358. DATA.Subscribe($"{Module}.IsDPROn", () => _isDPROn);
  359. DATA.Subscribe($"{Module}.IsCEXHOn", () => TrigCEXHON?.Value);
  360. DATA.Subscribe($"{Module}.IsF2ClnOn", () =>
  361. {
  362. return IsF2ClnOn;
  363. });
  364. DATA.Subscribe($"{Module}.IsHFClnOn", () =>
  365. {
  366. return IsHFClnOn;
  367. });
  368. DATA.Subscribe($"{Module}.IsDEPOOn", () => TrigDEPOSW != null ? TrigDEPOSW.Value : false);
  369. DATA.Subscribe($"{Module}.IsCREFOn", () => TrigCREFON != null ? TrigCREFON.Value : false);
  370. DATA.Subscribe($"{Module}.IsSIREFOn", () => TrigSIREFON != null ? TrigSIREFON.Value : false);
  371. DATA.Subscribe($"{Module}.MFCList", () =>
  372. {
  373. List<AITMfcData> aITMfcDataList = new List<AITMfcData>();
  374. var mfcs = DEVICE.GetDevice<PMs.Devices.IoMFC>();
  375. if (mfcs != null)
  376. {
  377. foreach (var item in mfcs)
  378. {
  379. if (item == null) continue;
  380. if (item.IsMFCInstalled)
  381. {
  382. aITMfcDataList.Add(item.DeviceData);
  383. }
  384. }
  385. }
  386. return aITMfcDataList;
  387. });
  388. InitScheduleData();
  389. FDCSubscribe();
  390. InitOtherData();
  391. InitN2PurgeData();
  392. }
  393. private void InitStats()
  394. {
  395. _statTubeCleanNumber = new StatsData($"{Module}.Tube Clean Number", "Tube clean number", 0);
  396. _statTubeCleanTime = new StatsData($"{Module}.Tube Clean Time", "Tube clean time(Min)", 0);
  397. _statTubeCleanThick = new StatsData($"{Module}.Tube Clean thick", "Tube clean thick(nm)", 0);
  398. _statBoatCleanNumber = new StatsData($"{Module}.Boat Clean Number", "Boat clean number", 0);
  399. _statBoatCleanTime = new StatsData($"{Module}.Boat Clean Time", "Boat clean time(Min)", 0);
  400. _statBoatCleanThick = new StatsData($"{Module}.Boat Clean thick", "Boat clean thick(nm)", 0);
  401. _statForkCleanNumber = new StatsData($"{Module}.Fork Clean Number", "Fork clean number", 0);
  402. _statForkCleanTime = new StatsData($"{Module}.Fork Clean Time", "Fork clean time(Min)", 0);
  403. _statBoatCleanThick = new StatsData($"{Module}.Boat Clean thick", "Boat clean thick(nm)", 0);
  404. _statForkCleanThick = new StatsData($"{Module}.Fork Clean thick", "Fork clean thick", 0);
  405. }
  406. private void InitOp()
  407. {
  408. OP.Subscribe($"{Module}.Home", (string cmd, object[] args) =>
  409. {
  410. if (!(Singleton<EquipmentManager>.Instance.Modules[ModuleName.WaferRobot] as IModuleDevice).IsReady)
  411. {
  412. TubeHomeFailedWarning.Set($"Wafer Robot is not in ilde state, init failed.");
  413. return false;
  414. }
  415. return CheckToPostMessage((int)MSG.Home);
  416. });
  417. OP.Subscribe($"{Module}.Reset", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Reset));
  418. OP.Subscribe($"{Module}.Abort", (string cmd, object[] args) => CheckToPostMessage((int)MSG.Abort));
  419. OP.Subscribe($"{Module}.PutOnline", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SetOnline));
  420. OP.Subscribe($"{Module}.PutOffline", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SetOffline));
  421. OP.Subscribe($"{Name}.SelectRecipe", (string cmd, object[] args) => CheckToPostMessage((int)MSG.SelectRecipe, args[0]));
  422. OP.Subscribe($"{Name}.RunRecipe", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RunRecipe, (string)args[0]));
  423. OP.Subscribe($"{Name}.RecipeSkipStep", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeSkipStep));
  424. OP.Subscribe($"{Name}.RecipeJumpStep", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeJumpStep, args[0], args[1]));
  425. OP.Subscribe($"{Name}.RecipePause", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipePause));
  426. OP.Subscribe($"{Name}.RecipeContinue", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeContinue));
  427. OP.Subscribe($"{Name}.RecipeAbort", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RecipeAbort));
  428. OP.Subscribe($"{Name}.RecipeIdle", (string cmd, object[] args) => CheckToPostMessage((int)MSG.RunIdleRecipe));
  429. OP.Subscribe($"{Name}.LeakCheck", (string cmd, object[] args) => CheckToPostMessage((int)MSG.LeakCheck, args[0], args[1], args[2], args[3]));
  430. OP.Subscribe($"{Name}.Wait", (string cmd, object[] args) =>
  431. {
  432. IsWait = !IsWait;
  433. return true;
  434. });
  435. OP.Subscribe($"{Module}.AlarmAction", (string cmd, object[] args) =>
  436. {
  437. Enum.TryParse(args[0].ToString(), out AlarmAction alarmAction);
  438. string eventName = null;
  439. if (args.Length > 1)
  440. eventName = args[1].ToString();
  441. if (eventName != null)
  442. {
  443. EV.ClearAlarmEvent(eventName);
  444. var item = _triggeredAlarmList.FirstOrDefault(x => x.EventEnum == eventName);
  445. if (item != null)
  446. {
  447. item.Reset();
  448. _triggeredAlarmList.Remove(item);
  449. }
  450. if (item != null)
  451. {
  452. switch (alarmAction)
  453. {
  454. case AlarmAction.Retry:
  455. {
  456. CheckToPostMessage((int)item.RetryMessage, item.RetryMessageParas);
  457. }
  458. break;
  459. case AlarmAction.Abort:
  460. {
  461. CheckToPostMessage((int)MSG.Abort);
  462. }
  463. break;
  464. case AlarmAction.Clear:
  465. {
  466. int alarmCount = 0;
  467. var alarms = EV.GetAlarmEvent();
  468. foreach (var alarm in alarms)
  469. {
  470. if (alarm.Level == EventLevel.Alarm && alarm.Source == Name)
  471. alarmCount++;
  472. }
  473. if (alarmCount == 0 && !IsProcessing)
  474. {
  475. CheckToPostMessage((int)MSG.Reset);
  476. _alarmNumber = 0;
  477. }
  478. }
  479. break;
  480. case AlarmAction.Continue:
  481. {
  482. int alarmCount = 0;
  483. var alarms = EV.GetAlarmEvent();
  484. foreach (var alarm in alarms)
  485. {
  486. if (alarm.Level == EventLevel.Alarm && alarm.Source == Name)
  487. alarmCount++;
  488. }
  489. if (alarmCount == 0)
  490. CheckToPostMessage((int)MSG.Reset);
  491. }
  492. break;
  493. case AlarmAction.ClearAll:
  494. ResetAUXTrig();
  495. break;
  496. }
  497. }
  498. }
  499. return true;
  500. });
  501. OP.Subscribe($"{Name}.SetConditionCheck", SetConditionCheck);
  502. OP.Subscribe($"{Name}.SetBoatZAxisMotion", SetBoatZAxisMotion);
  503. OP.Subscribe($"{Name}.SetBoatRAxisMotion", SetBoatRAxisMotion);
  504. OP.Subscribe($"{Name}.SetAutoShutterUp", SetAutoShutterUp);
  505. OP.Subscribe($"{Name}.SetAutoShutterOpen", SetAutoShutterOpen);
  506. OP.Subscribe($"{Name}.SetAutoShutterRotateOpen", SetAutoShutterRotateOpen);
  507. OP.Subscribe($"{Name}.BypassStandbyFactor", SeBypassStandbyFactor);
  508. OP.Subscribe($"{Name}.SetCommand", SetCommand);
  509. OP.Subscribe($"{Name}.SetN2PurgeMode", SetN2PurgeMode);
  510. OP.Subscribe($"{Name}.SetAllFFUPower", (out string reason, int time, object[] param) =>
  511. {
  512. reason = string.Empty;
  513. SetAllFFUPower(param);
  514. return true;
  515. });
  516. //OP.Subscribe($"{Name}.SetTemperatureDetail",)
  517. OP.Subscribe($"{Name}.SetSensorRecipeOK", SetSensorRecipeOK);
  518. OP.Subscribe($"{Name}.SetSensorPROCManualOK", SetSensorPROCManualOK);
  519. OP.Subscribe($"{Name}.SetEditRecipeName", SetEditRecipeName);
  520. OP.Subscribe($"{Name}.SetEditRecipeStepName", SetEditRecipeStepName);
  521. OP.Subscribe($"{Name}.Heater.SetParameters", (out string reason, int time, object[] param) =>
  522. {
  523. reason = string.Empty;
  524. //Mode参数;Correct Table;PID Table
  525. //"Heater;Parameter\\TempCorrection\\tempCorrect,2,Name2;Parameter\\TempPID\\tempPID,3,Name3"
  526. SetHeaterControlParameters(param);
  527. return true;
  528. });
  529. OP.Subscribe($"{Name}.Heater.SetPID", (out string reason, int time, object[] param) =>
  530. {
  531. reason = string.Empty;
  532. SetHeaterPIDParameters(param[0].ToString());
  533. return true;
  534. });
  535. OP.Subscribe($"{Name}.Heater.SetCorrect", (out string reason, int time, object[] param) =>
  536. {
  537. reason = string.Empty;
  538. SetHeaterCorrectParameters(param[0].ToString());
  539. return true;
  540. });
  541. //Recipe
  542. OP.Subscribe($"{Name}.SetBoatMotion", (out string reason, int time, object[] param) =>
  543. {
  544. reason = string.Empty;
  545. SetBoatMotion(param);
  546. return true;
  547. });
  548. //Recipe
  549. OP.Subscribe($"{Name}.SetValves", (out string reason, int time, object[] param) =>
  550. {
  551. reason = string.Empty;
  552. SetValves(param);
  553. return true;
  554. });
  555. //Recipe
  556. OP.Subscribe($"{Name}.SetAlarmConditionTable", (out string reason, int time, object[] param) =>
  557. {
  558. reason = string.Empty;
  559. SetAlarmConditionTable(param);
  560. return true;
  561. });
  562. //manual
  563. OP.Subscribe($"{Name}.SetAlarmConditionParameter", (out string reason, int time, object[] param) =>
  564. {
  565. reason = string.Empty;
  566. InitAlarmCondition(param[0].ToString());
  567. SetAlarmConditionTable(new object[1] { param[1] });
  568. return true;
  569. });
  570. OP.Subscribe($"{Name}.SetBoatManualMotion", (out string reason, int time, object[] param) =>
  571. {
  572. reason = string.Empty;
  573. SetBoatManualMotion(param);
  574. return true;
  575. });
  576. OP.Subscribe($"{Name}.SetBWREnable", (out string reason, int time, object[] param) =>
  577. {
  578. reason = string.Empty;
  579. SetBWREnable(param);
  580. return true;
  581. });
  582. OP.Subscribe($"{Name}.SetF2ClnEnable", (out string reason, int time, object[] param) =>
  583. {
  584. reason = string.Empty;
  585. SetF2ClnEnable(param);
  586. return true;
  587. });
  588. OP.Subscribe($"{Name}.SetHFClnEnable", (out string reason, int time, object[] param) =>
  589. {
  590. reason = string.Empty;
  591. SetHFClnEnable(param);
  592. return true;
  593. });
  594. OP.Subscribe($"{Name}.SetDEPOEnable", (out string reason, int time, object[] param) =>
  595. {
  596. reason = string.Empty;
  597. SetDEPOEnable(param);
  598. return true;
  599. });
  600. OP.Subscribe($"{Name}.SetHTR1Enable", (out string reason, int time, object[] param) =>
  601. {
  602. reason = string.Empty;
  603. SetHTR1Enable(param);
  604. return true;
  605. });
  606. OP.Subscribe($"{Name}.SetHTR2Enable", (out string reason, int time, object[] param) =>
  607. {
  608. reason = string.Empty;
  609. SetHTR2Enable(param);
  610. return true;
  611. });
  612. OP.Subscribe($"{Name}.SetHTR3Enable", (out string reason, int time, object[] param) =>
  613. {
  614. reason = string.Empty;
  615. SetHTR3Enable(param);
  616. return true;
  617. });
  618. OP.Subscribe($"{Name}.SetCEXHEnable", (out string reason, int time, object[] param) =>
  619. {
  620. reason = string.Empty;
  621. SetCEXHEnable(param);
  622. return true;
  623. });
  624. OP.Subscribe($"{Name}.AUX.SetParameters", (out string reason, int time, object[] param) =>
  625. {
  626. reason = string.Empty;
  627. //Mode参数;Correct Table;PID Table
  628. //"Heater;Parameter\\TempCorrection\\tempCorrect,2,Name2;Parameter\\TempPID\\tempPID,3,Name3"
  629. SetAUXParameters(param);
  630. return true;
  631. });
  632. OP.Subscribe($"{Module}.SetAllMfcVirtualValue", (out string reason, int time, object[] param) =>
  633. {
  634. reason = string.Empty;
  635. var dict = param[0] as Dictionary<string, string>;
  636. foreach (var item in dict)
  637. {
  638. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  639. if (mfc != null)
  640. {
  641. mfc.SetMfcVirtualValue(out reason, 0, new object[] { item.Value });
  642. }
  643. }
  644. return true;
  645. });
  646. OP.Subscribe($"{Module}.SetAllMfcValue", (out string reason, int time, object[] param) =>
  647. {
  648. reason = string.Empty;
  649. var dict = param[0] as Dictionary<string, string>;
  650. foreach (var item in dict)
  651. {
  652. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  653. if (mfc != null)
  654. { mfc.SetMfcValue(out reason, 0, new object[] { item.Value }); }
  655. }
  656. return true;
  657. });
  658. OP.Subscribe($"{Module}.SetAllMfcSetPoint", (out string reason, int time, object[] param) =>
  659. {
  660. reason = string.Empty;
  661. var dict = param[0] as Dictionary<string, string>;
  662. foreach (var item in dict)
  663. {
  664. var mfc = _processMFCs.FirstOrDefault(x => x.Name == item.Key);
  665. if (mfc != null)
  666. { mfc.SetMfcSetPoint(out reason, 0, new object[] { item.Value }); }
  667. }
  668. return true;
  669. });
  670. OP.Subscribe($"{Module}.SetAll{AITValveOperation.GVVirtualTurnValve}", (out string reason, int time, object[] param) =>
  671. {
  672. reason = string.Empty;
  673. var dict = param[0] as Dictionary<string, bool>;
  674. foreach (var item in dict)
  675. {
  676. var valve = _valves.FirstOrDefault(x => x.Name == item.Key);
  677. if (valve != null)
  678. {
  679. valve.InvokeOpenCloseVirtualValve("", new object[] { item.Value });
  680. }
  681. }
  682. return true;
  683. });
  684. OP.Subscribe($"{Module}.SetAll{AITValveOperation.GVTurnValve}", (out string reason, int time, object[] param) =>
  685. {
  686. reason = string.Empty;
  687. var dict = param[0] as Dictionary<string, bool>;
  688. foreach (var item in dict)
  689. {
  690. _valves.FirstOrDefault(x => x.Name == item.Key).InvokeOpenCloseValve("", new object[] { item.Value });
  691. }
  692. return true;
  693. });
  694. OP.Subscribe($"{Name}.SetCREFEnable", (out string reason, int time, object[] param) =>
  695. {
  696. reason = string.Empty;
  697. SetCREFEnable(param);
  698. return true;
  699. });
  700. OP.Subscribe($"{Name}.SetSIREFEnable", (out string reason, int time, object[] param) =>
  701. {
  702. reason = string.Empty;
  703. SetHREFEnable(param);
  704. return true;
  705. });
  706. OP.Subscribe($"{Name}.SetBufferPurge", (out string reason, int time, object[] param) =>
  707. {
  708. reason = string.Empty;
  709. if (param.Length > 0 && param[0] is List<PurgeParameter> purge)
  710. {
  711. reason = SetBufferPurge(purge);
  712. if (!string.IsNullOrEmpty(reason)) return false;
  713. SC.SetItemValue("BufferPurge.OperationOrder", $"{purge[0].Name},{purge[0].Speed},Time({purge[0].Time}),{(purge[0].IsOpen ? "Open" : (purge[0].IsClose ? "Close" : ""))}");
  714. }
  715. return true;
  716. });
  717. InitOtherOP();
  718. }
  719. private string SetBufferPurge(List<PurgeParameter> purge)
  720. {
  721. string reason = string.Empty;
  722. if (TrigBufferPurgeTime == null || TrigBufferN2PurageEN == null) { reason = "TrigBufferPurgeTime/TrigBufferN2PurageEN is null"; }
  723. if (purge[0].IsOpen || purge[0].IsClose)
  724. {
  725. if (TrigBufferPurgeTime.SetAOTrigger(purge[0].Time, out reason))
  726. {
  727. TrigBufferN2PurageEN.SetTrigger(purge[0].IsOpen, out reason);
  728. }
  729. }
  730. return reason;
  731. }
  732. public void SetTemperatureDetail()
  733. {
  734. }
  735. private void InitFsm()
  736. {
  737. //Error
  738. Transition(STATE.Error, MSG.Reset, FsmReset, STATE.Idle);
  739. AnyStateTransition(MSG.Error, FsmOnError, STATE.Error);
  740. AnyStateTransition(MSG.Disconnected, FsmOnDisconnect, STATE.NotConnected);
  741. EnterExitTransition<STATE, FSM_MSG>(STATE.Error, FsmEnterError, FSM_MSG.NONE, FsmExitError);
  742. Transition(STATE.Idle, MSG.Abort, null, STATE.Idle);
  743. Transition(STATE.Idle, MSG.Reset, null, STATE.Idle);
  744. Transition(STATE.Init, MSG.Reset, null, STATE.Idle);
  745. Transition(STATE.Error, MSG.Abort, null, STATE.Error);
  746. //init
  747. Transition(STATE.Init, MSG.Home, FsmStartHome, STATE.Homing);
  748. AnyStateTransition(MSG.ToInit, FsmToInit, STATE.Init);
  749. //not connected
  750. Transition(STATE.NotConnected, MSG.Connected, null, STATE.Init);
  751. //Home
  752. EnterExitTransition((int)STATE.Homing, FsmEnterHome, (int)FSM_MSG.NONE, FsmExitHome);
  753. Transition(STATE.Error, MSG.Home, FsmStartHome, STATE.Homing);
  754. Transition(STATE.Idle, MSG.Home, FsmStartHome, STATE.Homing);
  755. Transition(STATE.Homing, FSM_MSG.TIMER, FsmMonitorHomeTask, STATE.Idle);
  756. Transition(STATE.Homing, MSG.Error, null, STATE.Init);
  757. Transition(STATE.Homing, MSG.Abort, FsmAbortTask, STATE.Init);
  758. //PrepareTransfer
  759. Transition(STATE.Idle, MSG.PrepareTransfer, FsmStartPrepareTransfer, STATE.PrepareTransfer);
  760. Transition(STATE.PrepareTransfer, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  761. Transition(STATE.PrepareTransfer, MSG.Abort, FsmAbortTask, STATE.Idle);
  762. //PostTransfer
  763. Transition(STATE.InTransfer, MSG.PostTransfer, FsmStartPostTransfer, STATE.PostTransfer);
  764. Transition(STATE.Idle, MSG.PostTransfer, FsmStartPostTransfer, STATE.PostTransfer);
  765. Transition(STATE.PostTransfer, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  766. Transition(STATE.PostTransfer, MSG.Abort, FsmAbortTask, STATE.Idle);
  767. //online
  768. Transition(STATE.Idle, MSG.SetOnline, FsmStartSetOnline, STATE.Idle);
  769. Transition(STATE.Idle, MSG.SetOffline, FsmStartSetOffline, STATE.Idle);
  770. //Leak check
  771. Transition(STATE.Idle, MSG.LeakCheck, FsmStartLeakCheck, STATE.LeakCheck);
  772. Transition(STATE.LeakCheck, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  773. Transition(STATE.LeakCheck, MSG.Abort, FsmAbortTask, STATE.Idle);
  774. EnterExitTransition<STATE, FSM_MSG>(STATE.LeakCheck, FsmEnterLeakCheck, FSM_MSG.NONE, FsmExitLeakCheck);
  775. //open SlitValve
  776. Transition(STATE.Idle, MSG.OpenSlitValve, FsmStartOpenSlitValve, STATE.OpenSlitValve);
  777. Transition(STATE.OpenSlitValve, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  778. Transition(STATE.OpenSlitValve, MSG.Abort, FsmAbortTask, STATE.Idle);
  779. //close SlitValve
  780. Transition(STATE.Idle, MSG.CloseSlitValve, FsmStartCloseSlitValve, STATE.CloseSlitValve);
  781. Transition(STATE.CloseSlitValve, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  782. Transition(STATE.CloseSlitValve, MSG.Abort, FsmAbortTask, STATE.Idle);
  783. //PreProcess
  784. Transition(STATE.Process, MSG.RunIdleRecipe, FsmStartIdleRecipePreProcess, STATE.PreProcess);
  785. Transition(STATE.Process, MSG.RunOtherRecipe, FsmStartOtherRecipePreProcess, STATE.PreProcess);
  786. Transition(STATE.Idle, MSG.RunOtherRecipe, FsmStartOtherRecipePreProcess, STATE.PreProcess);
  787. Transition(STATE.Idle, MSG.SelectRecipe, FsmSelectRecipe, STATE.Idle);
  788. Transition(STATE.Idle, MSG.RunRecipe, FsmStartPreProcess, STATE.PreProcess);
  789. Transition(STATE.PreProcess, FSM_MSG.TIMER, FsmMonitorTask, STATE.PreProcess);
  790. Transition(STATE.PreProcess, MSG.Abort, FsmAbortTask, STATE.Idle);
  791. Transition(STATE.PreProcess, MSG.RecipeAbort, FsmAbortTask, STATE.Idle);
  792. //Process
  793. Transition(STATE.PreProcess, MSG.Process, FsmStartProcess, STATE.Process);
  794. Transition(STATE.Idle, MSG.AlarmConditionJumpStep, FsmStartAlarmConditionJumpStep, STATE.Process);
  795. Transition(STATE.Process, FSM_MSG.TIMER, FsmMonitorTask, STATE.Process);
  796. Transition(STATE.Process, MSG.Abort, FsmAbortTask, STATE.Idle);
  797. Transition(STATE.Process, MSG.EndIdleRecipe, null, STATE.Idle);
  798. EnterExitTransition<STATE, FSM_MSG>(STATE.Process, FsmEnterProcess, FSM_MSG.NONE, FsmExitProcess);
  799. Transition(STATE.Paused, FSM_MSG.TIMER, FsmMonitorTask, STATE.Paused);
  800. Transition(STATE.Paused, MSG.Continue, FsmStartContinue, STATE.Process);
  801. Transition(STATE.Paused, MSG.Error, null, STATE.Paused);
  802. Transition(STATE.Paused, MSG.Abort, FsmAbortTask, STATE.Idle);
  803. //Transition(STATE.Paused, MSG.Error, null, STATE.Paused);
  804. Transition(STATE.Process, MSG.RecipeSkipStep, FsmSkipStep, STATE.Process);
  805. Transition(STATE.Process, MSG.RecipeJumpStep, FsmJumpStep, STATE.Process);
  806. Transition(STATE.Process, MSG.RecipePause, FsmRecipePause, STATE.Process);
  807. Transition(STATE.Process, MSG.RecipeContinue, FsmRecipeContinue, STATE.Process);
  808. Transition(STATE.Process, MSG.RecipeAbort, FsmRecipeAbort, STATE.Process);
  809. //PostProcess
  810. Transition(STATE.Process, MSG.PostProcess, FsmStartPostProcess, STATE.PostProcess);
  811. Transition(STATE.PostProcess, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  812. Transition(STATE.PostProcess, MSG.Abort, FsmAbortTask, STATE.Idle);
  813. EnterExitTransition<STATE, FSM_MSG>(STATE.PostProcess, null, FSM_MSG.NONE, ExitPostProcess);
  814. //MFC Calibration
  815. Transition(STATE.Idle, MSG.StartMFCCalibration, FsmStartMFCCalibration, STATE.MFCCali);
  816. Transition(STATE.MFCCali, FSM_MSG.TIMER, FsmMonitorTask, STATE.Idle);
  817. Transition(STATE.MFCCali, MSG.Abort, FsmAbortTask, STATE.Idle);
  818. }
  819. private bool FsmToInit(object[] param)
  820. {
  821. return true;
  822. }
  823. private bool FsmExitError(object[] param)
  824. {
  825. return true;
  826. }
  827. private bool FsmEnterError(object[] param)
  828. {
  829. if (OnEnterError != null)
  830. OnEnterError(Module);
  831. if (IsOnline)
  832. {
  833. //EV.PostWarningLog(Module, $"{Module}");
  834. }
  835. return true;
  836. }
  837. private bool FsmStartPostTransfer(object[] param)
  838. {
  839. _postTransferRoutine.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]));
  840. Result ret = StartRoutine(_postTransferRoutine);
  841. if (ret == Result.FAIL || ret == Result.DONE)
  842. return false;
  843. return ret == Result.RUN;
  844. }
  845. private bool FsmStartPrepareTransfer(object[] param)
  846. {
  847. _prepareTransferRoutine.Init((EnumTransferType)Enum.Parse(typeof(EnumTransferType), (string)param[0]));
  848. Result ret = StartRoutine(_prepareTransferRoutine);
  849. if (ret == Result.FAIL || ret == Result.DONE)
  850. return false;
  851. return ret == Result.RUN;
  852. }
  853. private bool FsmStartSetOffline(object[] param)
  854. {
  855. IsOnline = false;
  856. return true;
  857. }
  858. private bool FsmStartSetOnline(object[] param)
  859. {
  860. IsOnline = true;
  861. return true;
  862. }
  863. private bool FsmStartLeakCheck(object[] param)
  864. {
  865. _leakCheckRoutine.Init((int)param[0], (int)param[1], (string)param[2], (bool[])param[3]);
  866. Result ret = StartRoutine(_leakCheckRoutine);
  867. if (ret == Result.FAIL || ret == Result.DONE)
  868. return false;
  869. return ret == Result.RUN;
  870. }
  871. private bool FsmEnterLeakCheck(object[] param)
  872. {
  873. return true;
  874. }
  875. private bool FsmExitLeakCheck(object[] param)
  876. {
  877. //ChamberProcessPressureGauge.UnsetTuning();
  878. return true;
  879. }
  880. private bool FsmStartOpenSlitValve(object[] param)
  881. {
  882. return true;
  883. }
  884. private bool FsmStartCloseSlitValve(object[] param)
  885. {
  886. return true;
  887. }
  888. private bool FsmSelectRecipe(object[] param)
  889. {
  890. return true;
  891. }
  892. private bool FsmStartPreProcess(object[] param)
  893. {
  894. _recipeRunningInfo.RecipeName = (string)param[0];
  895. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, "Process"))
  896. {
  897. PreprocessStartFailedWarning.Set($"Load process recipe {_recipeRunningInfo.RecipeName} failed, {reason}");
  898. return false;
  899. }
  900. if (recipeSteps == null || recipeSteps.Count == 0)
  901. {
  902. PreprocessStartFailedWarning.Set($"Process recipe {_recipeRunningInfo.RecipeName} is empty");
  903. return false;
  904. }
  905. string abortRecipeName = SC.ContainsItem("System.Recipe.Abort Recipe") ? SC.GetStringValue("System.Recipe.Abort Recipe") : string.Empty;
  906. if (string.IsNullOrEmpty(abortRecipeName))
  907. {
  908. PreprocessStartFailedWarning.Set($"Load abort recipe failed, recipe file is null");
  909. return false;
  910. }
  911. SC.SetItemValueFromString("PM1.ProcessRecipe", _recipeRunningInfo.RecipeName);
  912. if (!IsJobProcess)
  913. Singleton<EquipmentManager>.Instance.CreatePj((string)param[0]);
  914. RecipeExecEntryEnumValue = RecipeExecEntryEnum.MaintenanceJobTrigger;
  915. _preprocessRoutine.Init((string)param[0]);
  916. Result ret = StartRoutine(_preprocessRoutine);
  917. if (ret == Result.FAIL || ret == Result.DONE)
  918. return false;
  919. if (!IsJobProcess)
  920. SensorPROCManualOK.Value = true;
  921. return ret == Result.RUN;
  922. }
  923. private bool FsmStartOtherRecipePreProcess(object[] param)
  924. {
  925. Singleton<EquipmentManager>.Instance.EndPj("AbnormalEnd");
  926. _processRoutine?.Abort();
  927. IsWait = false;
  928. IsJobProcess = false;
  929. _recipeRunningInfo.RecipeName = param[0].ToString();
  930. var recipeType = param[1].ToString();
  931. var tableID = 1;
  932. if (param.Length > 2)
  933. int.TryParse(param[2].ToString(), out tableID);
  934. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, recipeType, tableID))
  935. {
  936. PreprocessStartFailedWarning.Set($"Load {recipeType} recipe {_recipeRunningInfo.RecipeName} failed {reason}");
  937. return false;
  938. }
  939. if (recipeSteps == null || recipeSteps.Count == 0)
  940. {
  941. PreprocessStartFailedWarning.Set($"{recipeType} recipe {_recipeRunningInfo.RecipeName} is empty");
  942. return false;
  943. }
  944. if (!IsJobProcess)
  945. Singleton<EquipmentManager>.Instance.CreatePj(_recipeRunningInfo.RecipeName);
  946. _preprocessRoutine.Init(_recipeRunningInfo.RecipeName, false);
  947. RecipeRunningInfo.MainRecipeName = _recipeRunningInfo.RecipeName;
  948. RecipeRunningInfo.Head = recipeHead;
  949. RecipeRunningInfo.RecipeStepList = recipeSteps;
  950. RecipeRunningInfo.RecipeName = _recipeRunningInfo.RecipeName;
  951. RecipeRunningInfo.ExecRecipeType = recipeSteps.Count > 0 ? recipeSteps[0].RecipeType : string.Empty;
  952. Result ret = StartRoutine(_preprocessRoutine);
  953. if (ret == Result.FAIL || ret == Result.DONE)
  954. return false;
  955. if (!IsJobProcess)
  956. SensorPROCManualOK.Value = true;
  957. return ret == Result.RUN;
  958. }
  959. private bool FsmStartIdleRecipePreProcess(object[] param)
  960. {
  961. if (!CheckBoatState())
  962. {
  963. PreprocessStartFailedWarning.Set($"boat is not ready");
  964. return false;
  965. }
  966. Singleton<EquipmentManager>.Instance.EndPj("AbnormalEnd");
  967. _recipeRunningInfo.RecipeName = SC.ContainsItem("System.Recipe.Idle Recipe") ? SC.GetStringValue("System.Recipe.Idle Recipe") : string.Empty;
  968. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, "Idle"))
  969. {
  970. PreprocessStartFailedWarning.Set($"Load idle recipe {_recipeRunningInfo.RecipeName} failed {reason}");
  971. return false;
  972. }
  973. if (recipeSteps == null || recipeSteps.Count == 0)
  974. {
  975. PreprocessStartFailedWarning.Set($"Process recipe {_recipeRunningInfo.RecipeName} is empty");
  976. return false;
  977. }
  978. if (!IsJobProcess)
  979. Singleton<EquipmentManager>.Instance.CreatePj(_recipeRunningInfo.RecipeName);
  980. _preprocessRoutine.Init(_recipeRunningInfo.RecipeName, false);
  981. RecipeRunningInfo.MainRecipeName = _recipeRunningInfo.RecipeName;
  982. RecipeRunningInfo.Head = recipeHead;
  983. RecipeRunningInfo.RecipeStepList = recipeSteps;
  984. RecipeRunningInfo.RecipeName = _recipeRunningInfo.RecipeName;
  985. RecipeRunningInfo.ExecRecipeType = recipeSteps.Count > 0 ? recipeSteps[0].RecipeType : string.Empty;
  986. RecipeExecEntryEnumValue = RecipeExecEntryEnum.IdleRecipeTrigger;
  987. Result ret = StartRoutine(_preprocessRoutine);
  988. if (ret == Result.FAIL || ret == Result.DONE)
  989. return false;
  990. if (!IsJobProcess)
  991. SensorPROCManualOK.Value = true;
  992. return ret == Result.RUN;
  993. }
  994. private bool FsmStartProcess(object[] param)
  995. {
  996. Result ret = StartRoutine(_processRoutine);
  997. if (ret == Result.FAIL || ret == Result.DONE)
  998. return false;
  999. if (ret == Result.RUN && !IsJobProcess)
  1000. Singleton<EquipmentManager>.Instance.StartPj();
  1001. return ret == Result.RUN;
  1002. }
  1003. private bool FsmStartAlarmConditionJumpStep(object[] param)
  1004. {
  1005. if (param != null && param.Length > 0)
  1006. {
  1007. int.TryParse(param[0].ToString(), out int jumpStep);
  1008. _processRoutine.AlarmConditionJumpStep = jumpStep;
  1009. Result ret = StartRoutine(_processRoutine);
  1010. if (ret == Result.FAIL || ret == Result.DONE)
  1011. return false;
  1012. return ret == Result.RUN;
  1013. }
  1014. return false;
  1015. }
  1016. private bool FsmEnterProcess(object[] param)
  1017. {
  1018. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  1019. {
  1020. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  1021. continue;
  1022. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.InProcess);
  1023. }
  1024. _processTimer.Restart();
  1025. return true;
  1026. }
  1027. private bool FsmExitProcess(object[] param)
  1028. {
  1029. _processRoutine.ExitProcess();
  1030. if (!IsJobProcess && !_processRoutine.IsExecuteAbort)//非jobprocess需要recipe结束也需要更新数据库
  1031. {
  1032. var firstPjId = Singleton<EquipmentManager>.Instance.GetFirstPJId();
  1033. Singleton<EquipmentManager>.Instance.EndPj();
  1034. }
  1035. //_statWaferCount.Increase();
  1036. //_statProcessTime.Increase((int)(_processTimer.ElapsedMilliseconds/1000));
  1037. _isPrepareProcess = true;
  1038. IsJobProcess = false;
  1039. SensorPROCManualOK.Value = false;
  1040. //if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "StandbyStep")
  1041. //{
  1042. // StringProcessFlowState = ProcessFlowState.Standby.ToString();
  1043. // _recipeRunningInfo.StepName = "Standby";
  1044. // var standbyStep = _recipeRunningInfo.RecipeStepList.Where(x => x.StepName == "Standby").FirstOrDefault();
  1045. // if (standbyStep != null)
  1046. // {
  1047. // EV.PostInfoLog(Module, $"Recipe {_recipeRunningInfo.RecipeName} complete excute standby step");
  1048. // foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  1049. // {
  1050. // if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out string reason, standbyStep.RecipeCommands[recipeCmd]))
  1051. // {
  1052. // if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1053. // {
  1054. // if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1055. // {
  1056. // reason = $"Can not execute {recipeCmd}, {reason}";
  1057. // return false;
  1058. // }
  1059. // else
  1060. // {
  1061. // OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1062. // }
  1063. // }
  1064. // else
  1065. // {
  1066. // OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1067. // }
  1068. // }
  1069. // else
  1070. // {
  1071. // OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1072. // }
  1073. // }
  1074. // }
  1075. // _isStandbyStep = true;
  1076. // IsExcuteIdleRecipe = false;
  1077. //}
  1078. //else if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "IdleRecipe")
  1079. //{
  1080. // if (!IsExcuteIdleRecipe)
  1081. // {
  1082. // PostMsg((int)MSG.RunIdleRecipe);
  1083. // IsExcuteIdleRecipe = true;
  1084. // }
  1085. // else
  1086. // {
  1087. // IsExcuteIdleRecipe = false;
  1088. // _isStandbyStep = false;
  1089. // }
  1090. //}
  1091. //else
  1092. //{
  1093. // IsExcuteIdleRecipe = false;
  1094. // _isStandbyStep = false;
  1095. //}
  1096. return true;
  1097. }
  1098. private bool FsmStartContinue(object[] param)
  1099. {
  1100. return true;
  1101. }
  1102. private bool FsmSkipStep(object[] param)
  1103. {
  1104. _processRoutine.SkipCurrentRecipeStep();
  1105. return true;
  1106. }
  1107. private bool FsmJumpStep(object[] param)
  1108. {
  1109. int.TryParse(param[0].ToString(), out int stepNumber);
  1110. _processRoutine.JumpCurrentRecipeStep(stepNumber, param[1].ToString());
  1111. return true;
  1112. }
  1113. private bool FsmRecipePause(object[] param)
  1114. {
  1115. _processRoutine.PauseRecipe();
  1116. return true;
  1117. }
  1118. private bool FsmRecipeContinue(object[] param)
  1119. {
  1120. _processRoutine.ContinueRecipe();
  1121. return true;
  1122. }
  1123. private bool FsmRecipeAbort(object[] param)
  1124. {
  1125. Singleton<EquipmentManager>.Instance.EndPj("AbnormalEnd");
  1126. var firstPjId = Singleton<EquipmentManager>.Instance.GetFirstPJId();
  1127. _processRoutine.UpdateProcessDataPJid(firstPjId);
  1128. _processRoutine.Abort();
  1129. IsWait = false;
  1130. IsJobProcess = false;
  1131. var recipeName = _recipeRunningInfo.Head.AbortRecipe;
  1132. var reason = "";
  1133. if (!File.Exists($"{PathManager.GetRecipeDir()}\\{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\Abort\\{recipeName}.rcp") ||
  1134. !RecipeParser.Parse(recipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out reason, "Abort"))
  1135. {
  1136. recipeName = SC.GetStringValue("System.Recipe.Abort Recipe");
  1137. if (!File.Exists($"{PathManager.GetRecipeDir()}\\{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\Abort\\{recipeName}.rcp") ||
  1138. !RecipeParser.Parse(SC.GetStringValue("System.Recipe.Abort Recipe"), ModuleName.PM1.ToString(), out recipeHead, out recipeSteps, out reason, "Abort"))
  1139. {
  1140. PostMsg(MSG.Error);
  1141. ExecuteAbortRecipeFailAlarm.Set($"Load abort recipe {recipeName} failed, {reason}");
  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. return false;
  1156. }
  1157. else
  1158. {
  1159. recipeTable = recipeData.FirstOrDefault().Key.ToString();
  1160. }
  1161. }
  1162. else
  1163. {
  1164. recipeTable = currectStep.AbortRecipeTableInfo.Split(':').FirstOrDefault();
  1165. }
  1166. }
  1167. else
  1168. {
  1169. if (!RecipeParser.ParseTables(SC.GetStringValue("System.Recipe.Abort Recipe"), Module, out var recipeData, out reason, "Abort"))
  1170. {
  1171. ExecuteAbortRecipeFailAlarm.Set($"Load abort recipe {recipeName} failed, {reason}");
  1172. return false;
  1173. }
  1174. else
  1175. {
  1176. recipeTable = recipeData.FirstOrDefault().Key.ToString();
  1177. }
  1178. }
  1179. RecipeExecEntryEnumValue = RecipeExecEntryEnum.AbortRecipeTrigger;
  1180. CheckToPostMessage((int)MSG.RunOtherRecipe, recipeName, recipeType, recipeTable);
  1181. return true;
  1182. }
  1183. private bool FsmStartPostProcess(object[] param)
  1184. {
  1185. Result ret = StartRoutine(_postprocessRoutine);
  1186. if (ret == Result.FAIL || ret == Result.DONE)
  1187. return false;
  1188. return ret == Result.RUN;
  1189. }
  1190. private bool ExitPostProcess(object[] param)
  1191. {
  1192. return true;
  1193. }
  1194. private bool FsmStartMFCCalibration(object[] param)
  1195. {
  1196. return true;
  1197. }
  1198. private bool FsmOnDisconnect(object[] param)
  1199. {
  1200. if (FsmState == (int)STATE.Error)
  1201. {
  1202. return false;
  1203. }
  1204. return true;
  1205. }
  1206. private bool FsmOnError(object[] param)
  1207. {
  1208. if (FsmState == (int)STATE.Error)
  1209. {
  1210. return false;
  1211. }
  1212. if ((FsmState == (int)STATE.Process) || (FsmState == (int)STATE.PreProcess) || (FsmState == (int)STATE.PostProcess))
  1213. {
  1214. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  1215. {
  1216. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  1217. continue;
  1218. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.Failed);
  1219. }
  1220. // _processRoutine.Abort();
  1221. _postprocessRoutine.Abort();
  1222. _preprocessRoutine.Abort();
  1223. IsWait = false;
  1224. }
  1225. return true;
  1226. }
  1227. private bool FsmReset(object[] param)
  1228. {
  1229. if (!_isInit)
  1230. {
  1231. PostMsg(MSG.ToInit);
  1232. return false;
  1233. }
  1234. foreach (var device in _allModuleDevice)
  1235. {
  1236. if (device.HasAlarm)
  1237. {
  1238. CheckHasAlarmWarning.Set($"{device.Name} has error");
  1239. }
  1240. }
  1241. if (CheckHasAlarm())
  1242. return false;
  1243. return true;
  1244. }
  1245. private bool FsmStartHome(object[] param)
  1246. {
  1247. //if (!CheckIsConnected())
  1248. //{
  1249. // PostMsg(MSG.Disconnected);
  1250. // return false;
  1251. //}
  1252. if (CheckHasAlarm())
  1253. {
  1254. CheckHasAlarmWarning.Set($"There exist active alarm, reset error before continue the initialization");
  1255. PostMsg(MSG.Error);
  1256. return false;
  1257. }
  1258. Result ret = StartRoutine(_homeRoutine);
  1259. if (ret == Result.FAIL || ret == Result.DONE)
  1260. return false;
  1261. _isInit = false;
  1262. return ret == Result.RUN;
  1263. }
  1264. private bool FsmExitHome(object[] param)
  1265. {
  1266. return true;
  1267. }
  1268. private bool FsmEnterHome(object[] param)
  1269. {
  1270. return true;
  1271. }
  1272. private bool FsmAbortTask(object[] param)
  1273. {
  1274. AbortRoutine();
  1275. _isPrepareProcess = true;
  1276. return true;
  1277. }
  1278. private bool FsmMonitorHomeTask(object[] param)
  1279. {
  1280. Result ret = MonitorRoutine();
  1281. if (ret == Result.FAIL)
  1282. {
  1283. PostMsg(MSG.Error);
  1284. return false;
  1285. }
  1286. if (ret == Result.DONE)
  1287. {
  1288. _isInit = true;
  1289. return true;
  1290. }
  1291. return false;
  1292. }
  1293. private bool FsmMonitorTask(object[] param)
  1294. {
  1295. Result ret = MonitorRoutine();
  1296. if (ret == Result.FAIL)
  1297. {
  1298. PostMsg(MSG.Error);
  1299. return false;
  1300. }
  1301. if (ret == Result.DONE && FsmState == (int)STATE.PreProcess)
  1302. {
  1303. PostMsg(MSG.Process);
  1304. return true;
  1305. }
  1306. if (ret == Result.DONE && FsmState == (int)STATE.Process)
  1307. {
  1308. PostMsg(MSG.PostProcess);
  1309. return true;
  1310. }
  1311. if (ret == Result.DONE && IsExcuteIdleRecipe && FsmState == (int)STATE.PostProcess)
  1312. {
  1313. PostMsg(MSG.RunIdleRecipe);
  1314. return true;
  1315. }
  1316. return ret == Result.DONE;
  1317. }
  1318. #region Service functions
  1319. public override bool Home(out string reason)
  1320. {
  1321. CheckToPostMessage((int)MSG.Home);
  1322. reason = string.Empty;
  1323. return true;
  1324. }
  1325. public override void Reset()
  1326. {
  1327. ResetAUXTrig();
  1328. if (!IsProcessing)
  1329. CheckToPostMessage((int)MSG.Reset);
  1330. }
  1331. public override bool PrepareTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1332. {
  1333. CheckToPostMessage((int)MSG.PrepareTransfer, transferType.ToString());
  1334. reason = string.Empty;
  1335. return true;
  1336. }
  1337. public override bool TransferHandoff(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1338. {
  1339. reason = string.Empty;
  1340. return true;
  1341. }
  1342. public override bool PostTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1343. {
  1344. CheckToPostMessage((int)MSG.PostTransfer, transferType.ToString());
  1345. reason = string.Empty;
  1346. return true;
  1347. }
  1348. public override bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1349. {
  1350. reason = string.Empty;
  1351. var boat = Singleton<EquipmentManager>.Instance.Modules[ModuleName.Boat] as BoatModule;
  1352. if (!boat.IsBoatElevatorAtHomePosition)
  1353. {
  1354. reason = "Boat z axis is not at home position";
  1355. return false;
  1356. }
  1357. if (!boat.IsBoatRotationAtHomePosition)
  1358. {
  1359. reason = "Boat r axis is not at home position";
  1360. return false;
  1361. }
  1362. return true;
  1363. }
  1364. public override void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1365. {
  1366. //if (FsmState == (int)STATE.InTransfer)
  1367. // CheckToPostMessage(MSG.Transfer)
  1368. }
  1369. public override void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1370. {
  1371. //if (FsmState == (int)STATE.InTransfer)
  1372. // CheckToPostMessage(MSG.Transfer)
  1373. }
  1374. public override bool Process(string recipeName, bool isCleanRecipe, bool withWafer, out string reason)
  1375. {
  1376. _recipeRunningInfo.RecipeName = recipeName;
  1377. _isPrepareProcess = false;
  1378. _isStandbyStep = false;
  1379. IsJobProcess = true;
  1380. IsExcuteIdleRecipe = false;
  1381. CheckToPostMessage((int)MSG.RunRecipe, recipeName);
  1382. reason = string.Empty;
  1383. return true;
  1384. }
  1385. public override bool Standby(string recipeName, out string reason)
  1386. {
  1387. reason = string.Empty;
  1388. _recipeRunningInfo.RecipeName = recipeName;
  1389. _recipeRunningInfo.MainRecipeName = recipeName;
  1390. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out reason, "Process"))
  1391. {
  1392. reason = $"Load process recipe {_recipeRunningInfo.RecipeName} failed, {reason}";
  1393. return false;
  1394. }
  1395. if (recipeSteps == null || recipeSteps.Count == 0)
  1396. {
  1397. reason = $"Process recipe {_recipeRunningInfo.RecipeName} is empty";
  1398. return false;
  1399. }
  1400. _isStandbyStep = true;
  1401. var standbyStep = recipeSteps.Where(x => x.StepName == "Standby").FirstOrDefault();
  1402. if (standbyStep != null)
  1403. {
  1404. StringProcessFlowState = ProcessFlowState.Standby.ToString();
  1405. _recipeRunningInfo.StepName = "Standby";
  1406. EV.PostInfoLog(Module, $"pj job excute recipe {recipeName} standby step");
  1407. foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  1408. {
  1409. if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1410. {
  1411. if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1412. {
  1413. if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1414. {
  1415. reason = $"Can not execute {recipeCmd}, {reason}";
  1416. return false;
  1417. }
  1418. else
  1419. {
  1420. OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1421. }
  1422. }
  1423. else
  1424. {
  1425. OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1426. }
  1427. }
  1428. else
  1429. {
  1430. OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1431. }
  1432. }
  1433. }
  1434. return true;
  1435. }
  1436. public void EndIdleRecipe()
  1437. {
  1438. CheckToPostMessage((int)MSG.EndIdleRecipe);
  1439. }
  1440. private double GetNewShowTime()
  1441. {
  1442. return GetWaitTime() + _recipeRunningInfo.HoldTime;
  1443. }
  1444. private double GetWaitTime()
  1445. {
  1446. if (StringFsmStatus == "Idle")
  1447. {
  1448. _waitTimer.Reset();
  1449. }
  1450. if (IsWait)
  1451. {
  1452. _waitTimer.Start();
  1453. }
  1454. else
  1455. {
  1456. _waitTimer.Stop();
  1457. }
  1458. return _waitTimer.ElapsedMilliseconds / 1000;
  1459. }
  1460. #region
  1461. #region
  1462. private string _processRecipeStepNumber = "";
  1463. private string _processRecipeStepName = "";
  1464. private string _subRecipeStepName = "";
  1465. private string _subRecipeStepNumber = "";
  1466. private string _currentFilmThickness = "";
  1467. private string _dryClearCount = "";
  1468. private bool _isInSubProcessing = false;
  1469. /// <summary>
  1470. /// 更新FDC采集的数据
  1471. /// </summary>
  1472. /// <param name="isSub"></param>
  1473. /// <param name="stepName"></param>
  1474. /// <param name="stepNo"></param>
  1475. public void SetFDCRecipeStepName(bool isSub, string stepName, string stepNo = "")
  1476. {
  1477. if (isSub)
  1478. {
  1479. _subRecipeStepName = stepName;
  1480. _subRecipeStepNumber = stepNo;
  1481. _isInSubProcessing = true;
  1482. _processRecipeStepName = "";
  1483. _processRecipeStepNumber = "";
  1484. }
  1485. else
  1486. {
  1487. _isInSubProcessing = false;
  1488. _processRecipeStepName = stepName;
  1489. _processRecipeStepNumber = stepNo;
  1490. _subRecipeStepName = string.Empty;
  1491. _subRecipeStepNumber = string.Empty;
  1492. }
  1493. }
  1494. #endregion
  1495. public void ResetFDCRecipeStepName()
  1496. {
  1497. _subRecipeStepName = "";
  1498. _subRecipeStepNumber = "";
  1499. _processRecipeStepName = "";
  1500. _processRecipeStepNumber = "";
  1501. _isInSubProcessing = false;
  1502. }
  1503. public void SetCurrentFilmThickness(float value)
  1504. {
  1505. _currentFilmThickness = value.ToString();
  1506. }
  1507. public void SetDryClearCount(float value)
  1508. {
  1509. _dryClearCount = value.ToString();
  1510. }
  1511. public void FDCSubscribe()
  1512. {
  1513. DATA.Subscribe($"DryClearCount", () => _dryClearCount);
  1514. DATA.Subscribe($"BoatCurrentFilmThickness", () => _currentFilmThickness);
  1515. DATA.Subscribe($"ProcessRecipeStepNumber", () => IsProcessing ? _processRecipeStepNumber : "");
  1516. DATA.Subscribe($"ProcessRecipeStepName", () => IsProcessing ? _processRecipeStepName : "");
  1517. DATA.Subscribe($"SubRecipeStepName", () => _subRecipeStepName);
  1518. DATA.Subscribe($"SubRecipeStepNumber", () => _subRecipeStepNumber);
  1519. //DATA.Subscribe($"IsInSubProcessing", () => _isInSubProcessing);
  1520. }
  1521. #endregion
  1522. #region
  1523. public void CarrierOutStart(CarrierInfo carrier)
  1524. {
  1525. List<string> crids = CarrierManager.Instance.GetBufferMaterialInfo();
  1526. SECsDataItem BufferMaterialInfos = new SECsDataItem(SECsFormat.List);
  1527. SECsDataItem BufferMaterialInfo = new SECsDataItem(SECsFormat.List);
  1528. foreach (var _id in crids)
  1529. {
  1530. BufferMaterialInfo = new SECsDataItem(SECsFormat.List);
  1531. BufferMaterialInfo.Add("StockerName", _id.Split(';')[0], SECsFormat.Ascii);
  1532. BufferMaterialInfo.Add("StockerCarrierID", _id.Split(';')[1].Replace("emptyid", ""), SECsFormat.Ascii);
  1533. BufferMaterialInfos.Add(BufferMaterialInfo);
  1534. }
  1535. if (carrier != null)
  1536. {
  1537. EV.Notify(UniversalEvents.CarrierOutStart, new SerializableDictionary<string, object>()
  1538. {
  1539. {DataVariables.Usage, carrier.CarrierType.ToString()},
  1540. {DataVariables.CarrierID, carrier.CarrierId},
  1541. {DataVariables.BufferCapacitiyList, GetBufferCapacitiyList()},
  1542. {DataVariables.BufferMaterialInfo, BufferMaterialInfos},
  1543. });
  1544. }
  1545. }
  1546. private SECsDataItem GetBufferCapacitiyList()
  1547. {
  1548. SECsDataItem bufinfo = new SECsDataItem(SECsFormat.List);
  1549. bufinfo.Add("BUFPara", "Partition1");
  1550. bufinfo.Add("BUFPara", "General");
  1551. int emptyStocker = 0;
  1552. int totalStocker = 0;
  1553. foreach (var key in Singleton<EquipmentManager>.Instance.Modules.Keys)
  1554. {
  1555. if (ModuleHelper.IsStocker(key))
  1556. totalStocker++;
  1557. if (ModuleHelper.IsStocker(key) && CarrierManager.Instance.CheckNoCarrier(key, 0))
  1558. {
  1559. var has = false;
  1560. foreach (var key1 in Singleton<EquipmentManager>.Instance.Modules.Keys)
  1561. {
  1562. if (CarrierManager.Instance.CheckHasCarrier(key1, 0) && CarrierManager.Instance.GetCarrier(key1, 0).InternalModuleName == key)
  1563. {
  1564. has = true;
  1565. break;
  1566. }
  1567. }
  1568. if (has)
  1569. continue;
  1570. emptyStocker++;
  1571. }
  1572. }
  1573. bufinfo.Add("BUFPara", emptyStocker, SECsFormat.U1);
  1574. bufinfo.Add("BUFPara", totalStocker, SECsFormat.U1);
  1575. int unallocatedPartitionCapacity = 0;
  1576. List<ModuleName> checkList = new List<ModuleName>()
  1577. {
  1578. ModuleName.LP1,
  1579. ModuleName.LP2,
  1580. ModuleName.FIMS1,
  1581. ModuleName.FIMS2,
  1582. };
  1583. foreach (var module in checkList)
  1584. {
  1585. if (CarrierManager.Instance.CheckHasCarrier(module, 0))
  1586. unallocatedPartitionCapacity++;
  1587. }
  1588. bufinfo.Add("BUFPara", unallocatedPartitionCapacity, SECsFormat.U1);
  1589. return bufinfo;
  1590. }
  1591. public void CarrierOutEnd(CarrierInfo carrier, string lPPortID)
  1592. {
  1593. List<string> crids = CarrierManager.Instance.GetBufferMaterialInfo();
  1594. SECsDataItem BufferMaterialInfos = new SECsDataItem(SECsFormat.List);
  1595. SECsDataItem BufferMaterialInfo = new SECsDataItem(SECsFormat.List);
  1596. foreach (var _id in crids)
  1597. {
  1598. BufferMaterialInfo = new SECsDataItem(SECsFormat.List);
  1599. BufferMaterialInfo.Add("StockerName", _id.Split(';')[0], SECsFormat.Ascii);
  1600. BufferMaterialInfo.Add("StockerCarrierID", _id.Split(';')[1].Replace("emptyid", ""), SECsFormat.Ascii);
  1601. BufferMaterialInfos.Add(BufferMaterialInfo);
  1602. }
  1603. if (carrier != null)
  1604. {
  1605. EV.Notify(UniversalEvents.CarrierOutEnd, new SerializableDictionary<string, object>()
  1606. {
  1607. {"PortID", lPPortID},
  1608. {DataVariables.Usage, carrier.CarrierType.ToString()},
  1609. {DataVariables.BufferCapacitiyList, GetBufferCapacitiyList()},
  1610. {DataVariables.BufferMaterialInfo, BufferMaterialInfos},
  1611. {DataVariables.CarrierID, carrier.CarrierId},
  1612. });
  1613. }
  1614. }
  1615. #endregion
  1616. }
  1617. #endregion
  1618. }