1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- from ui.hard import Hard
- from ui.own.frame_theme import MyFrame
- from utils.globalvar import SD
- from utils.qt import QMessageBox, Signal
- from functools import partial
- class Win_Hard(Hard, MyFrame):
- rtc_update_signal = Signal()
- read_hard_signal = Signal()
- write_param_signal = Signal()
- exit_hard_signal = Signal()
- pack_vol_cali_signal = Signal()
- cur_cali_signal = Signal()
- cell_vol_one_cali_signal = Signal()
- cell_vol_all_cali_signal = Signal()
- def __init__(self, parent=None):
- super(Win_Hard, self).__init__(parent)
- self.setupUi(self)
- self.btn_rtc.clicked.connect(self._rtc_update)
- self.btn_read_hard_param.clicked.connect(self.on_btn_read_hard)
- self.btn_exit_hard_param.clicked.connect(self.on_btn_exit_hard)
- self.btn_pack_vol_cali.clicked.connect(self._on_btn_pack_vol_cali)
- self.btn_cur_cali.clicked.connect(self._on_btn_cur_cali)
- self.btn_hand.clicked.connect(self._on_btn_hand)
- self.btn_auto.clicked.connect(self._on_btn_auto)
- for i in range(64):
- self.hard_table.cellWidget(i, 2).editingFinished.connect(partial(self._set_diff, i))
-
- def _rtc_update(self):
- self.rtc_update_signal.emit()
- def on_btn_read_hard(self):
- self.read_hard_signal.emit()
- def on_btn_exit_hard(self):
- self.exit_hard_signal.emit()
- def _on_btn_pack_vol_cali(self):
- self.pack_vol_cali_signal.emit()
- def _on_btn_cur_cali(self):
- self.cur_cali_signal.emit()
- def _on_btn_hand(self):
- self.cell_vol_one_cali_signal.emit()
- def _on_btn_auto(self):
- self.cell_vol_all_cali_signal.emit()
- def _set_diff(self, i):
- try:
- diff = int(float(self.hard_table.cellWidget(i, 2).text())) - int(self.hard_table.item(i, 3).text())
-
- self.hard_table.item(i, 4).setText(str(diff))
- # 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()):
- # return
- # else:
- # QMessageBox.critical(self, "失败" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Invalid value!")
- # self.hard_table.cellWidget(i, 1).setText("")
- # self.hard_table.cellWidget(i, 1).setFocus()
- # return
- except BaseException:
- # QMessageBox.critical(self, "失败" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Invalid value!")
- # self.hard_table.cellWidget(i, 1).setText("")
- # self.hard_table.cellWidget(i, 1).setFocusPolicy(Qt.StrongFocus)
- return
-
- def can_connect_error(self):
- QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")
|