RfMatchBase.cs 7.3 KB

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