bms_home_ctl.py 85 KB

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