bms_home_ctl.py 81 KB

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