bms_home_ctl.py 75 KB

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