12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.Util;
- using MECF.Framework.Common.IOCore;
- using MECF.Framework.Common.TwinCat;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Devices.SRD
- {
- public class TotalSRDDevice : BaseDevice, IDevice
- {
- #region 常量
- private const string FLUID_CONTAINMENT = "FluidContainment";
- private const string WATER_PRESSURE = "WaterPressure";
- #endregion
- #region 属性
- public bool FluidContainment { get; private set; }
- public double WaterPressure { get; private set; }
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="moduleName"></param>
- /// <param name="name"></param>
- public TotalSRDDevice() : base("SRD", "SRD", "SRD", "SRD")
- {
- }
- /// <summary>
- /// 初始化
- /// </summary>
- /// <returns></returns>
- public bool Initialize()
- {
- SubscribeValueAction();
- return true;
- }
- /// <summary>
- /// 订阅变量数值发生变化
- /// </summary>
- private void SubscribeValueAction()
- {
- IOModuleManager.Instance.SubscribeModuleVariable(Module, WATER_PRESSURE, UpdateVariableValue);
- IOModuleManager.Instance.SubscribeModuleVariable(Module, FLUID_CONTAINMENT, UpdateVariableValue);
- }
- /// 更新变量数值
- /// </summary>
- /// <param name="variable"></param>
- /// <param name="value"></param>
- private void UpdateVariableValue(string variable, object value)
- {
- if (variable == FLUID_CONTAINMENT)
- {
- FluidContainment = (bool)value;
- }
- else if (variable == WATER_PRESSURE)
- {
- WaterPressure = (double)value;
- }
- }
- public void Monitor()
- {
- }
- public void Reset()
- {
- }
- public void Terminate()
- {
- }
- }
- }
|