PMModule.cs 75 KB

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