IoSwitch.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.IOCore;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.RT.OperationCenter;
  7. using CdioCs;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Security.Cryptography;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Xml;
  15. namespace Venus_RT.Devices
  16. {
  17. public class IoSwitch : BaseDevice, IDevice
  18. {
  19. private readonly DIAccessor _di;
  20. private readonly DOAccessor _do;
  21. /// <summary>
  22. /// true是small size,false是big size,null di/do都为空
  23. /// </summary>
  24. public bool? Status
  25. {
  26. get
  27. {
  28. return _di==null? _do?.Value:_di.Value;
  29. }
  30. }
  31. public bool SetPoint
  32. {
  33. get
  34. {
  35. return _do.Value;
  36. }
  37. set
  38. {
  39. if (_do != null)
  40. {
  41. _do.Value = value;
  42. }
  43. }
  44. }
  45. public IoSwitch(string module, XmlElement node, string ioModule = "")
  46. {
  47. base.Module = module;
  48. base.Name = node.GetAttribute("id");
  49. base.Display = node.GetAttribute("display");
  50. base.DeviceID = node.GetAttribute("schematicId");
  51. _di = ParseDiNode("di", node, ioModule);
  52. _do = ParseDoNode("do", node, ioModule);
  53. }
  54. public bool Initialize()
  55. {
  56. return true;
  57. }
  58. public void Terminate()
  59. {
  60. }
  61. public void Monitor()
  62. {
  63. }
  64. public void Reset()
  65. {
  66. }
  67. public void TurnOn()
  68. {
  69. SetPoint = true;
  70. }
  71. public void TurnOff()
  72. {
  73. SetPoint = false;
  74. }
  75. }
  76. }