devicemanager.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #ifndef DEVICEMANAGER_H
  2. #define DEVICEMANAGER_H
  3. #include <QObject>
  4. #include <QJsonDocument>
  5. #include <QJsonObject>
  6. #include <QJsonArray>
  7. #include "common/Singletonwork/singletonwork.h"
  8. //MQTT链接超时设置
  9. #define MQTT_CONNECT_TIMEOUT 30000
  10. // mqtt webapi的topic
  11. #define MQTTWEBNAME "LH_WEBINFO"
  12. //服务类型本地显示
  13. #define APPTYPE "LH_EQM_ANALYSE"
  14. //数据库操作类型定义
  15. #define DBDOTYPE_SELECT 1
  16. #define DBDOTYPE_UPDATE 2
  17. #define DBDOTYPE_DELETE 3
  18. #define DBDOTYPE_INSERT 4
  19. #define DBDOTYPE_PROCEDURE 5
  20. #define TRANSMITTER_PT_CODE_1 955
  21. #define TRANSMITTER_PT_CODE_2 960
  22. #define TZ_PT_CODE_1 961
  23. #define TZ_PT_CODE_2 963
  24. #define ANT_PT_CODE_1 984
  25. #define ANT_PT_CODE_2 985
  26. struct tMPinData
  27. {
  28. int nMPID;
  29. int nDeviceID;
  30. int nFlags;
  31. int nChnID;
  32. QString strMPName;
  33. QString strDevName;
  34. QString strMaddress;
  35. tMPinData()
  36. {
  37. nMPID = 0; nDeviceID = 0;
  38. nFlags = -1;
  39. }
  40. };
  41. Q_DECLARE_METATYPE(tMPinData);
  42. struct tDeviceData
  43. {
  44. //同轴设备
  45. int nChnID;
  46. int nMPID;
  47. int nDeviceID;
  48. QString strChnName;
  49. QString strMPName;
  50. QString strDevName;
  51. QString strMaddress;
  52. //发射机设备
  53. tMPinData hostTransData;
  54. tMPinData backTransData;
  55. tMPinData emergencyTransData;
  56. tDeviceData()
  57. {
  58. nChnID = 0; nMPID = 0;
  59. nDeviceID = 0;
  60. }
  61. };
  62. Q_DECLARE_METATYPE(tDeviceData);
  63. struct tTZConfig
  64. {
  65. int mpid = 0; //同轴监测点MPID
  66. bool enable = true; //是否启用监测
  67. bool enablemutilchannel = false;//启用多频率 没有为false
  68. QString address; //同轴设备地址
  69. int port = 0; //同轴设备端口
  70. int slaveid = 1; //同轴设备机器码,全部设为1即可
  71. int hosttransmpid = 0; //同轴关联主发射机MPID
  72. int backtransmpid = 0; //同轴关联备发射机MPID
  73. int emergencympid = 0; //同轴关联应急发射机MPID,没有为0
  74. int powerofftime = 2; //发射机关机延时
  75. QString strhosttransName;
  76. QString strbacktransName;
  77. QString stremergencyName;
  78. bool isValid()
  79. {
  80. return (mpid == 0);
  81. }
  82. };
  83. class DeviceManager : public QObject
  84. {
  85. Q_OBJECT
  86. public:
  87. explicit DeviceManager(QObject *parent = nullptr);
  88. bool DoLoadTranPin();
  89. bool DoLoadDeviceData();
  90. bool DoLoadServiceConfig(int nServiceID);
  91. bool DoSaveServiceConfig(int nServiceID);
  92. void GetDeviceConfig(int nMPID, tTZConfig& config);
  93. void SetDeviceConfig(int nMPID, tTZConfig& config);
  94. void GetMonitorByID(int nMPID, tMPinData& pin);
  95. public:
  96. //发射机设备列表
  97. QList<tMPinData> m_transDataList;
  98. //同轴设备列表
  99. QList<tDeviceData> m_deviceDataList;
  100. //发射机采集服务ip
  101. QString m_transServerIP;
  102. //发射机采集服务port
  103. int m_transServerPort = 0;
  104. //同轴监测设备列表
  105. QList<tTZConfig> m_tzConfigList;
  106. };
  107. #endif // DEVICEMANAGER_H