PMModule.cs 77 KB

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