PMModule.cs 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593
  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. #region MyRegion
  819. if (CheckRecipeThicknessMoreThan(_recipeRunningInfo.RecipeName))
  820. return false;
  821. if (CheckRecipeExecuteFreqMoreThan(_recipeRunningInfo.RecipeName))
  822. return false;
  823. #endregion
  824. if (!IsJobProcess)
  825. SensorPROCManualOK.Value = true;
  826. return ret == Result.RUN;
  827. }
  828. private bool FsmStartOtherRecipePreProcess(object[] param)
  829. {
  830. _recipeRunningInfo.RecipeName = param[0].ToString();
  831. var recipeType = param[1].ToString();
  832. var tableID = 1;
  833. if (param.Length > 2)
  834. int.TryParse(param[2].ToString(), out tableID);
  835. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, recipeType, tableID))
  836. {
  837. PreprocessStartFailedWarning.Set($"Load {recipeType} recipe {_recipeRunningInfo.RecipeName} failed {reason}");
  838. return false;
  839. }
  840. if (recipeSteps == null || recipeSteps.Count == 0)
  841. {
  842. PreprocessStartFailedWarning.Set($"{recipeType} recipe {_recipeRunningInfo.RecipeName} is empty");
  843. return false;
  844. }
  845. if (!IsJobProcess)
  846. Singleton<EquipmentManager>.Instance.CreatePj(_recipeRunningInfo.RecipeName);
  847. _preprocessRoutine.Init(_recipeRunningInfo.RecipeName, false);
  848. RecipeRunningInfo.MainRecipeName = _recipeRunningInfo.RecipeName;
  849. RecipeRunningInfo.Head = recipeHead;
  850. RecipeRunningInfo.RecipeStepList = recipeSteps;
  851. Result ret = StartRoutine(_preprocessRoutine);
  852. if (ret == Result.FAIL || ret == Result.DONE)
  853. return false;
  854. if (!IsJobProcess)
  855. SensorPROCManualOK.Value = true;
  856. return ret == Result.RUN;
  857. }
  858. private bool FsmStartIdleRecipePreProcess(object[] param)
  859. {
  860. if (!CheckBoatState())
  861. {
  862. PreprocessStartFailedWarning.Set($"boat is not ready");
  863. return false;
  864. }
  865. _recipeRunningInfo.RecipeName = SC.ContainsItem("System.Recipe.Idle Recipe") ? SC.GetStringValue("System.Recipe.Idle Recipe") : string.Empty;
  866. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out string reason, "Idle"))
  867. {
  868. PreprocessStartFailedWarning.Set($"Load idle recipe {_recipeRunningInfo.RecipeName} failed {reason}");
  869. return false;
  870. }
  871. if (recipeSteps == null || recipeSteps.Count == 0)
  872. {
  873. PreprocessStartFailedWarning.Set($"Process recipe {_recipeRunningInfo.RecipeName} is empty");
  874. return false;
  875. }
  876. if (!IsJobProcess)
  877. Singleton<EquipmentManager>.Instance.CreatePj(_recipeRunningInfo.RecipeName);
  878. _preprocessRoutine.Init(_recipeRunningInfo.RecipeName, false);
  879. RecipeRunningInfo.MainRecipeName = _recipeRunningInfo.RecipeName;
  880. RecipeRunningInfo.Head = recipeHead;
  881. RecipeRunningInfo.RecipeStepList = recipeSteps;
  882. Result ret = StartRoutine(_preprocessRoutine);
  883. if (ret == Result.FAIL || ret == Result.DONE)
  884. return false;
  885. if (!IsJobProcess)
  886. SensorPROCManualOK.Value = true;
  887. return ret == Result.RUN;
  888. }
  889. private bool FsmStartProcess(object[] param)
  890. {
  891. Result ret = StartRoutine(_processRoutine);
  892. if (ret == Result.FAIL || ret == Result.DONE)
  893. return false;
  894. if (ret == Result.RUN && !IsJobProcess)
  895. Singleton<EquipmentManager>.Instance.StartPj();
  896. return ret == Result.RUN;
  897. }
  898. private bool FsmStartAlarmConditionJumpStep(object[] param)
  899. {
  900. if (param != null && param.Length > 0)
  901. {
  902. int.TryParse(param[0].ToString(), out int jumpStep);
  903. _processRoutine.AlarmConditionJumpStep = jumpStep;
  904. Result ret = StartRoutine(_processRoutine);
  905. if (ret == Result.FAIL || ret == Result.DONE)
  906. return false;
  907. return ret == Result.RUN;
  908. }
  909. return false;
  910. }
  911. private bool FsmEnterProcess(object[] param)
  912. {
  913. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  914. {
  915. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  916. continue;
  917. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.InProcess);
  918. }
  919. _processTimer.Restart();
  920. return true;
  921. }
  922. private bool FsmExitProcess(object[] param)
  923. {
  924. _processRoutine.ExitProcess();
  925. if (!IsJobProcess && !_processRoutine.IsExecuteAbort)//非jobprocess需要recipe结束也需要更新数据库
  926. {
  927. var firstPjId = Singleton<EquipmentManager>.Instance.GetFirstPJId();
  928. Singleton<EquipmentManager>.Instance.EndPj();
  929. _processRoutine.UpdateProcessDataPJid(firstPjId);
  930. }
  931. //_statWaferCount.Increase();
  932. //_statProcessTime.Increase((int)(_processTimer.ElapsedMilliseconds/1000));
  933. _isPrepareProcess = true;
  934. IsJobProcess = false;
  935. SensorPROCManualOK.Value = false;
  936. //if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "StandbyStep")
  937. //{
  938. // StringProcessFlowState = ProcessFlowState.Standby.ToString();
  939. // _recipeRunningInfo.StepName = "Standby";
  940. // var standbyStep = _recipeRunningInfo.RecipeStepList.Where(x => x.StepName == "Standby").FirstOrDefault();
  941. // if (standbyStep != null)
  942. // {
  943. // EV.PostInfoLog(Module, $"Recipe {_recipeRunningInfo.RecipeName} complete excute standby step");
  944. // foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  945. // {
  946. // if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out string reason, standbyStep.RecipeCommands[recipeCmd]))
  947. // {
  948. // if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  949. // {
  950. // if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  951. // {
  952. // reason = $"Can not execute {recipeCmd}, {reason}";
  953. // return false;
  954. // }
  955. // else
  956. // {
  957. // OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  958. // }
  959. // }
  960. // else
  961. // {
  962. // OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  963. // }
  964. // }
  965. // else
  966. // {
  967. // OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  968. // }
  969. // }
  970. // }
  971. // _isStandbyStep = true;
  972. // IsExcuteIdleRecipe = false;
  973. //}
  974. //else if (SC.GetStringValue($"System.Recipe.ExcuteAfterRecipeComplete") == "IdleRecipe")
  975. //{
  976. // if (!IsExcuteIdleRecipe)
  977. // {
  978. // PostMsg((int)MSG.RunIdleRecipe);
  979. // IsExcuteIdleRecipe = true;
  980. // }
  981. // else
  982. // {
  983. // IsExcuteIdleRecipe = false;
  984. // _isStandbyStep = false;
  985. // }
  986. //}
  987. //else
  988. //{
  989. // IsExcuteIdleRecipe = false;
  990. // _isStandbyStep = false;
  991. //}
  992. return true;
  993. }
  994. public string GetN2PurgeModeEnumByStr(string str)
  995. {
  996. if ((str == N2PurgeModeEnum.ATMMode.ToString()) || (str == N2PurgeModeEnum.ATMMode.ToDescription()) || (str.StartsWith("ATM")))
  997. {
  998. return N2PurgeModeEnum.ATMMode.ToString();
  999. }
  1000. if ((str == N2PurgeModeEnum.N2PurgeMode.ToString()) || (str == N2PurgeModeEnum.N2PurgeMode.ToDescription()) || (str.StartsWith("N2")))
  1001. {
  1002. return N2PurgeModeEnum.N2PurgeMode.ToString();
  1003. }
  1004. return N2PurgeModeEnum.ManualMode.ToString();
  1005. }
  1006. private bool FsmStartContinue(object[] param)
  1007. {
  1008. return true;
  1009. }
  1010. private bool FsmSkipStep(object[] param)
  1011. {
  1012. _processRoutine.SkipCurrentRecipeStep();
  1013. return true;
  1014. }
  1015. private bool FsmJumpStep(object[] param)
  1016. {
  1017. int.TryParse(param[0].ToString(), out int stepNumber);
  1018. _processRoutine.JumpCurrentRecipeStep(stepNumber, param[1].ToString());
  1019. return true;
  1020. }
  1021. private bool FsmRecipePause(object[] param)
  1022. {
  1023. _processRoutine.PauseRecipe();
  1024. return true;
  1025. }
  1026. private bool FsmRecipeContinue(object[] param)
  1027. {
  1028. _processRoutine.ContinueRecipe();
  1029. return true;
  1030. }
  1031. private bool FsmRecipeAbort(object[] param)
  1032. {
  1033. Singleton<EquipmentManager>.Instance.EndPj("Recipe Abort");
  1034. _processRoutine.Abort();
  1035. IsWait = false;
  1036. IsJobProcess = false;
  1037. var recipeName = _recipeRunningInfo.Head.AbortRecipe;
  1038. var reason = "";
  1039. if (!File.Exists($"{PathManager.GetRecipeDir()}\\{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\Abort\\{recipeName}.rcp") ||
  1040. !RecipeParser.Parse(recipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out reason, "Abort"))
  1041. {
  1042. recipeName = SC.GetStringValue("System.Recipe.Abort Recipe");
  1043. if (!File.Exists($"{PathManager.GetRecipeDir()}\\{SC.GetStringValue("System.Recipe.SupportedChamberType")}\\Abort\\{recipeName}.rcp") ||
  1044. !RecipeParser.Parse(SC.GetStringValue("System.Recipe.Abort Recipe"), ModuleName.PM1.ToString(), out recipeHead, out recipeSteps, out reason, "Abort"))
  1045. {
  1046. PostMsg(MSG.Error);
  1047. ExecuteAbortRecipeFailAlarm.Set($"Load abort recipe {recipeName} failed, {reason}");
  1048. return false;
  1049. }
  1050. }
  1051. RecipeRunningInfo.MainRecipeName = recipeName;
  1052. RecipeRunningInfo.Head = recipeHead;
  1053. RecipeRunningInfo.RecipeStepList = recipeSteps;
  1054. Result ret = StartRoutine(_processRoutine);
  1055. if (ret == Result.FAIL || ret == Result.DONE)
  1056. return false;
  1057. return ret == Result.RUN;
  1058. }
  1059. private bool FsmStartPostProcess(object[] param)
  1060. {
  1061. Result ret = StartRoutine(_postprocessRoutine);
  1062. if (ret == Result.FAIL || ret == Result.DONE)
  1063. return false;
  1064. return ret == Result.RUN;
  1065. }
  1066. private bool ExitPostProcess(object[] param)
  1067. {
  1068. return true;
  1069. }
  1070. private bool FsmStartMFCCalibration(object[] param)
  1071. {
  1072. return true;
  1073. }
  1074. private bool FsmOnDisconnect(object[] param)
  1075. {
  1076. if (FsmState == (int)STATE.Error)
  1077. {
  1078. return false;
  1079. }
  1080. return true;
  1081. }
  1082. private bool FsmOnError(object[] param)
  1083. {
  1084. if (FsmState == (int)STATE.Error)
  1085. {
  1086. return false;
  1087. }
  1088. if ((FsmState == (int)STATE.Process) || (FsmState == (int)STATE.PreProcess) || (FsmState == (int)STATE.PostProcess))
  1089. {
  1090. for (int i = 0; i < SC.GetValue<int>($"Boat.SlotCount"); i++)
  1091. {
  1092. if (!WaferManager.Instance.CheckHasWafer(ModuleHelper.Converter(Module), i))
  1093. continue;
  1094. WaferManager.Instance.UpdateWaferProcessStatus(ModuleHelper.Converter(Module), i, EnumWaferProcessStatus.Failed);
  1095. }
  1096. _processRoutine.Abort();
  1097. _postprocessRoutine.Abort();
  1098. _preprocessRoutine.Abort();
  1099. IsWait = false;
  1100. }
  1101. return true;
  1102. }
  1103. private bool FsmReset(object[] param)
  1104. {
  1105. if (!_isInit)
  1106. {
  1107. PostMsg(MSG.ToInit);
  1108. return false;
  1109. }
  1110. foreach (var device in _allModuleDevice)
  1111. {
  1112. if (device.HasAlarm)
  1113. {
  1114. CheckHasAlarmWarning.Set($"{device.Name} has error");
  1115. }
  1116. }
  1117. if (CheckHasAlarm())
  1118. return false;
  1119. return true;
  1120. }
  1121. private bool FsmStartHome(object[] param)
  1122. {
  1123. //if (!CheckIsConnected())
  1124. //{
  1125. // PostMsg(MSG.Disconnected);
  1126. // return false;
  1127. //}
  1128. if (CheckHasAlarm())
  1129. {
  1130. CheckHasAlarmWarning.Set($"There exist active alarm, reset error before continue the initialization");
  1131. PostMsg(MSG.Error);
  1132. return false;
  1133. }
  1134. Result ret = StartRoutine(_homeRoutine);
  1135. if (ret == Result.FAIL || ret == Result.DONE)
  1136. return false;
  1137. _isInit = false;
  1138. return ret == Result.RUN;
  1139. }
  1140. private bool FsmExitHome(object[] param)
  1141. {
  1142. return true;
  1143. }
  1144. private bool FsmEnterHome(object[] param)
  1145. {
  1146. return true;
  1147. }
  1148. private bool FsmAbortTask(object[] param)
  1149. {
  1150. AbortRoutine();
  1151. _isPrepareProcess = true;
  1152. return true;
  1153. }
  1154. private bool FsmMonitorHomeTask(object[] param)
  1155. {
  1156. Result ret = MonitorRoutine();
  1157. if (ret == Result.FAIL)
  1158. {
  1159. PostMsg(MSG.Error);
  1160. return false;
  1161. }
  1162. if (ret == Result.DONE)
  1163. {
  1164. _isInit = true;
  1165. return true;
  1166. }
  1167. return false;
  1168. }
  1169. private bool FsmMonitorTask(object[] param)
  1170. {
  1171. Result ret = MonitorRoutine();
  1172. if (ret == Result.FAIL)
  1173. {
  1174. PostMsg(MSG.Error);
  1175. return false;
  1176. }
  1177. if (ret == Result.DONE && FsmState == (int)STATE.PreProcess)
  1178. {
  1179. PostMsg(MSG.Process);
  1180. return true;
  1181. }
  1182. if (ret == Result.DONE && FsmState == (int)STATE.Process)
  1183. {
  1184. PostMsg(MSG.PostProcess);
  1185. return true;
  1186. }
  1187. if (ret == Result.DONE && IsExcuteIdleRecipe && FsmState == (int)STATE.PostProcess)
  1188. {
  1189. PostMsg(MSG.RunIdleRecipe);
  1190. return true;
  1191. }
  1192. return ret == Result.DONE;
  1193. }
  1194. #region Service functions
  1195. public override bool Home(out string reason)
  1196. {
  1197. CheckToPostMessage((int)MSG.Home);
  1198. reason = string.Empty;
  1199. return true;
  1200. }
  1201. public override void Reset()
  1202. {
  1203. ResetAUXTrig();
  1204. if (!IsProcessing)
  1205. CheckToPostMessage((int)MSG.Reset);
  1206. }
  1207. public override bool PrepareTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1208. {
  1209. CheckToPostMessage((int)MSG.PrepareTransfer, transferType.ToString());
  1210. reason = string.Empty;
  1211. return true;
  1212. }
  1213. public override bool TransferHandoff(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1214. {
  1215. reason = string.Empty;
  1216. return true;
  1217. }
  1218. public override bool PostTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1219. {
  1220. CheckToPostMessage((int)MSG.PostTransfer, transferType.ToString());
  1221. reason = string.Empty;
  1222. return true;
  1223. }
  1224. public override bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason)
  1225. {
  1226. reason = string.Empty;
  1227. var boat = Singleton<EquipmentManager>.Instance.Modules[ModuleName.Boat] as BoatModule;
  1228. if (!boat.IsBoatElevatorAtHomePosition)
  1229. {
  1230. reason = "Boat z axis is not at home position";
  1231. return false;
  1232. }
  1233. if (!boat.IsBoatRotationAtHomePosition)
  1234. {
  1235. reason = "Boat r axis is not at home position";
  1236. return false;
  1237. }
  1238. return true;
  1239. }
  1240. public override void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1241. {
  1242. //if (FsmState == (int)STATE.InTransfer)
  1243. // CheckToPostMessage(MSG.Transfer)
  1244. }
  1245. public override void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType)
  1246. {
  1247. //if (FsmState == (int)STATE.InTransfer)
  1248. // CheckToPostMessage(MSG.Transfer)
  1249. }
  1250. public override bool Process(string recipeName, bool isCleanRecipe, bool withWafer, out string reason)
  1251. {
  1252. _recipeRunningInfo.RecipeName = recipeName;
  1253. _isPrepareProcess = false;
  1254. _isStandbyStep = false;
  1255. IsJobProcess = true;
  1256. IsExcuteIdleRecipe = false;
  1257. CheckToPostMessage((int)MSG.RunRecipe, recipeName);
  1258. reason = string.Empty;
  1259. return true;
  1260. }
  1261. public override bool Standby(string recipeName, out string reason)
  1262. {
  1263. reason = string.Empty;
  1264. _recipeRunningInfo.RecipeName = recipeName;
  1265. _recipeRunningInfo.MainRecipeName = recipeName;
  1266. if (!RecipeParser.Parse(_recipeRunningInfo.RecipeName, ModuleName.PM1.ToString(), out var recipeHead, out var recipeSteps, out reason, "Process"))
  1267. {
  1268. reason = $"Load process recipe {_recipeRunningInfo.RecipeName} failed, {reason}";
  1269. return false;
  1270. }
  1271. if (recipeSteps == null || recipeSteps.Count == 0)
  1272. {
  1273. reason = $"Process recipe {_recipeRunningInfo.RecipeName} is empty";
  1274. return false;
  1275. }
  1276. _isStandbyStep = true;
  1277. var standbyStep = recipeSteps.Where(x => x.StepName == "Standby").FirstOrDefault();
  1278. if (standbyStep != null)
  1279. {
  1280. StringProcessFlowState = ProcessFlowState.Standby.ToString();
  1281. _recipeRunningInfo.StepName = "Standby";
  1282. EV.PostInfoLog(Module, $"pj job excute recipe {recipeName} standby step");
  1283. foreach (var recipeCmd in standbyStep.RecipeCommands.Keys)
  1284. {
  1285. if (!OP.CanDoOperation($"{Module}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1286. {
  1287. if (!OP.CanDoOperation($"{ModuleName.PM1}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1288. {
  1289. if (!OP.CanDoOperation($"{ModuleName.System}.{recipeCmd}", out reason, standbyStep.RecipeCommands[recipeCmd]))
  1290. {
  1291. reason = $"Can not execute {recipeCmd}, {reason}";
  1292. return false;
  1293. }
  1294. else
  1295. {
  1296. OP.DoOperation($"{ModuleName.System}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1297. }
  1298. }
  1299. else
  1300. {
  1301. OP.DoOperation($"{ModuleName.PM1}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1302. }
  1303. }
  1304. else
  1305. {
  1306. OP.DoOperation($"{Module}.{recipeCmd}", out string reason1, 0, standbyStep.RecipeCommands[recipeCmd]);
  1307. }
  1308. }
  1309. }
  1310. return true;
  1311. }
  1312. public void EndIdleRecipe()
  1313. {
  1314. CheckToPostMessage((int)MSG.EndIdleRecipe);
  1315. }
  1316. private double GetNewShowTime()
  1317. {
  1318. return GetWaitTime() + _recipeRunningInfo.HoldTime;
  1319. }
  1320. private double GetWaitTime()
  1321. {
  1322. if (StringFsmStatus == "Idle")
  1323. {
  1324. _waitTimer.Reset();
  1325. }
  1326. if (IsWait)
  1327. {
  1328. _waitTimer.Start();
  1329. }
  1330. else
  1331. {
  1332. _waitTimer.Stop();
  1333. }
  1334. return _waitTimer.ElapsedMilliseconds / 1000;
  1335. }
  1336. }
  1337. #endregion
  1338. }