bms_work.py 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #!/usr/bin/env python
  2. # -*- encoding: utf-8 -*-
  3. from utils.globalvar import SD
  4. from utils.qt import QObject, Signal
  5. class BmsReceived(QObject):
  6. to_show_masterid_signal = Signal(int)
  7. to_show_0000_signal = Signal(object, int)
  8. to_show_0001_signal = Signal(object, int)
  9. to_show_0002_signal = Signal(object, int)
  10. to_show_0003_signal = Signal(object, int)
  11. to_show_0004_signal = Signal(object, int)
  12. to_show_0005_signal = Signal(object, int)
  13. to_show_0006_signal = Signal(object, int)
  14. to_show_0007_signal = Signal(object, int)
  15. to_show_0008_signal = Signal(object, int)
  16. to_show_0009_signal = Signal(object, int)
  17. to_show_000A_signal = Signal(object, int)
  18. to_show_000B_signal = Signal(object, int)
  19. to_show_000C_signal = Signal(object, int)
  20. to_show_000D_signal = Signal(object, int)
  21. to_show_000E_signal = Signal(object, int)
  22. to_show_000F_signal = Signal(object, int)
  23. to_show_0010_signal = Signal(object, int)
  24. to_show_0011_signal = Signal(object, int)
  25. to_show_0012_signal = Signal(object, int)
  26. to_show_0013_signal = Signal(object, int)
  27. to_show_0014_signal = Signal(object, int)
  28. to_show_0015_signal = Signal(object, int)
  29. to_show_0016_signal = Signal(object, int)
  30. to_show_0017_signal = Signal(object, int)
  31. to_show_0018_signal = Signal(object, int)
  32. to_show_0019_signal = Signal(object, int)
  33. to_show_001A_signal = Signal(object, int)
  34. to_show_001B_signal = Signal(object, int)
  35. to_show_001C_signal = Signal(object, int)
  36. to_show_001D_signal = Signal(object, int)
  37. to_show_001E_signal = Signal(object, int)
  38. to_show_001F_signal = Signal(object, int)
  39. to_show_0020_signal = Signal(object, int)
  40. to_show_0021_signal = Signal(object, int)
  41. to_show_0022_signal = Signal(object, int)
  42. to_show_0023_signal = Signal(object, int)
  43. to_show_1802_signal = Signal(object, int)
  44. to_show_1803_signal = Signal(object, int)
  45. def __init__(self):
  46. super(BmsReceived, self).__init__()
  47. self.dantidianya = [0 for i in range(10000)]
  48. self.dantiwendu = [0 for i in range(10000)]
  49. self.masterVersion = ["" for i in range(18)]
  50. self.fram_param = ["" for i in range(24)]
  51. self.single_low_vol_x = ""
  52. self.single_high_temp_x = ""
  53. # 接收数据
  54. def received(self):
  55. while SD.CAN_ON_OFF:
  56. result = SD.CAN_CONTROL.receive()
  57. if (result[1]):
  58. # ID主机号识别
  59. if result[1] & 0xFFFF == 1:
  60. self.to_show_masterid_signal.emit((result[1] >> 16) & 0xFF)
  61. # 0001
  62. if (result[1] ^ 0x18000000) & 0xFFFF == 0:
  63. self.to_show_0000_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  64. # 0001
  65. if (result[1] ^ 0x18000001) & 0xFFFF == 0:
  66. self.to_show_0001_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  67. # 0002
  68. elif (result[1] ^ 0x18000002) & 0xFFFF == 0:
  69. self.to_show_0002_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  70. # 0003
  71. elif (result[1] ^ 0x18000003) & 0xFFFF == 0:
  72. self.to_show_0003_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  73. # 0004
  74. elif (result[1] ^ 0x18000004) & 0xFFFF == 0:
  75. self.to_show_0004_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  76. # 0005
  77. elif (result[1] ^ 0x18000005) & 0xFFFF == 0:
  78. self.to_show_0005_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  79. # 0006
  80. elif (result[1] ^ 0x18000006) & 0xFFFF == 0:
  81. self.to_show_0006_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  82. # 0007
  83. elif (result[1] ^ 0x18000007) & 0xFFFF == 0:
  84. self.to_show_0007_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  85. # 0008
  86. elif (result[1] ^ 0x18000008) & 0xFFFF == 0:
  87. self.to_show_0008_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  88. # 0009
  89. elif (result[1] ^ 0x18000009) & 0xFFFF == 0:
  90. self.to_show_0009_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  91. # 000A
  92. elif (result[1] ^ 0x1800000A) & 0xFFFF == 0:
  93. self.to_show_000A_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  94. # 000B
  95. elif (result[1] ^ 0x1800000B) & 0xFFFF == 0:
  96. self.to_show_000B_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  97. # 000C
  98. elif (result[1] ^ 0x1800000C) & 0xFFFF == 0:
  99. self.to_show_000C_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  100. # 000D
  101. elif (result[1] ^ 0x1800000D) & 0xFFFF == 0:
  102. self.to_show_000D_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  103. # 000E
  104. elif (result[1] ^ 0x1800000E) & 0xFFFF == 0:
  105. self.to_show_000E_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  106. # 000F
  107. elif (result[1] ^ 0x1800000F) & 0xFFFF == 0:
  108. self.to_show_000F_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  109. # 0010
  110. elif (result[1] ^ 0x18000010) & 0xFFFF == 0:
  111. self.to_show_0010_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  112. # 0011
  113. elif (result[1] ^ 0x18000011) & 0xFFFF == 0:
  114. self.to_show_0011_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  115. # 0012
  116. elif (result[1] ^ 0x18000012) & 0xFFFF == 0:
  117. self.to_show_0012_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  118. # 0013
  119. elif (result[1] ^ 0x18000013) & 0xFFFF == 0:
  120. self.to_show_0013_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  121. # 0014
  122. elif (result[1] ^ 0x18000014) & 0xFFFF == 0:
  123. self.to_show_0014_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  124. # 0015
  125. elif (result[1] ^ 0x18000015) & 0xFFFF == 0:
  126. self.to_show_0015_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  127. # 0016
  128. elif (result[1] ^ 0x18000016) & 0xFFFF == 0:
  129. self.to_show_0016_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  130. # 0017
  131. elif (result[1] ^ 0x18000017) & 0xFFFF == 0:
  132. self.to_show_0017_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  133. # 0018
  134. elif (result[1] ^ 0x18000018) & 0xFFFF == 0:
  135. self.to_show_0018_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  136. # 0019
  137. elif (result[1] ^ 0x18000019) & 0xFFFF == 0:
  138. self.to_show_0019_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  139. # 001A
  140. elif (result[1] ^ 0x1800001A) & 0xFFFF == 0:
  141. self.to_show_001A_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  142. # 001B
  143. elif (result[1] ^ 0x1800001B) & 0xFFFF == 0:
  144. self.to_show_001B_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  145. # 001C
  146. elif (result[1] ^ 0x1800001C) & 0xFFFF == 0:
  147. self.to_show_001C_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  148. # 001D
  149. elif (result[1] ^ 0x1800001D) & 0xFFFF == 0:
  150. self.to_show_001D_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  151. # 001E
  152. elif (result[1] ^ 0x1800001E) & 0xFFFF == 0:
  153. self.to_show_001E_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  154. # 001F
  155. elif (result[1] ^ 0x1800001F) & 0xFFFF == 0:
  156. self.to_show_001F_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  157. # 0020
  158. elif (result[1] ^ 0x18000020) & 0xFFFF == 0:
  159. self.to_show_0020_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  160. # 0021
  161. elif (result[1] ^ 0x18000021) & 0xFFFF == 0:
  162. self.to_show_0021_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  163. # 0022
  164. elif (result[1] ^ 0x18000022) & 0xFFFF == 0:
  165. self.to_show_0022_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  166. # 0023
  167. elif (result[1] ^ 0x18000023) & 0xFFFF == 0:
  168. self.to_show_0023_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  169. # 1802
  170. elif (result[1] ^ 0x18001802) & 0xFFFF == 0:
  171. self.to_show_1802_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  172. # 1803
  173. elif (result[1] ^ 0x18001803) & 0xFFFF == 0:
  174. self.to_show_1803_signal.emit(result[2], (result[1] >> 16) & 0xFF)