Kaynağa Gözat

1.8版本更新

Franike 6 ay önce
ebeveyn
işleme
96a594ae6a

+ 1 - 0
.gitignore

@@ -14,6 +14,7 @@ __pycache__/
 .Python
 build/
 DataDirectory/
+screen_shot/
 develop-eggs/
 dist/
 downloads/

+ 11 - 32
controller/bms_balance_ctl.py

@@ -16,35 +16,14 @@ class BmsBalanceControll:
         
     def _cell_balance_ctl(self, cmu_id, cell_id, state):
         print(cmu_id, cell_id, state)
-        if (cell_id <= 40):
-            try:
-                data = []
-                if len(data) < 8:
-                    data += (8 - len(data)) * [0]
-                data[0] = 0x02
-                data[1] = 0xC0
-                data[2] = cmu_id
-                data[3] = ((1 if (state > 0) else 0) << (cell_id - 1)) & 0xFF
-                data[4] = (((1 if (state > 0) else 0) << (cell_id - 1)) & 0xFF00) >> 8
-                data[5] = (((1 if (state > 0) else 0) << (cell_id - 1)) & 0xFF0000) >> 16
-                data[6] = (((1 if (state > 0) else 0) << (cell_id - 1)) & 0xFF000000) >> 24
-                data[7] = (((1 if (state > 0) else 0) << (cell_id - 1)) & 0xFF00000000) >> 32
-                msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
-            except:
-                self._view.can_connect_error()
-        else:
-            try:
-                data = []
-                if len(data) < 8:
-                    data += (8 - len(data)) * [0]
-                data[0] = 0x03
-                data[1] = 0xC0
-                data[2] = cmu_id
-                data[3] = ((1 if (state > 0) else 0) << (cell_id - 41)) & 0xFF
-                data[4] = (((1 if (state > 0) else 0) << (cell_id - 41)) & 0xFF00) >> 8
-                data[5] = (((1 if (state > 0) else 0) << (cell_id - 41)) & 0xFF0000) >> 16
-                data[6] = (((1 if (state > 0) else 0) << (cell_id - 41)) & 0xFF000000) >> 24
-                data[7] = (((1 if (state > 0) else 0) << (cell_id - 41)) & 0xFF00000000) >> 32
-                msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
-            except:
-                self._view.can_connect_error()
+        try:
+            data = []
+            if len(data) < 8:
+                data += (8 - len(data)) * [0]
+            data[0] = 0x02
+            data[1] = 0xC0
+            data[2] = cmu_id
+            data[3] = ((1 if (state > 0) else 0) << (cell_id - 1)) & 0xFF
+            msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
+        except:
+            self._view.can_connect_error()

+ 0 - 1
controller/bms_download_ctl.py

@@ -15,7 +15,6 @@ class BmsDownloadControll:
         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)

+ 23 - 5
controller/bms_hard_ctl.py

@@ -22,12 +22,12 @@ class BmsHardControll:
         self._view.cur_cali_signal.connect(self._cur_cali)
         self._view.cell_vol_one_cali_signal.connect(self._cell_one)
         self._view.cell_vol_all_cali_signal.connect(self._cell_all)
-
+        self._view.temp_control_signal.connect(self._temp_ctl)
+        
     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:
@@ -143,10 +143,16 @@ class BmsHardControll:
         except:
             self._view.can_connect_error()
 
-
     def _cell_one(self):
         current_onclick_index = self._view.hard_table.currentRow()
+        if current_onclick_index == -1:
+            self._view.data_error()
+            return    
+        if (self._view.hard_table.item(current_onclick_index, 3).text() == '0') | (self._view.hard_table.item(current_onclick_index, 3).text() == ''):
+            self._view.data_error()
+            return
         try:
+            self._view.set_diff(current_onclick_index)
             data = []
             if len(data) < 8:
                 data += (8 - len(data)) * [0]
@@ -161,7 +167,6 @@ class BmsHardControll:
 
     def _cell_all(self):
         try:
-            # value = float(self._view.edt_cell.text()) * 1000
             data = []
             if len(data) < 8:
                 data += (8 - len(data)) * [0]
@@ -173,3 +178,16 @@ class BmsHardControll:
             msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1803, data)
         except:
             self._view.can_connect_error()
+
+    def _temp_ctl(self, cmu_id, cell_id, state):
+        try:
+            data = []
+            if len(data) < 8:
+                data += (8 - len(data)) * [0]
+            data[0] = 0x05 + int(cell_id/8)
+            data[1] = 0xC0
+            data[2] = cmu_id
+            data[3] = ((1 if (state > 0) else 0) << int(cell_id % 8)) & 0xFF
+            msg = SD.CAN_CONTROL.send((0x18 << 24) | (SD.BCU_ID << 16) | 0x1804, data)
+        except:
+            self._view.can_connect_error()

+ 75 - 43
controller/bms_home_ctl.py

@@ -13,14 +13,16 @@ from controller.bms_set_ctl import BmsSetControll
 from controller.bms_status_ctl import BmsStatusControll
 from model.record_model import RecordModel
 from widget.bms_home import Win_GotionBMS
