bms_home_ctl.py 84 KB

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