bms_hard_ctl.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. dataTime = QDateTime.currentDateTime()
  14. text = dataTime.toString("yy MM dd HH mm ss")
  15. time_str = text.split(" ")
  16. print(time_str)
  17. # time_list = [bcd_hex(data) for data in time_str]
  18. try:
  19. data = []
  20. if len(data) < 8:
  21. data += (8 - len(data)) * [0]
  22. data[0] = 0x05
  23. data[1] = 0xB0
  24. data[2] = int(time_str[0])
  25. data[3] = int(time_str[1])
  26. data[4] = int(time_str[2])
  27. data[5] = int(time_str[3])
  28. data[6] = int(time_str[4])
  29. data[7] = int(time_str[5])
  30. msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1803, data)
  31. except:
  32. self._view.can_connect_error()