终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

63 lines
1.7 KiB

  1. using BPASmartClient.Model;
  2. using System;
  3. using System.Collections.Concurrent;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace BPASmartClient.Peripheral
  10. {
  11. /// <summary>
  12. /// 外设基类
  13. /// </summary>
  14. public abstract class BasePeripheral : IPeripheral
  15. {
  16. /// <summary>
  17. /// 是否已连接
  18. /// </summary>
  19. public bool IsConnected { get; set; }
  20. /// <summary>
  21. /// 是否工作正常
  22. /// </summary>
  23. public bool IsWork { get; set; }
  24. /// <summary>
  25. /// 归属设备Id
  26. /// </summary>
  27. public int DeviceId { get; set; }
  28. public CommunicationPar communicationPar { get; set; } = new CommunicationPar();
  29. public ConcurrentDictionary<string, object> status { get; set; } = new ConcurrentDictionary<string, object>();
  30. public ObservableCollection<Variable> variables { get; set; } = new ObservableCollection<Variable>();
  31. /// <summary>
  32. /// 外设状态集合
  33. /// </summary>
  34. //protected ConcurrentDictionary<string, object> status = new ConcurrentDictionary<string, object>();
  35. /// <summary>
  36. /// 初始化外设状态
  37. /// </summary>
  38. protected abstract void InitStatus();
  39. public object? GetStatus(string statusName)
  40. {
  41. if (status.ContainsKey(statusName))
  42. return status[statusName];
  43. return null;
  44. }
  45. public abstract void Start();
  46. public abstract void Stop();
  47. public abstract void Init();
  48. public ConcurrentDictionary<string, object> GetAllStatus()
  49. {
  50. return status;
  51. }
  52. }
  53. }