|
@@ -13,14 +13,16 @@ from controller.bms_set_ctl import BmsSetControll
|
|
from controller.bms_status_ctl import BmsStatusControll
|
|
from controller.bms_status_ctl import BmsStatusControll
|
|
from model.record_model import RecordModel
|
|
from model.record_model import RecordModel
|
|
from widget.bms_home import Win_GotionBMS
|
|
from widget.bms_home import Win_GotionBMS
|
|
-from utils.globalvar import SD
|
|
|
|
from controller.bms_main_ctl import BmsMainControll
|
|
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.hex_bit import a_bit
|
|
|
|
+from utils.resource import resource_path
|
|
|
|
+from utils.globalvar import SD
|
|
from worker.bms_work import BmsReceived
|
|
from worker.bms_work import BmsReceived
|
|
from ui.own.palette_theme import set_edt_bg
|
|
from ui.own.palette_theme import set_edt_bg
|
|
from ctypes import c_int16
|
|
from ctypes import c_int16
|
|
import csv
|
|
import csv
|
|
|
|
+import os
|
|
|
|
|
|
|
|
|
|
class BmsHomeControll:
|
|
class BmsHomeControll:
|
|
@@ -33,6 +35,7 @@ class BmsHomeControll:
|
|
self.cell_single_temp = [0 for i in range(360)]
|
|
self.cell_single_temp = [0 for i in range(360)]
|
|
self.init()
|
|
self.init()
|
|
|
|
|
|
|
|
+
|
|
def init(self):
|
|
def init(self):
|
|
self.bms_main_ctl = BmsMainControll()
|
|
self.bms_main_ctl = BmsMainControll()
|
|
self._view.bms_tab.addWidget(self.bms_main_ctl._view.main)
|
|
self._view.bms_tab.addWidget(self.bms_main_ctl._view.main)
|
|
@@ -72,6 +75,7 @@ class BmsHomeControll:
|
|
def _page_index(self,index):
|
|
def _page_index(self,index):
|
|
self._view.bms_tab.setCurrentIndex(index)
|
|
self._view.bms_tab.setCurrentIndex(index)
|
|
|
|
|
|
|
|
+
|
|
def bcu_connect(self):
|
|
def bcu_connect(self):
|
|
try:
|
|
try:
|
|
SD.CAN_ON_OFF = SD.CAN_CONTROL.open_device()
|
|
SD.CAN_ON_OFF = SD.CAN_CONTROL.open_device()
|
|
@@ -133,6 +137,7 @@ class BmsHomeControll:
|
|
else:
|
|
else:
|
|
self._view.can_connect_error()
|
|
self._view.can_connect_error()
|
|
|
|
|
|
|
|
+
|
|
def bcu_disconnect(self):
|
|
def bcu_disconnect(self):
|
|
if SD.CAN_ON_OFF:
|
|
if SD.CAN_ON_OFF:
|
|
SD.CAN_ON_OFF = False
|
|
SD.CAN_ON_OFF = False
|
|
@@ -156,9 +161,25 @@ class BmsHomeControll:
|
|
|
|
|
|
def app_cut(self):
|
|
def app_cut(self):
|
|
main_window = QApplication.primaryScreen()
|
|
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):
|
|
def _get_master_id(self, data):
|
|
SD.BCU_LIST[data - 1] = 1
|
|
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)))
|
|
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):
|
|
def _inf_0008_signal(self, data, id):
|
|
if id == SD.BCU_ID:
|
|
if id == SD.BCU_ID:
|
|
# 电池组单体电压累加和
|
|
# 电池组单体电压累加和
|
|
@@ -860,6 +882,7 @@ class BmsHomeControll:
|
|
item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
|
|
item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
|
|
self.bms_double_ccu_ctl._view.on_line_ccu_table.setItem(id - 1, 6, item)
|
|
self.bms_double_ccu_ctl._view.on_line_ccu_table.setItem(id - 1, 6, item)
|
|
|
|
|
|
|
|
+
|
|
def _inf_000A_signal(self, data, id):
|
|
def _inf_000A_signal(self, data, id):
|
|
if id == SD.BCU_ID:
|
|
if id == SD.BCU_ID:
|
|
# 最高单体SOC
|
|
# 最高单体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]))
|
|
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):
|
|
def _inf_000B_signal(self, data, id):
|
|
if id == SD.BCU_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)) + " ℃")
|
|
# 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:
|
|
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]] = 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)
|
|
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))
|
|
set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 1).widget(), QtGui.QColor(Qt.red))
|
|
else:
|
|
else:
|
|
set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 1).widget(), QtGui.QColor(Qt.white))
|
|
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):
|
|
def _inf_001B_signal(self, data, id):
|
|
if id == SD.BCU_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):
|
|
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))
|
|
# 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):
|
|
def _inf_001E_signal(self, data, id):
|
|
return
|
|
return
|
|
|
|
|
|
|
|
+
|
|
def _inf_001F_signal(self, data, id):
|
|
def _inf_001F_signal(self, data, id):
|
|
return
|
|
return
|
|
|
|
|
|
|
|
+
|
|
def _inf_0020_signal(self, data, id):
|
|
def _inf_0020_signal(self, data, id):
|
|
if id == SD.BCU_ID:
|
|
if id == SD.BCU_ID:
|
|
# BMS 电池编码
|
|
# BMS 电池编码
|
|
@@ -1316,6 +1343,7 @@ class BmsHomeControll:
|
|
self.bms_sn_version[6] = chr(data[6])
|
|
self.bms_sn_version[6] = chr(data[6])
|
|
self.bms_sn_version[7] = chr(data[7])
|
|
self.bms_sn_version[7] = chr(data[7])
|
|
|
|
|
|
|
|
+
|
|
def _inf_0021_signal(self, data, id):
|
|
def _inf_0021_signal(self, data, id):
|
|
if id == SD.BCU_ID:
|
|
if id == SD.BCU_ID:
|
|
self.bms_sn_version[8] = chr(data[0])
|
|
self.bms_sn_version[8] = chr(data[0])
|
|
@@ -1330,6 +1358,7 @@ class BmsHomeControll:
|
|
bms_sn_version = ''.join(self.bms_sn_version)
|
|
bms_sn_version = ''.join(self.bms_sn_version)
|
|
self.bms_download_ctl._view.message_table.item(4, 2).setText(bms_sn_version)
|
|
self.bms_download_ctl._view.message_table.item(4, 2).setText(bms_sn_version)
|
|
|
|
|
|
|
|
+
|
|
def _inf_0022_signal(self, data, id):
|
|
def _inf_0022_signal(self, data, id):
|
|
if id == SD.BCU_ID:
|
|
if id == SD.BCU_ID:
|
|
# BMS 电池编码
|
|
# BMS 电池编码
|
|
@@ -1342,6 +1371,7 @@ class BmsHomeControll:
|
|
self.battery_sn_version[6] = chr(data[6])
|
|
self.battery_sn_version[6] = chr(data[6])
|
|
self.battery_sn_version[7] = chr(data[7])
|
|
self.battery_sn_version[7] = chr(data[7])
|
|
|
|
|
|
|
|
+
|
|
def _inf_0023_signal(self, data, id):
|
|
def _inf_0023_signal(self, data, id):
|
|
if id == SD.BCU_ID:
|
|
if id == SD.BCU_ID:
|
|
self.battery_sn_version[8] = chr(data[0])
|
|
self.battery_sn_version[8] = chr(data[0])
|
|
@@ -1397,6 +1427,7 @@ class BmsHomeControll:
|
|
writer = csv.writer(csvfile, dialect='excel', lineterminator='\n')
|
|
writer = csv.writer(csvfile, dialect='excel', lineterminator='\n')
|
|
writer.writerow(record_data)
|
|
writer.writerow(record_data)
|
|
|
|
|
|
|
|
+
|
|
def _inf_1802_signal(self, data, id):
|
|
def _inf_1802_signal(self, data, id):
|
|
if id == SD.BCU_ID:
|
|
if id == SD.BCU_ID:
|
|
addr_index = ((data[1] << 8) | data[0])- 0xA000
|
|
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)
|
|
self.bms_protect_ctl._view.protect_table.setItem(addr_index, 1, item)
|
|
except:
|
|
except:
|
|
return
|
|
return
|
|
|
|
+
|
|
|
|
|
|
def _inf_1803_signal(self, data, id):
|
|
def _inf_1803_signal(self, data, id):
|
|
if id == SD.BCU_ID:
|
|
if id == SD.BCU_ID:
|