IoTrigger.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Xml;
  2. using Aitex.Core.RT.IOCore;
  3. namespace Aitex.Core.RT.Device.Unit
  4. {
  5. public class IoTrigger : BaseDevice, IDevice
  6. {
  7. private DIAccessor _diFeedback = null;
  8. public DIAccessor DiFeedback => _diFeedback;
  9. private DOAccessor _doTrigger = null;
  10. public DOAccessor DoTrigger => _doTrigger;
  11. public IoTrigger(string module, XmlElement node, string ioModule = "")
  12. {
  13. base.Module = module;
  14. base.Name = node.GetAttribute("id");
  15. base.Display = node.GetAttribute("display");
  16. base.DeviceID = node.GetAttribute("schematicId");
  17. _diFeedback = ParseDiNode("diFeedback", node, ioModule);
  18. _doTrigger = ParseDoNode("doTrigger", node, ioModule);
  19. }
  20. public bool Value => _doTrigger.Value;
  21. public bool SetTrigger(bool value, out string reason)
  22. {
  23. return _doTrigger.SetValue(value, out reason);
  24. }
  25. public bool Initialize()
  26. {
  27. return true;
  28. }
  29. public void Terminate()
  30. {
  31. }
  32. public void Monitor()
  33. {
  34. if (_diFeedback != null && _diFeedback.Value&& _doTrigger!=null&& _doTrigger.Value)
  35. SetTrigger(false, out _);
  36. }
  37. public void Reset()
  38. {
  39. }
  40. }
  41. }