-from utils.globalvar import SD
 from controller.bms_main_ctl import BmsMainControll
-from utils.qt import QThread, QColor, Qt, QDateTime, QtGui, QtWidgets, QApplication
+from utils.qt import QThread, QColor, Qt, QDateTime, QtGui, QtWidgets, QApplication, QtCore
 from utils.hex_bit import a_bit
+from utils.resource import resource_path
+from utils.globalvar import SD
 from worker.bms_work import BmsReceived
 from ui.own.palette_theme import set_edt_bg
 from ctypes import c_int16
 import csv
+import os
 
 
 class BmsHomeControll:
@@ -33,6 +35,7 @@ class BmsHomeControll:
         self.cell_single_temp = [0 for i in range(360)]
         self.init()
 
+
     def init(self):
         self.bms_main_ctl = BmsMainControll()
         self._view.bms_tab.addWidget(self.bms_main_ctl._view.main)
@@ -72,6 +75,7 @@ class BmsHomeControll:
     def _page_index(self,index):
         self._view.bms_tab.setCurrentIndex(index)
 
+
     def bcu_connect(self):
         try:
             SD.CAN_ON_OFF = SD.CAN_CONTROL.open_device()
@@ -133,6 +137,7 @@ class BmsHomeControll:
         else:
             self._view.can_connect_error()
             
+
     def bcu_disconnect(self):
         if SD.CAN_ON_OFF:
             SD.CAN_ON_OFF = False
@@ -156,9 +161,25 @@ class BmsHomeControll:
 
     def app_cut(self):
         main_window = QApplication.primaryScreen()
-        pixmap = main_window.grabWindow(QtWidgets.QApplication.desktop().winId())
-        pixmap.save("screenshot.png"); 
-        # QtWidgets.QWidget.screen().grabWindow(0).save()
+        rect = QtCore.QRect()
+        rect.setX(self._view.mapToGlobal(QtCore.QPoint(0, 0)).x())
+        rect.setY(self._view.mapToGlobal(QtCore.QPoint(0, 0)).y())
+        rect.setWidth(self._view.width())
+        rect.setHeight(self._view.height())
+        print(rect.x())
+        print(rect.y())
+        print(rect.width())
+        print(rect.height())
+        pixmap = main_window.grabWindow(self._view.winId(), rect.x(), rect.y(), rect.width(), rect.height())
+        # pixmap = pixmap.scaled(QtCore.QSize(rect.width(), rect.height()), Qt.KeepAspectRatio)
+
+        time_str = "/shotcut_" + QDateTime.currentDateTime().toString("yyyy_MM_dd_HH_mm_ss") + '.png'
+        shot_str_path = resource_path("screen_shot")
+        if not os.path.exists(shot_str_path):
+            os.mkdir(shot_str_path)
+        pic_cut_name = shot_str_path + time_str
+        pixmap.save(pic_cut_name); 
+
 
     def _get_master_id(self, data):
         SD.BCU_LIST[data - 1] = 1
@@ -832,6 +853,7 @@ class BmsHomeControll:
             # 当前允许放电限制电压
             self.bms_main_ctl._view.top_widget.lb_max_dchg_vol_value.setText(str(round((data[7] << 8 | data[6]) * 0.1, 1)))
 
+
     def _inf_0008_signal(self, data, id):
         if id == SD.BCU_ID:
             # 电池组单体电压累加和
@@ -860,6 +882,7 @@ class BmsHomeControll:
         item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
         self.bms_double_ccu_ctl._view.on_line_ccu_table.setItem(id - 1, 6, item)    
 
+
     def _inf_000A_signal(self, data, id):
         if id == SD.BCU_ID:
             # 最高单体SOC
@@ -874,6 +897,7 @@ class BmsHomeControll:
             # 循环次数
             self.bms_main_ctl._view.top_widget.lb_circle_num_value.setText(str(data[7] << 8 | data[6]))
 
+
     def _inf_000B_signal(self, data, id):
         if id == SD.BCU_ID:
             # 电池组标称能量
@@ -998,9 +1022,9 @@ class BmsHomeControll:
             #     self.bms_cell_ctl._view.home_cell_table.cellWidget(3, 11).setText(str(round((data[3] << 8 | data[2]) * 0.1 - 40, 1)) + " ℃")
 
             if data[0] < 25: 
-                self.bms_cell_ctl._view.cell_temp_table.cellWidget(3 * data[1], data[0] + 1).setText(str(round((data[3] << 8 | data[2]) * 0.1 - 40, 1)) + " ℃")
-                self.bms_cell_ctl._view.cell_temp_table.cellWidget(3 * data[1] + 1, data[0] + 1).setText(str(round((data[5] << 8 | data[4]) * 0.1 - 40, 1)) + " ℃")
-                self.bms_cell_ctl._view.cell_temp_table.cellWidget(3 * data[1] + 2, data[0] + 1).setText(str(round((data[7] << 8 | data[6]) * 0.1 - 40, 1)) + " ℃")   
+                self.bms_cell_ctl._view.cell_temp_table.cellWidget(3 * data[1], data[0]).setText(str(round((data[3] << 8 | data[2]) * 0.1 - 40, 1)) + " ℃")
+                self.bms_cell_ctl._view.cell_temp_table.cellWidget(3 * data[1] + 1, data[0]).setText(str(round((data[5] << 8 | data[4]) * 0.1 - 40, 1)) + " ℃")
+                self.bms_cell_ctl._view.cell_temp_table.cellWidget(3 * data[1] + 2, data[0]).setText(str(round((data[7] << 8 | data[6]) * 0.1 - 40, 1)) + " ℃")   
 
                 self.cell_single_temp[3 * data[1]] = round((data[3] << 8 | data[2]) * 0.1 - 40, 1)
                 self.cell_single_temp[3 * data[1] + 1] = round((data[5] << 8 | data[4]) * 0.1 - 40, 1)
