PMModule.cs 71 KB

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