using System.Xml; using Aitex.Core.RT.IOCore; namespace Aitex.Core.RT.Device.Unit { public class IoTrigger : BaseDevice, IDevice { private DIAccessor _diFeedback = null; public DIAccessor DiFeedback => _diFeedback; private DOAccessor _doTrigger = null; public DOAccessor DoTrigger => _doTrigger; public IoTrigger(string module, XmlElement node, string ioModule = "") { base.Module = module; base.Name = node.GetAttribute("id"); base.Display = node.GetAttribute("display"); base.DeviceID = node.GetAttribute("schematicId"); _diFeedback = ParseDiNode("diFeedback", node, ioModule); _doTrigger = ParseDoNode("doTrigger", node, ioModule); } public bool Value => _doTrigger.Value; public bool SetTrigger(bool value, out string reason) { return _doTrigger.SetValue(value, out reason); } public bool Initialize() { return true; } public void Terminate() { } public void Monitor() { if (_diFeedback != null && _diFeedback.Value&& _doTrigger!=null&& _doTrigger.Value) SetTrigger(false, out _); } public void Reset() { } } }