@@ -1171,45 +1195,45 @@ class BmsHomeControll:
                     set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 1).widget(), QtGui.QColor(Qt.red))
                 else:
                     set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 1).widget(), QtGui.QColor(Qt.white))
-                # if a_bit(data[2], i + 1) == 1:
-                #     set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 9).widget(), QtGui.QColor(Qt.red))
-                # else:
-                #     set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 9).widget(), QtGui.QColor(Qt.white))
-                # if a_bit(data[3], i + 1) == 1:
-                #     set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 17).widget(), QtGui.QColor(Qt.red))
-                # else:
-                #     set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 17).widget(), QtGui.QColor(Qt.white))
-                # if a_bit(data[4], i + 1) == 1:
-                #     set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 25).widget(), QtGui.QColor(Qt.red))
-                # else:
-                #     set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 25).widget(), QtGui.QColor(Qt.white))
+                if a_bit(data[2], i + 1) == 1:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 9).widget(), QtGui.QColor(Qt.red))
+                else:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 9).widget(), QtGui.QColor(Qt.white))
+                if a_bit(data[3], i + 1) == 1:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 17).widget(), QtGui.QColor(Qt.red))
+                else:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 17).widget(), QtGui.QColor(Qt.white))
+                if a_bit(data[4], i + 1) == 1:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 25).widget(), QtGui.QColor(Qt.red))
+                else:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 25).widget(), QtGui.QColor(Qt.white))
 
 
     def _inf_001B_signal(self, data, id):
         if id == SD.BCU_ID:
-            return
-            # # 电池均衡故障
-            # for i in range(8):
-            #     if a_bit(data[1], i + 1) == 1:
-            #         set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 33).widget(), QtGui.QColor(Qt.red))
-            #     else:
-            #         set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 33).widget(), QtGui.QColor(Qt.white))
-            #     if a_bit(data[2], i + 1) == 1:
-            #         set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 41).widget(), QtGui.QColor(Qt.red))
-            #     else:
-            #         set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 41).widget(), QtGui.QColor(Qt.white))
-            #     if a_bit(data[3], i + 1) == 1:
-            #         set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 49).widget(), QtGui.QColor(Qt.red))
-            #     else:
-            #         set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 49).widget(), QtGui.QColor(Qt.white))
-            #     if a_bit(data[4], i + 1) == 1:
-            #         set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 57).widget(), QtGui.QColor(Qt.red))
-            #     else:
-            #         set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 57).widget(), QtGui.QColor(Qt.white))
-            #     if a_bit(data[5], i + 1) == 1:
-            #         set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 65).widget(), QtGui.QColor(Qt.red))
-            #     else:
-            #         set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 65).widget(), QtGui.QColor(Qt.white))
+            # return
+            # 电池均衡故障
+            for i in range(8):
+                if a_bit(data[1], i + 1) == 1:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 33).widget(), QtGui.QColor(Qt.red))
+                else:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 33).widget(), QtGui.QColor(Qt.white))
+                if a_bit(data[2], i + 1) == 1:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 41).widget(), QtGui.QColor(Qt.red))
+                else:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 41).widget(), QtGui.QColor(Qt.white))
+                if a_bit(data[3], i + 1) == 1:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 49).widget(), QtGui.QColor(Qt.red))
+                else:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 49).widget(), QtGui.QColor(Qt.white))
+                if a_bit(data[4], i + 1) == 1:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 57).widget(), QtGui.QColor(Qt.red))
+                else:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 57).widget(), QtGui.QColor(Qt.white))
+                if a_bit(data[5], i + 1) == 1:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 65).widget(), QtGui.QColor(Qt.red))
+                else:
+                    set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 65).widget(), QtGui.QColor(Qt.white))
 
 
     def _inf_001C_signal(self, data, id):
@@ -1298,12 +1322,15 @@ class BmsHomeControll:
             #         set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 65, data[0] + 1).widget(), QtGui.QColor(Qt.white))
 
 
+
     def _inf_001E_signal(self, data, id):
         return  
 
+
     def _inf_001F_signal(self, data, id):
         return
 
+
     def _inf_0020_signal(self, data, id):
         if id == SD.BCU_ID:
             # BMS 电池编码								
@@ -1316,6 +1343,7 @@ class BmsHomeControll:
             self.bms_sn_version[6] = chr(data[6])
             self.bms_sn_version[7] = chr(data[7])
 
