bms_home.py 5.1 KB

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