PMModule.cs 63 KB

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