IoMagnet.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.IOCore;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Core.RT.Tolerance;
  8. using Aitex.Core.UI.View.Common;
  9. using Aitex.Core.Util;
  10. using MECF.Framework.Common.CommonData.DeviceData;
  11. using MECF.Framework.Common.Equipment;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Linq;
  15. using System.Security.Cryptography;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. using System.Xml;
  19. using Venus_Core;
  20. namespace Venus_RT.Devices.IODevices
  21. {
  22. public class IoMagnet : BaseDevice, IDevice
  23. {
  24. public enum MagnetStatus
  25. {
  26. Unknown,
  27. OFF,
  28. ON,
  29. ERROR
  30. }
  31. public IoMagnet(string module, XmlElement node, string ioModule = "")
  32. {
  33. base.Module = module;
  34. Name = "AIoMagnet";
  35. //base.Name = node.GetAttribute("id");
  36. base.Display = node.GetAttribute("display");
  37. base.DeviceID = node.GetAttribute("schematicId");
  38. this.Status = MagnetStatus.Unknown;
  39. _aiMagnet1U = ParseAiNode("aiMagnet1U", node, ioModule);
  40. _aiMagnet1V = ParseAiNode("aiMagnet1V", node, ioModule);
  41. _aiMagnet1W = ParseAiNode("aiMagnet1W", node, ioModule);
  42. _aiMagnet2V = ParseAiNode("aiMagnet2V", node, ioModule);
  43. _aiMagnet2U = ParseAiNode("aiMagnet2U", node, ioModule);
  44. _aiMagnet2W = ParseAiNode("aiMagnet2W", node, ioModule);
  45. _doMagnetOn = ParseDoNode("doPowerOn", node, ioModule);
  46. _aoMagnetintensity= ParseAoNode("aoSetPoint", node, ioModule);
  47. _aoMagnetWaveForm = ParseAoNode("aoWaveSsquare", node, ioModule);
  48. // _aoMagnetFieldRadio = ParseAoNode("aoSetPoint", node, ioModule);
  49. _aoMagnetCycle = ParseAoNode("aoCycletime", node, ioModule);
  50. _aoMinMagnet = ParseAoNode("aoCurrentLimit", node, ioModule);
  51. }
  52. private SCConfigItem _scMagnetWaveForm;
  53. private SCConfigItem _scMagnetFieldRadio;
  54. private SCConfigItem _scMagnetCycle;
  55. private SCConfigItem _scMinMagnet;
  56. public MagnetStatus Status { get; set; }
  57. private readonly AIAccessor _aiMagnet1U;
  58. private readonly AIAccessor _aiMagnet1V;
  59. private readonly AIAccessor _aiMagnet1W;
  60. private readonly AIAccessor _aiMagnet2U;
  61. private readonly AIAccessor _aiMagnet2V;
  62. private readonly AIAccessor _aiMagnet2W;
  63. private readonly DOAccessor _doMagnetOn;
  64. private readonly AOAccessor _aoMagnetintensity;
  65. private readonly AOAccessor _aoMagnetWaveForm;
  66. private readonly AOAccessor _aoMagnetFieldRadio;
  67. private readonly AOAccessor _aoMagnetCycle;
  68. private readonly AOAccessor _aoMinMagnet;
  69. private ToleranceChecker _toleranceChecker = new ToleranceChecker();
  70. public bool Initialize()
  71. {
  72. DATA.Subscribe($"{Module}.AIoMagnet.DeviceData", () => DeviceData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  73. _SetRealFloat(_aoMagnetWaveForm, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnetwareform").Value));
  74. _SetRealFloat(_aoMagnetCycle, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnetcycleperiod").Value));
  75. _SetRealFloat(_aoMinMagnet, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Min_Magnet_Coil_Current").Value));
  76. return true;
  77. }
  78. public AITMagnetData DeviceData
  79. {
  80. get
  81. {
  82. AITMagnetData deviceData = new AITMagnetData
  83. {
  84. Magnet1UFeedBack = Magent1U,
  85. Magnet1VFeedBack = Magent1V,
  86. Magnet1WFeedBack = Magent1W,
  87. Magnet2UFeedBack = Magent2U,
  88. Magnet2VFeedBack = Magent2V,
  89. Magnet2WFeedBack = Magent2W,
  90. IsMagnetOn = MagnetOn,
  91. MagnetIntensity= MagnetPowerIntensity
  92. };
  93. return deviceData;
  94. }
  95. }
  96. public void Monitor()
  97. {
  98. //throw new NotImplementedException();
  99. }
  100. [Subscription(AITMfcDataPropertyName.FeedBack)]
  101. public float Magent1V
  102. {
  103. get
  104. {
  105. if (_aiMagnet1V == null) return -1;
  106. float real = _GetRealFloat(_aiMagnet1V);
  107. return real;
  108. }
  109. }
  110. public float Magent1U
  111. {
  112. get
  113. {
  114. if (_aiMagnet1U == null) return -1;
  115. float real = _GetRealFloat(_aiMagnet1U);
  116. return real;
  117. }
  118. }
  119. public float Magent1W
  120. {
  121. get
  122. {
  123. if (_aiMagnet1W == null) return -1;
  124. float real = _GetRealFloat(_aiMagnet1W);
  125. return real;
  126. }
  127. }
  128. public float Magent2U
  129. {
  130. get
  131. {
  132. if (_aiMagnet2U == null) return -1;
  133. float real = _GetRealFloat(_aiMagnet2U);
  134. return real;
  135. }
  136. }
  137. public float Magent2V
  138. {
  139. get
  140. {
  141. if (_aiMagnet2V == null) return -1;
  142. float real = _GetRealFloat(_aiMagnet2V);
  143. return real;
  144. }
  145. }
  146. public bool MagnetOn
  147. {
  148. get => Status == MagnetStatus.ON;
  149. set { }
  150. }
  151. public bool SetMagnetOnOff(bool on, out string str)
  152. {
  153. str = "";
  154. var _chamber = DEVICE.GetDevice<JetPMBase>(Module);
  155. //if (on && !_chamber.CheckGeneratorAndHVInterlock(VenusDevice.Rf))
  156. //{
  157. // return false;
  158. //}
  159. if (!_doMagnetOn.SetValue(on, out string reason))
  160. {
  161. LOG.Write(eEvent.INFO_DEVICE_IO_MAGNET, ModuleHelper.Converter(Module), reason);
  162. return false;
  163. }
  164. LOG.Write(eEvent.INFO_DEVICE_IO_MAGNET, ModuleHelper.Converter(Module), $"Set Magnet Contact {(on ? "ON" : "OFF")}");
  165. if (on)
  166. {
  167. Status = MagnetStatus.ON;
  168. }
  169. else
  170. {
  171. Status = MagnetStatus.OFF;
  172. }
  173. return true;
  174. }
  175. public bool SetMagnetPower(float val)
  176. {
  177. _SetRealFloat(_aoMagnetintensity, val);
  178. return true;
  179. }
  180. public float Magent2W
  181. {
  182. get
  183. {
  184. if (_aiMagnet2W == null) return -1;
  185. float real = _GetRealFloat(_aiMagnet2W);
  186. return real;
  187. }
  188. }
  189. public float MagnetPowerIntensity
  190. {
  191. get
  192. {
  193. if (_aoMagnetintensity == null) return -1;
  194. float real = _GetRealFloat(_aoMagnetintensity);
  195. return real;
  196. }
  197. }
  198. public void Reset()
  199. {
  200. _toleranceChecker.Reset(21);
  201. }
  202. public void Terminate()
  203. {
  204. //throw new NotImplementedException();
  205. }
  206. }
  207. }