PMModule.cs 62 KB

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