bms_home_ctl.py 84 KB

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