Device.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Runtime.CompilerServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace DeviceCenter
  9. {
  10. abstract class Device : INotifyPropertyChanged
  11. {
  12. private string _name;
  13. private string _ip;
  14. private Device.Type _type;
  15. private Device.Status _status;
  16. public enum Type
  17. {
  18. CAR_CAM,
  19. ACS
  20. }
  21. public enum Status
  22. {
  23. IDEL,
  24. CONNECTING,
  25. CONNECTED,
  26. FAIL
  27. }
  28. public string name
  29. {
  30. get { return _name; }
  31. set
  32. {
  33. _name = value;
  34. OnPropertyChanged();
  35. }
  36. }
  37. public string ip
  38. {
  39. get
  40. {
  41. return _ip;
  42. }
  43. set
  44. {
  45. _ip = value;
  46. OnPropertyChanged("ip");
  47. }
  48. }
  49. public Status status
  50. {
  51. get
  52. {
  53. return _status;
  54. }
  55. set
  56. {
  57. _status = value;
  58. OnPropertyChanged();
  59. }
  60. }
  61. public Type type
  62. {
  63. get {
  64. return _type;
  65. }
  66. set
  67. {
  68. _type = value;
  69. OnPropertyChanged();
  70. }
  71. }
  72. public event PropertyChangedEventHandler PropertyChanged;
  73. abstract public void Init();
  74. abstract public void dispose();
  75. protected void OnPropertyChanged([CallerMemberName] string name = null)
  76. {
  77. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
  78. }
  79. }
  80. }