PMModule.cs 78 KB

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