PMModule.cs 70 KB

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