bms_hard.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. from ui.hard import Hard
  4. from ui.own.frame_theme import MyFrame
  5. from utils.globalvar import SD
  6. from utils.qt import QMessageBox, Signal
  7. from functools import partial
  8. class Win_Hard(Hard, MyFrame):
  9. rtc_update_signal = Signal()
  10. read_hard_signal = Signal()
  11. write_param_signal = Signal()
  12. exit_hard_signal = Signal()
  13. pack_vol_cali_signal = Signal()
  14. cur_cali_signal = Signal()
  15. cell_vol_one_cali_signal = Signal()
  16. cell_vol_all_cali_signal = Signal()
  17. temp_control_signal = Signal(int, int, int)
  18. def __init__(self, parent=None):
  19. super(Win_Hard, self).__init__(parent)
  20. self.setupUi(self)
  21. self.btn_rtc.clicked.connect(self._rtc_update)
  22. self.btn_read_hard_param.clicked.connect(self.on_btn_read_hard)
  23. self.btn_exit_hard_param.clicked.connect(self.on_btn_exit_hard)
  24. self.btn_pack_vol_cali.clicked.connect(self._on_btn_pack_vol_cali)
  25. self.btn_cur_cali.clicked.connect(self._on_btn_cur_cali)
  26. self.btn_hand.clicked.connect(self._on_btn_hand)
  27. self.btn_auto.clicked.connect(self._on_btn_auto)
  28. for index in range(64):
  29. self.hard_table.cellWidget(index, 2).editingFinished.connect(partial(self.set_diff, index))
  30. for i in range(15):
  31. for j in range(72):
  32. self.temp_qscrollarea_layout.itemAtPosition(i + 1, j + 1).widget().layout().itemAt(0).widget().stateChanged.connect(lambda state = self.temp_qscrollarea_layout.itemAtPosition(i + 1, j + 1).widget().layout().itemAt(0).widget(), cmu_id = i + 1, cell_id = j: self._temp_ctl(state, cmu_id, cell_id))
  33. def _rtc_update(self):
  34. self.rtc_update_signal.emit()
  35. def on_btn_read_hard(self):
  36. self.read_hard_signal.emit()
  37. def on_btn_exit_hard(self):
  38. self.exit_hard_signal.emit()
  39. def _on_btn_pack_vol_cali(self):
  40. self.pack_vol_cali_signal.emit()
  41. def _on_btn_cur_cali(self):
  42. self.cur_cali_signal.emit()
  43. def _on_btn_hand(self):
  44. self.cell_vol_one_cali_signal.emit()
  45. def _on_btn_auto(self):
  46. self.cell_vol_all_cali_signal.emit()
  47. def set_diff(self, i):
  48. try:
  49. diff = int(float(self.hard_table.cellWidget(i, 2).text())) - int(self.hard_table.item(i, 3).text())
  50. self.hard_table.item(i, 4).setText(str(diff))
  51. except BaseException:
  52. return
  53. def _temp_ctl(self, state, cmu_id, cell_id):
  54. self.temp_control_signal.emit(cmu_id, cell_id, state)
  55. def can_connect_error(self):
  56. QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")
  57. def data_error(self):
  58. QMessageBox.critical(self, "数据状态" if SD.SYSTEM_LANGUAGE == 0 else "Data State", "数据无效!" if SD.SYSTEM_LANGUAGE == 0 else "Data Error!")