IDevice.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Xml;
  6. using Aitex.Core.RT.IOCore;
  7. using Aitex.Core.RT.SCCore;
  8. using Aitex.Core.Util;
  9. using Aitex.Core.RT.Log;
  10. using System.Timers;
  11. using System.Diagnostics;
  12. using System.Collections.Concurrent;
  13. namespace Aitex.Core.RT.Device
  14. {
  15. public interface IDevice
  16. {
  17. string Module { get; set; }
  18. string Name { get; set; }
  19. bool Initialize();
  20. void Monitor();
  21. void Terminate();
  22. void Reset();
  23. }
  24. public interface IModuleDevice
  25. {
  26. bool IsReady { get; }
  27. bool IsError { get; }
  28. bool IsInit { get; }
  29. bool Home(out string reason);
  30. }
  31. public class BaseDevice
  32. {
  33. public string UniqueName { get; set; }
  34. public string Module { get; set; }
  35. public string Name { get; set; }
  36. public string Display { get; set; }
  37. public string DeviceID { get; set; }
  38. private DeviceTimer counter = new DeviceTimer();
  39. public string ScBasePath { get; set; }
  40. public string IoBasePath { get; set; }
  41. public List<string> SerachCommandList;
  42. public BlockingCollection<string> SetPointCommandQueue = new BlockingCollection<string>();
  43. public Stopwatch baseStopwatch = new Stopwatch();
  44. public int intervalTime = 500;
  45. public BaseDevice()
  46. {
  47. ScBasePath = "System";
  48. IoBasePath = "System";
  49. }
  50. public BaseDevice(string module, string name, string display, string id):this()
  51. {
  52. display = string.IsNullOrEmpty(display) ? name : display;
  53. id = string.IsNullOrEmpty(id) ? name : id;
  54. Module = module;
  55. Name = name;
  56. Display = display;
  57. DeviceID = id;
  58. UniqueName = $"{module}.{name}";
  59. }
  60. }
  61. }