RfMatchBase.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Aitex.Core.Common.DeviceData;
  7. using Aitex.Core.RT.DataCenter;
  8. using Aitex.Core.RT.Device;
  9. using Aitex.Core.RT.Event;
  10. using Aitex.Core.RT.OperationCenter;
  11. namespace MECF.Framework.Common.Device.Bases
  12. {
  13. public abstract class RfMatchBase : BaseDevice, IDevice
  14. {
  15. public virtual EnumRfMatchTuneMode TuneMode1 { get; set; }
  16. public virtual EnumRfMatchTuneMode TuneMode2 { get; set; }
  17. public virtual float LoadPosition1 { get; set; }
  18. public virtual float LoadPosition2 { get; set; }
  19. public virtual float TunePosition1 { get; set; }
  20. public virtual float TunePosition2 { get; set; }
  21. public virtual float DCBias { get; set; }
  22. public virtual float BiasPeak { get; set; }
  23. public virtual AITRfMatchData DeviceData { get; set; }
  24. protected RfMatchBase() : base()
  25. {
  26. }
  27. protected RfMatchBase(string module, string name) : base(module, name, name, name)
  28. {
  29. }
  30. public virtual bool Initialize()
  31. {
  32. DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
  33. DATA.Subscribe($"{Module}.{Name}.TuneMode1", () => TuneMode1.ToString());
  34. DATA.Subscribe($"{Module}.{Name}.TuneMode2", () => TuneMode2.ToString());
  35. DATA.Subscribe($"{Module}.{Name}.LoadPosition1", () => LoadPosition1);
  36. DATA.Subscribe($"{Module}.{Name}.LoadPosition2", () => LoadPosition2);
  37. DATA.Subscribe($"{Module}.{Name}.TunePosition1", () => TunePosition1);
  38. DATA.Subscribe($"{Module}.{Name}.TunePosition2", () => TunePosition2);
  39. OP.Subscribe($"{Module}.{Name}.SetTuneMode1", (function, args) =>
  40. {
  41. if (!Enum.TryParse((string)args[0], out EnumRfMatchTuneMode mode))
  42. {
  43. EV.PostWarningLog(Module, $"Argument {args[0]}not valid");
  44. return false;
  45. }
  46. SetTuneMode1(mode);
  47. return true;
  48. });
  49. OP.Subscribe($"{Module}.{Name}.SetLoad1", (function, args) =>
  50. {
  51. SetLoad1((float)args[0]);
  52. return true;
  53. });
  54. OP.Subscribe($"{Module}.{Name}.SetTune1", (function, args) =>
  55. {
  56. SetTune1((float)args[0]);
  57. return true;
  58. });
  59. OP.Subscribe($"{Module}.{Name}.SetTuneMode2", (function, args) =>
  60. {
  61. if (!Enum.TryParse((string)args[0], out EnumRfMatchTuneMode mode))
  62. {
  63. EV.PostWarningLog(Module, $"Argument {args[0]}not valid");
  64. return false;
  65. }
  66. SetTuneMode2(mode);
  67. return true;
  68. });
  69. OP.Subscribe($"{Module}.{Name}.SetLoad2", (function, args) =>
  70. {
  71. SetLoad2((float)args[0]);
  72. return true;
  73. });
  74. OP.Subscribe($"{Module}.{Name}.SetTune2", (function, args) =>
  75. {
  76. SetTune2((float)args[0]);
  77. return true;
  78. });
  79. OP.Subscribe($"{Module}.{Name}.SetActivePresetNo1", (function, args) =>
  80. {
  81. SetActivePresetNo1((int)args[0]);
  82. return true;
  83. });
  84. OP.Subscribe($"{Module}.{Name}.SetActivePresetNo2", (function, args) =>
  85. {
  86. SetActivePresetNo2((int)args[0]);
  87. return true;
  88. });
  89. OP.Subscribe($"{Module}.{Name}.SetPreSetsAndTrajectories1", (function, args) =>
  90. {
  91. SetPreSetsAndTrajectories1((Presets)args[0]);
  92. return true;
  93. });
  94. OP.Subscribe($"{Module}.{Name}.SetPreSetsAndTrajectories2", (function, args) =>
  95. {
  96. SetPreSetsAndTrajectories2((Presets)args[0]);
  97. return true;
  98. });
  99. OP.Subscribe($"{Module}.{Name}.EnablePreset1", (function, args) =>
  100. {
  101. EnablePreset1((bool)args[0]);
  102. return true;
  103. });
  104. OP.Subscribe($"{Module}.{Name}.EnablePreset2", (function, args) =>
  105. {
  106. EnablePreset2((bool)args[0]);
  107. return true;
  108. });
  109. OP.Subscribe($"{Module}.{Name}.EnableCapacitorMove1", (function, args) =>
  110. {
  111. EnableCapacitorMove1((bool)args[0]);
  112. return true;
  113. });
  114. OP.Subscribe($"{Module}.{Name}.EnableCapacitorMove2", (function, args) =>
  115. {
  116. EnableCapacitorMove2((bool)args[0]);
  117. return true;
  118. });
  119. return true;
  120. }
  121. public virtual void SetPreSetsAndTrajectories1(Presets presets)
  122. {
  123. throw new NotImplementedException();
  124. }
  125. public virtual void SetActivePresetNo2(int v)
  126. {
  127. throw new NotImplementedException();
  128. }
  129. public virtual void SetPreSetsAndTrajectories2(Presets presets)
  130. {
  131. throw new NotImplementedException();
  132. }
  133. public virtual void EnablePreset1(bool v)
  134. {
  135. throw new NotImplementedException();
  136. }
  137. public virtual void EnablePreset2(bool v)
  138. {
  139. throw new NotImplementedException();
  140. }
  141. public virtual void EnableCapacitorMove1(bool v)
  142. {
  143. throw new NotImplementedException();
  144. }
  145. public virtual void EnableCapacitorMove2(bool v)
  146. {
  147. throw new NotImplementedException();
  148. }
  149. public virtual void SetActivePresetNo1(int v)
  150. {
  151. throw new NotImplementedException();
  152. }
  153. public virtual void SetTuneMode1(EnumRfMatchTuneMode enumRfMatchTuneMode)
  154. {
  155. }
  156. public virtual void SetMatchPositionC1(float c1, out string reason)
  157. {
  158. reason = string.Empty;
  159. TunePosition1 = c1;
  160. }
  161. public virtual void SetMatchPositionC2(float c2, out string reason)
  162. {
  163. reason = string.Empty;
  164. TunePosition2 = c2;
  165. }
  166. public virtual void SetMatchPosition(float c1, float c2, out string reason)
  167. {
  168. reason = string.Empty;
  169. TunePosition1 = c1;
  170. TunePosition2 = c2;
  171. }
  172. public bool SetMatchMode(string mode, out string reason)
  173. {
  174. reason = string.Empty;
  175. return true;
  176. }
  177. public virtual void SetLoad1(float load)
  178. {
  179. }
  180. public virtual void SetTune1(float tune)
  181. {
  182. }
  183. public virtual void SetTuneMode2(EnumRfMatchTuneMode enumRfMatchTuneMode)
  184. {
  185. }
  186. public virtual void SetLoad2(float load)
  187. {
  188. }
  189. public virtual void SetTune2(float tune)
  190. {
  191. }
  192. public virtual void Terminate()
  193. {
  194. }
  195. public virtual void Monitor()
  196. {
  197. }
  198. public virtual void Reset()
  199. {
  200. }
  201. }
  202. }