+
     def _inf_0021_signal(self, data, id):
         if id == SD.BCU_ID:
             self.bms_sn_version[8] = chr(data[0])
@@ -1330,6 +1358,7 @@ class BmsHomeControll:
             bms_sn_version = ''.join(self.bms_sn_version)
             self.bms_download_ctl._view.message_table.item(4, 2).setText(bms_sn_version)
 
+
     def _inf_0022_signal(self, data, id):
         if id == SD.BCU_ID:
             # BMS 电池编码								
@@ -1342,6 +1371,7 @@ class BmsHomeControll:
             self.battery_sn_version[6] = chr(data[6])
             self.battery_sn_version[7] = chr(data[7])
 
+
     def _inf_0023_signal(self, data, id):
         if id == SD.BCU_ID:
             self.battery_sn_version[8] = chr(data[0])
@@ -1397,6 +1427,7 @@ class BmsHomeControll:
                     writer = csv.writer(csvfile, dialect='excel', lineterminator='\n')
                     writer.writerow(record_data)
 
+
     def _inf_1802_signal(self, data, id):
         if id == SD.BCU_ID:
             addr_index = ((data[1] << 8) | data[0])- 0xA000
@@ -1413,6 +1444,7 @@ class BmsHomeControll:
                 self.bms_protect_ctl._view.protect_table.setItem(addr_index, 1, item)
             except:
                 return
+        
             
     def _inf_1803_signal(self, data, id):
         if id == SD.BCU_ID:

+ 7 - 0
controller/bms_login_ctl.py

@@ -7,6 +7,7 @@ from widget.bms_login import Win_Login
 from controller.bms_home_ctl import BmsHomeControll
 from utils.qt import QApplication
 
+
 class BmsLoginControll:
     def __init__(self):
         # 不需要从命令行输入参数
@@ -14,12 +15,14 @@ class BmsLoginControll:
         self._view = Win_Login()
         self.init()
 
+
     def init(self):
         self._view.login_signal.connect(self._verify_user)
         self._view.cancel_signal.connect(self._login_cancel)
         self._view.home_show_signal.connect(self._show_main)
         self._view.language_signal.connect(self._change_language)
 
+
     def _verify_user(self):
         password = self._view.edt_password.text().strip()
         if self._view.cb_role.currentIndex() == 0:
@@ -45,13 +48,16 @@ class BmsLoginControll:
             else:
                 self._view.on_error()
 
+
     def _show_main(self):
         self.home = BmsHomeControll()
         self.home.run()
 
+
     def _login_cancel(self):
         self._view.close()
 
+
     def _change_language(self, index):
         SD.SYSTEM_LANGUAGE = index
         self._view.setWindowTitle("用户登录" if SD.SYSTEM_LANGUAGE == 0 else "Login")
@@ -73,6 +79,7 @@ class BmsLoginControll:
         self._view.cb_prj.setItemText(0, "户储" if SD.SYSTEM_LANGUAGE == 0 else "Home")
         self._view.cb_prj.setItemText(1, "工商业" if SD.SYSTEM_LANGUAGE == 0 else "Industry")
 
+
     def run(self):
         self._view.show()
         return self._app.exec_()

+ 6 - 0
controller/bms_main_ctl.py

@@ -12,6 +12,7 @@ class BmsMainControll:
         self.i = 0
         self.init()
 
+
     def init(self):
         self._view.up_signal.connect(self.sys_up)
         self._view.down_signal.connect(self.sys_down)
@@ -39,6 +40,7 @@ class BmsMainControll:
         self._view.clear_balance_signal.connect(self.operate12)
         self._view.fan_signal.connect(self.operate13)
 
+
     def sys_up(self):
         try:
             data = []
@@ -118,6 +120,7 @@ class BmsMainControll:
             except:
                 self._view.can_connect_error()
 
+
     def do1(self, do1_status):
         try:
             data = []
@@ -229,6 +232,7 @@ class BmsMainControll:
         except:
             self._view.can_connect_error()
 
+
     def operate1(self, status):
         try:
             data = []
@@ -354,6 +358,7 @@ class BmsMainControll:
         except:
             self._view.can_connect_error()
 
+
     def operate10(self, status):
         try:
             data = []
@@ -395,6 +400,7 @@ class BmsMainControll:
         except:
             self._view.can_connect_error()
 
+
     def operate13(self, status):
         try:
             data = []

+ 2 - 0
controller/bms_protect_ctl.py

@@ -12,6 +12,7 @@ class BmsProtectControll:
         self.i = 0
         self.init()
 
+
     def init(self):
         self._view.read_param_signal.connect(self._read_param)
         self._view.write_param_signal.connect(self._write_param)
@@ -44,6 +45,7 @@ class BmsProtectControll:
         except:
             self._view.can_connect_error()
 
+
     def _write_param(self):
         try:
             value = (decimal.Decimal(self._view.qline_data_set.text()) - decimal.Decimal(self._view.qline_offset.text()))/decimal.Decimal(self._view.qline_fbl.text())

+ 3 - 0
controller/bms_record_ctl.py

@@ -14,10 +14,12 @@ class BmsRecordControll:
         self._model = RecordModel()
         self.init()
 
