#!/usr/bin/env python # -*- encoding: utf-8 -*- from widget.bms_hard import Win_Hard from utils.globalvar import SD from utils.qt import QDateTime class BmsHardControll: def __init__(self): self._view = Win_Hard() self.init() def init(self): self._view.rtc_update_signal.connect(self._rtc_time_update) def _rtc_time_update(self): text = QDateTime.currentDateTime().toString("yy MM dd HH mm ss") time_str = text.split(" ") print(time_str) # time_list = [bcd_hex(data) for data in time_str] try: data = [] if len(data) < 8: data += (8 - len(data)) * [0] data[0] = 0x05 data[1] = 0xB0 data[2] = int(time_str[0]) data[3] = int(time_str[1]) data[4] = int(time_str[2]) data[5] = int(time_str[3]) data[6] = int(time_str[4]) data[7] = int(time_str[5]) msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1803, data) except: self._view.can_connect_error()