using Aitex.Core.Common.DeviceData; using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.Device; using Aitex.Core.RT.IOCore; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; namespace SicPM.Devices { class IoWaterFlow : BaseDevice, IDevice { private AIAccessor _aiFeedBack = null; private DIAccessor _diFlowSW = null; private bool _isFloatAioType; public AITDeviceData DeviceData { get { AITDeviceData data = new AITDeviceData() { Module = Module, DeviceName = Name, DisplayName = Display, DeviceSchematicId = DeviceID, UniqueName = UniqueName, }; data.AttrValue["FeedBack"] = _aiFeedBack.FloatValue; //data.AttrValue["FlowSW"] = _diFlowSW.Value; return data; } } public float FeedBack { get { if (_aiFeedBack != null) return _isFloatAioType ? _aiFeedBack.FloatValue : _aiFeedBack.Value; return 0; } } public bool FlowSW { get { if (_diFlowSW != null) return _diFlowSW.Value; return false; } } public IoWaterFlow(string module, XmlElement node, string ioModule = "") { var attrModule = node.GetAttribute("module"); base.Module = string.IsNullOrEmpty(attrModule) ? module : attrModule; base.Name = node.GetAttribute("id"); base.Display = node.GetAttribute("display"); base.DeviceID = node.GetAttribute("schematicId"); _isFloatAioType = !string.IsNullOrEmpty(node.GetAttribute("aioType")) && (node.GetAttribute("aioType") == "float"); _aiFeedBack = ParseAiNode("aiFeedback", node, ioModule); _diFlowSW = ParseDiNode("diFlowSW", node, ioModule); UniqueName = Module + "." + Name; } public bool Initialize() { DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData); DATA.Subscribe($"{Module}.{Name}.FeedBack", () => FeedBack); DATA.Subscribe($"{Module}.{Name}.FlowSW", () => FlowSW); return false; } public void Monitor() { } public void Reset() { } public void Terminate() { } } }