123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- from widget.bms_main import Win_Main
- from utils.globalvar import SD
- from utils.qt import Qt
- class BmsMainControll:
- def __init__(self):
- self._view = Win_Main()
- self.i = 0
- self.init()
- def init(self):
- self._view.up_signal.connect(self.sys_up)
- self._view.down_signal.connect(self.sys_down)
- self._view.controll_signal.connect(self.sys_controller)
- self._view.do1_signal.connect(self.do1)
- self._view.do2_signal.connect(self.do2)
- self._view.do3_signal.connect(self.do3)
- self._view.do4_signal.connect(self.do4)
- self._view.do5_signal.connect(self.do5)
- self._view.do6_signal.connect(self.do6)
- self._view.do7_signal.connect(self.do7)
- self._view.do8_signal.connect(self.do8)
-
- self._view.fault_release_signal.connect(self.operate1)
- self._view.jy_signal.connect(self.operate2)
- self._view.jy_one_signal.connect(self.operate3)
- self._view.dchg_mos_signal.connect(self.operate4)
- self._view.chg_mos_signal.connect(self.operate5)
- self._view.pre_mos_signal.connect(self.operate6)
- self._view.gjd1_signal.connect(self.operate7)
- self._view.gjd2_signal.connect(self.operate8)
- self._view.chg_signal.connect(self.operate9)
- self._view.sleep_signal.connect(self.operate10)
- self._view.reset_signal.connect(self.operate11)
- self._view.clear_balance_signal.connect(self.operate12)
- self._view.fan_signal.connect(self.operate13)
- def sys_up(self):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0xFF
- data[1] = 0xFF
- data[2] = 0xAA
- data[6] = self.i
- self.i = self.i + 1
- if self.i == 255:
- self.i = 0
- data[7] = data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6]
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1801, data)
- except:
- self._view.can_connect_error()
- def sys_down(self):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0xFF
- data[1] = 0xFF
- data[2] = 0xBB
- data[6] = self.i
- self.i = self.i + 1
- if self.i == 255:
- self.i = 0
- data[7] = data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6]
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1801, data)
- except:
- self._view.can_connect_error()
- def sys_controller(self, check_status):
- if check_status:
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0xFF
- data[1] = 0xFF
- data[2] = 0xAA
- data[6] = self.i
- self.i = self.i + 1
- if self.i == 255:
- self.i = 0
- data[7] = data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6]
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1801, data)
- data[0] = 4
- data[1] = 0xFF
- data[2] = 0
- data[6] = self.i
- self.i = self.i + 1
- if self.i == 255:
- self.i = 0
- data[7] = data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6]
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1801, data)
- except:
- self._view.can_connect_error()
- else:
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 5
- data[1] = 0xFF
- data[2] = 0
- data[6] = self.i
- self.i = self.i + 1
- if self.i == 255:
- self.i = 0
- data[7] = data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6]
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1801, data)
- except:
- self._view.can_connect_error()
- def do1(self, do1_status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x01
- data[1] = 0xC0
- data[2] = (do1_status >> 1) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def do2(self, do2_status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x01
- data[1] = 0xC0
- data[2] = do2_status & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def do3(self, do3_status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x01
- data[1] = 0xC0
- data[2] = (do3_status << 1) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def do4(self, do4_status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x01
- data[1] = 0xC0
- data[2] = (do4_status << 2) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def do5(self, do5_status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x01
- data[1] = 0xC0
- data[2] = (do5_status << 3) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def do6(self, do6_status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x01
- data[1] = 0xC0
- data[2] = (do6_status << 4) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def do7(self, do7_status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x01
- data[1] = 0xC0
- data[2] = (do7_status << 5) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def do8(self, do8_status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x01
- data[1] = 0xC0
- data[2] = (do8_status << 6) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate1(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = (status >> 1) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate2(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = (status) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate3(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = (status << 1) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate4(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = (status << 2) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate5(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = (status << 3) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate6(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = (status << 4) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate7(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = (status << 5) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate8(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = (status << 6) & 0xFF
- data[3] = 0
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate9(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = 0
- data[3] = (status >> 1) & 0xFF
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate10(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = 0
- data[3] = (status) & 0xFF
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate11(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = 0
- data[3] = (status << 1) & 0xFF
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate12(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = 0
- data[3] = (status << 2) & 0xFF
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
- def operate13(self, status):
- try:
- data = []
- if len(data) < 8:
- data += (8 - len(data)) * [0]
- data[0] = 0x00
- data[1] = 0xC0
- data[2] = 0
- data[3] = (status << 4) & 0xFF
- msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
- except:
- self._view.can_connect_error()
|