TotalSRDDevice.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.Util;
  4. using MECF.Framework.Common.IOCore;
  5. using MECF.Framework.Common.TwinCat;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Reflection;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace CyberX8_RT.Devices.SRD
  13. {
  14. public class TotalSRDDevice : BaseDevice, IDevice
  15. {
  16. #region 常量
  17. private const string FLUID_CONTAINMENT = "FluidContainment";
  18. private const string WATER_PRESSURE = "WaterPressure";
  19. #endregion
  20. #region 属性
  21. public bool FluidContainment { get; private set; }
  22. public double WaterPressure { get; private set; }
  23. #endregion
  24. /// <summary>
  25. /// 构造函数
  26. /// </summary>
  27. /// <param name="moduleName"></param>
  28. /// <param name="name"></param>
  29. public TotalSRDDevice() : base("SRD", "SRD", "SRD", "SRD")
  30. {
  31. }
  32. /// <summary>
  33. /// 初始化
  34. /// </summary>
  35. /// <returns></returns>
  36. public bool Initialize()
  37. {
  38. SubscribeValueAction();
  39. return true;
  40. }
  41. /// <summary>
  42. /// 订阅变量数值发生变化
  43. /// </summary>
  44. private void SubscribeValueAction()
  45. {
  46. IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_PRESSURE, UpdateVariableValue);
  47. IOModuleManager.Instance.SubscribeModuleVariable(Module, FLUID_CONTAINMENT, UpdateVariableValue);
  48. }
  49. /// 更新变量数值
  50. /// </summary>
  51. /// <param name="variable"></param>
  52. /// <param name="value"></param>
  53. private void UpdateVariableValue(string variable, object value)
  54. {
  55. if (variable == FLUID_CONTAINMENT)
  56. {
  57. FluidContainment = (bool)value;
  58. }
  59. else if (variable == WATER_PRESSURE)
  60. {
  61. WaterPressure = (double)value;
  62. }
  63. }
  64. public void Monitor()
  65. {
  66. }
  67. public void Reset()
  68. {
  69. }
  70. public void Terminate()
  71. {
  72. }
  73. }
  74. }