bms_hard_ctl.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. from widget.bms_hard import Win_Hard
  4. from utils.globalvar import SD
  5. from utils.qt import QDateTime
  6. class BmsHardControll:
  7. def __init__(self):
  8. self._view = Win_Hard()
  9. self.init()
  10. def init(self):
  11. self._view.rtc_update_signal.connect(self._rtc_time_update)
  12. def _rtc_time_update(self):
  13. text = QDateTime.currentDateTime().toString("yy MM dd HH mm ss")
  14. time_str = text.split(" ")
  15. print(time_str)
  16. # time_list = [bcd_hex(data) for data in time_str]
  17. try:
  18. data = []
  19. if len(data) < 8:
  20. data += (8 - len(data)) * [0]
  21. data[0] = 0x05
  22. data[1] = 0xB0
  23. data[2] = int(time_str[0])
  24. data[3] = int(time_str[1])
  25. data[4] = int(time_str[2])
  26. data[5] = int(time_str[3])
  27. data[6] = int(time_str[4])
  28. data[7] = int(time_str[5])
  29. msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1803, data)
  30. except:
  31. self._view.can_connect_error()