PMModule.cs 78 KB

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