bms_balance.py 1.6 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. from ui.balance import Balance
  4. from ui.own.frame_theme import MyFrame
  5. from ui.own.my_chart_view import MyChartView
  6. from utils.globalvar import SD
  7. from utils.qt import QMessageBox, QChart, QValueAxis, QHBoxLayout, QPainter, Qt, Signal, Slot, QLegendMarker
  8. class Win_Balance(Balance, MyFrame):
  9. balance_control_signal = Signal(int, int, int)
  10. def __init__(self, parent=None):
  11. super(Win_Balance, self).__init__(parent)
  12. self.setupUi(self)
  13. for i in range(15):
  14. for j in range(72):
  15. # self.balance_control_qscrollarea_layout.itemAtPosition(j + 1, i).widget().layout().itemAt(1).widget().stateChanged.connect(lambda state = self.balance_control_qscrollarea_layout.itemAtPosition(j + 1, i).widget().layout().itemAt(1).widget(), cmu_id = i + 1, cell_id = j + 1: self._balance_ctl(state, cmu_id, cell_id))
  16. self.balance_control_qscrollarea_layout.itemAtPosition(i, j + 1).widget().layout().itemAt(1).widget().stateChanged.connect(lambda state = self.balance_control_qscrollarea_layout.itemAtPosition(i, j + 1).widget().layout().itemAt(1).widget(), cmu_id = i + 1, cell_id = j + 1: self._balance_ctl(state, cmu_id, cell_id))
  17. def can_connect_error(self):
  18. QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")
  19. def _balance_ctl(self, state, cmu_id, cell_id):
  20. # print(cmu_id, cell_id, state)
  21. self.balance_control_signal.emit(cmu_id, cell_id, state)