balance.py 17 KB

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