bms_hard.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. def __init__(self, parent=None):
  18. super(Win_Hard, self).__init__(parent)
  19. self.setupUi(self)
  20. self.btn_rtc.clicked.connect(self._rtc_update)
  21. self.btn_read_hard_param.clicked.connect(self.on_btn_read_hard)
  22. self.btn_exit_hard_param.clicked.connect(self.on_btn_exit_hard)
  23. self.btn_pack_vol_cali.clicked.connect(self._on_btn_pack_vol_cali)
  24. self.btn_cur_cali.clicked.connect(self._on_btn_cur_cali)
  25. self.btn_hand.clicked.connect(self._on_btn_hand)
  26. self.btn_auto.clicked.connect(self._on_btn_auto)
  27. for i in range(64):
  28. self.hard_table.cellWidget(i, 2).editingFinished.connect(partial(self._set_diff, i))
  29. def _rtc_update(self):
  30. self.rtc_update_signal.emit()
  31. def on_btn_read_hard(self):
  32. self.read_hard_signal.emit()
  33. def on_btn_exit_hard(self):
  34. self.exit_hard_signal.emit()
  35. def _on_btn_pack_vol_cali(self):
  36. self.pack_vol_cali_signal.emit()
  37. def _on_btn_cur_cali(self):
  38. self.cur_cali_signal.emit()
  39. def _on_btn_hand(self):
  40. self.cell_vol_one_cali_signal.emit()
  41. def _on_btn_auto(self):
  42. self.cell_vol_all_cali_signal.emit()
  43. def _set_diff(self, i):
  44. try:
  45. diff = int(float(self.hard_table.cellWidget(i, 2).text())) - int(self.hard_table.item(i, 3).text())
  46. self.hard_table.item(i, 4).setText(str(diff))
  47. # if int(self.hard_table.item(i, 2).text()) <= int(float(self.hard_table.cellWidget(i, 1).text())) <= int(self.hard_table.item(i, 3).text()):
  48. # return
  49. # else:
  50. # QMessageBox.critical(self, "失败" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Invalid value!")
  51. # self.hard_table.cellWidget(i, 1).setText("")
  52. # self.hard_table.cellWidget(i, 1).setFocus()
  53. # return
  54. except BaseException:
  55. # QMessageBox.critical(self, "失败" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Invalid value!")
  56. # self.hard_table.cellWidget(i, 1).setText("")
  57. # self.hard_table.cellWidget(i, 1).setFocusPolicy(Qt.StrongFocus)
  58. return
  59. def can_connect_error(self):
  60. QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")