PMModule.cs 62 KB

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