bms_balance.py 1.5 KB

12345678910111213141516171819202122232425262728293031
  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 utils.globalvar import SD
  6. from utils.qt import QMessageBox, Signal
  7. class Win_Balance(Balance, MyFrame):
  8. balance_control_signal = Signal(int, int, int)
  9. def __init__(self, parent=None):
  10. super(Win_Balance, self).__init__(parent)
  11. self.setupUi(self)
  12. for i in range(15):
  13. for j in range(72):
  14. # 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))
  15. 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))
  16. def can_connect_error(self):
  17. QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")
  18. def _balance_ctl(self, state, cmu_id, cell_id):
  19. # print(cmu_id, cell_id, state)
  20. self.balance_control_signal.emit(cmu_id, cell_id, state)