DummyDevice.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.Util;
  4. using MECF.Framework.Common.Equipment;
  5. using MECF.Framework.Common.IOCore;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Reflection;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace CyberX8_RT.Devices.EFEM
  13. {
  14. public class DummyDevice
  15. {
  16. #region 常量
  17. private const string CASSETE_200_PRESENT = "Cassete200Present";
  18. private const string CASSETE_150_PRESENT = "Cassete150Present";
  19. private const string CASSETE_100_PRESENT = "Cassete100Present";
  20. #endregion
  21. #region 内部变量
  22. private bool _cassete200Present = false;
  23. private bool _cassete150Present = false;
  24. private bool _cassete100Present = false;
  25. /// <summary>
  26. /// 变量是否初始化字典
  27. /// </summary>
  28. private Dictionary<string, bool> _variableInitializeDic = new Dictionary<string, bool>();
  29. /// <summary>
  30. ///
  31. /// </summary>
  32. private ModuleName _module;
  33. /// <summary>
  34. /// 尺寸
  35. /// </summary>
  36. private WaferSize _waferSize;
  37. /// <summary>
  38. /// 是否存在Cassete
  39. /// </summary>
  40. private bool _hasCassete;
  41. #endregion
  42. #region 属性
  43. /// <summary>
  44. /// 尺寸
  45. /// </summary>
  46. public WaferSize WaferSize { get { return _waferSize; } }
  47. /// <summary>
  48. /// 是否存在Cassete
  49. /// </summary>
  50. public bool HasCassette { get { return _hasCassete; } }
  51. #endregion
  52. /// <summary>
  53. /// 构造函数
  54. /// </summary>
  55. /// <param name="moduleName"></param>
  56. public DummyDevice(ModuleName moduleName)
  57. {
  58. _module = moduleName;
  59. SubscribeValueAction();
  60. DATA.Subscribe($"{_module}.CassettePlaced", () => _hasCassete, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  61. DATA.Subscribe($"{_module}.WaferSize", () => WaferSize.ToString(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  62. }
  63. /// <summary>
  64. /// 订阅变量数值发生变化
  65. /// </summary>
  66. private void SubscribeValueAction()
  67. {
  68. BeckhoffIoSubscribeUpdateVariable(CASSETE_100_PRESENT);
  69. BeckhoffIoSubscribeUpdateVariable(CASSETE_150_PRESENT);
  70. BeckhoffIoSubscribeUpdateVariable(CASSETE_200_PRESENT);
  71. }
  72. /// <summary>
  73. /// 订阅IO变量
  74. /// </summary>
  75. /// <param name="variable"></param>
  76. private void BeckhoffIoSubscribeUpdateVariable(string variable)
  77. {
  78. _variableInitializeDic[variable] = false;
  79. IOModuleManager.Instance.SubscribeModuleVariable(_module.ToString(), variable, UpdateVariableValue);
  80. }
  81. /// 更新变量数值
  82. /// </summary>
  83. /// <param name="variable"></param>
  84. /// <param name="value"></param>
  85. private void UpdateVariableValue(string variable, object value)
  86. {
  87. bool cassete = (bool)value;
  88. if (variable == CASSETE_200_PRESENT)
  89. {
  90. _cassete200Present = cassete;
  91. if (cassete)
  92. {
  93. _waferSize = WaferSize.WS8;
  94. }
  95. }
  96. else if (variable == CASSETE_150_PRESENT)
  97. {
  98. _cassete150Present = cassete;
  99. if (cassete&&!_cassete200Present)
  100. {
  101. _waferSize = WaferSize.WS6;
  102. }
  103. }
  104. else if (variable == CASSETE_100_PRESENT)
  105. {
  106. _cassete100Present = cassete;
  107. if (cassete&&!_cassete200Present&&!_cassete150Present)
  108. {
  109. _waferSize = WaferSize.WS4;
  110. }
  111. }
  112. if (!_cassete100Present && !_cassete150Present && !_cassete200Present)
  113. {
  114. _hasCassete = false;
  115. }
  116. else
  117. {
  118. _hasCassete = true;
  119. }
  120. }
  121. }
  122. }