bms_home.py 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. '''
  4. @文件 :bms_home.py
  5. @时间 :2021/12/09 13:33:56
  6. @作者 :None
  7. @版本 :1.0
  8. @说明 :主页面逻辑
  9. '''
  10. from utils.globalvar import SD
  11. from ui.home import UiBmsHomePage
  12. from utils.qt import QMainWindow, Qt, QStyle, QMessageBox, QGuiApplication, Signal
  13. class Win_GotionBMS(UiBmsHomePage, QMainWindow):
  14. main_control_signal = Signal(int)
  15. cell_inf_signal = Signal(int)
  16. double_ccu_signal = Signal(int)
  17. protect_inf_signal = Signal(int)
  18. hard_cali_signal = Signal(int)
  19. balance_inf_signal = Signal(int)
  20. data_inf_signal = Signal(int)
  21. download_signal = Signal(int)
  22. set_inf_signal = Signal(int)
  23. bcu_online_list_signal = Signal(list)
  24. can_start_signal = Signal()
  25. can_stop_signal = Signal()
  26. cut_start_signal = Signal()
  27. def __init__(self, parent=None):
  28. super(Win_GotionBMS, self).__init__(parent)
  29. self.setupUi(self)
  30. self.btn_main_control.clicked.connect(self._main_control)
  31. self.btn_cell_inf.clicked.connect(self._cell_inf)
  32. self.btn_double_ccu.clicked.connect(self._double_ccu)
  33. self.btn_protect_inf.clicked.connect(self._protect_inf)
  34. self.btn_hard_cali.clicked.connect(self._hard_cali)
  35. self.btn_balance_inf.clicked.connect(self._balance_inf)
  36. self.btn_data_inf.clicked.connect(self._data_inf)
  37. self.btn_download.clicked.connect(self._download)
  38. self.btn_set_inf.clicked.connect(self._set_inf)
  39. self.btn_start.clicked.connect(self._can_start)
  40. self.btn_stop.clicked.connect(self._can_stop)
  41. self.btn_cut.clicked.connect(self._app_cut)
  42. self.cb_bcu.currentIndexChanged.connect(self._bcu_masterid_set)
  43. self.cb_bmu.currentIndexChanged.connect(self._bmu_id_set)
  44. def can_connect_error(self):
  45. QMessageBox.critical(self, "连接状态" if SD.SYSTEM_LANGUAGE == 0 else "Connect State", "CAN 连接失败!" if SD.SYSTEM_LANGUAGE == 0 else "CAN Connect Error!")
  46. def _main_control(self):
  47. self.main_control_signal.emit(0)
  48. def _cell_inf(self):
  49. self.cell_inf_signal.emit(1)
  50. def _double_ccu(self):
  51. self.double_ccu_signal.emit(2)
  52. def _protect_inf(self):
  53. self.protect_inf_signal.emit(3)
  54. def _hard_cali(self):
  55. self.hard_cali_signal.emit(4)
  56. def _balance_inf(self):
  57. self.balance_inf_signal.emit(5)
  58. def _data_inf(self):
  59. self.data_inf_signal.emit(6)
  60. def _download(self):
  61. self.download_signal.emit(7)
  62. def _set_inf(self):
  63. self.set_inf_signal.emit(8)
  64. def _can_start(self):
  65. self.can_start_signal.emit()
  66. def _can_stop(self):
  67. self.can_stop_signal.emit()
  68. def _app_cut(self):
  69. self.cut_start_signal.emit()
  70. def _bcu_masterid_set(self):
  71. SD.BCU_ID = int(self.cb_bcu.currentIndex() + 1)
  72. def _bmu_id_set(self):
  73. int(self.cb_bmu.currentIndex() + 1)
  74. def _bcu_connect_get(self, data):
  75. bcu_on_line = ["BCU1", "BCU2", "BCU3", "BCU4", "BCU5", "BCU6", "BCU7", "BCU8", "BCU9", "BCU10", "BCU11", "BCU12", "BCU13", "BCU14", "BCU15"]
  76. bcu_on_line_set = []
  77. if data[0] == 1:
  78. bcu_on_line[0] = "BCU1"
  79. else:
  80. bcu_on_line[0] = ""
  81. if data[1] == 1:
  82. bcu_on_line[1] = "BCU2"
  83. else:
  84. bcu_on_line[1] = ""
  85. if data[2] == 1:
  86. bcu_on_line[2] = "BCU3"
  87. else:
  88. bcu_on_line[2] = ""
  89. if data[3] == 1:
  90. bcu_on_line[3] = "BCU4"
  91. else:
  92. bcu_on_line[3] = ""
  93. if data[4] == 1:
  94. bcu_on_line[4] = "BCU5"
  95. else:
  96. bcu_on_line[4] = ""
  97. if data[5] == 1:
  98. bcu_on_line[5] = "BCU6"
  99. else:
  100. bcu_on_line[5] = ""
  101. if data[6] == 1:
  102. bcu_on_line[6] = "BCU7"
  103. else:
  104. bcu_on_line[6] = ""
  105. if data[7] == 1:
  106. bcu_on_line[7] = "BCU8"
  107. else:
  108. bcu_on_line[7] = ""
  109. if data[8] == 1:
  110. bcu_on_line[8] = "BCU9"
  111. else:
  112. bcu_on_line[8] = ""
  113. if data[9] == 1:
  114. bcu_on_line[9] = "BCU10"
  115. else:
  116. bcu_on_line[9] = ""
  117. if data[10] == 1:
  118. bcu_on_line[10] = "BCU11"
  119. else:
  120. bcu_on_line[10] = ""
  121. if data[11] == 1:
  122. bcu_on_line[11] = "BCU12"
  123. else:
  124. bcu_on_line[11] = ""
  125. if data[12] == 1:
  126. bcu_on_line[12] = "BCU13"
  127. else:
  128. bcu_on_line[12] = ""
  129. if data[13] == 1:
  130. bcu_on_line[13] = "BCU14"
  131. else:
  132. bcu_on_line[13] = ""
  133. if data[14] == 1:
  134. bcu_on_line[14] = "BCU15"
  135. else:
  136. bcu_on_line[14] = ""
  137. for a in list(bcu_on_line):
  138. if a != "":
  139. bcu_on_line_set.append(a)
  140. self.edt_online.setText('、'.join([i for i in list(bcu_on_line_set)]))
  141. # 居中显示
  142. def center(self):
  143. # 新方法
  144. self.setGeometry(
  145. QStyle.alignedRect(
  146. Qt.LeftToRight,
  147. Qt.AlignCenter,
  148. self.size(),
  149. QGuiApplication.primaryScreen().availableGeometry(),
  150. ),
  151. )