using System; using System.Collections.Generic; using System.Threading.Tasks; using Aitex.Common.Util; using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.Event; using Aitex.Core.RT.Log; using Aitex.Core.RT.OperationCenter; using Aitex.Core.RT.RecipeCenter; using Aitex.Core.Util; using Aitex.RT.Properties; using Aitex.Triton160.Common; using Aitex.Triton160.RT.Module; namespace Aitex.RT.FactoryAutomation { class FaManager : FaHost, IHostCallback { public void Initialize() { base.Initialize(this, PathManager.GetCfgDir()+"GemModel.xml"); OP.Subscribe("FACommand", InvokeFaCommand ); DATA.Subscribe("System.CommunicationStatus", () => FaCommunicationState); DATA.Subscribe("System.ControlStatus", () => FaControlState); DATA.Subscribe("System.ControlSubStatus", () => FaControlSubState); DATA.Subscribe("System.SpoolingState", () => SpoolingState); DATA.Subscribe("System.SpoolingActual", () => SpoolingActual); DATA.Subscribe("System.SpoolingTotal", () => SpoolingTotal); DATA.Subscribe("System.SpoolingFullTime", () => SpoolingFullTime); DATA.Subscribe("System.SpoolingStartTime", () => SpoolingStartTime); DATA.Subscribe("System.IsSpoolingEnable", () => IsSpoolingEnable); } private bool InvokeFaCommand(string arg1, object[] arg2) { Invoke(arg2[0].ToString(), null); return true; } public string GetSvidValue(string svName) { object data = DATA.Poll(svName); if (data != null) { return data.ToString(); } return ""; } public List GetListSvidValue(string svName) { List result = new List(); if (svName == "RecipeList") { result = (List) DATA.Poll(svName); } return result; } bool IHostCallback.Start(out string reason) { reason = ""; return true; } public bool Pause(out string reason) { reason = ""; return true; } public bool Resume(out string reason) { reason = ""; return true; } public bool Abort(out string reason) { reason = ""; return true; } public bool RunRecipe(string lotId, string jobId, string recipeName, out string reason) { var recipeContent = RecipeFileManager.Instance.LoadRecipe(ModuleName.System.ToString(), recipeName, true); if (string.IsNullOrEmpty(recipeContent)) { reason = $"Recipe file {recipeName} not valid"; return false; } List reasons; if (!RecipeFileManager.Instance.CheckRecipe(ModuleName.System.ToString(), recipeContent, out reasons)) { EV.PostMessage(ModuleName.System.ToString(), EventEnum.PrepareProcessErr, ModuleName.System.ToString(), string.Format(Resources.RTEntity_Invoke_RecipeFileContentNotValid0, recipeName)); string info = ""; foreach (var item in reasons) info += item; reason = $"Recipe file {recipeName} not valid, " + info; return false; //Recipe content check. } Singleton.Instance.PostMsg((int)PMEntity.MSG.RunRecipe, recipeName, recipeContent, lotId, jobId); reason = ""; return true; } } }