bms_home_ctl.py 82 KB

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