RfMatchBase.cs 7.3 KB

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