+
     def init(self):
         self._view.can_record_start_signal.connect(self._save)
         self._view.can_record_stop_signal.connect(self._stop)
         
+
     def _save(self):
         SD.RECORD_NAME, ok = self._view.save_csv()
         if SD.RECORD_NAME == "":
@@ -41,6 +43,7 @@ class BmsRecordControll:
         else:
             return
 
+
     def _stop(self):
         self._view.save_record.setDisabled(False)
         self._view.stop_record.setDisabled(True)

+ 1 - 0
controller/bms_status_ctl.py

@@ -8,5 +8,6 @@ class BmsStatusControll:
     def __init__(self):
         self._view = Win_Bms_Status_Bar()
 
+
     def run(self):
         self._view.show()

+ 1 - 0
model/record_model.py

@@ -8,6 +8,7 @@ class Singleton(object):
             cls._instance = orig.__new__(cls, *args, **kw)
         return cls._instance
 
+
 class RecordModel(Singleton):
     def __init__(self):
         # 时间戳	簇号	故障等级	簇电压	簇电流	簇SOC	簇SOH	

+ 1 - 1
start.py

@@ -13,7 +13,7 @@ def bms_start():
     # 主版本号
     SD.MAJOR_VERSION_NUMBER = 1
     # 子版本号
-    SD.MINOR_VERSION_NUMBER = 7
+    SD.MINOR_VERSION_NUMBER = 8
     # 修正版本号
     SD.REVISION_NUMBER = "0-build_test"
 

+ 4 - 4
ui/balance.py

@@ -203,12 +203,12 @@ class Balance(MyFrame):
             bmu_label.setFixedWidth(50)
             self.balance_control_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
         for i in range(15):
-            for j in range(72):
+            for j in range(8):
                 qbalance_control_widget = QtWidgets.QWidget()
                 qbalance_control_widget_layout = QtWidgets.QHBoxLayout(qbalance_control_widget)
                 qbalance_control_widget_layout.setContentsMargins(5, 5, 5, 5)
                 qbalance_control_widget_layout.setSpacing(0)
-                qbalance_control_lebal = QtWidgets.QLineEdit("C" + str(j + 1))
+                qbalance_control_lebal = QtWidgets.QLineEdit("AFE" + str(j + 1))
                 qbalance_control_lebal.setAlignment(Qt.AlignCenter)
                 qbalance_control_lebal.setReadOnly(True)
                 qbalance_control_lebal.setFixedWidth(50)
@@ -241,8 +241,8 @@ class Balance(MyFrame):
             bmu_label.setFixedWidth(50)
             self.balance_fault_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
         for i in range(15):
-            for j in range(8):
-                qbalance_fault_lebal = QtWidgets.QLineEdit("AFE" + str(j + 1))
+            for j in range(72):
+                qbalance_fault_lebal = QtWidgets.QLineEdit("C" + str(j + 1))
                 qbalance_fault_lebal.setAlignment(Qt.AlignCenter)
                 qbalance_fault_lebal.setReadOnly(True)
                 qbalance_fault_lebal.setFixedWidth(50)

+ 13 - 9
ui/hard.py

@@ -269,25 +269,29 @@ class Hard(MyFrame):
         for i in range(16):
             if i == 0:
                 bmu_label = QtWidgets.QLabel("CMU ID")
-                bmu_label.setAlignment(Qt.AlignCenter)
+                # bmu_label.setAlignment(Qt.AlignCenter)
                 self.temp_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)  
             else:              
                 bmu_label = QtWidgets.QLabel("CMU" + str(i))
-                bmu_label.setAlignment(Qt.AlignCenter)
+                # bmu_label.setAlignment(Qt.AlignCenter)
                 self.temp_qscrollarea_layout.addWidget(bmu_label, i, 0, 1, 1)
         for i in range(16):
             for j in range(72):
                 if i == 0:
-                    bmu_label = QtWidgets.QLabel("T" + str(j + 1))
-                    # bmu_label.setAlignment(Qt.AlignCenter)
+                    bmu_label = QtWidgets.QLineEdit("T" + str(j + 1))
+                    # bmu_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
+                    bmu_label.setReadOnly(True)
+                    bmu_label.setFixedWidth(30)
                     self.temp_qscrollarea_layout.addWidget(bmu_label, i , j + 1, 1, 1)               
                 else:
-                    qtemp_checkbox = QtWidgets.QCheckBox()
-                    # qtemp_lebal.setAlignment(Qt.AlignCenter)
-                    # qtemp_checkbox
+                    qtemp_check_widget = QtWidgets.QWidget()
+                    qtemp_check_widget_layout = QtWidgets.QHBoxLayout(qtemp_check_widget)
+                    qtemp_check_widget_layout.setContentsMargins(5, 5, 5, 5)
+                    qtemp_check_widget_layout.setSpacing(0)
+                    qtemp_checkbox = QtWidgets.QCheckBox(qtemp_check_widget)
                     qtemp_checkbox.setFixedWidth(40)
