bms_work.py 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. def __init__(self):
  44. super(BmsReceived, self).__init__()
  45. self.dantidianya = [0 for i in range(10000)]
  46. self.dantiwendu = [0 for i in range(10000)]
  47. self.masterVersion = ["" for i in range(18)]
  48. self.fram_param = ["" for i in range(24)]
  49. self.single_low_vol_x = ""
  50. self.single_high_temp_x = ""
  51. # 接收数据
  52. def received(self):
  53. while SD.CAN_ON_OFF:
  54. result = SD.CAN_CONTROL.receive()
  55. if (result[1]):
  56. # ID主机号识别
  57. if result[1] & 0xFFFF == 1:
  58. self.to_show_masterid_signal.emit((result[1] >> 16) & 0xFF)
  59. # 0001
  60. if (result[1] ^ 0x18000000) & 0xFFFF == 0:
  61. self.to_show_0000_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  62. # 0001
  63. if (result[1] ^ 0x18000001) & 0xFFFF == 0:
  64. self.to_show_0001_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  65. # 0002
  66. elif (result[1] ^ 0x18000002) & 0xFFFF == 0:
  67. self.to_show_0002_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  68. # 0003
  69. elif (result[1] ^ 0x18000003) & 0xFFFF == 0:
  70. self.to_show_0003_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  71. # 0004
  72. elif (result[1] ^ 0x18000004) & 0xFFFF == 0:
  73. self.to_show_0004_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  74. # 0005
  75. elif (result[1] ^ 0x18000005) & 0xFFFF == 0:
  76. self.to_show_0005_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  77. # 0006
  78. elif (result[1] ^ 0x18000006) & 0xFFFF == 0:
  79. self.to_show_0006_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  80. # 0007
  81. elif (result[1] ^ 0x18000007) & 0xFFFF == 0:
  82. self.to_show_0007_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  83. # 0008
  84. elif (result[1] ^ 0x18000008) & 0xFFFF == 0:
  85. self.to_show_0008_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  86. # 0009
  87. elif (result[1] ^ 0x18000009) & 0xFFFF == 0:
  88. self.to_show_0009_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  89. # 000A
  90. elif (result[1] ^ 0x1800000A) & 0xFFFF == 0:
  91. self.to_show_000A_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  92. # 000B
  93. elif (result[1] ^ 0x1800000B) & 0xFFFF == 0:
  94. self.to_show_000B_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  95. # 000C
  96. elif (result[1] ^ 0x1800000C) & 0xFFFF == 0:
  97. self.to_show_000C_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  98. # 000D
  99. elif (result[1] ^ 0x1800000D) & 0xFFFF == 0:
  100. self.to_show_000D_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  101. # 000E
  102. elif (result[1] ^ 0x1800000E) & 0xFFFF == 0:
  103. self.to_show_000E_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  104. # 000F
  105. elif (result[1] ^ 0x1800000F) & 0xFFFF == 0:
  106. self.to_show_000F_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  107. # 0010
  108. elif (result[1] ^ 0x18000010) & 0xFFFF == 0:
  109. self.to_show_0010_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  110. # 0011
  111. elif (result[1] ^ 0x18000011) & 0xFFFF == 0:
  112. self.to_show_0011_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  113. # 0012
  114. elif (result[1] ^ 0x18000012) & 0xFFFF == 0:
  115. self.to_show_0012_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  116. # 0013
  117. elif (result[1] ^ 0x18000013) & 0xFFFF == 0:
  118. self.to_show_0013_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  119. # 0014
  120. elif (result[1] ^ 0x18000014) & 0xFFFF == 0:
  121. self.to_show_0014_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  122. # 0015
  123. elif (result[1] ^ 0x18000015) & 0xFFFF == 0:
  124. self.to_show_0015_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  125. # 0016
  126. elif (result[1] ^ 0x18000016) & 0xFFFF == 0:
  127. self.to_show_0016_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  128. # 0017
  129. elif (result[1] ^ 0x18000017) & 0xFFFF == 0:
  130. self.to_show_0017_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  131. # 0018
  132. elif (result[1] ^ 0x18000018) & 0xFFFF == 0:
  133. self.to_show_0018_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  134. # 0019
  135. elif (result[1] ^ 0x18000019) & 0xFFFF == 0:
  136. self.to_show_0019_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  137. # 001A
  138. elif (result[1] ^ 0x1800001A) & 0xFFFF == 0:
  139. self.to_show_001A_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  140. # 001B
  141. elif (result[1] ^ 0x1800001B) & 0xFFFF == 0:
  142. self.to_show_001B_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  143. # 001C
  144. elif (result[1] ^ 0x1800001C) & 0xFFFF == 0:
  145. self.to_show_001C_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  146. # 001D
  147. elif (result[1] ^ 0x1800001D) & 0xFFFF == 0:
  148. self.to_show_001D_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  149. # 001E
  150. elif (result[1] ^ 0x1800001E) & 0xFFFF == 0:
  151. self.to_show_001E_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  152. # 001F
  153. elif (result[1] ^ 0x1800001F) & 0xFFFF == 0:
  154. self.to_show_001F_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  155. # 0020
  156. elif (result[1] ^ 0x18000020) & 0xFFFF == 0:
  157. self.to_show_0020_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  158. # 0021
  159. elif (result[1] ^ 0x18000021) & 0xFFFF == 0:
  160. self.to_show_0021_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  161. # 0022
  162. elif (result[1] ^ 0x18000022) & 0xFFFF == 0:
  163. self.to_show_0022_signal.emit(result[2], (result[1] >> 16) & 0xFF)
  164. # 0023
  165. elif (result[1] ^ 0x18000023) & 0xFFFF == 0:
  166. self.to_show_0023_signal.emit(result[2], (result[1] >> 16) & 0xFF)