bms_protect.py 2.6 KB

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