PMModule.cs 76 KB

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