bms_protect.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. def __init__(self, parent=None):
  13. super(Win_Protect, self).__init__(parent)
  14. self.setupUi(self)
  15. self.btn_read_param.clicked.connect(self.on_btn_read_param)
  16. self.btn_write_param.clicked.connect(self.on_btn_write_param)
  17. self.btn_exit_param.clicked.connect(self.on_btn_exit_param)
  18. self.protect_table.itemClicked.connect(self._param_item_clicked)
  19. self.qline_data_set.returnPressed.connect(self._protect_data_changed)
  20. def on_btn_read_param(self):
  21. self.read_param_signal.emit()
  22. def on_btn_write_param(self):
  23. self.write_param_signal.emit()
  24. def on_btn_exit_param(self):
  25. self.exit_param_signal.emit()
  26. def _protect_data_changed(self):
  27. value = (float(self.qline_data_set.text()) - float(self.qline_offset.text()))/float(self.qline_fbl.text())
  28. self.qline_data.setText(str(value))
  29. def _param_item_clicked(self, index):
  30. self.qline_name.setText(self.protect_table.item(index.row(), 0).text())
  31. self.qline_addr.setText(self.protect_table.item(index.row(), 3).text())
  32. self.qline_data_long.setText(self.protect_table.item(index.row(), 5).text())
  33. self.qline_fbl.setText(self.protect_table.item(index.row(), 6).text())
  34. self.qline_offset.setText(self.protect_table.item(index.row(), 7).text())
  35. self.qline_dw.setText(self.protect_table.item(index.row(), 2).text())
  36. self.qline_data.setText(self.protect_table.item(index.row(), 8).text())
  37. self.qline_data_set.setText(self.protect_table.item(index.row(), 1).text())
  38. def set_error(self):
  39. QMessageBox.critical(self, "错误" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Param Error!")
  40. def can_connect_error(self):
  41. QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")