TransmitterSwitchInfo.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. #include "TransmitterSwitchInfo.h"
  2. // #include "lhstylemanager.h"
  3. #include <QFile>
  4. #include <QEventLoop>
  5. /**
  6. * @brief 全局的回调函数传入值和说明
  7. *
  8. */
  9. const QMap<int, QString> g_mapTrack = {
  10. {1, ""}, /* 保存计划 */
  11. {2, ""}, /* 加载计划 */
  12. {3, "保存模板"},
  13. {4, "导入模板"}
  14. };
  15. /**
  16. * @brief 更新一个配置,不存在则添加
  17. *
  18. * @param data
  19. */
  20. void ConfigDataContainer::updateConfigData(const ConfigData& data)
  21. {
  22. if(m_mapConfigData.contains(data.key))
  23. {
  24. m_mapConfigData[data.key].value = data.value;
  25. m_mapConfigData[data.key].updateTime = data.updateTime;
  26. }else
  27. {
  28. /* 加入新的内容,添加说明 */
  29. m_mapConfigData.insert(data.key, data);
  30. if(KeyNotes.contains(data.key))
  31. {
  32. m_mapConfigData[data.key].notes = KeyNotes[data.key];
  33. }
  34. }
  35. }
  36. /* 获取一个配置 */
  37. ConfigData& ConfigDataContainer::getConfigData(int key)
  38. {
  39. if(m_mapConfigData.contains(key))
  40. {
  41. return m_mapConfigData[key];
  42. }
  43. return m_mapConfigData[0];
  44. }
  45. /* 查找一个配置是否在不在 */
  46. bool ConfigDataContainer::findConfigData(int key)
  47. {
  48. return m_mapConfigData.contains(key);
  49. }
  50. /* 删除一个配置 */
  51. void ConfigDataContainer::deleteConfigData(int key)
  52. {
  53. if(m_mapConfigData.contains(key))
  54. {
  55. m_mapConfigData.remove(key);
  56. }
  57. }
  58. ExecPlanItemInfo::ExecPlanItemInfo()
  59. {
  60. ChannelID = -1;
  61. ExecType = -1;
  62. WeekDay = enum_WeekDay::WeekDay_Mon;
  63. dateTime = QDateTime::fromString("1970-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
  64. devName = "未定义";
  65. actionID = 0;
  66. actionName = "未定义";
  67. }
  68. ExecPlanItemInfo::ExecPlanItemInfo(const ExecPlanItemInfo& item)
  69. {
  70. ChannelID = item.ChannelID;
  71. ExecType = item.ExecType;
  72. WeekDay = item.WeekDay;
  73. dateTime = item.dateTime;
  74. actionID = item.actionID;
  75. devName = item.devName;
  76. actionName = item.actionName;
  77. }
  78. ExecPlanItemInfo& ExecPlanItemInfo::operator=(const ExecPlanItemInfo& item)
  79. {
  80. if(this == &item)
  81. return *this;
  82. ChannelID = item.ChannelID;
  83. ExecType = item.ExecType;
  84. WeekDay = item.WeekDay;
  85. dateTime = item.dateTime;
  86. devName = item.devName;
  87. actionID = item.actionID;
  88. actionName = item.actionName;
  89. return *this;
  90. }
  91. ChannelInfo::ChannelInfo(const ChannelInfo& channel)
  92. {
  93. ChannelID = channel.ChannelID;
  94. ChannelName = channel.ChannelName;
  95. }
  96. ChannelInfo& ChannelInfo::operator=(const ChannelInfo& channel)
  97. {
  98. if(this == &channel)
  99. return *this;
  100. ChannelID = channel.ChannelID;
  101. ChannelName = channel.ChannelName;
  102. return *this;
  103. }
  104. /* 添加一个频率 */
  105. void MapChannel::addChannel(const ChannelInfo& channelInfo)
  106. {
  107. m_mapChannel.insert(channelInfo.ChannelID, channelInfo);
  108. }
  109. /* 获取一个频率 */
  110. ChannelInfo MapChannel::getChannel(int channelID)
  111. {
  112. if(m_mapChannel.contains(channelID))
  113. {
  114. return m_mapChannel[channelID];
  115. }
  116. return ChannelInfo();
  117. }
  118. DevTypeInfo::DevTypeInfo()
  119. {
  120. devTypeName = "";
  121. devAction.clear();
  122. devType_MB.clear();
  123. PTTypeCode = -1;
  124. }
  125. DevTypeInfo& DevTypeInfo::operator=(const DevTypeInfo& devInfo)
  126. {
  127. devTypeName = devInfo.devTypeName;
  128. devAction = devInfo.devAction;
  129. devType_MB = devInfo.devType_MB;
  130. PTTypeCode = devInfo.PTTypeCode;
  131. return *this;
  132. }
  133. MapDevType::MapDevType()
  134. {
  135. initDevType();
  136. }
  137. /* 添加支持的设备类型 */
  138. void MapDevType::initDevType()
  139. {
  140. /* 955发射机 */
  141. DevTypeInfo devInfo;
  142. devInfo.devTypeName = "衢州台发射机";
  143. devInfo.PTTypeCode = 955;
  144. devInfo.devAction[1] = "开机";
  145. devInfo.devAction[2] = "关机";
  146. devInfo.devType_MB.insert(enum_DeviceMB::Dev_Main,"主");
  147. devInfo.devType_MB.insert(enum_DeviceMB::Dev_Backup,"备");
  148. devInfo.devType_MB.insert(enum_DeviceMB::Dev_Contingency,"应急");
  149. m_mapDevType.insert(955, devInfo);
  150. /* 其他发射机 */
  151. }
  152. /* 获取某一个发射机类型 */
  153. DevTypeInfo MapDevType::getDevType(int PTTypeCode)
  154. {
  155. if(m_mapDevType.contains(PTTypeCode))
  156. {
  157. return m_mapDevType[PTTypeCode];
  158. }
  159. return DevTypeInfo();
  160. }
  161. DeviceInfo::DeviceInfo()
  162. {
  163. devName = "未定义";
  164. PTTypeCode = -1;
  165. DevType = DevTypeInfo();
  166. DTID = 0;
  167. DID = 0;
  168. ChannelID = 0;
  169. }
  170. DeviceInfo::DeviceInfo(const DeviceInfo& devInfo)
  171. {
  172. devName = devInfo.devName;
  173. PTTypeCode = devInfo.PTTypeCode;
  174. DevType = devInfo.DevType;
  175. DTID = devInfo.DTID;
  176. DID = devInfo.DID;
  177. MPID = devInfo.MPID;
  178. ChannelID = devInfo.ChannelID;
  179. }
  180. DeviceInfo& DeviceInfo::operator=(const DeviceInfo& devInfo)
  181. {
  182. devName = devInfo.devName;
  183. PTTypeCode = devInfo.PTTypeCode;
  184. DevType = devInfo.DevType;
  185. DTID = devInfo.DTID;
  186. DID = devInfo.DID;
  187. MPID = devInfo.MPID;
  188. ChannelID = devInfo.ChannelID;
  189. return *this;
  190. }
  191. MapDevice::MapDevice()
  192. {
  193. }
  194. /* 添加一个设备 */
  195. void MapDevice::addDevice(const DeviceInfo& devInfo)
  196. {
  197. /* 先查重 */
  198. if(m_mapDevice.contains(devInfo.devName))
  199. {
  200. return;
  201. }
  202. m_mapDevice.insert(devInfo.devName, devInfo);
  203. }
  204. /* 获取一个设备 */
  205. DeviceInfo MapDevice::getDevice(const QString& devName)
  206. {
  207. if(m_mapDevice.contains(devName))
  208. {
  209. return m_mapDevice[devName];
  210. }
  211. return DeviceInfo();
  212. }
  213. /* 查找一个设备 */
  214. bool MapDevice::findDevice(const QString& devName)
  215. {
  216. return m_mapDevice.contains(devName);
  217. }
  218. /* 根据设备名称获取设备动作 */
  219. bool MapDevice::getDevAction(const QString& devName, QMap<int, QString>& devAction)
  220. {
  221. if(m_mapDevice.contains(devName))
  222. {
  223. devAction = m_mapDevice[devName].DevType.devAction;
  224. return true;
  225. }
  226. return false;
  227. }
  228. /* 删除一个设备 */
  229. void MapDevice::deleteDevice(const QString& devName)
  230. {
  231. if(m_mapDevice.contains(devName))
  232. {
  233. m_mapDevice.remove(devName);
  234. }
  235. }