-                    # qtemp_lebal.setReadOnly(True)
-                    self.temp_qscrollarea_layout.addWidget(qtemp_checkbox, i, j + 1, 1, 1)
+                    qtemp_check_widget_layout.addWidget(qtemp_checkbox)
+                    self.temp_qscrollarea_layout.addWidget(qtemp_check_widget, i, j + 1, 1, 1)
 
         self.hard_right_frame_layout.addWidget(self.temp_groupbox, 5)
         

+ 0 - 1
utils/globalvar.py

@@ -5,7 +5,6 @@
 from utils.can import MessageDeal
 
 class SD:
-
     MAJOR_VERSION_NUMBER = 0
     # 子版本号
     MINOR_VERSION_NUMBER = 0

+ 2 - 2
widget/bms_balance.py

@@ -16,12 +16,12 @@ class Win_Balance(Balance, MyFrame):
         super(Win_Balance, self).__init__(parent)
         self.setupUi(self)
 
-
         for i in range(15):
-            for j in range(72):
+            for j in range(8):
                 # self.balance_control_qscrollarea_layout.itemAtPosition(j + 1, i).widget().layout().itemAt(1).widget().stateChanged.connect(lambda state = self.balance_control_qscrollarea_layout.itemAtPosition(j + 1, i).widget().layout().itemAt(1).widget(), cmu_id = i + 1, cell_id = j + 1: self._balance_ctl(state, cmu_id, cell_id))
                 self.balance_control_qscrollarea_layout.itemAtPosition(i, j + 1).widget().layout().itemAt(1).widget().stateChanged.connect(lambda state = self.balance_control_qscrollarea_layout.itemAtPosition(i, j + 1).widget().layout().itemAt(1).widget(), cmu_id = i + 1, cell_id = j + 1: self._balance_ctl(state, cmu_id, cell_id))    
 
+
     def can_connect_error(self):
         QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")
 

+ 0 - 1
widget/bms_cell.py

@@ -20,7 +20,6 @@ class Win_Cell(Cell, MyFrame):
         super(Win_Cell, self).__init__(parent)
         self.setupUi(self)
         
-        # if SD.CCU_TYPE == 1:
         self.btn_cell_vol.clicked.connect(self._cell_vol)
         self.btn_cell_temp.clicked.connect(self._cell_temp)
         self.btn_jz_temp.clicked.connect(self._jz_temp)

+ 4 - 0
widget/bms_download.py

@@ -19,14 +19,18 @@ class Win_Download(Download, MyFrame):
         self.btn_bms_sn.clicked.connect(self._bms_sn)
         self.btn_battery_sn.clicked.connect(self._battery_sn)
 
+
     def _bms_sn(self):
         self.bms_sn_signal.emit()
 
+
     def _battery_sn(self):
         self.bat_sn_signal.emit()
 
+
     def can_connect_error(self):
         QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")
 
+
     def index_error(self):
         QMessageBox.critical(self, "错误的SN" if SD.SYSTEM_LANGUAGE == 0 else "SN error", "SN不符!" if SD.SYSTEM_LANGUAGE == 0 else "SN not aviable!")

+ 28 - 17
widget/bms_hard.py

@@ -18,6 +18,7 @@ class Win_Hard(Hard, MyFrame):
     cur_cali_signal = Signal()
     cell_vol_one_cali_signal = Signal()
     cell_vol_all_cali_signal = Signal()
+    temp_control_signal = Signal(int, int, int)
 
     def __init__(self, parent=None):
         super(Win_Hard, self).__init__(parent)
@@ -31,47 +32,57 @@ class Win_Hard(Hard, MyFrame):
         self.btn_hand.clicked.connect(self._on_btn_hand)
         self.btn_auto.clicked.connect(self._on_btn_auto)
 
-        for i in range(64):
-                self.hard_table.cellWidget(i, 2).editingFinished.connect(partial(self._set_diff, i))
-       
+        for index in range(64):
+                self.hard_table.cellWidget(index, 2).editingFinished.connect(partial(self.set_diff, index))
+      
+        for i in range(15):
+            for j in range(72):
+                self.temp_qscrollarea_layout.itemAtPosition(i + 1, j + 1).widget().layout().itemAt(0).widget().stateChanged.connect(lambda state = self.temp_qscrollarea_layout.itemAtPosition(i + 1, j + 1).widget().layout().itemAt(0).widget(), cmu_id = i + 1, cell_id = j: self._temp_ctl(state, cmu_id, cell_id))    
+ 
+
     def _rtc_update(self):
          self.rtc_update_signal.emit()
 
+
     def on_btn_read_hard(self):
         self.read_hard_signal.emit()
 
+
     def on_btn_exit_hard(self):
         self.exit_hard_signal.emit()
 
+
     def _on_btn_pack_vol_cali(self):
         self.pack_vol_cali_signal.emit()
 
+
     def _on_btn_cur_cali(self):
         self.cur_cali_signal.emit()
 
+
     def _on_btn_hand(self):
         self.cell_vol_one_cali_signal.emit()
 
+
     def _on_btn_auto(self):
         self.cell_vol_all_cali_signal.emit()
 
-    def _set_diff(self, i):
+
+    def set_diff(self, i):
         try:
