IoTempMeter.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Xml;
  11. namespace JetMainframe.Devices
  12. {
  13. public class IoTempMeter : BaseDevice, IDevice
  14. {
  15. private AIAccessor _aiFeedBack = null;
  16. private bool _isFloatAioType;
  17. public float FeedBack
  18. {
  19. get
  20. {
  21. if (_aiFeedBack != null)
  22. return _isFloatAioType ? _aiFeedBack.FloatValue : _aiFeedBack.Value;
  23. return 0;
  24. }
  25. }
  26. public AITHeaterData DeviceData
  27. {
  28. get
  29. {
  30. var data = new AITHeaterData()
  31. {
  32. Module = Module,
  33. DeviceName = Name,
  34. DisplayName = Display,
  35. DeviceSchematicId = DeviceID,
  36. //UniqueName = UniqueName,
  37. FeedBack = FeedBack,
  38. };
  39. // data.AttrValue["PV"] = _aiFeedBack;
  40. return data;
  41. }
  42. }
  43. public IoTempMeter(string module, XmlElement node, string ioModule = "")
  44. {
  45. var attrModule = node.GetAttribute("module");
  46. base.Module = string.IsNullOrEmpty(attrModule) ? module : attrModule;
  47. base.Name = node.GetAttribute("id");
  48. base.Display = node.GetAttribute("display");
  49. base.DeviceID = node.GetAttribute("schematicId");
  50. _isFloatAioType = !string.IsNullOrEmpty(node.GetAttribute("aioType")) && (node.GetAttribute("aioType") == "float");
  51. _aiFeedBack = ParseAiNode("aiFeedback", node, ioModule);
  52. UniqueName = Module + "." + Name;
  53. }
  54. public bool Initialize()
  55. {
  56. //DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
  57. DATA.Subscribe($"BufferA.Heater", () => FeedBack);
  58. return true;
  59. }
  60. public void Reset()
  61. {
  62. }
  63. public void Terminate()
  64. {
  65. }
  66. public void Monitor()
  67. {
  68. }
  69. }
  70. }