123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- from widget.bms_download import Win_Download
- from utils.globalvar import SD
- class BmsDownloadControll:
- def __init__(self):
- self._view = Win_Download()
- self.init()
- def init(self):
- self._view.bms_sn_signal.connect(self._bms_sn_set)
- self._view.bat_sn_signal.connect(self._bat_sn_set)
-
- def _bms_sn_set(self):
- bms_sn_str = self._view.edt_bms_sn.text()
- bms_sn_list = list(bms_sn_str)
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xB2
- data[2] = ord(bms_sn_list[0])
- data[3] = ord(bms_sn_list[1])
- data[4] = ord(bms_sn_list[2])
- data[5] = ord(bms_sn_list[3])
- data[6] = ord(bms_sn_list[4])
- data[7] = ord(bms_sn_list[5])
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1803, data)
-
- data[0] = 0x01
- data[1] = 0xB2
- data[2] = ord(bms_sn_list[6])
- data[3] = ord(bms_sn_list[7])
- data[4] = ord(bms_sn_list[8])
- data[5] = ord(bms_sn_list[9])
- data[6] = ord(bms_sn_list[10])
- data[7] = ord(bms_sn_list[11])
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1803, data)
- data[0] = 0x02
- data[1] = 0xB2
- data[2] = ord(bms_sn_list[12])
- data[3] = ord(bms_sn_list[13])
- data[4] = ord(bms_sn_list[14])
- data[5] = ord(bms_sn_list[15])
- data[6] = 0xFF
- data[7] = 0xFF
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1803, data)
- except IndexError:
- self._view.index_error()
- except:
- self._view.can_connect_error()
- def _bat_sn_set(self):
- bat_sn_str = self._view.edt_battery_sn.text()
- bat_sn_list = list(bat_sn_str)
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x03
- data[1] = 0xB2
- data[2] = ord(bat_sn_list[0])
- data[3] = ord(bat_sn_list[1])
- data[4] = ord(bat_sn_list[2])
- data[5] = ord(bat_sn_list[3])
- data[6] = ord(bat_sn_list[4])
- data[7] = ord(bat_sn_list[5])
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1803, data)
-
- data[0] = 0x04
- data[1] = 0xB2
- data[2] = ord(bat_sn_list[6])
- data[3] = ord(bat_sn_list[7])
- data[4] = ord(bat_sn_list[8])
- data[5] = ord(bat_sn_list[9])
- data[6] = ord(bat_sn_list[10])
- data[7] = ord(bat_sn_list[11])
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1803, data)
- data[0] = 0x05
- data[1] = 0xB2
- data[2] = ord(bat_sn_list[12])
- data[3] = ord(bat_sn_list[13])
- data[4] = ord(bat_sn_list[14])
- data[5] = ord(bat_sn_list[15])
- data[6] = 0xFF
- data[7] = 0xFF
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1803, data)
- except IndexError:
- self._view.index_error()
- except:
- self._view.can_connect_error()
|