-            diff = int(float(self.hard_table.cellWidget(i, 2).text())) - int(self.hard_table.item(i, 3).text())
-            
+            diff = int(float(self.hard_table.cellWidget(i, 2).text())) - int(self.hard_table.item(i, 3).text())  
             self.hard_table.item(i, 4).setText(str(diff))
-            # if int(self.hard_table.item(i, 2).text()) <= int(float(self.hard_table.cellWidget(i, 1).text())) <= int(self.hard_table.item(i, 3).text()):
-            #     return
-            # else:
-            #     QMessageBox.critical(self, "失败" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Invalid value!")
-            #     self.hard_table.cellWidget(i, 1).setText("")
-            #     self.hard_table.cellWidget(i, 1).setFocus()
-            #     return
         except BaseException:
-            # QMessageBox.critical(self, "失败" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Invalid value!")
-            # self.hard_table.cellWidget(i, 1).setText("")
-            # self.hard_table.cellWidget(i, 1).setFocusPolicy(Qt.StrongFocus)
             return
-        
+
+
+    def _temp_ctl(self, state, cmu_id, cell_id):
+        self.temp_control_signal.emit(cmu_id, cell_id, state)     
+
+
     def can_connect_error(self):
         QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")
+
+
+    def data_error(self):
+        QMessageBox.critical(self, "数据状态" if SD.SYSTEM_LANGUAGE == 0 else "Data State", "数据无效!" if SD.SYSTEM_LANGUAGE == 0 else "Data Error!")

+ 18 - 3
widget/bms_home.py

@@ -18,11 +18,11 @@ class Win_GotionBMS(UiBmsHomePage, QMainWindow):
     download_signal = Signal(int)
     set_inf_signal = Signal(int)
     bcu_online_list_signal = Signal(list)
-
     can_start_signal = Signal()
     can_stop_signal = Signal()
     cut_start_signal = Signal()
     
+
     def __init__(self, parent=None):
         super(Win_GotionBMS, self).__init__(parent)
         self.setupUi(self)
@@ -39,55 +39,70 @@ class Win_GotionBMS(UiBmsHomePage, QMainWindow):
         self.btn_start.clicked.connect(self._can_start)
         self.btn_stop.clicked.connect(self._can_stop)
         self.btn_cut.clicked.connect(self._app_cut)
-        
         self.cb_bcu.currentIndexChanged.connect(self._bcu_masterid_set)
         self.cb_bmu.currentIndexChanged.connect(self._bmu_id_set)
     
+
     def can_connect_error(self):
         QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")
 
+
     def _main_control(self):
         self.main_control_signal.emit(0)
     
+
     def _cell_inf(self):
         self.cell_inf_signal.emit(1)
 
+
     def _double_ccu(self):
         self.double_ccu_signal.emit(2)
 
+
     def _protect_inf(self):
         self.protect_inf_signal.emit(3)
 
+
     def _hard_cali(self):
         self.hard_cali_signal.emit(4)
 
+
     def _balance_inf(self):
         self.balance_inf_signal.emit(5)
 
+
     def _data_inf(self):
         self.data_inf_signal.emit(6)
 
+
     def _download(self):
         self.download_signal.emit(7)
 
+
     def _set_inf(self):
         self.set_inf_signal.emit(8)
 
+
     def _can_start(self):
         self.can_start_signal.emit()
 
+
     def _can_stop(self):
         self.can_stop_signal.emit()
 
+
     def _app_cut(self):
         self.cut_start_signal.emit()
-        
+
+
     def _bcu_masterid_set(self):
         SD.BCU_ID = int(self.cb_bcu.currentIndex() +  1)
 
+
     def _bmu_id_set(self):
         int(self.cb_bmu.currentIndex() +  1)
 
+
     def _bcu_connect_get(self, data):
         bcu_on_line = ["BCU1", "BCU2", "BCU3", "BCU4", "BCU5", "BCU6", "BCU7", "BCU8", "BCU9", "BCU10", "BCU11", "BCU12", "BCU13", "BCU14", "BCU15"]
         bcu_on_line_set = []

+ 7 - 0
widget/bms_login.py

@@ -15,26 +15,32 @@ class Win_Login(UiBmsLoginPage, MyFrame):
     home_show_signal = Signal()
     language_signal = Signal(int)
 
+
     def __init__(self, parent=None):
         super(Win_Login, self).__init__(parent)
         self.setupUi(self)
 
+
     @Slot()
     def on_btn_login_clicked(self):
         self.login_signal.emit()
 
+
     @Slot()
     def on_edt_password_returnPressed(self):
         self.login_signal.emit()
 
+
     @Slot()
     def on_btn_cancel_clicked(self):
         self.cancel_signal.emit()
 
+
     @Slot(int)
     def on_language_currentIndexChanged(self, index):
         self.language_signal.emit(index)
 
+
     def on_success(self):
         SD.CCU_TYPE = self.cb_prj.currentIndex()
         self.can_type = self.cb_con_type.currentIndex()
@@ -52,5 +58,6 @@ class Win_Login(UiBmsLoginPage, MyFrame):
         self.home_show_signal.emit()
         self.close()
 
+
     def on_error(self):
         QMessageBox.critical(self, "登录失败" if SD.SYSTEM_LANGUAGE == 0 else "Login Error", "帐号密码错误" if SD.SYSTEM_LANGUAGE == 0 else "UserName or Pwd Error!")

