IoEmo.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System.Xml;
  2. using Aitex.Core.Common.DeviceData;
  3. using Aitex.Core.RT.DataCenter;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.RT.IOCore;
  6. using Aitex.Core.Util;
  7. namespace Aitex.Core.RT.Device.Unit
  8. {
  9. public class IoEmo : BaseDevice, IDevice
  10. {
  11. public bool StopButtonSignal
  12. {
  13. get
  14. {
  15. return _diStopButton != null && _diStopButton.Value;
  16. }
  17. }
  18. public bool MainContactorSignal
  19. {
  20. get
  21. {
  22. return _diMainContactor == null || _diMainContactor.Value;
  23. }
  24. }
  25. private DIAccessor _diStopButton = null;
  26. private DIAccessor _diMainContactor = null;
  27. //private R_TRIG _trigStopButton = new R_TRIG();
  28. //private F_TRIG _trigMainContactor = new F_TRIG();
  29. private R_TRIG _trigEmoSignaled = new R_TRIG();
  30. public IoEmo(string module, XmlElement node, string ioModule = "")
  31. {
  32. base.Module = module;
  33. base.Name = node.GetAttribute("id");
  34. base.Display = node.GetAttribute("display");
  35. base.DeviceID = node.GetAttribute("schematicId");
  36. _diStopButton = ParseDiNode("diStopButton", node, ioModule);
  37. _diMainContactor = ParseDiNode("diMainContactor", node, ioModule);
  38. }
  39. public bool Initialize()
  40. {
  41. DATA.Subscribe(string.Format("Device.{0}.{1}", Module, Name), () =>
  42. {
  43. AITEmoData data = new AITEmoData()
  44. {
  45. DeviceName = Name,
  46. DeviceSchematicId = DeviceID,
  47. DisplayName = Display,
  48. StopButtonSignal = StopButtonSignal,
  49. MainContactorSignal = MainContactorSignal,
  50. };
  51. return data;
  52. }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  53. return true;
  54. }
  55. public void Terminate()
  56. {
  57. }
  58. public void Monitor()
  59. {
  60. _trigEmoSignaled.CLK = StopButtonSignal || (!MainContactorSignal);
  61. if (_trigEmoSignaled.Q) //EMO被拍下
  62. {
  63. EV.PostMessage(Module, EventEnum.DefaultAlarm, "Emergency Off button was pressed");
  64. }
  65. }
  66. public void Reset()
  67. {
  68. _trigEmoSignaled.RST = true;
  69. }
  70. }
  71. }