bms_home_ctl.py 73 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. '''
  4. @文件 :bms_home_ctl.py
  5. @时间 :2022/02/21 16:56:26
  6. @作者 :None
  7. @版本 :1.0
  8. @说明 :主页面 CTL
  9. '''
  10. from controller.bms_cell_ctl import BmsCellControll
  11. from controller.bms_double_ccu_ctl import BmsDoubleCcuControll
  12. from controller.bms_protect_ctl import BmsProtectControll
  13. from controller.bms_hard_ctl import BmsHardControll
  14. from controller.bms_balance_ctl import BmsBalanceControll
  15. from controller.bms_record_ctl import BmsRecordControll
  16. from controller.bms_download_ctl import BmsDownloadControll
  17. from controller.bms_set_ctl import BmsSetControll
  18. from controller.bms_status_ctl import BmsStatusControll
  19. from model.record_model import RecordModel
  20. from widget.bms_home import Win_GotionBMS
  21. from utils.globalvar import SD
  22. from controller.bms_main_ctl import BmsMainControll
  23. from utils.qt import QTimer, QThread, QColor, Qt, QDateTime, QtGui, QtWidgets, QPixmap,QApplication
  24. from utils.hex_bit import a_bit
  25. from worker.bms_work import BmsSend, BmsReceived
  26. from ui.own.palette_theme import set_edt_bg
  27. class BmsHomeControll:
  28. def __init__(self):
  29. self._view = Win_GotionBMS()
  30. self._model = RecordModel()
  31. self.bms_sn_version = ["" for i in range(16)]
  32. self.battery_sn_version = ["" for i in range(16)]
  33. self.cell_single_volt = [0 for i in range(396)]
  34. self.cell_single_temp = [0 for i in range(360)]
  35. self.init()
  36. def init(self):
  37. self.bms_main_ctl = BmsMainControll()
  38. self._view.bms_tab.addWidget(self.bms_main_ctl._view.main)
  39. self.bms_cell_ctl = BmsCellControll()
  40. self._view.bms_tab.addWidget(self.bms_cell_ctl._view.cell)
  41. self.bms_double_ccu_ctl = BmsDoubleCcuControll()
  42. self._view.bms_tab.addWidget(self.bms_double_ccu_ctl._view.double_ccu)
  43. self.bms_protect_ctl = BmsProtectControll()
  44. self._view.bms_tab.addWidget(self.bms_protect_ctl._view.protect)
  45. self.bms_hard_ctl = BmsHardControll()
  46. self._view.bms_tab.addWidget(self.bms_hard_ctl._view.hard)
  47. self.bms_balance_ctl = BmsBalanceControll()
  48. self._view.bms_tab.addWidget(self.bms_balance_ctl._view.balance)
  49. self.bms_record_ctl = BmsRecordControll()
  50. self._view.bms_tab.addWidget(self.bms_record_ctl._view.record)
  51. self.bms_download_ctl = BmsDownloadControll()
  52. self._view.bms_tab.addWidget(self.bms_download_ctl._view.download)
  53. self.bms_set_ctl = BmsSetControll()
  54. self._view.bms_tab.addWidget(self.bms_set_ctl._view.set)
  55. self.bms_status = BmsStatusControll()
  56. self._view.setStatusBar(self.bms_status._view.statusbar)
  57. self._view.main_control_signal.connect(self._page_index)
  58. self._view.cell_inf_signal.connect(self._page_index)
  59. self._view.double_ccu_signal.connect(self._page_index)
  60. self._view.protect_inf_signal.connect(self._page_index)
  61. self._view.hard_cali_signal.connect(self._page_index)
  62. self._view.balance_inf_signal.connect(self._page_index)
  63. self._view.data_inf_signal.connect(self._page_index)
  64. self._view.download_signal.connect(self._page_index)
  65. self._view.set_inf_signal.connect(self._page_index)
  66. self._view.can_start_signal.connect(self.bcu_connect)
  67. self._view.can_stop_signal.connect(self.bcu_disconnect)
  68. self._view.cut_start_signal.connect(self.app_cut)
  69. self._view.bcu_online_list_signal.connect(self._view._bcu_connect_get)
  70. def _page_index(self,index):
  71. self._view.bms_tab.setCurrentIndex(index)
  72. def bcu_connect(self):
  73. try:
  74. SD.CAN_ON_OFF = SD.CAN_CONTROL.open_device()
  75. except:
  76. SD.CAN_ON_OFF = 0
  77. if SD.CAN_ON_OFF:
  78. self.bms_status._view.label_bms_connect.setText("通讯已连接" if SD.SYSTEM_LANGUAGE == 0 else "BMS Connected")
  79. SD.START_RUN = True
  80. # CAN数据发送类
  81. # self.bms_send_thread = QThread()
  82. # self.bms_send = BmsSend()
  83. # self.bms_send.moveToThread(self.bms_send_thread)
  84. # self.bms_send_thread.started.connect(self.bms_send.send)
  85. # CAN数据接收类
  86. self.bms_received_thread = QThread()
  87. self.bms_received = BmsReceived()
  88. self.bms_received.moveToThread(self.bms_received_thread)
  89. self.bms_received_thread.started.connect(self.bms_received.received)
  90. # 启动线程
  91. # self.bms_send_thread.start()
  92. self.bms_received_thread.start()
  93. self.bms_received.to_show_masterid_signal.connect(self._get_master_id)
  94. self.bms_received.to_show_0000_signal.connect(self._inf_0000_signal)
  95. self.bms_received.to_show_0001_signal.connect(self._inf_0001_signal)
  96. self.bms_received.to_show_0002_signal.connect(self._inf_0002_signal)
  97. self.bms_received.to_show_0003_signal.connect(self._inf_0003_signal)
  98. self.bms_received.to_show_0004_signal.connect(self._inf_0004_signal)
  99. self.bms_received.to_show_0005_signal.connect(self._inf_0005_signal)
  100. self.bms_received.to_show_0006_signal.connect(self._inf_0006_signal)
  101. self.bms_received.to_show_0007_signal.connect(self._inf_0007_signal)
  102. self.bms_received.to_show_0008_signal.connect(self._inf_0008_signal)
  103. self.bms_received.to_show_0009_signal.connect(self._inf_0009_signal)
  104. self.bms_received.to_show_000A_signal.connect(self._inf_000A_signal)
  105. self.bms_received.to_show_000B_signal.connect(self._inf_000B_signal)
  106. self.bms_received.to_show_000C_signal.connect(self._inf_000C_signal)
  107. self.bms_received.to_show_000D_signal.connect(self._inf_000D_signal)
  108. self.bms_received.to_show_000E_signal.connect(self._inf_000E_signal)
  109. self.bms_received.to_show_000F_signal.connect(self._inf_000F_signal)
  110. self.bms_received.to_show_0010_signal.connect(self._inf_0010_signal)
  111. self.bms_received.to_show_0011_signal.connect(self._inf_0011_signal)
  112. self.bms_received.to_show_0012_signal.connect(self._inf_0012_signal)
  113. self.bms_received.to_show_0013_signal.connect(self._inf_0013_signal)
  114. self.bms_received.to_show_0014_signal.connect(self._inf_0014_signal)
  115. self.bms_received.to_show_0015_signal.connect(self._inf_0015_signal)
  116. self.bms_received.to_show_0016_signal.connect(self._inf_0016_signal)
  117. self.bms_received.to_show_0017_signal.connect(self._inf_0017_signal)
  118. self.bms_received.to_show_0018_signal.connect(self._inf_0018_signal)
  119. self.bms_received.to_show_0019_signal.connect(self._inf_0019_signal)
  120. self.bms_received.to_show_001A_signal.connect(self._inf_001A_signal)
  121. self.bms_received.to_show_001B_signal.connect(self._inf_001B_signal)
  122. self.bms_received.to_show_001C_signal.connect(self._inf_001C_signal)
  123. self.bms_received.to_show_001D_signal.connect(self._inf_001D_signal)
  124. self.bms_received.to_show_001E_signal.connect(self._inf_001E_signal)
  125. self.bms_received.to_show_001F_signal.connect(self._inf_001F_signal)
  126. self.bms_received.to_show_0020_signal.connect(self._inf_0020_signal)
  127. self.bms_received.to_show_0021_signal.connect(self._inf_0021_signal)
  128. self.bms_received.to_show_0022_signal.connect(self._inf_0022_signal)
  129. self.bms_received.to_show_0023_signal.connect(self._inf_0023_signal)
  130. self._view.btn_start.setDisabled(True)
  131. self._view.btn_stop.setDisabled(False)
  132. else:
  133. self._view.can_connect_error()
  134. def bcu_disconnect(self):
  135. if SD.CAN_ON_OFF:
  136. SD.CAN_ON_OFF = False
  137. SD.START_RUN = False
  138. SD.CAN_CONTROL.close_can()
  139. # if self.bms_send_thread.isRunning():
  140. # self.bms_send_thread.quit()
  141. # self.bms_send_thread.wait()
  142. # if self.bms_send_thread.isFinished():
  143. # del self.bms_send
  144. # del self.bms_send_thread
  145. if self.bms_received_thread.isRunning():
  146. self.bms_received_thread.quit()
  147. self.bms_received_thread.wait()
  148. if self.bms_received_thread.isFinished():
  149. del self.bms_received
  150. del self.bms_received_thread
  151. self._view.btn_start.setDisabled(False)
  152. self._view.btn_stop.setDisabled(True)
  153. self.bms_status._view.label_bms_connect.setText("通讯未连接" if SD.SYSTEM_LANGUAGE == 0 else "Not Connected")
  154. else:
  155. self._view.can_connect_error()
  156. def app_cut(self):
  157. # return
  158. main_window = QApplication.primaryScreen()
  159. pixmap = main_window.grabWindow(QtWidgets.QApplication.desktop().winId())
  160. pixmap.save("screenshot.png");
  161. # QtWidgets.QWidget.screen().grabWindow(0).save()
  162. def _get_master_id(self, data):
  163. SD.BCU_LIST[data - 1] = 1
  164. SD.BCU_LIFE_STATE[data - 1] = QDateTime.currentMSecsSinceEpoch()
  165. current_secs_since_epoch = QDateTime.currentMSecsSinceEpoch()
  166. for i in range(9):
  167. if current_secs_since_epoch - SD.BCU_LIFE_STATE[i] > 2000:
  168. SD.BCU_LIST[i] = 0
  169. self._view.bcu_online_list_signal.emit(SD.BCU_LIST)
  170. def _inf_0000_signal(self, data):
  171. self._model.ccu_id = SD.BCU_ID
  172. if SD.CCU_TYPE == 1:
  173. set_edt_bg(self.bms_main_ctl._view.under_widget.di_1, QColor(Qt.gray) if (data[0] & 0x01 == 0) else QColor(Qt.green))
  174. set_edt_bg(self.bms_main_ctl._view.under_widget.di_2, QColor(Qt.gray) if (data[0] & 0x02 == 0) else QColor(Qt.green))
  175. set_edt_bg(self.bms_main_ctl._view.under_widget.di_3, QColor(Qt.gray) if (data[0] & 0x04 == 0) else QColor(Qt.green))
  176. set_edt_bg(self.bms_main_ctl._view.under_widget.di_4, QColor(Qt.gray) if (data[0] & 0x08 == 0) else QColor(Qt.green))
  177. set_edt_bg(self.bms_main_ctl._view.under_widget.di_5, QColor(Qt.gray) if (data[0] & 0x10 == 0) else QColor(Qt.green))
  178. set_edt_bg(self.bms_main_ctl._view.under_widget.di_6, QColor(Qt.gray) if (data[0] & 0x20 == 0) else QColor(Qt.green))
  179. set_edt_bg(self.bms_main_ctl._view.under_widget.di_7, QColor(Qt.gray) if (data[0] & 0x40 == 0) else QColor(Qt.green))
  180. set_edt_bg(self.bms_main_ctl._view.under_widget.di_8, QColor(Qt.gray) if (data[0] & 0x80 == 0) else QColor(Qt.green))
  181. set_edt_bg(self.bms_main_ctl._view.under_widget.do_1, QColor(Qt.gray) if (data[1] & 0x01 == 0) else QColor(Qt.green))
  182. self._model.p = data[1] & 0x01
  183. set_edt_bg(self.bms_main_ctl._view.under_widget.do_2, QColor(Qt.gray) if (data[1] & 0x02 == 0) else QColor(Qt.green))
  184. self._model.n = (data[1] & 0x02) >> 1
  185. set_edt_bg(self.bms_main_ctl._view.under_widget.do_3, QColor(Qt.gray) if (data[1] & 0x04 == 0) else QColor(Qt.green))
  186. self._model.pre = (data[1] & 0x04) >> 2
  187. set_edt_bg(self.bms_main_ctl._view.under_widget.do_4, QColor(Qt.gray) if (data[1] & 0x08 == 0) else QColor(Qt.green))
  188. set_edt_bg(self.bms_main_ctl._view.under_widget.do_5, QColor(Qt.gray) if (data[1] & 0x10 == 0) else QColor(Qt.green))
  189. self._model.dlq = (data[1] & 0x10) >> 4
  190. set_edt_bg(self.bms_main_ctl._view.under_widget.do_6, QColor(Qt.gray) if (data[1] & 0x20 == 0) else QColor(Qt.green))
  191. set_edt_bg(self.bms_main_ctl._view.under_widget.do_7, QColor(Qt.gray) if (data[1] & 0x40 == 0) else QColor(Qt.green))
  192. set_edt_bg(self.bms_main_ctl._view.under_widget.do_8, QColor(Qt.gray) if (data[1] & 0x80 == 0) else QColor(Qt.green))
  193. else:
  194. set_edt_bg(self.bms_main_ctl._view.under_widget.fjd_1, QColor(Qt.gray) if (data[2] & 0x01 == 0) else QColor(Qt.green))
  195. self._model.gjd_first = data[2] & 0x01
  196. set_edt_bg(self.bms_main_ctl._view.under_widget.fjd_1, QColor(Qt.gray) if (data[2] & 0x02 == 0) else QColor(Qt.green))
  197. self._model.gjd_second = (data[2] & 0x02) >> 1
  198. def _inf_0001_signal(self, data):
  199. # 系统状态
  200. if data[0] & 0x0F == 0x00:
  201. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_no, QColor(Qt.green))
  202. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_high_no, QColor(Qt.gray))
  203. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_chg, QColor(Qt.gray))
  204. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_dchg, QColor(Qt.gray))
  205. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_stop, QColor(Qt.gray))
  206. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_sleep, QColor(Qt.gray))
  207. elif data[0] & 0x0F == 0x01:
  208. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_no, QColor(Qt.gray))
  209. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_high_no, QColor(Qt.green))
  210. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_chg, QColor(Qt.gray))
  211. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_dchg, QColor(Qt.gray))
  212. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_stop, QColor(Qt.gray))
  213. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_sleep, QColor(Qt.gray))
  214. elif data[0] & 0x0F == 0x02:
  215. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_no, QColor(Qt.gray))
  216. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_high_no, QColor(Qt.gray))
  217. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_chg, QColor(Qt.gray))
  218. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_dchg, QColor(Qt.green))
  219. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_stop, QColor(Qt.gray))
  220. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_sleep, QColor(Qt.gray))
  221. elif data[0] & 0x0F == 0x03:
  222. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_no, QColor(Qt.gray))
  223. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_high_no, QColor(Qt.gray))
  224. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_chg, QColor(Qt.green))
  225. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_dchg, QColor(Qt.gray))
  226. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_stop, QColor(Qt.gray))
  227. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_sleep, QColor(Qt.gray))
  228. elif data[0] & 0x0F == 0x04:
  229. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_no, QColor(Qt.gray))
  230. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_high_no, QColor(Qt.gray))
  231. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_chg, QColor(Qt.gray))
  232. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_dchg, QColor(Qt.gray))
  233. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_stop, QColor(Qt.green))
  234. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_sleep, QColor(Qt.gray))
  235. else:
  236. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_no, QColor(Qt.gray))
  237. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_high_no, QColor(Qt.gray))
  238. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_chg, QColor(Qt.gray))
  239. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_dchg, QColor(Qt.gray))
  240. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_stop, QColor(Qt.gray))
  241. set_edt_bg(self.bms_main_ctl._view.under_widget.sys_status_sleep, QColor(Qt.green))
  242. # 最高报警等级
  243. if (data[0] & 0x30) >> 4 == 0x00:
  244. self.bms_status._view.qrb_status_normal.setChecked(1)
  245. self.bms_status._view.qrb_status_warn.setChecked(0)
  246. self.bms_status._view.qrb_status_warner.setChecked(0)
  247. self.bms_status._view.qrb_status_warnest.setChecked(0)
  248. elif (data[0] & 0x30) >> 4 == 0x01:
  249. self.bms_status._view.qrb_status_normal.setChecked(0)
  250. self.bms_status._view.qrb_status_warn.setChecked(1)
  251. self.bms_status._view.qrb_status_warner.setChecked(0)
  252. self.bms_status._view.qrb_status_warnest.setChecked(0)
  253. elif (data[0] & 0x30) >> 4 == 0x02:
  254. self.bms_status._view.qrb_status_normal.setChecked(0)
  255. self.bms_status._view.qrb_status_warn.setChecked(0)
  256. self.bms_status._view.qrb_status_warner.setChecked(1)
  257. self.bms_status._view.qrb_status_warnest.setChecked(0)
  258. else:
  259. self.bms_status._view.qrb_status_normal.setChecked(0)
  260. self.bms_status._view.qrb_status_warn.setChecked(0)
  261. self.bms_status._view.qrb_status_warner.setChecked(0)
  262. self.bms_status._view.qrb_status_warnest.setChecked(1)
  263. self._model.fault_level = (data[0] & 0x30) >> 4
  264. # 继电器
  265. if SD.CCU_TYPE == 1:
  266. set_edt_bg(self.bms_main_ctl._view.under_widget.do_1, QColor(Qt.gray) if (data[0] & 0x40 == 0) else QColor(Qt.green))
  267. set_edt_bg(self.bms_main_ctl._view.under_widget.do_2, QColor(Qt.gray) if (data[0] & 0x80 == 0) else QColor(Qt.green))
  268. # SOC
  269. self.bms_main_ctl._view.top_widget.lb_soc_value.setText(str(round(data[1] * 0.4, 1)))
  270. self._model.soc = round(data[1] * 0.4, 1)
  271. # 总压
  272. self.bms_main_ctl._view.top_widget.lb_tv_value.setText(str(round((data[3] << 8 | data[2]) * 0.1, 1)))
  273. self._model.volt = round((data[3] << 8 | data[2]) * 0.1, 1)
  274. # 电流
  275. self.bms_main_ctl._view.top_widget.lb_tcur_value.setText(str(round((data[5] << 8 | data[4]) * 0.1 - 3200, 1)))
  276. self._model.cur = round((data[5] << 8 | data[4]) * 0.1 - 3200, 1)
  277. # SOH
  278. self.bms_main_ctl._view.top_widget.lb_tsoh_value.setText(str(round(data[6] * 0.4, 1)))
  279. self._model.soh = round(data[6] * 0.4, 1)
  280. # MOS标志
  281. if SD.CCU_TYPE == 0:
  282. set_edt_bg(self.bms_main_ctl._view.under_widget.mos_dchg, QColor(Qt.gray) if (data[7] & 0x01 == 0) else QColor(Qt.green))
  283. set_edt_bg(self.bms_main_ctl._view.under_widget.mos_chg, QColor(Qt.gray) if (data[7] & 0x02 == 0) else QColor(Qt.green))
  284. set_edt_bg(self.bms_main_ctl._view.under_widget.mos_pre, QColor(Qt.gray) if (data[7] & 0x04 == 0) else QColor(Qt.green))
  285. if SD.CCU_TYPE == 1:
  286. set_edt_bg(self.bms_main_ctl._view.under_widget.do_4, QColor(Qt.gray) if (data[7] & 0x08 == 0) else QColor(Qt.green))
  287. set_edt_bg(self.bms_main_ctl._view.under_widget.do_3, QColor(Qt.gray) if (data[7] & 0x40 == 0) else QColor(Qt.green))
  288. set_edt_bg(self.bms_main_ctl._view.under_widget.do_5, QColor(Qt.gray) if (data[7] & 0x80 == 0) else QColor(Qt.green))
  289. set_edt_bg(self.bms_main_ctl._view.under_widget.permit_chg, QColor(Qt.gray) if (data[0] & 0x40 == 0) else QColor(Qt.red))
  290. set_edt_bg(self.bms_main_ctl._view.under_widget.permit_dchg, QColor(Qt.gray) if (data[0] & 0x80 == 0) else QColor(Qt.red))
  291. def _inf_0002_signal(self, data):
  292. # 单体过压告警
  293. if data[0] & 0x03 == 0:
  294. set_edt_bg(self.bms_main_ctl._view.center_widget.over_cell_warn, QColor(Qt.gray))
  295. elif data[0] & 0x03 == 1:
  296. set_edt_bg(self.bms_main_ctl._view.center_widget.over_cell_warn, QColor(Qt.red))
  297. elif data[0] & 0x03 == 2:
  298. set_edt_bg(self.bms_main_ctl._view.center_widget.over_cell_warn, QColor(Qt.magenta))
  299. else:
  300. set_edt_bg(self.bms_main_ctl._view.center_widget.over_cell_warn, QColor(Qt.yellow))
  301. # 总压过压告警
  302. if (data[0] & 0x0C >> 2) == 0:
  303. set_edt_bg(self.bms_main_ctl._view.center_widget.hv_warn, QColor(Qt.gray))
  304. elif (data[0] & 0x0C >> 2) == 1:
  305. set_edt_bg(self.bms_main_ctl._view.center_widget.hv_warn, QColor(Qt.red))
  306. elif (data[0] & 0x0C >> 2) == 2:
  307. set_edt_bg(self.bms_main_ctl._view.center_widget.hv_warn, QColor(Qt.magenta))
  308. else:
  309. set_edt_bg(self.bms_main_ctl._view.center_widget.hv_warn, QColor(Qt.yellow))
  310. # 单体欠压告警
  311. if (data[0] & 0x30 >> 4) == 0:
  312. set_edt_bg(self.bms_main_ctl._view.center_widget.under_cell_warn, QColor(Qt.gray))
  313. elif (data[0] & 0x30 >> 4) == 1:
  314. set_edt_bg(self.bms_main_ctl._view.center_widget.under_cell_warn, QColor(Qt.red))
  315. elif (data[0] & 0x30 >> 4) == 2:
  316. set_edt_bg(self.bms_main_ctl._view.center_widget.under_cell_warn, QColor(Qt.magenta))
  317. else:
  318. set_edt_bg(self.bms_main_ctl._view.center_widget.under_cell_warn, QColor(Qt.yellow))
  319. # 总压欠压告警
  320. if (data[0] & 0xC0 >> 6) == 0:
  321. set_edt_bg(self.bms_main_ctl._view.center_widget.lv_warn, QColor(Qt.gray))
  322. elif (data[0] & 0xC0 >> 6) == 1:
  323. set_edt_bg(self.bms_main_ctl._view.center_widget.lv_warn, QColor(Qt.red))
  324. elif (data[0] & 0xC0 >> 6) == 2:
  325. set_edt_bg(self.bms_main_ctl._view.center_widget.lv_warn, QColor(Qt.magenta))
  326. else:
  327. set_edt_bg(self.bms_main_ctl._view.center_widget.lv_warn, QColor(Qt.yellow))
  328. # =====================================================================================
  329. # 充电低温告警
  330. if data[1] & 0x03 == 0:
  331. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_lt_warn, QColor(Qt.gray))
  332. elif data[1] & 0x03 == 1:
  333. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_lt_warn, QColor(Qt.red))
  334. elif data[1] & 0x03 == 2:
  335. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_lt_warn, QColor(Qt.magenta))
  336. else:
  337. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_lt_warn, QColor(Qt.yellow))
  338. # 充电高温告警
  339. if (data[1] & 0x0C >> 2) == 0:
  340. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_ht_warn, QColor(Qt.gray))
  341. elif (data[1] & 0x0C >> 2) == 1:
  342. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_ht_warn, QColor(Qt.red))
  343. elif (data[1] & 0x0C >> 2) == 2:
  344. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_ht_warn, QColor(Qt.magenta))
  345. else:
  346. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_ht_warn, QColor(Qt.yellow))
  347. # 放电低温告警
  348. if (data[1] & 0x30 >> 4) == 0:
  349. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_lt_warn, QColor(Qt.gray))
  350. elif (data[1] & 0x30 >> 4) == 1:
  351. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_lt_warn, QColor(Qt.red))
  352. elif (data[1] & 0x30 >> 4) == 2:
  353. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_lt_warn, QColor(Qt.magenta))
  354. else:
  355. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_lt_warn, QColor(Qt.yellow))
  356. # 放电高温告警
  357. if (data[1] & 0xC0 >> 6) == 0:
  358. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_ht_warn, QColor(Qt.gray))
  359. elif (data[1] & 0xC0 >> 6) == 1:
  360. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_ht_warn, QColor(Qt.red))
  361. elif (data[1] & 0xC0 >> 6) == 2:
  362. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_ht_warn, QColor(Qt.magenta))
  363. else:
  364. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_ht_warn, QColor(Qt.yellow))
  365. # =====================================================================================
  366. # 充电过流告警
  367. if data[2] & 0x03 == 0:
  368. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_hcur_warn, QColor(Qt.gray))
  369. elif data[2] & 0x03 == 1:
  370. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_hcur_warn, QColor(Qt.red))
  371. elif data[2] & 0x03 == 2:
  372. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_hcur_warn, QColor(Qt.magenta))
  373. else:
  374. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_hcur_warn, QColor(Qt.yellow))
  375. # 放电过流告警
  376. if (data[2] & 0x0C >> 2) == 0:
  377. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_hcur_warn, QColor(Qt.gray))
  378. elif (data[2] & 0x0C >> 2) == 1:
  379. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_hcur_warn, QColor(Qt.red))
  380. elif (data[2] & 0x0C >> 2) == 2:
  381. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_hcur_warn, QColor(Qt.magenta))
  382. else:
  383. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_hcur_warn, QColor(Qt.yellow))
  384. # 单体压差告警
  385. if (data[2] & 0x30 >> 4) == 0:
  386. set_edt_bg(self.bms_main_ctl._view.center_widget.diff_cell_vol_warn, QColor(Qt.gray))
  387. elif (data[2] & 0x30 >> 4) == 1:
  388. set_edt_bg(self.bms_main_ctl._view.center_widget.diff_cell_vol_warn, QColor(Qt.red))
  389. elif (data[2] & 0x30 >> 4) == 2:
  390. set_edt_bg(self.bms_main_ctl._view.center_widget.diff_cell_vol_warn, QColor(Qt.magenta))
  391. else:
  392. set_edt_bg(self.bms_main_ctl._view.center_widget.diff_cell_vol_warn, QColor(Qt.yellow))
  393. # 单体温差告警
  394. if (data[2] & 0xC0 >> 6) == 0:
  395. set_edt_bg(self.bms_main_ctl._view.center_widget.diff_cell_temp_warn, QColor(Qt.gray))
  396. elif (data[2] & 0xC0 >> 6) == 1:
  397. set_edt_bg(self.bms_main_ctl._view.center_widget.diff_cell_temp_warn, QColor(Qt.red))
  398. elif (data[2] & 0xC0 >> 6) == 2:
  399. set_edt_bg(self.bms_main_ctl._view.center_widget.diff_cell_temp_warn, QColor(Qt.magenta))
  400. else:
  401. set_edt_bg(self.bms_main_ctl._view.center_widget.diff_cell_temp_warn, QColor(Qt.yellow))
  402. # =====================================================================================
  403. # 绝缘过低报警
  404. if data[3] & 0x03 == 0:
  405. set_edt_bg(self.bms_main_ctl._view.center_widget.against_warn, QColor(Qt.gray))
  406. elif data[3] & 0x03 == 1:
  407. set_edt_bg(self.bms_main_ctl._view.center_widget.against_warn, QColor(Qt.red))
  408. elif data[3] & 0x03 == 2:
  409. set_edt_bg(self.bms_main_ctl._view.center_widget.against_warn, QColor(Qt.magenta))
  410. else:
  411. set_edt_bg(self.bms_main_ctl._view.center_widget.against_warn, QColor(Qt.yellow))
  412. # 正极绝缘过低报警
  413. if (data[3] & 0x0C >> 2) == 0:
  414. set_edt_bg(self.bms_main_ctl._view.center_widget.p_against_warn, QColor(Qt.gray))
  415. elif (data[3] & 0x0C >> 2) == 1:
  416. set_edt_bg(self.bms_main_ctl._view.center_widget.p_against_warn, QColor(Qt.red))
  417. elif (data[3] & 0x0C >> 2) == 2:
  418. set_edt_bg(self.bms_main_ctl._view.center_widget.p_against_warn, QColor(Qt.magenta))
  419. else:
  420. set_edt_bg(self.bms_main_ctl._view.center_widget.p_against_warn, QColor(Qt.yellow))
  421. # 负极绝缘过低报警
  422. if (data[3] & 0x30 >> 4) == 0:
  423. set_edt_bg(self.bms_main_ctl._view.center_widget.p_against_warn, QColor(Qt.gray))
  424. elif (data[3] & 0x30 >> 4) == 1:
  425. set_edt_bg(self.bms_main_ctl._view.center_widget.p_against_warn, QColor(Qt.red))
  426. elif (data[3] & 0x30 >> 4) == 2:
  427. set_edt_bg(self.bms_main_ctl._view.center_widget.p_against_warn, QColor(Qt.magenta))
  428. else:
  429. set_edt_bg(self.bms_main_ctl._view.center_widget.p_against_warn, QColor(Qt.yellow))
  430. # 极柱温度过高
  431. if (data[3] & 0xC0 >> 6) == 0:
  432. set_edt_bg(self.bms_main_ctl._view.center_widget.jz_ht_warn, QColor(Qt.gray))
  433. elif (data[3] & 0xC0 >> 6) == 1:
  434. set_edt_bg(self.bms_main_ctl._view.center_widget.jz_ht_warn, QColor(Qt.red))
  435. elif (data[3] & 0xC0 >> 6) == 2:
  436. set_edt_bg(self.bms_main_ctl._view.center_widget.jz_ht_warn, QColor(Qt.magenta))
  437. else:
  438. set_edt_bg(self.bms_main_ctl._view.center_widget.jz_ht_warn, QColor(Qt.yellow))
  439. # =====================================================================================
  440. # 总压检测故障
  441. if a_bit(data[4], 1) == 0:
  442. set_edt_bg(self.bms_main_ctl._view.center_widget.vol_fault, QColor(Qt.gray))
  443. else:
  444. set_edt_bg(self.bms_main_ctl._view.center_widget.vol_fault, QColor(Qt.red))
  445. # 总压检测故障
  446. if a_bit(data[4], 2) == 0:
  447. set_edt_bg(self.bms_main_ctl._view.center_widget.cur_fault, QColor(Qt.gray))
  448. else:
  449. set_edt_bg(self.bms_main_ctl._view.center_widget.cur_fault, QColor(Qt.red))
  450. # 总控通讯故障
  451. if a_bit(data[4], 3) == 0:
  452. set_edt_bg(self.bms_main_ctl._view.center_widget.ccu_control_fault, QColor(Qt.gray))
  453. else:
  454. set_edt_bg(self.bms_main_ctl._view.center_widget.ccu_control_fault, QColor(Qt.red))
  455. # BMU通讯故障
  456. if a_bit(data[4], 4) == 0:
  457. set_edt_bg(self.bms_main_ctl._view.center_widget.bmu_fault, QColor(Qt.gray))
  458. else:
  459. set_edt_bg(self.bms_main_ctl._view.center_widget.bmu_fault, QColor(Qt.red))
  460. # 急停
  461. if a_bit(data[4], 5) == 0:
  462. set_edt_bg(self.bms_main_ctl._view.center_widget.stop_fault, QColor(Qt.gray))
  463. else:
  464. set_edt_bg(self.bms_main_ctl._view.center_widget.stop_fault, QColor(Qt.red))
  465. # NTC故障
  466. if a_bit(data[4], 6) == 0:
  467. set_edt_bg(self.bms_main_ctl._view.center_widget.ntc_fault, QColor(Qt.gray))
  468. else:
  469. set_edt_bg(self.bms_main_ctl._view.center_widget.ntc_fault, QColor(Qt.red))
  470. # AFE失效
  471. if a_bit(data[4], 7) == 0:
  472. set_edt_bg(self.bms_main_ctl._view.center_widget.afe_fault, QColor(Qt.gray))
  473. else:
  474. set_edt_bg(self.bms_main_ctl._view.center_widget.afe_fault, QColor(Qt.red))
  475. # 主正接触器故障
  476. if a_bit(data[4], 8) == 0:
  477. set_edt_bg(self.bms_main_ctl._view.center_widget.p_fault, QColor(Qt.gray))
  478. else:
  479. set_edt_bg(self.bms_main_ctl._view.center_widget.p_fault, QColor(Qt.red))
  480. # =====================================================================================
  481. # 主负接触器故障
  482. if a_bit(data[5], 1) == 0:
  483. set_edt_bg(self.bms_main_ctl._view.center_widget.n_fault, QColor(Qt.gray))
  484. else:
  485. set_edt_bg(self.bms_main_ctl._view.center_widget.n_fault, QColor(Qt.red))
  486. # 预充故障
  487. if a_bit(data[5], 2) == 0:
  488. set_edt_bg(self.bms_main_ctl._view.center_widget.pre_chg_fault, QColor(Qt.gray))
  489. else:
  490. set_edt_bg(self.bms_main_ctl._view.center_widget.pre_chg_fault, QColor(Qt.red))
  491. # 充电MOS故障
  492. if a_bit(data[5], 3) == 0:
  493. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_mos_fault, QColor(Qt.gray))
  494. else:
  495. set_edt_bg(self.bms_main_ctl._view.center_widget.chg_mos_fault, QColor(Qt.red))
  496. # 放电MOS故障
  497. if a_bit(data[5], 4) == 0:
  498. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_mos_fault, QColor(Qt.gray))
  499. else:
  500. set_edt_bg(self.bms_main_ctl._view.center_widget.dchg_mos_fault, QColor(Qt.red))
  501. # 风扇控制失效
  502. if a_bit(data[5], 5) == 0:
  503. set_edt_bg(self.bms_main_ctl._view.center_widget.fan_fault, QColor(Qt.gray))
  504. else:
  505. set_edt_bg(self.bms_main_ctl._view.center_widget.fan_fault, QColor(Qt.red))
  506. # 热失控故障
  507. if a_bit(data[5], 6) == 0:
  508. set_edt_bg(self.bms_main_ctl._view.center_widget.temp_fault, QColor(Qt.gray))
  509. else:
  510. set_edt_bg(self.bms_main_ctl._view.center_widget.temp_fault, QColor(Qt.red))
  511. # 温升过高故障
  512. if a_bit(data[5], 7) == 0:
  513. set_edt_bg(self.bms_main_ctl._view.center_widget.temp_up_fault, QColor(Qt.gray))
  514. else:
  515. set_edt_bg(self.bms_main_ctl._view.center_widget.temp_up_fault, QColor(Qt.red))
  516. # 中间接触器故障
  517. if a_bit(data[5], 8) == 0:
  518. set_edt_bg(self.bms_main_ctl._view.center_widget.center_fault, QColor(Qt.gray))
  519. else:
  520. set_edt_bg(self.bms_main_ctl._view.center_widget.center_fault, QColor(Qt.red))
  521. # =====================================================================================
  522. # 单体断线故障
  523. if a_bit(data[6], 1) == 0:
  524. set_edt_bg(self.bms_main_ctl._view.center_widget.cell_single_fault, QColor(Qt.gray))
  525. else:
  526. set_edt_bg(self.bms_main_ctl._view.center_widget.cell_single_fault, QColor(Qt.red))
  527. # 主控硬件故障
  528. if a_bit(data[6], 2) == 0:
  529. set_edt_bg(self.bms_main_ctl._view.center_widget.ccu_hard_fault, QColor(Qt.gray))
  530. else:
  531. set_edt_bg(self.bms_main_ctl._view.center_widget.ccu_hard_fault, QColor(Qt.red))
  532. # 主控初始化故障
  533. if a_bit(data[6], 3) == 0:
  534. set_edt_bg(self.bms_main_ctl._view.center_widget.ccu_start_fault, QColor(Qt.gray))
  535. else:
  536. set_edt_bg(self.bms_main_ctl._view.center_widget.ccu_start_fault, QColor(Qt.red))
  537. # EEPROM故障
  538. if a_bit(data[6], 4) == 0:
  539. set_edt_bg(self.bms_main_ctl._view.center_widget.eeprom_fault, QColor(Qt.gray))
  540. else:
  541. set_edt_bg(self.bms_main_ctl._view.center_widget.eeprom_fault, QColor(Qt.red))
  542. # 熔断器故障
  543. if a_bit(data[6], 5) == 0:
  544. set_edt_bg(self.bms_main_ctl._view.center_widget.rdq_fault, QColor(Qt.gray))
  545. else:
  546. set_edt_bg(self.bms_main_ctl._view.center_widget.rdq_fault, QColor(Qt.red))
  547. # 断路器反馈故障
  548. if a_bit(data[6], 6) == 0:
  549. set_edt_bg(self.bms_main_ctl._view.center_widget.dlq_fault, QColor(Qt.gray))
  550. else:
  551. set_edt_bg(self.bms_main_ctl._view.center_widget.dlq_fault, QColor(Qt.red))
  552. # 簇间压差故障
  553. if a_bit(data[6], 7) == 0:
  554. set_edt_bg(self.bms_main_ctl._view.center_widget.ccu_diff_vol_fault, QColor(Qt.gray))
  555. else:
  556. set_edt_bg(self.bms_main_ctl._view.center_widget.ccu_diff_vol_fault, QColor(Qt.red))
  557. # PCS通讯故障
  558. if a_bit(data[6], 8) == 0:
  559. set_edt_bg(self.bms_main_ctl._view.center_widget.pcs_fault, QColor(Qt.gray))
  560. else:
  561. set_edt_bg(self.bms_main_ctl._view.center_widget.pcs_fault, QColor(Qt.red))
  562. # =====================================================================================
  563. # 跳机故障
  564. if a_bit(data[7], 1) == 0:
  565. set_edt_bg(self.bms_main_ctl._view.center_widget.jump_fault, QColor(Qt.gray))
  566. else:
  567. set_edt_bg(self.bms_main_ctl._view.center_widget.jump_fault, QColor(Qt.red))
  568. # 极柱温度过高故障
  569. if a_bit(data[7], 2) == 0:
  570. set_edt_bg(self.bms_main_ctl._view.center_widget.jz_ht_warn, QColor(Qt.gray))
  571. else:
  572. set_edt_bg(self.bms_main_ctl._view.center_widget.jz_ht_warn, QColor(Qt.red))
  573. # 主控检测温度过高故障
  574. if a_bit(data[7], 3) == 0:
  575. set_edt_bg(self.bms_main_ctl._view.center_widget.ccu_ht_warn, QColor(Qt.gray))
  576. else:
  577. set_edt_bg(self.bms_main_ctl._view.center_widget.ccu_ht_warn, QColor(Qt.red))
  578. # MOS温度过高故障
  579. if (data[7] & 0x18 >> 3) == 0:
  580. set_edt_bg(self.bms_main_ctl._view.center_widget.mos_ht_warn, QColor(Qt.gray))
  581. elif (data[7] & 0x18 >> 3) == 1:
  582. set_edt_bg(self.bms_main_ctl._view.center_widget.mos_ht_warn, QColor(Qt.red))
  583. elif (data[2] & 0x18 >> 3) == 2:
  584. set_edt_bg(self.bms_main_ctl._view.center_widget.mos_ht_warn, QColor(Qt.magenta))
  585. else:
  586. set_edt_bg(self.bms_main_ctl._view.center_widget.mos_ht_warn, QColor(Qt.yellow))
  587. # 电芯故障
  588. if a_bit(data[7], 6) == 0:
  589. set_edt_bg(self.bms_main_ctl._view.center_widget.cell_fault, QColor(Qt.gray))
  590. else:
  591. set_edt_bg(self.bms_main_ctl._view.center_widget.cell_fault, QColor(Qt.red))
  592. # SOC过低故障
  593. if a_bit(data[7], 7) == 0:
  594. set_edt_bg(self.bms_main_ctl._view.center_widget.soc_fault, QColor(Qt.gray))
  595. else:
  596. set_edt_bg(self.bms_main_ctl._view.center_widget.soc_fault, QColor(Qt.red))
  597. def _inf_0003_signal(self, data):
  598. # 最高单体电压值
  599. self.bms_main_ctl._view.top_widget.lb_tcellhv_value.setText(str(data[1] << 8 | data[0]))
  600. self._model.max_cell_volt = data[1] << 8 | data[0]
  601. # 最高单体电压所在编号
  602. self.bms_main_ctl._view.top_widget.lb_tcellhv_index_value.setText(str(data[3] << 8 | data[2]))
  603. self._model.max_cell_volt_id = data[3] << 8 | data[2]
  604. # 最低单体电压值
  605. self.bms_main_ctl._view.top_widget.lb_tcelllv_value.setText(str(data[5] << 8 | data[4]))
  606. self._model.min_cell_volt = data[5] << 8 | data[4]
  607. # 最低单体电压所在编号
  608. self.bms_main_ctl._view.top_widget.lb_tcelllv_index_value.setText(str(data[7] << 8 | data[6]))
  609. self._model.min_cell_volt_id = data[7] << 8 | data[6]
  610. def _inf_0004_signal(self, data):
  611. # 最大压差
  612. self.bms_main_ctl._view.top_widget.lb_diff_vol_value.setText(str(data[1] << 8 | data[0]))
  613. # 平均电压
  614. self.bms_main_ctl._view.top_widget.lb_avg_vol_value.setText(str(data[3] << 8 | data[2]))
  615. self._model.avg_cell_volt = data[3] << 8 | data[2]
  616. # 最大温差
  617. self.bms_main_ctl._view.top_widget.lb_diff_temp_value.setText(str(round((data[5] << 8 | data[4]) * 0.1 - 40, 1)))
  618. # 平均温度
  619. self.bms_main_ctl._view.top_widget.lb_avg_temp_value.setText(str(round((data[7] << 8 | data[6]) * 0.1 - 40, 1)))
  620. self._model.avg_cell_temp = round((data[7] << 8 | data[6]) * 0.1 - 40, 1)
  621. def _inf_0005_signal(self, data):
  622. # 最高单体温度值
  623. self.bms_main_ctl._view.top_widget.lb_h_temp_value.setText(str(round((data[1] << 8 | data[0]) * 0.1 - 40, 1)))
  624. self._model.max_cell_temp = round((data[1] << 8 | data[0]) * 0.1 - 40, 1)
  625. # 最高单体温度所在编号
  626. self.bms_main_ctl._view.top_widget.lb_h_temp_index_value.setText(str(data[3] << 8 | data[2]))
  627. self._model.max_cell_temp_id = data[3] << 8 | data[2]
  628. # 最低单体温度值
  629. self.bms_main_ctl._view.top_widget.lb_l_temp_value.setText(str(round((data[5] << 8 | data[4]) * 0.1 - 40, 1)))
  630. self._model.min_cell_temp = round((data[5] << 8 | data[4]) * 0.1 - 40, 1)
  631. # # 最低单体温度所在编号
  632. # self.bms_main_ctl._view.top_widget.lb_tcelllv_index_value.setText(str(data[7] << 8 | data[6]))
  633. self._model.min_cell_temp_id = data[7] << 8 | data[6]
  634. def _inf_0006_signal(self, data):
  635. # 当前允许最大放电功率
  636. self.bms_main_ctl._view.top_widget.lb_dchg_kw_value.setText(str(round((data[1] << 8 | data[0]) * 0.1, 1)))
  637. # 当前允许最大充电功率
  638. self.bms_main_ctl._view.top_widget.lb_chg_kw_value.setText(str(round((data[3] << 8 | data[2]) * 0.1, 1)))
  639. # # 当前可放电量
  640. # self.bms_main_ctl._view.top_widget.lb_.setText(str((data[5] << 8 | data[4]) * 0.1 - 40))
  641. # # 当前可充电量
  642. # self.bms_main_ctl._view.top_widget.lb_avg_temp_value.setText(str((data[7] << 8 | data[6]) * 0.1 - 40))
  643. def _inf_0007_signal(self, data):
  644. # 当前允许最大充电电压
  645. self.bms_main_ctl._view.top_widget.lb_max_chg_vol_value.setText(str(round((data[1] << 8 | data[0]) * 0.1, 1)))
  646. # 当前允许最大充电电流
  647. self.bms_main_ctl._view.top_widget.lb_max_chg_cur_value.setText(str(round((data[3] << 8 | data[2]) * 0.1 - 3200, 1)))
  648. # 当前允许最大放电电流
  649. self.bms_main_ctl._view.top_widget.lb_max_dchg_cur_value.setText(str(round((data[5] << 8 | data[4]) * 0.1 - 3200, 1)))
  650. # 当前允许放电限制电压
  651. self.bms_main_ctl._view.top_widget.lb_max_dchg_vol_value.setText(str(round((data[7] << 8 | data[6]) * 0.1, 1)))
  652. def _inf_0008_signal(self, data):
  653. # 电池组单体电压累加和
  654. self.bms_main_ctl._view.top_widget.lb_sum_vol_value.setText(str(round((data[1] << 8 | data[0]) * 0.1, 1)))
  655. # 总压一检测
  656. self.bms_main_ctl._view.top_widget.lb_tv_value.setText(str(round((data[3] << 8 | data[2]) * 0.1, 1)))
  657. # 总压二检测
  658. self.bms_main_ctl._view.top_widget.lb_tv_2_value.setText(str(round((data[5] << 8 | data[4]) * 0.1, 1)))
  659. # 总压三检测
  660. self.bms_main_ctl._view.top_widget.lb_tv_3_value.setText(str(round((data[7] << 8 | data[6]) * 0.1, 1)))
  661. def _inf_0009_signal(self, data):
  662. # 电池组标称容量
  663. self.bms_main_ctl._view.top_widget.lb_nom_cap_value.setText(str(round((data[1] << 8 | data[0]) * 0.1, 1)))
  664. # 电池组总容量
  665. self.bms_main_ctl._view.top_widget.lb_all_cap_value.setText(str(round((data[3] << 8 | data[2]) * 0.1, 1)))
  666. # 电池组剩余容量
  667. self.bms_main_ctl._view.top_widget.lb_left_cap_value.setText(str(round((data[5] << 8 | data[4]) * 0.1, 1)))
  668. # SOE
  669. self.bms_main_ctl._view.top_widget.lb_tsoe_value.setText(str(round(data[6] * 0.4, 1)))
  670. def _inf_000A_signal(self, data):
  671. # 最高单体SOC
  672. self.bms_main_ctl._view.top_widget.lb_soc_high_value.setText(str(round((data[1] << 8 | data[0]) * 0.4, 1)))
  673. self._model.max_soc = round((data[1] << 8 | data[0]) * 0.4, 1)
  674. # 最低单体SOC
  675. self.bms_main_ctl._view.top_widget.lb_soc_low_value.setText(str(round((data[3] << 8 | data[2]) * 0.4, 1)))
  676. self._model.min_soc = round((data[3] << 8 | data[2]) * 0.4, 1)
  677. # 平均单体SOC
  678. self.bms_main_ctl._view.top_widget.lb_soc_avg_value.setText(str(round((data[5] << 8 | data[4]) * 0.4, 1)))
  679. self._model.avg_soc = round((data[5] << 8 | data[4]) * 0.4, 1)
  680. # 循环次数
  681. self.bms_main_ctl._view.top_widget.lb_circle_num_value.setText(str(data[7] << 8 | data[6]))
  682. def _inf_000B_signal(self, data):
  683. # 电池组标称能量
  684. self.bms_main_ctl._view.top_widget.lb_nom_energy_value.setText(str(round((data[1] << 8 | data[0]) * 0.1, 1)))
  685. # 电池组总能量
  686. self.bms_main_ctl._view.top_widget.lb_all_energy_value.setText(str(round((data[3] << 8 | data[2]) * 0.1, 1)))
  687. # 电池组剩余能量
  688. self.bms_main_ctl._view.top_widget.lb_left_energy_value.setText(str(round((data[5] << 8 | data[4]) * 0.1, 1)))
  689. # 供电采样电压
  690. self.bms_main_ctl._view.top_widget.lb_gdcy_vol_value.setText(str(round((data[7] << 8 | data[6]) * 0.1, 1)))
  691. def _inf_000C_signal(self, data):
  692. # 累计放电电量
  693. self.bms_main_ctl._view.top_widget.lb_chg_kwh_value.setText(str(round((data[3] << 24 | data[2] << 16 | data[1] << 8 | data[0]) * 0.01, 2)))
  694. # 累计充电电量
  695. self.bms_main_ctl._view.top_widget.lb_dchg_kwh_value.setText(str(round((data[7] << 24 | data[6] << 16 | data[5] << 8 | data[4]) * 0.01, 2)))
  696. def _inf_000D_signal(self, data):
  697. # 当天累计放电电量
  698. self.bms_main_ctl._view.top_widget.lb_nowday_chg_energy_value.setText(str(round((data[3] << 24 | data[2] << 16 | data[1] << 8 | data[0]) * 0.01, 2)))
  699. # 当天累计充电电量
  700. self.bms_main_ctl._view.top_widget.lb_nowday_dchg_energy_value.setText(str(round((data[7] << 24 | data[6] << 16 | data[5] << 8 | data[4]) * 0.01, 2)))
  701. def _inf_000E_signal(self, data):
  702. # 系统对地绝缘阻值
  703. self.bms_main_ctl._view.top_widget.lb_sys_against_value.setText(str(data[1] << 8 | data[0]))
  704. # 正母线对地绝缘阻值
  705. self.bms_main_ctl._view.top_widget.lb_sys_p_against_value.setText(str(data[3] << 8 | data[2]))
  706. # 负母线对地绝缘阻值
  707. self.bms_main_ctl._view.top_widget.lb_sys_n_against_value.setText(str(data[5] << 8 | data[4]))
  708. def _inf_000F_signal(self, data):
  709. # 单体电压
  710. # if data[1] == 0:
  711. # self.bms_cell_ctl._view.home_cell_table.cellWidget(0, 1).setText(str(data[3] << 8 | data[2]) + " mV")
  712. # self.bms_cell_ctl._view.home_cell_table.cellWidget(1, 1).setText(str(data[5] << 8 | data[4]) + " mV")
  713. # self.bms_cell_ctl._view.home_cell_table.cellWidget(2, 1).setText(str(data[7] << 8 | data[6]) + " mV")
  714. # if data[1] == 1:
  715. # self.bms_cell_ctl._view.home_cell_table.cellWidget(3, 1).setText(str(data[3] << 8 | data[2]) + " mV")
  716. # self.bms_cell_ctl._view.home_cell_table.cellWidget(0, 4).setText(str(data[5] << 8 | data[4]) + " mV")
  717. # self.bms_cell_ctl._view.home_cell_table.cellWidget(1, 4).setText(str(data[7] << 8 | data[6]) + " mV")
  718. # if data[1] == 2:
  719. # self.bms_cell_ctl._view.home_cell_table.cellWidget(2, 4).setText(str(data[3] << 8 | data[2]) + " mV")
  720. # self.bms_cell_ctl._view.home_cell_table.cellWidget(3, 4).setText(str(data[5] << 8 | data[4]) + " mV")
  721. # self.bms_cell_ctl._view.home_cell_table.cellWidget(0, 7).setText(str(data[7] << 8 | data[6]) + " mV")
  722. # if data[1] == 3:
  723. # self.bms_cell_ctl._view.home_cell_table.cellWidget(1, 7).setText(str(data[3] << 8 | data[2]) + " mV")
  724. # self.bms_cell_ctl._view.home_cell_table.cellWidget(2, 7).setText(str(data[5] << 8 | data[4]) + " mV")
  725. # self.bms_cell_ctl._view.home_cell_table.cellWidget(3, 7).setText(str(data[7] << 8 | data[6]) + " mV")
  726. # if data[1] == 4:
  727. # self.bms_cell_ctl._view.home_cell_table.cellWidget(0, 10).setText(str(data[3] << 8 | data[2]) + " mV")
  728. # self.bms_cell_ctl._view.home_cell_table.cellWidget(1, 10).setText(str(data[5] << 8 | data[4]) + " mV")
  729. # self.bms_cell_ctl._view.home_cell_table.cellWidget(2, 10).setText(str(data[7] << 8 | data[6]) + " mV")
  730. # if data[1] == 5:
  731. # self.bms_cell_ctl._view.home_cell_table.cellWidget(3, 10).setText(str(data[3] << 8 | data[2]) + " mV")
  732. if data[0] < 25:
  733. # 单体信息页面
  734. self.bms_cell_ctl._view.cell_vol_table.cellWidget(3 * data[1], data[0] + 1).setText(str(data[3] << 8 | data[2]) + " mV")
  735. self.bms_cell_ctl._view.cell_vol_table.cellWidget(3 * data[1] + 1, data[0] + 1).setText(str(data[5] << 8 | data[4]) + " mV")
  736. self.bms_cell_ctl._view.cell_vol_table.cellWidget(3 * data[1] + 2, data[0] + 1).setText(str(data[7] << 8 | data[6]) + " mV")
  737. self.cell_single_volt[3 * data[1]] = data[3] << 8 | data[2]
  738. self.cell_single_volt[3 * data[1] + 1] = data[5] << 8 | data[4]
  739. self.cell_single_volt[3 * data[1] + 2] = data[7] << 8 | data[6]
  740. self._model.cell_volt = self.cell_single_volt
  741. # 硬件校准页面
  742. if (self.bms_hard_ctl._view.cb_bmu_index.currentIndex() == data[0]):
  743. self.bms_hard_ctl._view.hard_table.item(3 * data[1], 3).setText(str(data[3] << 8 | data[2]))
  744. self.bms_hard_ctl._view.hard_table.item(3 * data[1] + 1, 3).setText(str(data[5] << 8 | data[4]))
  745. self.bms_hard_ctl._view.hard_table.item(3 * data[1] + 2, 3).setText(str(data[7] << 8 | data[6]))
  746. def _inf_0010_signal(self, data):
  747. # 单体温度
  748. # if data[1] == 0:
  749. # self.bms_cell_ctl._view.home_cell_table.cellWidget(0, 2).setText(str(round((data[3] << 8 | data[2]) * 0.1 - 40, 1)) + " ℃")
  750. # self.bms_cell_ctl._view.home_cell_table.cellWidget(1, 2).setText(str(round((data[5] << 8 | data[4]) * 0.1 - 40, 1)) + " ℃")
  751. # self.bms_cell_ctl._view.home_cell_table.cellWidget(2, 2).setText(str(round((data[7] << 8 | data[6]) * 0.1 - 40, 1)) + " ℃")
  752. # if data[1] == 1:
  753. # self.bms_cell_ctl._view.home_cell_table.cellWidget(3, 2).setText(str(round((data[3] << 8 | data[2]) * 0.1 - 40, 1)) + " ℃")
  754. # self.bms_cell_ctl._view.home_cell_table.cellWidget(0, 5).setText(str(round((data[5] << 8 | data[4]) * 0.1 - 40, 1)) + " ℃")
  755. # self.bms_cell_ctl._view.home_cell_table.cellWidget(1, 5).setText(str(round((data[7] << 8 | data[6]) * 0.1 - 40, 1)) + " ℃")
  756. # if data[1] == 2:
  757. # self.bms_cell_ctl._view.home_cell_table.cellWidget(2, 5).setText(str(round((data[3] << 8 | data[2]) * 0.1 - 40, 1)) + " ℃")
  758. # self.bms_cell_ctl._view.home_cell_table.cellWidget(3, 5).setText(str(round((data[5] << 8 | data[4]) * 0.1 - 40, 1)) + " ℃")
  759. # self.bms_cell_ctl._view.home_cell_table.cellWidget(0, 8).setText(str(round((data[7] << 8 | data[6]) * 0.1 - 40, 1)) + " ℃")
  760. # if data[1] == 3:
  761. # self.bms_cell_ctl._view.home_cell_table.cellWidget(1, 8).setText(str(round((data[3] << 8 | data[2]) * 0.1 - 40, 1)) + " ℃")
  762. # self.bms_cell_ctl._view.home_cell_table.cellWidget(2, 8).setText(str(round((data[5] << 8 | data[4]) * 0.1 - 40, 1)) + " ℃")
  763. # self.bms_cell_ctl._view.home_cell_table.cellWidget(3, 8).setText(str(round((data[7] << 8 | data[6]) * 0.1 - 40, 1)) + " ℃")
  764. # if data[1] == 4:
  765. # self.bms_cell_ctl._view.home_cell_table.cellWidget(0, 11).setText(str(round((data[3] << 8 | data[2]) * 0.1 - 40, 1)) + " ℃")
  766. # self.bms_cell_ctl._view.home_cell_table.cellWidget(1, 11).setText(str(round((data[5] << 8 | data[4]) * 0.1 - 40, 1)) + " ℃")
  767. # self.bms_cell_ctl._view.home_cell_table.cellWidget(2, 11).setText(str(round((data[7] << 8 | data[6]) * 0.1 - 40, 1)) + " ℃")
  768. # if data[1] == 5:
  769. # self.bms_cell_ctl._view.home_cell_table.cellWidget(3, 11).setText(str(round((data[3] << 8 | data[2]) * 0.1 - 40, 1)) + " ℃")
  770. if data[0] < 25:
  771. 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)) + " ℃")
  772. 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)) + " ℃")
  773. 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)) + " ℃")
  774. self.cell_single_temp[3 * data[1]] = round((data[3] << 8 | data[2]) * 0.1 - 40, 1)
  775. self.cell_single_temp[3 * data[1] + 1] = round((data[5] << 8 | data[4]) * 0.1 - 40, 1)
  776. self.cell_single_temp[3 * data[1] + 2] = round((data[7] << 8 | data[6]) * 0.1 - 40, 1)
  777. self._model.cell_temp = self.cell_single_temp
  778. # to do
  779. def _inf_0011_signal(self, data):
  780. # 最高单体电压所在从控编号
  781. self.bms_main_ctl._view.top_widget.lb_tcellhv_slave_index_value.setText(str(data[0]))
  782. # 最高单体电压所在从控内编号
  783. self.bms_main_ctl._view.top_widget.lb_tcellhv_in_index_value.setText(str(data[1]))
  784. # 最高单体温度所在从控编号
  785. self.bms_main_ctl._view.top_widget.lb_h_temp_slave_index_value.setText(str(data[2]))
  786. # 最高单体温度所在从控内编号
  787. self.bms_main_ctl._view.top_widget.lb_h_temp_in_index_value.setText(str(data[3]))
  788. # 最低单体电压所在从控编号
  789. self.bms_main_ctl._view.top_widget.lb_tcelllv_slave_index_value.setText(str(data[4]))
  790. # 最低单体电压所在从控内编号
  791. self.bms_main_ctl._view.top_widget.lb_tcelllv_in_index_value.setText(str(data[5]))
  792. # to do
  793. # # 最低单体温度所在从控编号
  794. # self.bms_main_ctl._view.top_widget.lb_l_temp_slave_index_value.setText(str(data[6]))
  795. # # 最低单体温度所在从控内编号
  796. # self.bms_main_ctl._view.top_widget.lb_h_temp_in_index_value.setText(str(data[7]))
  797. def _inf_0012_signal(self, data):
  798. return
  799. # if SD.CCU_TYPE == 1:
  800. # set_edt_bg(self.bms_main_ctl._view.under_widget.di_1, QColor(Qt.gray) if (data[0] & 0x01 == 0) else QColor(Qt.green))
  801. # set_edt_bg(self.bms_main_ctl._view.under_widget.di_2, QColor(Qt.gray) if (data[0] & 0x02 == 0) else QColor(Qt.green))
  802. # set_edt_bg(self.bms_main_ctl._view.under_widget.di_3, QColor(Qt.gray) if (data[0] & 0x04 == 0) else QColor(Qt.green))
  803. # set_edt_bg(self.bms_main_ctl._view.under_widget.di_4, QColor(Qt.gray) if (data[0] & 0x08 == 0) else QColor(Qt.green))
  804. # set_edt_bg(self.bms_main_ctl._view.under_widget.di_5, QColor(Qt.gray) if (data[0] & 0x10 == 0) else QColor(Qt.green))
  805. # set_edt_bg(self.bms_main_ctl._view.under_widget.di_6, QColor(Qt.gray) if (data[0] & 0x20 == 0) else QColor(Qt.green))
  806. # set_edt_bg(self.bms_main_ctl._view.under_widget.di_7, QColor(Qt.gray) if (data[0] & 0x40 == 0) else QColor(Qt.green))
  807. # set_edt_bg(self.bms_main_ctl._view.under_widget.di_8, QColor(Qt.gray) if (data[0] & 0x80 == 0) else QColor(Qt.green))
  808. # set_edt_bg(self.bms_main_ctl._view.under_widget.do_1, QColor(Qt.gray) if (data[1] & 0x01 == 0) else QColor(Qt.green))
  809. # self._model.p(data[1] & 0x01)
  810. # set_edt_bg(self.bms_main_ctl._view.under_widget.do_2, QColor(Qt.gray) if (data[1] & 0x02 == 0) else QColor(Qt.green))
  811. # self._model.n((data[1] & 0x02) >> 1)
  812. # set_edt_bg(self.bms_main_ctl._view.under_widget.do_3, QColor(Qt.gray) if (data[1] & 0x04 == 0) else QColor(Qt.green))
  813. # self._model.pre((data[1] & 0x04) >> 2)
  814. # set_edt_bg(self.bms_main_ctl._view.under_widget.do_4, QColor(Qt.gray) if (data[1] & 0x08 == 0) else QColor(Qt.green))
  815. # set_edt_bg(self.bms_main_ctl._view.under_widget.do_5, QColor(Qt.gray) if (data[1] & 0x10 == 0) else QColor(Qt.green))
  816. # self._model.dlq((data[1] & 0x10) >> 4)
  817. # set_edt_bg(self.bms_main_ctl._view.under_widget.do_6, QColor(Qt.gray) if (data[1] & 0x20 == 0) else QColor(Qt.green))
  818. # set_edt_bg(self.bms_main_ctl._view.under_widget.do_7, QColor(Qt.gray) if (data[1] & 0x40 == 0) else QColor(Qt.green))
  819. # set_edt_bg(self.bms_main_ctl._view.under_widget.do_8, QColor(Qt.gray) if (data[1] & 0x80 == 0) else QColor(Qt.green))
  820. # else:
  821. # set_edt_bg(self.bms_main_ctl._view.under_widget.fjd_1, QColor(Qt.gray) if (data[2] & 0x01 == 0) else QColor(Qt.green))
  822. # self._model.gjd_first(data[2] & 0x01)
  823. # set_edt_bg(self.bms_main_ctl._view.under_widget.fjd_1, QColor(Qt.gray) if (data[2] & 0x02 == 0) else QColor(Qt.green))
  824. # self._model.gjd_second((data[2] & 0x02) >> 1)
  825. # def _inf_0013_signal(self, data):
  826. # # BMS 电池编码
  827. # self.bms_sn_version = ["" for i in range(8)]
  828. # self.bms_sn_version[0] = chr(data[0])
  829. # self.bms_sn_version[1] = chr(data[1])
  830. # self.bms_sn_version[2] = chr(data[2])
  831. # self.bms_sn_version[3] = chr(data[3])
  832. # self.bms_sn_version[4] = chr(data[4])
  833. # self.bms_sn_version[5] = chr(data[5])
  834. # self.bms_sn_version[6] = chr(data[6])
  835. # self.bms_sn_version[7] = chr(data[7])
  836. # bms_sn_version = ''.join(self.bms_sn_version)
  837. # self.bms_download_ctl._view.message_table.cellWidget(5, 2).setText(bms_sn_version)
  838. def _inf_0013_signal(self, data):
  839. # BMS 硬件版本号
  840. self.bms_hard_version = ["" for i in range(8)]
  841. self.bms_hard_version[0] = chr(data[0])
  842. self.bms_hard_version[1] = chr(data[1])
  843. self.bms_hard_version[2] = chr(data[2])
  844. self.bms_hard_version[3] = chr(data[3])
  845. self.bms_hard_version[4] = chr(data[4])
  846. self.bms_hard_version[5] = chr(data[5])
  847. self.bms_hard_version[6] = chr(data[6])
  848. self.bms_hard_version[7] = chr(data[7])
  849. bms_hard_version = ''.join(self.bms_hard_version)
  850. self.bms_download_ctl._view.message_table.item(3, 2).setText(bms_hard_version)
  851. def _inf_0014_signal(self, data):
  852. # BMS Boot版本号
  853. self.bms_boot_version = ["" for i in range(8)]
  854. self.bms_boot_version[0] = chr(data[0])
  855. self.bms_boot_version[1] = chr(data[1])
  856. self.bms_boot_version[2] = chr(data[2])
  857. self.bms_boot_version[3] = chr(data[3])
  858. self.bms_boot_version[4] = chr(data[4])
  859. self.bms_boot_version[5] = chr(data[5])
  860. self.bms_boot_version[6] = chr(data[6])
  861. self.bms_boot_version[7] = chr(data[7])
  862. bms_boot_version = ''.join(self.bms_boot_version)
  863. self.bms_download_ctl._view.message_table.item(0, 2).setText(bms_boot_version)
  864. def _inf_0016_signal(self, data):
  865. # BMS 软件版本号
  866. self.bms_soft_version = ["" for i in range(8)]
  867. self.bms_soft_version[0] = chr(data[0])
  868. self.bms_soft_version[1] = chr(data[1])
  869. self.bms_soft_version[2] = chr(data[2])
  870. self.bms_soft_version[3] = chr(data[3])
  871. self.bms_soft_version[4] = chr(data[4])
  872. self.bms_soft_version[5] = chr(data[5])
  873. self.bms_soft_version[6] = chr(data[6])
  874. self.bms_soft_version[7] = chr(data[7])
  875. bms_soft_version = ''.join(self.bms_soft_version)
  876. self.bms_download_ctl._view.message_table.item(1, 2).setText(bms_soft_version)
  877. def _inf_0015_signal(self, data):
  878. # BMS 算法版本号
  879. self.bms_sf_version = ["" for i in range(8)]
  880. self.bms_sf_version[0] = chr(data[0])
  881. self.bms_sf_version[1] = chr(data[1])
  882. self.bms_sf_version[2] = chr(data[2])
  883. self.bms_sf_version[3] = chr(data[3])
  884. self.bms_sf_version[4] = chr(data[4])
  885. self.bms_sf_version[5] = chr(data[5])
  886. self.bms_sf_version[6] = chr(data[6])
  887. self.bms_sf_version[7] = chr(data[7])
  888. bms_sf_version = ''.join(self.bms_sf_version)
  889. self.bms_download_ctl._view.message_table.item(2, 2).setText(bms_sf_version)
  890. def _inf_0017_signal(self, data):
  891. # RTC时钟
  892. self.bms_hard_ctl._view.lb_rtc.setText(str(data[0] + 2000)+ "-" + str(data[1]) + "-" + str(data[2])+ " " + str(data[3]) + ":" + str(data[4]) + ":" + str(data[5]))
  893. def _inf_0018_signal(self, data):
  894. # 电池均衡状态
  895. for i in range(8):
  896. if a_bit(data[1], i + 1) == 1:
  897. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 1).widget(), QtGui.QColor(Qt.green))
  898. else:
  899. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 1).widget(), QtGui.QColor(Qt.white))
  900. if a_bit(data[2], i + 1) == 1:
  901. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 9).widget(), QtGui.QColor(Qt.green))
  902. else:
  903. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 9).widget(), QtGui.QColor(Qt.white))
  904. if a_bit(data[3], i + 1) == 1:
  905. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 17).widget(), QtGui.QColor(Qt.green))
  906. else:
  907. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 17).widget(), QtGui.QColor(Qt.white))
  908. if a_bit(data[4], i + 1) == 1:
  909. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 25).widget(), QtGui.QColor(Qt.green))
  910. else:
  911. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 25).widget(), QtGui.QColor(Qt.white))
  912. def _inf_0019_signal(self, data):
  913. # 电池均衡状态
  914. for i in range(8):
  915. if a_bit(data[1], i + 1) == 1:
  916. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 33).widget(), QtGui.QColor(Qt.green))
  917. else:
  918. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 33).widget(), QtGui.QColor(Qt.white))
  919. if a_bit(data[2], i + 1) == 1:
  920. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 41).widget(), QtGui.QColor(Qt.green))
  921. else:
  922. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 41).widget(), QtGui.QColor(Qt.white))
  923. if a_bit(data[3], i + 1) == 1:
  924. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 49).widget(), QtGui.QColor(Qt.green))
  925. else:
  926. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 49).widget(), QtGui.QColor(Qt.white))
  927. if a_bit(data[4], i + 1) == 1:
  928. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 57).widget(), QtGui.QColor(Qt.green))
  929. else:
  930. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 57).widget(), QtGui.QColor(Qt.white))
  931. if a_bit(data[5], i + 1) == 1:
  932. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 65).widget(), QtGui.QColor(Qt.green))
  933. else:
  934. set_edt_bg(self.bms_balance_ctl._view.on_off_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 65).widget(), QtGui.QColor(Qt.white))
  935. def _inf_001A_signal(self, data):
  936. # 电池均衡故障
  937. for i in range(8):
  938. if a_bit(data[1], i + 1) == 1:
  939. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 1).widget(), QtGui.QColor(Qt.red))
  940. else:
  941. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 1).widget(), QtGui.QColor(Qt.white))
  942. if a_bit(data[2], i + 1) == 1:
  943. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 9).widget(), QtGui.QColor(Qt.red))
  944. else:
  945. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 9).widget(), QtGui.QColor(Qt.white))
  946. if a_bit(data[3], i + 1) == 1:
  947. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 17).widget(), QtGui.QColor(Qt.red))
  948. else:
  949. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 17).widget(), QtGui.QColor(Qt.white))
  950. if a_bit(data[4], i + 1) == 1:
  951. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 25).widget(), QtGui.QColor(Qt.red))
  952. else:
  953. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 25).widget(), QtGui.QColor(Qt.white))
  954. def _inf_001B_signal(self, data):
  955. # 电池均衡故障
  956. for i in range(8):
  957. if a_bit(data[1], i + 1) == 1:
  958. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 33).widget(), QtGui.QColor(Qt.red))
  959. else:
  960. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 33).widget(), QtGui.QColor(Qt.white))
  961. if a_bit(data[2], i + 1) == 1:
  962. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 41).widget(), QtGui.QColor(Qt.red))
  963. else:
  964. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 41).widget(), QtGui.QColor(Qt.white))
  965. if a_bit(data[3], i + 1) == 1:
  966. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 49).widget(), QtGui.QColor(Qt.red))
  967. else:
  968. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 49).widget(), QtGui.QColor(Qt.white))
  969. if a_bit(data[4], i + 1) == 1:
  970. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 57).widget(), QtGui.QColor(Qt.red))
  971. else:
  972. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 57).widget(), QtGui.QColor(Qt.white))
  973. if a_bit(data[5], i + 1) == 1:
  974. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 65).widget(), QtGui.QColor(Qt.red))
  975. else:
  976. set_edt_bg(self.bms_balance_ctl._view.balance_fault_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 65).widget(), QtGui.QColor(Qt.white))
  977. def _inf_001C_signal(self, data):
  978. # 电池连接线状态
  979. for i in range(8):
  980. if a_bit(data[1], i + 1) == 1:
  981. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 1).widget(), QtGui.QColor(Qt.red))
  982. else:
  983. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 1).widget(), QtGui.QColor(Qt.white))
  984. if a_bit(data[2], i + 1) == 1:
  985. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 9).widget(), QtGui.QColor(Qt.red))
  986. else:
  987. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 9).widget(), QtGui.QColor(Qt.white))
  988. if a_bit(data[3], i + 1) == 1:
  989. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 17).widget(), QtGui.QColor(Qt.red))
  990. else:
  991. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 17).widget(), QtGui.QColor(Qt.white))
  992. if a_bit(data[4], i + 1) == 1:
  993. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 25).widget(), QtGui.QColor(Qt.red))
  994. else:
  995. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 25).widget(), QtGui.QColor(Qt.white))
  996. # for i in range(8):
  997. # if a_bit(data[1], i + 1) == 1:
  998. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 1, data[0] + 1).widget(), QtGui.QColor(Qt.red))
  999. # else:
  1000. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 1, data[0] + 1).widget(), QtGui.QColor(Qt.white))
  1001. # if a_bit(data[2], i + 1) == 1:
  1002. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 9, data[0] + 1).widget(), QtGui.QColor(Qt.red))
  1003. # else:
  1004. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 9, data[0] + 1).widget(), QtGui.QColor(Qt.white))
  1005. # if a_bit(data[3], i + 1) == 1:
  1006. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 17, data[0] + 1).widget(), QtGui.QColor(Qt.red))
  1007. # else:
  1008. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 17, data[0] + 1).widget(), QtGui.QColor(Qt.white))
  1009. # if a_bit(data[4], i + 1) == 1:
  1010. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 25, data[0] + 1).widget(), QtGui.QColor(Qt.red))
  1011. # else:
  1012. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 25, data[0] + 1).widget(), QtGui.QColor(Qt.white))
  1013. def _inf_001D_signal(self, data):
  1014. # 电池连接线状态
  1015. for i in range(8):
  1016. if a_bit(data[1], i + 1) == 1:
  1017. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 33).widget(), QtGui.QColor(Qt.red))
  1018. else:
  1019. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 33).widget(), QtGui.QColor(Qt.white))
  1020. if a_bit(data[2], i + 1) == 1:
  1021. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 41).widget(), QtGui.QColor(Qt.red))
  1022. else:
  1023. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 41).widget(), QtGui.QColor(Qt.white))
  1024. if a_bit(data[3], i + 1) == 1:
  1025. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 49).widget(), QtGui.QColor(Qt.red))
  1026. else:
  1027. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 49).widget(), QtGui.QColor(Qt.white))
  1028. if a_bit(data[4], i + 1) == 1:
  1029. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 57).widget(), QtGui.QColor(Qt.red))
  1030. else:
  1031. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 57).widget(), QtGui.QColor(Qt.white))
  1032. if a_bit(data[5], i + 1) == 1:
  1033. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 65).widget(), QtGui.QColor(Qt.red))
  1034. else:
  1035. set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(data[0] - 1, i + 65).widget(), QtGui.QColor(Qt.white))
  1036. # for i in range(8):
  1037. # if a_bit(data[1], i + 1) == 1:
  1038. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 33, data[0] + 1).widget(), QtGui.QColor(Qt.red))
  1039. # else:
  1040. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 33, data[0] + 1).widget(), QtGui.QColor(Qt.white))
  1041. # if a_bit(data[2], i + 1) == 1:
  1042. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 41, data[0] + 1).widget(), QtGui.QColor(Qt.red))
  1043. # else:
  1044. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 41, data[0] + 1).widget(), QtGui.QColor(Qt.white))
  1045. # if a_bit(data[3], i + 1) == 1:
  1046. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 49, data[0] + 1).widget(), QtGui.QColor(Qt.red))
  1047. # else:
  1048. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 49, data[0] + 1).widget(), QtGui.QColor(Qt.white))
  1049. # if a_bit(data[4], i + 1) == 1:
  1050. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 57, data[0] + 1).widget(), QtGui.QColor(Qt.red))
  1051. # else:
  1052. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 57, data[0] + 1).widget(), QtGui.QColor(Qt.white))
  1053. # if a_bit(data[5], i + 1) == 1:
  1054. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 65, data[0] + 1).widget(), QtGui.QColor(Qt.red))
  1055. # else:
  1056. # set_edt_bg(self.bms_balance_ctl._view.line_qscrollarea_layout.itemAtPosition(i + 65, data[0] + 1).widget(), QtGui.QColor(Qt.white))
  1057. def _inf_001E_signal(self, data):
  1058. return
  1059. def _inf_001F_signal(self, data):
  1060. return
  1061. def _inf_0020_signal(self, data):
  1062. # BMS 电池编码
  1063. self.bms_sn_version[0] = chr(data[0])
  1064. self.bms_sn_version[1] = chr(data[1])
  1065. self.bms_sn_version[2] = chr(data[2])
  1066. self.bms_sn_version[3] = chr(data[3])
  1067. self.bms_sn_version[4] = chr(data[4])
  1068. self.bms_sn_version[5] = chr(data[5])
  1069. self.bms_sn_version[6] = chr(data[6])
  1070. self.bms_sn_version[7] = chr(data[7])
  1071. def _inf_0021_signal(self, data):
  1072. self.bms_sn_version[8] = chr(data[0])
  1073. self.bms_sn_version[9] = chr(data[1])
  1074. self.bms_sn_version[10] = chr(data[2])
  1075. self.bms_sn_version[11] = chr(data[3])
  1076. self.bms_sn_version[12] = chr(data[4])
  1077. self.bms_sn_version[13] = chr(data[5])
  1078. self.bms_sn_version[14] = chr(data[6])
  1079. self.bms_sn_version[15] = chr(data[7])
  1080. bms_sn_version = ''.join(self.bms_sn_version)
  1081. self.bms_download_ctl._view.message_table.item(4, 2).setText(bms_sn_version)
  1082. def _inf_0022_signal(self, data):
  1083. # BMS 电池编码
  1084. self.battery_sn_version[0] = chr(data[0])
  1085. self.battery_sn_version[1] = chr(data[1])
  1086. self.battery_sn_version[2] = chr(data[2])
  1087. self.battery_sn_version[3] = chr(data[3])
  1088. self.battery_sn_version[4] = chr(data[4])
  1089. self.battery_sn_version[5] = chr(data[5])
  1090. self.battery_sn_version[6] = chr(data[6])
  1091. self.battery_sn_version[7] = chr(data[7])
  1092. def _inf_0023_signal(self, data):
  1093. self.battery_sn_version[8] = chr(data[0])
  1094. self.battery_sn_version[9] = chr(data[1])
  1095. self.battery_sn_version[10] = chr(data[2])
  1096. self.battery_sn_version[11] = chr(data[3])
  1097. self.battery_sn_version[12] = chr(data[4])
  1098. self.battery_sn_version[13] = chr(data[5])
  1099. self.battery_sn_version[14] = chr(data[6])
  1100. self.battery_sn_version[15] = chr(data[7])
  1101. battery_sn_version = ''.join(self.battery_sn_version)
  1102. self.bms_download_ctl._view.message_table.item(5, 2).setText(battery_sn_version)
  1103. self.bms_status._view.lb_bms_sn.setText("BATSN:" + battery_sn_version)
  1104. dataTime = QDateTime.currentDateTime()
  1105. text = dataTime.toString("yyyy-MM-dd HH:mm:ss")
  1106. self._model.now_time = text
  1107. def run(self):
  1108. self._view.show()