bms_protect.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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, QTimer
  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. self.timer = QTimer()
  23. self.timer.timeout.connect(self.over_time)
  24. def start_timer(self):
  25. self.timer.start(3000)
  26. def end_timer(self):
  27. self.timer.stop()
  28. def on_btn_read_param(self):
  29. self.read_param_signal.emit()
  30. def on_btn_write_param(self):
  31. self.write_param_signal.emit()
  32. def on_btn_exit_param(self):
  33. self.exit_param_signal.emit()
  34. def on_btn_reset_param(self):
  35. self.reset_param_signal.emit()
  36. # def _protect_data_changed(self):
  37. # value = (float(self.qline_data_set.text()) - float(self.qline_offset.text()))/float(self.qline_fbl.text())
  38. # self.qline_data.setText(str(value))
  39. def _param_item_clicked(self, index):
  40. self.qline_name.setText(self.protect_table.item(index.row(), 0).text())
  41. self.qline_addr.setText(self.protect_table.item(index.row(), 3).text())
  42. self.qline_data_long.setText(self.protect_table.item(index.row(), 5).text())
  43. self.qline_fbl.setText(self.protect_table.item(index.row(), 6).text())
  44. self.qline_offset.setText(self.protect_table.item(index.row(), 7).text())
  45. self.qline_dw.setText(self.protect_table.item(index.row(), 2).text())
  46. self.qline_data.setText(self.protect_table.item(index.row(), 8).text())
  47. self.qline_data_set.setText(self.protect_table.item(index.row(), 1).text())
  48. def set_error(self):
  49. QMessageBox.critical(self, "错误" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Param Error!")
  50. def can_connect_error(self):
  51. QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")
  52. def over_time(self):
  53. self.timer.stop()
  54. QMessageBox.critical(self, "错误" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数设置超时!" if SD.SYSTEM_LANGUAGE == 0 else "Param Set OverTime!")