| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 | 
							- using Aitex.Core.Common.DeviceData;
 
- using Aitex.Core.RT.DataCenter;
 
- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.IOCore;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Core.RT.Tolerance;
 
- using Aitex.Core.UI.View.Common;
 
- using Aitex.Core.Util;
 
- using CdioCs;
 
- using MECF.Framework.Common.CommonData.DeviceData;
 
- using MECF.Framework.Common.Equipment;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Security.Cryptography;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- using System.Xml;
 
- using Venus_Core;
 
- namespace Venus_RT.Devices.IODevices
 
- {
 
-     public class IoMagnet : BaseDevice, IDevice
 
-     {
 
-         public enum MagnetStatus
 
-         {
 
-             Unknown,
 
-             OFF,
 
-             ON,
 
-             ERROR
 
-         }
 
-         public IoMagnet(string module, XmlElement node, string ioModule = "") 
 
-         {
 
-             base.Module = module;
 
-             Name = "AIoMagnet";
 
-             //base.Name = node.GetAttribute("id");
 
-             base.Display = node.GetAttribute("display");
 
-             base.DeviceID = node.GetAttribute("schematicId");
 
-             this.Status = MagnetStatus.Unknown;
 
-             _aiMagnet1U = ParseAiNode("aiMagnet1U", node, ioModule);
 
-             _aiMagnet1V = ParseAiNode("aiMagnet1V", node, ioModule);
 
-             _aiMagnet1W = ParseAiNode("aiMagnet1W", node, ioModule);
 
-             _aiMagnet2V = ParseAiNode("aiMagnet2V", node, ioModule);
 
-             _aiMagnet2U = ParseAiNode("aiMagnet2U", node, ioModule);
 
-             _aiMagnet2W = ParseAiNode("aiMagnet2W", node, ioModule);
 
-             _diMagnetOn = ParseDiNode("diPowerOn", node, ioModule);
 
-             _aoMagnetintensity= ParseAoNode("aoSetPoint", node, ioModule);
 
-             _aoMagnetWaveForm = ParseAoNode("aoWaveSsquare", node, ioModule);
 
-             _aoMagnetFieldRadio = ParseAoNode("aoMagnetFieldRadio", node, ioModule);
 
-             _aoMagnetCycle = ParseAoNode("aoCycletime", node, ioModule);
 
-             _aoMinMagnet = ParseAoNode("aoCurrentLimit", node, ioModule);
 
-             _ao1Aoutput= ParseAoNode("ao1Aoutput", node, ioModule);
 
-             _ao1Boutput = ParseAoNode("ao1Boutput", node, ioModule);
 
-             _ao2Aoutput = ParseAoNode("ao2Aoutput", node, ioModule);
 
-             _ao2Boutput = ParseAoNode("ao2Boutput", node, ioModule);
 
-         }
 
-         public MagnetStatus Status { get; set; }
 
-         private readonly AIAccessor _aiMagnet1U;    
 
-         private readonly AIAccessor _aiMagnet1V;
 
-         private readonly AIAccessor _aiMagnet1W;
 
-         private readonly AIAccessor _aiMagnet2U;
 
-         private readonly AIAccessor _aiMagnet2V;
 
-         private readonly AIAccessor _aiMagnet2W;
 
-         private readonly DIAccessor _diMagnetOn;
 
-         private readonly AOAccessor _aoMagnetintensity;
 
-         private readonly AOAccessor _aoMagnetWaveForm;
 
-         private readonly AOAccessor _aoMagnetFieldRadio;
 
-         private readonly AOAccessor _aoMagnetCycle;
 
-         private readonly AOAccessor _aoMinMagnet;
 
-         private readonly AOAccessor _ao1Aoutput;
 
-         private readonly AOAccessor _ao1Boutput;
 
-         private readonly AOAccessor _ao2Aoutput;
 
-         private readonly AOAccessor _ao2Boutput;
 
-         private ToleranceChecker _toleranceChecker = new ToleranceChecker();
 
-         public bool Initialize()
 
-         {
 
-             DATA.Subscribe($"{Module}.AIoMagnet.DeviceData", () => DeviceData, SubscriptionAttribute.FLAG.IgnoreSaveDB);
 
-             _SetRealFloat(_aoMagnetWaveForm, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnetwareform").Value));          
 
-             _SetRealFloat(_aoMagnetCycle, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnetcycleperiod").Value));
 
-             _SetRealFloat(_aoMinMagnet, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Min_Magnet_Coil_Current").Value));
 
-             _SetRealFloat(_aoMagnetFieldRadio, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.MagentFieldRatio").Value));
 
-             _SetRealFloat(_ao1Aoutput, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnet_1A_output_full_scale").Value));
 
-             _SetRealFloat(_ao1Boutput, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnet_1B_output_full_scale").Value));
 
-             _SetRealFloat(_ao2Aoutput, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnet_2A_output_full_scale").Value));
 
-             _SetRealFloat(_ao2Boutput, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnet_2B_output_full_scale").Value));
 
-             return true;
 
-         }
 
-         public AITMagnetData DeviceData
 
-         {
 
-             get
 
-             {
 
-                 AITMagnetData deviceData = new AITMagnetData
 
-                 {
 
-                     Magnet1UFeedBack = Magent1U,
 
-                     Magnet1VFeedBack = Magent1V,
 
-                     Magnet1WFeedBack = Magent1W,
 
-                     Magnet2UFeedBack = Magent2U,
 
-                     Magnet2VFeedBack = Magent2V,
 
-                     Magnet2WFeedBack = Magent2W,
 
-                     IsMagnetOn = MagnetOn,
 
-                     MagnetIntensity= MagnetPowerIntensity
 
-                 };
 
-                 return deviceData;
 
-             }
 
-         }
 
-         public void Setpoint(AOAccessor ao,float config)
 
-         {
 
-             if (_GetRealFloat(ao) != config)
 
-             {
 
-                 _SetRealFloat(ao, config);
 
-             }
 
-         }
 
-         public void Monitor()
 
-         {
 
-             Setpoint(_aoMagnetFieldRadio, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.MagentFieldRatio").Value));
 
-             Setpoint(_ao1Aoutput, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnet_1A_output_full_scale").Value));
 
-             Setpoint(_ao1Boutput, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnet_1B_output_full_scale").Value));
 
-             Setpoint(_ao2Aoutput, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnet_2A_output_full_scale").Value));
 
-             Setpoint(_ao2Boutput, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnet_2B_output_full_scale").Value));
 
-             Setpoint(_aoMagnetCycle, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnetcycleperiod").Value));
 
-             Setpoint(_aoMagnetWaveForm, Convert.ToSingle(SC.GetConfigItem($"{Module}.Magnet.Magnetwareform").Value));
 
-         }
 
-        
 
-         public float Magent1V
 
-         {
 
-             get
 
-             {
 
-                 if (_aiMagnet1V == null) return -1;
 
-                 float real = _GetRealFloat(_aiMagnet1V);
 
-                 return (float)Math.Round(real, 1);
 
-             }
 
-         }
 
-         public float Magent1U
 
-         {
 
-             get
 
-             {
 
-                 if (_aiMagnet1U == null) return -1;
 
-                 float real = _GetRealFloat(_aiMagnet1U);
 
-                 return (float)Math.Round(real, 1);
 
-             }
 
-         }
 
-         public bool MagnetOn
 
-         {
 
-             get { return _diMagnetOn != null && _diMagnetOn.Value; }
 
-         }
 
-         public float Magent1W
 
-         {
 
-             get
 
-             {
 
-                 if (_aiMagnet1W == null) return -1;
 
-                 float real = _GetRealFloat(_aiMagnet1W);
 
-                 return (float)Math.Round(real, 1);
 
-             }
 
-         }
 
-         public float Magent2U
 
-         {
 
-             get
 
-             {
 
-                 if (_aiMagnet2U == null) return -1;
 
-                 float real = _GetRealFloat(_aiMagnet2U);
 
-                 return (float)Math.Round(real, 1);
 
-             }
 
-         }
 
-         public float Magent2V
 
-         {
 
-             get
 
-             {
 
-                 if (_aiMagnet2V == null) return -1;
 
-                 float real = _GetRealFloat(_aiMagnet2V);
 
-                 return (float)Math.Round(real, 1);
 
-             }
 
-         }
 
-         public bool SetMagnetPower(float val)
 
-         {
 
-             _SetRealFloat(_aoMagnetintensity, val);
 
-             return true;  
 
-         }
 
-         public float Magent2W
 
-         {
 
-             get
 
-             {
 
-                 if (_aiMagnet2W == null) return -1;
 
-                 float real = _GetRealFloat(_aiMagnet2W);
 
-                 return (float)Math.Round(real, 1);
 
-             }
 
-         }
 
-         public float MagnetPowerIntensity
 
-         {
 
-             get
 
-             {
 
-                 if (_aoMagnetintensity == null) return -1;
 
-                 float real = _GetRealFloat(_aoMagnetintensity);
 
-                 return real;
 
-             }
 
-         }
 
-         public void Reset()
 
-         {
 
-             _toleranceChecker.Reset(21);
 
-         }
 
-         public void Terminate()
 
-         {
 
-             //throw new NotImplementedException();
 
-         }
 
-     }
 
- }
 
 
  |