bms_protect.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. from ui.protect import Protect
  4. from ui.own.frame_theme import MyFrame
  5. from utils.globalvar import SD
  6. from utils.qt import QMessageBox, Signal
  7. class Win_Protect(Protect, MyFrame):
  8. # 信号传递
  9. read_param_signal = Signal()
  10. write_param_signal = Signal()
  11. exit_param_signal = Signal()
  12. reset_param_signal = Signal()
  13. def __init__(self, parent=None):
  14. super(Win_Protect, self).__init__(parent)
  15. self.setupUi(self)
  16. self.btn_read_param.clicked.connect(self.on_btn_read_param)
  17. self.btn_write_param.clicked.connect(self.on_btn_write_param)
  18. self.btn_exit_param.clicked.connect(self.on_btn_exit_param)
  19. self.btn_reset_param.clicked.connect(self.on_btn_reset_param)
  20. self.protect_table.itemClicked.connect(self._param_item_clicked)
  21. self.qline_data_set.returnPressed.connect(self._protect_data_changed)
  22. def on_btn_read_param(self):
  23. self.read_param_signal.emit()
  24. def on_btn_write_param(self):
  25. self.write_param_signal.emit()
  26. def on_btn_exit_param(self):
  27. self.exit_param_signal.emit()
  28. def on_btn_reset_param(self):
  29. self.reset_param_signal.emit()
  30. def _protect_data_changed(self):
  31. value = (float(self.qline_data_set.text()) - float(self.qline_offset.text()))/float(self.qline_fbl.text())
  32. self.qline_data.setText(str(value))
  33. def _param_item_clicked(self, index):
  34. self.qline_name.setText(self.protect_table.item(index.row(), 0).text())
  35. self.qline_addr.setText(self.protect_table.item(index.row(), 3).text())
  36. self.qline_data_long.setText(self.protect_table.item(index.row(), 5).text())
  37. self.qline_fbl.setText(self.protect_table.item(index.row(), 6).text())
  38. self.qline_offset.setText(self.protect_table.item(index.row(), 7).text())
  39. self.qline_dw.setText(self.protect_table.item(index.row(), 2).text())
  40. self.qline_data.setText(self.protect_table.item(index.row(), 8).text())
  41. self.qline_data_set.setText(self.protect_table.item(index.row(), 1).text())
  42. def set_error(self):
  43. QMessageBox.critical(self, "错误" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Param Error!")
  44. def can_connect_error(self):
  45. QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")