FaManager.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using Aitex.Common.Util;
  5. using Aitex.Core.RT.DataCenter;
  6. using Aitex.Core.RT.Event;
  7. using Aitex.Core.RT.Log;
  8. using Aitex.Core.RT.OperationCenter;
  9. using Aitex.Core.RT.RecipeCenter;
  10. using Aitex.Core.Util;
  11. using Aitex.RT.Properties;
  12. using Aitex.Triton160.Common;
  13. using Aitex.Triton160.RT.Module;
  14. namespace Aitex.RT.FactoryAutomation
  15. {
  16. class FaManager : FaHost, IHostCallback
  17. {
  18. public void Initialize()
  19. {
  20. base.Initialize(this, PathManager.GetCfgDir()+"GemModel.xml");
  21. OP.Subscribe("FACommand", InvokeFaCommand );
  22. DATA.Subscribe("System.CommunicationStatus", () => FaCommunicationState);
  23. DATA.Subscribe("System.ControlStatus", () => FaControlState);
  24. DATA.Subscribe("System.ControlSubStatus", () => FaControlSubState);
  25. DATA.Subscribe("System.SpoolingState", () => SpoolingState);
  26. DATA.Subscribe("System.SpoolingActual", () => SpoolingActual);
  27. DATA.Subscribe("System.SpoolingTotal", () => SpoolingTotal);
  28. DATA.Subscribe("System.SpoolingFullTime", () => SpoolingFullTime);
  29. DATA.Subscribe("System.SpoolingStartTime", () => SpoolingStartTime);
  30. DATA.Subscribe("System.IsSpoolingEnable", () => IsSpoolingEnable);
  31. }
  32. private bool InvokeFaCommand(string arg1, object[] arg2)
  33. {
  34. Invoke(arg2[0].ToString(), null);
  35. return true;
  36. }
  37. public string GetSvidValue(string svName)
  38. {
  39. object data = DATA.Poll(svName);
  40. if (data != null)
  41. {
  42. return data.ToString();
  43. }
  44. return "";
  45. }
  46. public List<string> GetListSvidValue(string svName)
  47. {
  48. List<string> result = new List<string>();
  49. if (svName == "RecipeList")
  50. {
  51. result = (List<string>) DATA.Poll(svName);
  52. }
  53. return result;
  54. }
  55. bool IHostCallback.Start(out string reason)
  56. {
  57. reason = "";
  58. return true;
  59. }
  60. public bool Pause(out string reason)
  61. {
  62. reason = "";
  63. return true;
  64. }
  65. public bool Resume(out string reason)
  66. {
  67. reason = "";
  68. return true;
  69. }
  70. public bool Abort(out string reason)
  71. {
  72. reason = "";
  73. return true;
  74. }
  75. public bool RunRecipe(string lotId, string jobId, string recipeName, out string reason)
  76. {
  77. var recipeContent = RecipeFileManager.Instance.LoadRecipe(ModuleName.System.ToString(), recipeName, true);
  78. if (string.IsNullOrEmpty(recipeContent))
  79. {
  80. reason = $"Recipe file {recipeName} not valid";
  81. return false;
  82. }
  83. List<string> reasons;
  84. if (!RecipeFileManager.Instance.CheckRecipe(ModuleName.System.ToString(), recipeContent, out reasons))
  85. {
  86. EV.PostMessage(ModuleName.System.ToString(), EventEnum.PrepareProcessErr, ModuleName.System.ToString(), string.Format(Resources.RTEntity_Invoke_RecipeFileContentNotValid0, recipeName));
  87. string info = "";
  88. foreach (var item in reasons)
  89. info += item;
  90. reason = $"Recipe file {recipeName} not valid, " + info;
  91. return false; //Recipe content check.
  92. }
  93. Singleton<PMEntity>.Instance.PostMsg((int)PMEntity.MSG.RunRecipe, recipeName, recipeContent, lotId, jobId);
  94. reason = "";
  95. return true;
  96. }
  97. }
  98. }