PMModule.cs 63 KB

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