balance.py 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. from ui.own.frame_theme import MyFrame
  4. from utils.qt import QtWidgets, QtCore, Qt
  5. class Balance(MyFrame):
  6. def setupUi(self, Balance):
  7. self.balance = MyFrame(Balance)
  8. self.balance_layout = QtWidgets.QGridLayout(self.balance)
  9. self.balance_layout.setContentsMargins(5, 5, 5, 5)
  10. self.balance_layout.setSpacing(0)
  11. self.line_groupbox = QtWidgets.QGroupBox(self.balance)
  12. self.line_groupbox.setTitle("采样线故障(红色:故障)")
  13. self.line_groupbox_layout = QtWidgets.QHBoxLayout(self.line_groupbox)
  14. self.line_qscrollarea = QtWidgets.QScrollArea(self.line_groupbox)
  15. self.line_qscrollarea.setWidgetResizable(True)
  16. self.line_qscrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
  17. self.line_groupbox_layout.addWidget(self.line_qscrollarea)
  18. self.line_qwidget = QtWidgets.QWidget()
  19. self.line_qscrollarea.setWidget(self.line_qwidget)
  20. self.line_qscrollarea_layout = QtWidgets.QGridLayout(self.line_qwidget)
  21. self.line_qscrollarea_layout.setContentsMargins(3, 3, 3, 3)
  22. self.line_qscrollarea_layout.setSpacing(0)
  23. for i in range(15):
  24. bmu_label = QtWidgets.QLabel("CMU" + str(i + 1))
  25. bmu_label.setAlignment(Qt.AlignCenter)
  26. bmu_label.setFixedWidth(50)
  27. self.line_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
  28. for i in range(15):
  29. for j in range(72):
  30. qline_lebal = QtWidgets.QLineEdit("C" + str(j + 1))
  31. qline_lebal.setAlignment(Qt.AlignCenter)
  32. qline_lebal.setFixedWidth(50)
  33. qline_lebal.setReadOnly(True)
  34. self.line_qscrollarea_layout.addWidget(qline_lebal, i, j + 1, 1, 1)
  35. # self.line_groupbox = QtWidgets.QGroupBox(self.balance)
  36. # self.line_groupbox.setTitle("采样线故障(红:故障)")
  37. # self.line_groupbox_layout = QtWidgets.QVBoxLayout(self.line_groupbox)
  38. # self.line_qscrollarea = QtWidgets.QScrollArea(self.line_groupbox)
  39. # self.line_qscrollarea.setWidgetResizable(True)
  40. # # self.line_qscrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
  41. # self.line_groupbox_layout.addWidget(self.line_qscrollarea)
  42. # self.line_qwidget = QtWidgets.QWidget()
  43. # self.line_qscrollarea.setWidget(self.line_qwidget)
  44. # self.line_qscrollarea_layout = QtWidgets.QGridLayout(self.line_qwidget)
  45. # self.line_qscrollarea_layout.setContentsMargins(3, 3, 3, 3)
  46. # self.line_qscrollarea_layout.setSpacing(0)
  47. # for i in range(15):
  48. # bmu_label = QtWidgets.QLabel("CMU" + str(i + 1))
  49. # bmu_label.setAlignment(Qt.AlignCenter)
  50. # self.line_qscrollarea_layout.addWidget(bmu_label, 0, i, 1, 1)
  51. # for i in range(15):
  52. # for j in range(72):
  53. # qline_lebal = QtWidgets.QLineEdit("C" + str(j + 1))
  54. # qline_lebal.setAlignment(Qt.AlignCenter)
  55. # qline_lebal.setReadOnly(True)
  56. # qline_lebal.setFixedWidth(50)
  57. # self.line_qscrollarea_layout.addWidget(qline_lebal, j + 1, i, 1, 1)
  58. # to do
  59. # set_edt_bg(self.line_qscrollarea_layout.itemAtPosition(2, 0).widget(), QtGui.QColor(Qt.red))
  60. # set_edt_bg(self.line_qscrollarea_layout.itemAtPosition(3, 1).widget(), QtGui.QColor(Qt.red))
  61. # self.line_status_widget = QtWidgets.QWidget()
  62. # self.line_status_widget_layout = QtWidgets.QHBoxLayout(self.line_status_widget)
  63. # self.line_status_widget_layout.setContentsMargins(0, 0, 0, 0)
  64. # self.line_status_widget_layout.setSpacing(0)
  65. # self.line_status_widget_layout.addStretch()
  66. # self.qline_lebal = QtWidgets.QLineEdit("")
  67. # self.qline_lebal.setAlignment(Qt.AlignCenter)
  68. # self.qline_lebal.setReadOnly(True)
  69. # set_edt_bg(self.qline_lebal, QtGui.QColor(Qt.white))
  70. # self.line_status_widget_layout.addWidget(self.qline_lebal)
  71. # self.lb_lebal = QtWidgets.QLabel(" 无故障 ")
  72. # self.line_status_widget_layout.addWidget(self.lb_lebal)
  73. # self.line_status_widget_layout.addStretch()
  74. # self.line_groupbox_layout.addWidget(self.line_status_widget)
  75. # self.line_status_widget_2 = QtWidgets.QWidget()
  76. # self.line_status_widget_2_layout = QtWidgets.QHBoxLayout(self.line_status_widget_2)
  77. # self.line_status_widget_2_layout.setContentsMargins(0, 0, 0, 0)
  78. # self.line_status_widget_2_layout.setSpacing(0)
  79. # self.line_status_widget_2_layout.addStretch()
  80. # self.qline_bal = QtWidgets.QLineEdit("")
  81. # self.qline_bal.setAlignment(Qt.AlignCenter)
  82. # self.qline_bal.setReadOnly(True)
  83. # set_edt_bg(self.qline_bal, QtGui.QColor(Qt.red))
  84. # self.line_status_widget_2_layout.addWidget(self.qline_bal)
  85. # self.lb_bal = QtWidgets.QLabel("采样线故障")
  86. # self.line_status_widget_2_layout.addWidget(self.lb_bal)
  87. # self.line_status_widget_2_layout.addStretch()
  88. # self.line_groupbox_layout.addWidget(self.line_status_widget_2)
  89. self.balance_layout.addWidget(self.line_groupbox, 0, 0, 1, 1)
  90. self.on_off_groupbox = QtWidgets.QGroupBox(self.balance)
  91. self.on_off_groupbox.setTitle("均衡开关(绿色:开启)")
  92. self.on_off_groupbox_layout = QtWidgets.QHBoxLayout(self.on_off_groupbox)
  93. self.on_off_qscrollarea = QtWidgets.QScrollArea(self.on_off_groupbox)
  94. self.on_off_qscrollarea.setWidgetResizable(True)
  95. self.on_off_qscrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
  96. self.on_off_groupbox_layout.addWidget(self.on_off_qscrollarea)
  97. self.on_off_qwidget = QtWidgets.QWidget()
  98. self.on_off_qscrollarea.setWidget(self.on_off_qwidget)
  99. self.on_off_qscrollarea_layout = QtWidgets.QGridLayout(self.on_off_qwidget)
  100. self.on_off_qscrollarea_layout.setContentsMargins(3, 3, 3, 3)
  101. self.on_off_qscrollarea_layout.setSpacing(0)
  102. for i in range(15):
  103. bmu_label = QtWidgets.QLabel("CMU" + str(i + 1))
  104. bmu_label.setAlignment(Qt.AlignCenter)
  105. bmu_label.setFixedWidth(50)
  106. self.on_off_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
  107. for i in range(15):
  108. for j in range(72):
  109. qon_off_lebal = QtWidgets.QLineEdit("C" + str(j + 1))
  110. qon_off_lebal.setAlignment(Qt.AlignCenter)
  111. qon_off_lebal.setFixedWidth(50)
  112. qon_off_lebal.setReadOnly(True)
  113. self.on_off_qscrollarea_layout.addWidget(qon_off_lebal, i, j + 1, 1, 1)
  114. # set_edt_bg(self.on_off_qscrollarea_layout.itemAtPosition( 0 + 0,1).widget(), QtGui.QColor(Qt.red))
  115. # set_edt_bg(self.on_off_qscrollarea_layout.itemAtPosition( 0 + 2, 6).widget(), QtGui.QColor(Qt.red))
  116. # set_edt_bg(self.on_off_qscrollarea_layout.itemAtPosition(3, 1).widget(), QtGui.QColor(Qt.red))
  117. # self.on_off_widget = QtWidgets.QWidget()
  118. # self.on_off_widget_layout = QtWidgets.QVBoxLayout(self.on_off_widget)
  119. # self.on_off_widget_layout.setContentsMargins(0, 0, 0, 0)
  120. # self.on_off_widget_layout.setSpacing(0)
  121. # self.on_off_widget_layout.addStretch()
  122. # self.qline_l = QtWidgets.QLineEdit("")
  123. # self.qline_l.setAlignment(Qt.AlignCenter)
  124. # self.qline_l.setReadOnly(True)
  125. # set_edt_bg(self.qline_l, QtGui.QColor(Qt.white))
  126. # self.on_off_widget_layout.addWidget(self.qline_l)
  127. # self.lb_l = QtWidgets.QLabel("关闭均衡")
  128. # self.lb_l.setAlignment(Qt.AlignCenter)
  129. # self.on_off_widget_layout.addWidget(self.lb_l)
  130. # self.qline_ll = QtWidgets.QLineEdit("")
  131. # self.qline_ll.setAlignment(Qt.AlignCenter)
  132. # self.qline_ll.setReadOnly(True)
  133. # set_edt_bg(self.qline_ll, QtGui.QColor(Qt.green))
  134. # self.on_off_widget_layout.addWidget(self.qline_ll)
  135. # self.lb_ll = QtWidgets.QLabel("打开均衡")
  136. # self.lb_ll.setAlignment(Qt.AlignCenter)
  137. # self.on_off_widget_layout.addWidget(self.lb_ll)
  138. # self.on_off_widget_layout.addStretch()
  139. # self.on_off_groupbox_layout.addWidget(self.on_off_widget)
  140. self.balance_layout.addWidget(self.on_off_groupbox, 0, 1, 1, 1)
  141. # self.balance_control_groupbox = QtWidgets.QGroupBox(self.balance)
  142. # self.balance_control_groupbox.setTitle("均衡强制控制(选中:控制)")
  143. # self.balance_control_groupbox_layout = QtWidgets.QVBoxLayout(self.balance_control_groupbox)
  144. # self.balance_control_qscrollarea = QtWidgets.QScrollArea(self.balance_control_groupbox)
  145. # self.balance_control_qscrollarea.setWidgetResizable(True)
  146. # # self.balance_control_qscrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
  147. # self.balance_control_groupbox_layout.addWidget(self.balance_control_qscrollarea)
  148. # self.balance_control_qwidget = QtWidgets.QWidget()
  149. # self.balance_control_qscrollarea.setWidget(self.balance_control_qwidget)
  150. # self.balance_control_qscrollarea_layout = QtWidgets.QGridLayout(self.balance_control_qwidget)
  151. # self.balance_control_qscrollarea_layout.setContentsMargins(3, 3, 3, 3)
  152. # self.balance_control_qscrollarea_layout.setSpacing(0)
  153. # for i in range(15):
  154. # bmu_label = QtWidgets.QLabel("CMU" + str(i + 1))
  155. # bmu_label.setAlignment(Qt.AlignCenter)
  156. # self.balance_control_qscrollarea_layout.addWidget(bmu_label, 0, i, 1, 1)
  157. # for i in range(15):
  158. # for j in range(72):
  159. # qbalance_control_widget = QtWidgets.QWidget()
  160. # qbalance_control_widget_layout = QtWidgets.QHBoxLayout(qbalance_control_widget)
  161. # qbalance_control_widget_layout.setContentsMargins(5, 5, 5, 5)
  162. # qbalance_control_widget_layout.setSpacing(0)
  163. # qbalance_control_lebal = QtWidgets.QLineEdit("C" + str(j + 1))
  164. # qbalance_control_lebal.setAlignment(Qt.AlignCenter)
  165. # qbalance_control_lebal.setReadOnly(True)
  166. # qbalance_control_lebal.setFixedWidth(50)
  167. # qbalance_control_widget_layout.addWidget(qbalance_control_lebal)
  168. # qbalance_control_checkbox = QtWidgets.QCheckBox()
  169. # qbalance_control_widget_layout.addWidget(qbalance_control_checkbox)
  170. # self.balance_control_qscrollarea_layout.addWidget(qbalance_control_widget, j + 1, i, 1, 1)
  171. self.balance_control_groupbox = QtWidgets.QGroupBox(self.balance)
  172. self.balance_control_groupbox.setTitle("均衡强制控制(选中:控制)")
  173. self.balance_control_groupbox_layout = QtWidgets.QHBoxLayout(self.balance_control_groupbox)
  174. self.balance_control_qscrollarea = QtWidgets.QScrollArea(self.balance_control_groupbox)
  175. self.balance_control_qscrollarea.setWidgetResizable(True)
  176. self.balance_control_qscrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
  177. self.balance_control_groupbox_layout.addWidget(self.balance_control_qscrollarea)
  178. self.balance_control_qwidget = QtWidgets.QWidget()
  179. self.balance_control_qscrollarea.setWidget(self.balance_control_qwidget)
  180. self.balance_control_qscrollarea_layout = QtWidgets.QGridLayout(self.balance_control_qwidget)
  181. self.balance_control_qscrollarea_layout.setContentsMargins(3, 3, 3, 3)
  182. self.balance_control_qscrollarea_layout.setSpacing(0)
  183. for i in range(15):
  184. bmu_label = QtWidgets.QLabel("CMU" + str(i + 1))
  185. bmu_label.setAlignment(Qt.AlignCenter)
  186. bmu_label.setFixedWidth(50)
  187. self.balance_control_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
  188. for i in range(15):
  189. for j in range(8):
  190. qbalance_control_widget = QtWidgets.QWidget()
  191. qbalance_control_widget_layout = QtWidgets.QHBoxLayout(qbalance_control_widget)
  192. qbalance_control_widget_layout.setContentsMargins(5, 5, 5, 5)
  193. qbalance_control_widget_layout.setSpacing(0)
  194. qbalance_control_lebal = QtWidgets.QLineEdit("AFE" + str(j + 1))
  195. qbalance_control_lebal.setAlignment(Qt.AlignCenter)
  196. qbalance_control_lebal.setReadOnly(True)
  197. qbalance_control_lebal.setFixedWidth(50)
  198. qbalance_control_widget_layout.addWidget(qbalance_control_lebal)
  199. qbalance_control_checkbox = QtWidgets.QCheckBox()
  200. qbalance_control_widget_layout.addWidget(qbalance_control_checkbox)
  201. self.balance_control_qscrollarea_layout.addWidget(qbalance_control_widget, i, j + 1, 1, 1)
  202. self.balance_layout.addWidget(self.balance_control_groupbox, 1, 0, 1, 1)
  203. # self.balance_control_qscrollarea_layout.itemAtPosition(0 + 0, 1).widget().layout().itemAt(1).widget().stateChanged.connect(lambda state = self.balance_control_qscrollarea_layout.itemAtPosition(0 + 0, 1).widget().layout().itemAt(1).widget(), cmu_id = i + 1, cell_id = j + 1: self._balance_ctl(state, cmu_id, cell_id))
  204. # set_edt_bg(self.on_off_qscrollarea_layout.itemAtPosition( 0 + 0,1).widget(), QtGui.QColor(Qt.red))
  205. # self.balance_control_qscrollarea_layout.itemAtPosition(2, 3).widget().layout().itemAt(1).widget().setCheckState(Qt.Checked)
  206. # self.balance_control_qscrollarea_layout.itemAtPosition(0, 1).widget().layout().itemAt(1).widget().setCheckState(Qt.Checked)
  207. self.balance_fault_groupbox = QtWidgets.QGroupBox(self.balance)
  208. self.balance_fault_groupbox.setTitle("均衡故障(红色:故障)")
  209. self.balance_fault_groupbox_layout = QtWidgets.QHBoxLayout(self.balance_fault_groupbox)
  210. self.balance_fault_qscrollarea = QtWidgets.QScrollArea(self.balance_fault_groupbox)
  211. self.balance_fault_qscrollarea.setWidgetResizable(True)
  212. self.balance_fault_qscrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
  213. self.balance_fault_groupbox_layout.addWidget(self.balance_fault_qscrollarea)
  214. self.balance_fault_qwidget = QtWidgets.QWidget()
  215. self.balance_fault_qscrollarea.setWidget(self.balance_fault_qwidget)
  216. self.balance_fault_qscrollarea_layout = QtWidgets.QGridLayout(self.balance_fault_qwidget)
  217. self.balance_fault_qscrollarea_layout.setContentsMargins(3, 3, 3, 3)
  218. self.balance_fault_qscrollarea_layout.setSpacing(0)
  219. for i in range(15):
  220. bmu_label = QtWidgets.QLabel("CMU" + str(i + 1))
  221. bmu_label.setAlignment(Qt.AlignCenter)
  222. bmu_label.setFixedWidth(50)
  223. self.balance_fault_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
  224. for i in range(15):
  225. for j in range(72):
  226. qbalance_fault_lebal = QtWidgets.QLineEdit("C" + str(j + 1))
  227. qbalance_fault_lebal.setAlignment(Qt.AlignCenter)
  228. qbalance_fault_lebal.setReadOnly(True)
  229. qbalance_fault_lebal.setFixedWidth(50)
  230. self.balance_fault_qscrollarea_layout.addWidget(qbalance_fault_lebal, i, j + 1, 1, 1)
  231. # set_edt_bg(self.balance_fault_qscrollarea_layout.itemAtPosition( 0 + 0,1).widget(), QtGui.QColor(Qt.red))
  232. # set_edt_bg(self.balance_fault_qscrollarea_layout.itemAtPosition( 0 + 2, 6).widget(), QtGui.QColor(Qt.red))
  233. # self.balance_fault_widget = QtWidgets.QWidget()
  234. # self.balance_fault_widget_layout = QtWidgets.QVBoxLayout(self.balance_fault_widget)
  235. # self.balance_fault_widget_layout.setContentsMargins(0, 0, 0, 0)
  236. # self.balance_fault_widget_layout.setSpacing(0)
  237. # self.balance_fault_widget_layout.addStretch()
  238. # self.edt_fault = QtWidgets.QLineEdit("")
  239. # self.edt_fault.setAlignment(Qt.AlignCenter)
  240. # self.edt_fault.setReadOnly(True)
  241. # set_edt_bg(self.edt_fault, QtGui.QColor(Qt.white))
  242. # self.balance_fault_widget_layout.addWidget(self.edt_fault)
  243. # self.lb_fault = QtWidgets.QLabel("无故障")
  244. # self.lb_fault.setAlignment(Qt.AlignCenter)
  245. # self.balance_fault_widget_layout.addWidget(self.lb_fault)
  246. # self.edt_faultl = QtWidgets.QLineEdit("")
  247. # self.edt_faultl.setAlignment(Qt.AlignCenter)
  248. # self.edt_faultl.setReadOnly(True)
  249. # set_edt_bg(self.edt_faultl, QtGui.QColor(Qt.red))
  250. # self.balance_fault_widget_layout.addWidget(self.edt_faultl)
  251. # self.lb_faultl = QtWidgets.QLabel("均衡故障")
  252. # self.lb_faultl.setAlignment(Qt.AlignCenter)
  253. # self.balance_fault_widget_layout.addWidget(self.lb_faultl)
  254. # self.balance_fault_widget_layout.addStretch()
  255. # self.balance_fault_groupbox_layout.addWidget(self.balance_fault_widget)
  256. self.balance_layout.addWidget(self.balance_fault_groupbox, 1, 1, 1, 1)
  257. QtCore.QMetaObject.connectSlotsByName(Balance)