+ 1 - 0
widget/bms_main.py

@@ -36,6 +36,7 @@ class Win_Main(Main, MyFrame):
     clear_balance_signal = Signal(int)
     fan_signal = Signal(int)
 
+
     def __init__(self, parent=None):
         super(Win_Main, self).__init__(parent)
         self.setupUi(self)

+ 7 - 5
widget/bms_protect.py

@@ -25,33 +25,34 @@ class Win_Protect(Protect, MyFrame):
         self.btn_exit_param.clicked.connect(self.on_btn_exit_param)
         self.btn_reset_param.clicked.connect(self.on_btn_reset_param)
         self.protect_table.itemClicked.connect(self._param_item_clicked)
-        # self.qline_data_set.returnPressed.connect(self._protect_data_changed)
 
         self.timer = QTimer()
         self.timer.timeout.connect(self.over_time)
 
+
     def start_timer(self):
         self.timer.start(3000)
     
+
     def end_timer(self):   
         self.timer.stop()
     
+
     def on_btn_read_param(self):
         self.read_param_signal.emit()
 
+
     def on_btn_write_param(self):
         self.write_param_signal.emit()
 
+
     def on_btn_exit_param(self):
         self.exit_param_signal.emit()
 
+
     def on_btn_reset_param(self):
         self.reset_param_signal.emit()
 
-    # def _protect_data_changed(self):
-    #     value = (float(self.qline_data_set.text()) - float(self.qline_offset.text()))/float(self.qline_fbl.text())
-    #     self.qline_data.setText(str(value))
-
 
     def _param_item_clicked(self, index):
         self.qline_name.setText(self.protect_table.item(index.row(), 0).text())
@@ -67,6 +68,7 @@ class Win_Protect(Protect, MyFrame):
     def set_error(self):
         QMessageBox.critical(self, "错误" if SD.SYSTEM_LANGUAGE == 0 else "Error", "参数无效!" if SD.SYSTEM_LANGUAGE == 0 else "Param Error!")
 
+
     def can_connect_error(self):
         QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")
 

+ 3 - 0
widget/bms_record.py

@@ -19,11 +19,14 @@ class Win_Record(Record, MyFrame):
         self.save_record.clicked.connect(self._start)
         self.stop_record.clicked.connect(self._stop)
 
+
     def _start(self):
         self.can_record_start_signal.emit()
 
+
     def _stop(self):
         self.can_record_stop_signal.emit()
 
+
     def save_csv(self):
         return QFileDialog.getSaveFileName(self, "保存文件" if SD.SYSTEM_LANGUAGE == 0 else "Save File", SD.FILE_PATH, 'CSV(*.csv)')

+ 9 - 0
widget/bms_status_bar.py

@@ -19,30 +19,39 @@ class Win_Bms_Status_Bar(UiStatusBar, MyFrame):
         self.timer.start(1000)
         self._show_local_data_time()
 
+
     def _show_local_data_time(self):
         text = QDateTime.currentDateTime().toString("yyyy-MM-dd HH:mm:ss")
         self.lb_local_time.setText(text)
 
+
     def bms_error(self):
         QMessageBox.warning(self, "警告" if SD.SYSTEM_LANGUAGE == 0 else "Warning", "请连接BMS!" if SD.SYSTEM_LANGUAGE == 0 else "No BMS!")
 
+
     def h86_error(self):
         QMessageBox.critical(self, "错误" if SD.SYSTEM_LANGUAGE == 0 else "Error", "不是标准的h86文件!" if SD.SYSTEM_LANGUAGE == 0 else "H86 Error!")
 
+
     def hex_error(self):
         QMessageBox.critical(self, "错误" if SD.SYSTEM_LANGUAGE == 0 else "Error", "不是标准的hex文件!" if SD.SYSTEM_LANGUAGE == 0 else "Hex Error!")
 
+
     def s19_error(self):
         QMessageBox.critical(self, "错误" if SD.SYSTEM_LANGUAGE == 0 else "Error", "不是标准的s19文件!" if SD.SYSTEM_LANGUAGE == 0 else "S19 Error!")
 
+
     def bmu_can_file(self):
         return QFileDialog.getOpenFileName(self, "选取文件" if SD.SYSTEM_LANGUAGE == 0 else "Chose File", SD.FILE_PATH, "Text Files (*.hex)")
 
+
     def ccu_can_file(self):
         return QFileDialog.getOpenFileName(self, "选取文件" if SD.SYSTEM_LANGUAGE == 0 else "Chose File", SD.FILE_PATH, "Text Files (*.h86 , *.hex , *.s19)")
 
+
     def bams_can_file(self):
         return QFileDialog.getOpenFileName(self, "选取文件" if SD.SYSTEM_LANGUAGE == 0 else "Chose File", SD.FILE_PATH, "Text Files (*.hex)")
 
+
     def bams_net_file(self):
         return QFileDialog.getOpenFileName(self, "选取文件" if SD.SYSTEM_LANGUAGE == 0 else "Chose File", SD.FILE_PATH, "Text Files (*.bin)")