VpwCellEntity.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Fsm;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.Utilities;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.Persistent.Temperature;
  7. using MECF.Framework.Common.Persistent.VpwCell;
  8. using MECF.Framework.Common.Persistent.VpwMain;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. using MECF.Framework.Common.ToolLayout;
  11. using PunkHPX8_Core;
  12. using PunkHPX8_RT.Devices.VpwCell;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Threading;
  18. using System.Threading.Tasks;
  19. namespace PunkHPX8_RT.Modules.VpwMain
  20. {
  21. public class VpwCellEntity : Entity, IEntity, IModuleEntity
  22. {
  23. public enum MSG
  24. {
  25. Home
  26. }
  27. #region 常量
  28. private const string STRATUS = "Stratus";
  29. private const string AUTO = "Auto";
  30. private const string MANUAL = "Manual";
  31. private const string DISABLED = "Disabled";
  32. private const string ENGINEERING = "Engineering";
  33. private const string PRODUCTION = "Production";
  34. #endregion
  35. #region 内部变量
  36. /// <summary>
  37. /// 持久化数值
  38. /// </summary>
  39. private VpwCellPersistentValue _persistentValue;
  40. #endregion
  41. #region 属性
  42. public ModuleName Module { get; private set; }
  43. /// <summary>
  44. /// 是否Init
  45. /// </summary>
  46. public bool IsInit
  47. {
  48. get { return fsm.State == (int)VPWMainState.Init; }
  49. }
  50. /// <summary>
  51. /// 是否Idle
  52. /// </summary>
  53. public bool IsIdle
  54. {
  55. get
  56. {
  57. return fsm.State == (int)VPWMainState.Idle;
  58. }
  59. }
  60. /// <summary>
  61. /// 是否错误
  62. /// </summary>
  63. public bool IsError
  64. {
  65. get { return fsm.State == (int)VPWMainState.Error; }
  66. }
  67. /// <summary>
  68. /// 正在忙碌
  69. /// </summary>
  70. public bool IsBusy
  71. {
  72. get { return fsm.State == (int)VPWMainState.Initializing; }
  73. }
  74. /// <summary>
  75. /// 是否禁用
  76. /// </summary>
  77. public bool IsDisable { get { return _persistentValue == null || _persistentValue.OperatingMode == DISABLED; } }
  78. /// <summary>
  79. /// 自动模式
  80. /// </summary>
  81. public bool IsAuto { get { return _persistentValue != null && _persistentValue.OperatingMode == AUTO; } }
  82. /// <summary>
  83. /// 自动模式
  84. /// </summary>
  85. public bool IsManual { get { return _persistentValue != null && _persistentValue.OperatingMode == MANUAL; } }
  86. /// <summary>
  87. /// 是否为工程模式
  88. /// </summary>
  89. public bool IsEngineering { get { return _persistentValue != null && _persistentValue.RecipeOperatingMode == ENGINEERING; } }
  90. /// <summary>
  91. /// 是否为产品模式
  92. /// </summary>
  93. public bool IsProduction { get { return _persistentValue != null && _persistentValue.RecipeOperatingMode == PRODUCTION; } }
  94. #endregion
  95. /// <summary>
  96. /// 构造函数
  97. /// </summary>
  98. /// <param name="module"></param>
  99. public VpwCellEntity(ModuleName module)
  100. {
  101. this.Module = module;
  102. }
  103. /// <summary>
  104. /// 初始化
  105. /// </summary>
  106. /// <returns></returns>
  107. protected override bool Init()
  108. {
  109. InitializeParameter();
  110. InitialFsm();
  111. return true;
  112. }
  113. /// <summary>
  114. /// 初始化参数
  115. /// </summary>
  116. private void InitializeParameter()
  117. {
  118. _persistentValue = VpwCellPersistentManager.Instance.GetPersistentValue(Module.ToString());
  119. if (_persistentValue == null)
  120. {
  121. LOG.WriteLog(eEvent.ERR_VPW, Module.ToString(), "Persistent Value Object is not exist");
  122. }
  123. }
  124. private void InitialFsm()
  125. {
  126. fsm = new StateMachine<VpwMainEntity>(Module.ToString(), (int)VPWMainState.Init, 100);
  127. fsm.EnableRepeatedMsg(true);
  128. }
  129. public bool Check(int msg, out string reason, params object[] args)
  130. {
  131. reason = "";
  132. return false;
  133. }
  134. public bool CheckAcked(int msg)
  135. {
  136. return false;
  137. }
  138. /// <summary>
  139. /// EnterInit
  140. /// </summary>
  141. public void EnterInit()
  142. {
  143. }
  144. public int Invoke(string function, params object[] args)
  145. {
  146. switch (function)
  147. {
  148. case "HomeAll":
  149. return (int)MSG.Home;
  150. }
  151. return (int)FSM_MSG.NONE;
  152. }
  153. }
  154. }