TransmitterSwitchInfo.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. #include "TransmitterSwitchInfo.h"
  2. ExecPlanItemInfo::ExecPlanItemInfo()
  3. {
  4. ExecType = -1;
  5. WeekDay = 0;
  6. // num = -1;
  7. date = QDate::fromString("1970-01-01","yyyy-MM-dd");
  8. execTime = QTime::fromString("00:00:00","hh:mm:ss");
  9. devName = "未定义";
  10. actionID = 0;
  11. actionName = "未定义";
  12. }
  13. ExecPlanItemInfo::ExecPlanItemInfo(const ExecPlanItemInfo& item)
  14. {
  15. ExecType = item.ExecType;
  16. WeekDay = item.WeekDay;
  17. date = item.date;
  18. execTime = item.execTime;
  19. actionID = item.actionID;
  20. devName = item.devName;
  21. actionName = item.actionName;
  22. }
  23. ExecPlanItemInfo& ExecPlanItemInfo::operator=(const ExecPlanItemInfo& item)
  24. {
  25. if(this == &item)
  26. return *this;
  27. ExecType = item.ExecType;
  28. WeekDay = item.WeekDay;
  29. // num = item.num;
  30. date = item.date;
  31. execTime = item.execTime;
  32. devName = item.devName;
  33. actionID = item.actionID;
  34. actionName = item.actionName;
  35. // dateType = item.dateType;
  36. // cfgDev = item.cfgDev;
  37. return *this;
  38. }
  39. DevTypeInfo::DevTypeInfo()
  40. {
  41. devTypeName = "";
  42. devAction.clear();
  43. devType_MB.clear();
  44. PTTypeCode = -1;
  45. }
  46. DevTypeInfo& DevTypeInfo::operator=(const DevTypeInfo& devInfo)
  47. {
  48. devTypeName = devInfo.devTypeName;
  49. devAction = devInfo.devAction;
  50. devType_MB = devInfo.devType_MB;
  51. PTTypeCode = devInfo.PTTypeCode;
  52. return *this;
  53. }
  54. MapDevType::MapDevType()
  55. {
  56. initDevType();
  57. }
  58. /* 添加支持的设备类型 */
  59. void MapDevType::initDevType()
  60. {
  61. /* 955发射机 */
  62. DevTypeInfo devInfo;
  63. devInfo.devTypeName = "衢州台发射机";
  64. devInfo.PTTypeCode = 955;
  65. devInfo.devAction[1] = "开机";
  66. devInfo.devAction[2] = "关机";
  67. devInfo.devType_MB.insert(enum_DeviceMB::Dev_Main,"主");
  68. devInfo.devType_MB.insert(enum_DeviceMB::Dev_Backup,"备");
  69. devInfo.devType_MB.insert(enum_DeviceMB::Dev_Contingency,"应急");
  70. m_mapDevType.insert(955, devInfo);
  71. /* 其他发射机 */
  72. }
  73. /* 获取某一个发射机类型 */
  74. DevTypeInfo MapDevType::getDevType(int PTTypeCode)
  75. {
  76. if(m_mapDevType.contains(PTTypeCode))
  77. {
  78. return m_mapDevType[PTTypeCode];
  79. }
  80. return DevTypeInfo();
  81. }
  82. DeviceInfo::DeviceInfo()
  83. {
  84. devName = "未定义";
  85. PTTypeCode = -1;
  86. DevType = DevTypeInfo();
  87. DTID = 0;
  88. DID = 0;
  89. ChannelID = 0;
  90. }
  91. DeviceInfo::DeviceInfo(const DeviceInfo& devInfo)
  92. {
  93. devName = devInfo.devName;
  94. PTTypeCode = devInfo.PTTypeCode;
  95. DevType = devInfo.DevType;
  96. DTID = devInfo.DTID;
  97. DID = devInfo.DID;
  98. ChannelID = devInfo.ChannelID;
  99. }
  100. DeviceInfo& DeviceInfo::operator=(const DeviceInfo& devInfo)
  101. {
  102. devName = devInfo.devName;
  103. PTTypeCode = devInfo.PTTypeCode;
  104. DevType = devInfo.DevType;
  105. DTID = devInfo.DTID;
  106. DID = devInfo.DID;
  107. ChannelID = devInfo.ChannelID;
  108. return *this;
  109. }
  110. MapDevice::MapDevice()
  111. {
  112. }
  113. /* 添加一个设备 */
  114. void MapDevice::addDevice(const DeviceInfo& devInfo)
  115. {
  116. /* 先查重 */
  117. if(m_mapDevice.contains(devInfo.devName))
  118. {
  119. return;
  120. }
  121. m_mapDevice.insert(devInfo.devName, devInfo);
  122. }
  123. /* 获取一个设备 */
  124. DeviceInfo MapDevice::getDevice(const QString& devName)
  125. {
  126. if(m_mapDevice.contains(devName))
  127. {
  128. return m_mapDevice[devName];
  129. }
  130. return DeviceInfo();
  131. }
  132. /* 查找一个设备 */
  133. bool MapDevice::findDevice(const QString& devName)
  134. {
  135. return m_mapDevice.contains(devName);
  136. }
  137. /* 根据设备名称获取设备动作 */
  138. bool MapDevice::getDevAction(const QString& devName, QMap<int, QString>& devAction)
  139. {
  140. if(m_mapDevice.contains(devName))
  141. {
  142. devAction = m_mapDevice[devName].DevType.devAction;
  143. return true;
  144. }
  145. return false;
  146. }
  147. /* 删除一个设备 */
  148. void MapDevice::deleteDevice(const QString& devName)
  149. {
  150. if(m_mapDevice.contains(devName))
  151. {
  152. m_mapDevice.remove(devName);
  153. }
  154. }