window_screen_pyqt.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. import datetime
  2. import threading
  3. from PyQt5.QtWidgets import QWidget, QApplication, QMainWindow, QLabel
  4. from PyQt5.QtGui import QPixmap, QPainter, QResizeEvent, QCloseEvent, QPaintEvent, QFont, QColor
  5. from PyQt5.QtCore import QSize, QTimer, QRect, Qt
  6. import async_communication as CM
  7. import message_pb2 as message
  8. import google.protobuf.text_format as tf
  9. import logging
  10. logging.basicConfig(filename='log.txt',
  11. format='%(asctime)s - %(name)s - %(levelname)s - %(message)s-%(funcName)s',
  12. level=logging.ERROR)
  13. MeasureStatu = {"ok": 0, "无数据": 1, "噪声": 2, "超界": 3, "故障": 4, "失去连接": 5}
  14. ArrowType = {message.Range_status.Value('Range_correct'): "正确图片",
  15. message.Range_status.Value('Range_front'): "向后调整",
  16. message.Range_status.Value('Range_back'): "向前调整",
  17. message.Range_status.Value('Range_left'): "向右调整",
  18. message.Range_status.Value('Range_right'): "向左调整",
  19. message.Range_status.Value('Range_car_width'): "超宽车辆",
  20. message.Range_status.Value('Range_car_wheelbase'): "轴距超差",
  21. message.Range_status.Value('Range_angle_anti_clock'): "向右旋转",
  22. message.Range_status.Value('Range_angle_clock'): "向左旋转",
  23. message.Range_status.Value('Range_steering_wheel_nozero'): "回正方向盘",
  24. }
  25. class PicLabel(QLabel):
  26. def __init__(self, parent):
  27. super(PicLabel, self).__init__(parent=parent)
  28. self.image = None
  29. self.Txt = None
  30. self.show = False
  31. self.setStyleSheet("border-width:1px;border-style:solid;border-color:rgb(150,150,150)")
  32. self.timer = QTimer()
  33. self.timer.timeout.connect(self.OnTimer)
  34. def FlashImg(self, pixmap):
  35. self.image = pixmap
  36. if self.timer.isActive() == False:
  37. self.timer.start(500)
  38. def ShowImg(self, pixmap):
  39. self.timer.stop()
  40. self.show = True
  41. self.Txt = None
  42. self.image = pixmap
  43. self.repaint()
  44. def ShowTxt(self, txt):
  45. self.timer.stop()
  46. self.show = True
  47. self.image = None
  48. self.Txt = txt
  49. self.repaint()
  50. def OnTimer(self):
  51. self.show = not self.show
  52. self.repaint()
  53. def paintEvent(self, a0: QPaintEvent) -> None:
  54. if self.show is True:
  55. if self.image is not None:
  56. w, h = self.size().width(), self.size().height()
  57. iw, ih = self.image.width(), self.image.height()
  58. painter = QPainter(self)
  59. painter.drawPixmap(QRect(0, 0, w, h), self.image, QRect(0, 0, iw, ih))
  60. elif self.Txt is not None:
  61. w, h = self.size().width() / len(self.Txt), self.size().height() / 1.5
  62. painter = QPainter(self)
  63. painter.setPen(QColor(255, 0, 0))
  64. painter.setFont(QFont('SimSun', int(min(w, h)),QFont.Bold))
  65. # print(self.Txt)
  66. painter.drawText(a0.rect(), Qt.AlignCenter, self.Txt)
  67. class Frame(QMainWindow):
  68. def __init__(self, import_id, images, prj_parameter, second_screen=False):
  69. super(Frame, self).__init__()
  70. self.flag = None
  71. self.last_back_io = None
  72. self.images = images
  73. self.images = {}
  74. self.import_id = import_id
  75. self.dispatch_statu = CM.TimeStatu(timeout=0.1)
  76. self.measure_statu = CM.TimeStatu(timeout=0.1)
  77. self.terminal_statu = CM.TimeStatu(timeout=0.1)
  78. for key, file in images.items():
  79. self.images[key] = pix = QPixmap(file)
  80. self.InitUI()
  81. # self.last_door_statu=None
  82. self.last_moving_statu = None
  83. # self.last_show = None
  84. # self.last_back_io = "正常"
  85. # self.flag = None
  86. if second_screen == True:
  87. desktop = QApplication.desktop()
  88. screen_count = desktop.screenCount()
  89. displays = [desktop.availableGeometry(i) for i in range(desktop.screenCount())]
  90. second_offx = 0
  91. second_offy = 0
  92. if len(displays) == 2:
  93. second_offx = displays[1].width()
  94. second_offy = displays[1].height()
  95. self.setGeometry(second_offx, second_offy, 200, 500)
  96. self.timer = QTimer()
  97. self.timer.timeout.connect(self.Switch)
  98. self.timer.start(200)
  99. self.lock = threading.Lock()
  100. def InitUI(self):
  101. self.measure_info_txt = QLabel(self)
  102. self.car_number_txt = QLabel(self)
  103. self.car_number_txt.setStyleSheet("border-width:1px;border-style:solid;border-color:rgb(150,150,150)")
  104. self.car_number_txt.setAlignment(Qt.AlignCenter)
  105. self.measure_info_txt.setStyleSheet("color:blue")
  106. self.panel_txt = PicLabel(self)
  107. self.panel_arrow = PicLabel(self)
  108. def receive_dispatch(self, statu):
  109. self.dispatch_statu = statu
  110. def receive_measureInfo(self, statu):
  111. self.measure_statu = statu
  112. def receive_terminal(self, statu):
  113. self.terminal_statu = statu
  114. def receive_entrance_update(self,statu):
  115. with self.lock:
  116. print("---------------刷新投影-----------------")
  117. self.last_moving_statu = None
  118. def resizeEvent(self, a0: QResizeEvent) -> None:
  119. w, h = a0.size().width(), a0.size().height()
  120. w, h = self.size().width(), self.size().height()
  121. top_w, top_h = w, int(h * 0.15)
  122. car_number_w, car_number_h = w, int(h * 0.10)
  123. txt_w, txt_h = w, int(h * 0.20)
  124. arrow_w, arrow_h = w, int(h * 0.55)
  125. font = QFont()
  126. font.setBold(True)
  127. font.setPixelSize(int(w / 40))
  128. self.measure_info_txt.setFont(font)
  129. self.measure_info_txt.setGeometry(0, 0, top_w, top_h)
  130. font.setPixelSize(int(w / 20))
  131. self.car_number_txt.setFont(font)
  132. self.car_number_txt.setGeometry(0, top_h, car_number_w, car_number_h)
  133. self.panel_txt.setGeometry(0, top_h + car_number_h, txt_w, txt_h)
  134. self.panel_arrow.setGeometry(0, top_h + car_number_h + txt_h, arrow_w, arrow_h)
  135. def Switch(self):
  136. try:
  137. if self.terminal_statu.timeout() is False:
  138. terminal_statu = message.terminal_node_statu()
  139. tf.Parse(self.terminal_statu.statu, terminal_statu)
  140. self.car_number_txt.setText(terminal_statu.car_number)
  141. self.car_number_txt.setStyleSheet(
  142. "border-width:1px;border-style:solid;border-color:rgb(150,150,150);color:green")
  143. else:
  144. self.car_number_txt.setText("车牌号为空!")
  145. self.car_number_txt.setStyleSheet(
  146. "border-width:1px;border-style:solid;border-color:rgb(150,150,150);color:red")
  147. # 先判断连接状态
  148. if self.dispatch_statu.timeout():
  149. self.panel_txt.ShowImg(self.images['传感器超时'])
  150. self.panel_arrow.FlashImg(self.images['传感器超时'])
  151. return
  152. if self.measure_statu.timeout():
  153. self.panel_txt.ShowImg(self.images['测绘超时'])
  154. self.panel_arrow.FlashImg(self.images['测绘超时'])
  155. return
  156. # 有车才显示
  157. dispatch_statu = message.dispatch_node_statu()
  158. tf.Parse(self.dispatch_statu.statu, dispatch_statu)
  159. measure_buffer = message.measure_buffer()
  160. measure_info = message.measure_info()
  161. tf.Parse(self.measure_statu.statu, measure_buffer)
  162. measure_info.CopyFrom(measure_buffer.measure_info_to_terminal)
  163. # 测量状态
  164. lidar_statu = measure_info.ground_status # 测量状态(正常,无数据、噪声、超界)
  165. # 传感器状态
  166. dispatch_plc_passway_status = dispatch_statu.dispatch_plc_passway_status_vector[self.import_id - 1]
  167. sensor_1 = dispatch_plc_passway_status.sensor_1
  168. if lidar_statu == MeasureStatu['故障']:
  169. self.panel_txt.ShowImg(self.images['测绘超时'])
  170. self.panel_arrow.FlashImg(self.images['测绘超时'])
  171. return
  172. # 获取传感器数据
  173. # print('---------------------------------')
  174. # print('PLC数据:')
  175. # print(dispatch_plc_passway_status)
  176. # print('----------------------------------')
  177. # print('====================================')
  178. # print('雷达数据:')
  179. # print(measure_info)
  180. # print('====================================')
  181. # 判断超界信息
  182. if (sensor_1 >> 3) & 0x01 == 0:
  183. if not self.last_back_io == "超界":
  184. self.last_back_io = "超界"
  185. self.flag = False
  186. else:
  187. if not self.last_back_io == "正常":
  188. self.last_back_io = "正常"
  189. self.flag = True
  190. # if dispatch_plc_passway_status.car_height == 0:
  191. # self.panel_txt.ShowImg(self.images["空闲"])
  192. # self.panel_arrow.ShowImg(self.images["空闲"])
  193. # return
  194. if dispatch_plc_passway_status.car_height == 4:
  195. self.panel_txt.ShowImg(self.images["超高车辆"])
  196. self.panel_arrow.ShowImg(self.images["超高车辆"])
  197. return
  198. # 以下是有车的处理
  199. # 1,显示测量数据(实时和静态)
  200. static_info_txt = ''
  201. realtime_info_txt = "(实时) 中心(%.3f,%.3f) 角度:%.2f° 宽:%.3f 轴距:%.3f 前轮角:%.2f°" % \
  202. (measure_info.cx, measure_info.cy, measure_info.theta, measure_info.width,
  203. measure_info.wheelbase, measure_info.front_theta)
  204. if not self.last_moving_statu == None:
  205. static_info_txt = "(静止) 中心(%.3f,%.3f) 角度:%.2f° 宽:%.3f 轴距:%.3f 前轮角:%.2f°" % \
  206. (self.last_moving_statu.cx, self.last_moving_statu.cy,
  207. self.last_moving_statu.theta, self.last_moving_statu.width,
  208. self.last_moving_statu.wheelbase, self.last_moving_statu.front_theta)
  209. self.measure_info_txt.setText(realtime_info_txt + "\n" + static_info_txt)
  210. # 2,获取车辆运动状态(静止or动态)
  211. border_statu = measure_info.border_statu
  212. is_moving = measure_info.motion_statu == 0
  213. print(is_moving)
  214. # 当前运动
  215. if is_moving:
  216. with self.lock:
  217. self.last_moving_statu = None
  218. else:
  219. # 当前静止
  220. if lidar_statu == MeasureStatu["ok"]:
  221. with self.lock:
  222. self.last_moving_statu = measure_info
  223. elif lidar_statu == MeasureStatu["超界"]:
  224. if not self.last_moving_statu == None:
  225. # 上一刻静止且数据正确,当前静止,不可能出现超界,将超界清除
  226. new_border = border_statu
  227. new_border = (new_border & (~(0x01 << 0)))
  228. new_border = (new_border & (~(0x01 << 1)))
  229. new_border = (new_border & (~(0x01 << 2)))
  230. new_border = (new_border & (~(0x01 << 3)))
  231. new_border = (new_border & (~(0x01 << 6)))
  232. new_border = (new_border & (~(0x01 << 7)))
  233. new_border = (new_border & (~(0x01 << 8)))
  234. new_border = (new_border & (~(0x01 << 9)))
  235. border_statu = new_border
  236. elif lidar_statu == MeasureStatu["无数据"]:
  237. # 当前静止无车,清除上一时刻数据
  238. with self.lock:
  239. self.last_moving_statu = None
  240. # elif lidar_statu == MeasureStatu["噪声"]:
  241. # if not self.last_moving_statu == None:
  242. # 上一时刻静止且正确,当前噪声,不显示当前数据,显示上一正确数据
  243. # measure_info.CopyFrom(self.last_moving_statu)
  244. # print((sensor_1 >> 4) & 0x01)
  245. # 先判断光电
  246. if (sensor_1 >> 3) & 0x01 == 0:
  247. self.panel_txt.ShowImg(self.images["请调整"])
  248. self.panel_arrow.FlashImg(self.images["向前调整"])
  249. self.last_show = "调整"
  250. return
  251. elif (sensor_1 >> 4) & 0x01 == 0:
  252. self.panel_txt.ShowImg(self.images["请调整"])
  253. self.panel_arrow.FlashImg(self.images["向后调整"])
  254. self.last_show = "调整"
  255. # print(111)
  256. return
  257. # elif (sensor_1 >> 5) & 0x01 == 0:
  258. # self.panel_txt.ShowImg(self.images["请调整"])
  259. # self.panel_arrow.FlashImg(self.images["向右调整"])
  260. # self.last_show = "调整"
  261. # return
  262. # elif (sensor_1 >> 6) & 0x01 == 0:
  263. # self.panel_txt.ShowImg(self.images["请调整"])
  264. # self.panel_arrow.FlashImg(self.images["向左调整"])
  265. # self.last_show = "调整"
  266. # return
  267. lidar_statu = measure_info.ground_status # 测量状态(正常,无数据、噪声、超界)
  268. # 光电正常
  269. if lidar_statu == MeasureStatu["无数据"]:
  270. self.panel_txt.ShowImg(self.images["空闲"])
  271. self.panel_arrow.ShowImg(self.images["空闲"])
  272. return
  273. elif lidar_statu == MeasureStatu["失去连接"]:
  274. self.panel_txt.ShowImg(self.images['测绘超时'])
  275. self.panel_arrow.FlashImg(self.images['测绘超时'])
  276. return
  277. elif lidar_statu == MeasureStatu["噪声"]:
  278. self.panel_txt.ShowImg(self.images['请调整'])
  279. self.panel_arrow.ShowImg(self.images["请调整"])
  280. return
  281. elif lidar_statu == MeasureStatu["ok"]:
  282. self.panel_txt.ShowImg(self.images['正确文字'])
  283. self.panel_arrow.ShowImg(self.images['正确图片'])
  284. return
  285. # 查看是否超界
  286. elif lidar_statu == MeasureStatu["超界"]:
  287. border = border_statu & 0xf7ff
  288. if (border in ArrowType.keys()) is False:
  289. self.panel_txt.ShowImg(self.images['检查杂物'])
  290. self.panel_arrow.FlashImg(self.images['检查杂物'])
  291. else:
  292. if ArrowType[border] == "正确图片":
  293. self.panel_arrow.ShowImg(self.images[ArrowType[border]])
  294. self.panel_txt.ShowImg(self.images['正确文字'])
  295. elif ArrowType[border] == "向前调整":
  296. if measure_info.move_distance > 0.01:
  297. self.panel_txt.ShowTxt("请向前" + '%.2f'%(measure_info.move_distance * 100) + "厘米")
  298. else:
  299. self.panel_txt.ShowImg(self.images['请调整'])
  300. self.panel_arrow.FlashImg(self.images["向前调整"])
  301. else:
  302. self.panel_arrow.FlashImg(self.images[ArrowType[border]])
  303. self.panel_txt.ShowImg(self.images['请调整'])
  304. except Exception as e:
  305. print(str(e.args))
  306. logging.error(str(e.args))
  307. def Switch1(self):
  308. try:
  309. if self.terminal_statu.timeout() is False:
  310. terminal_statu = message.terminal_node_statu()
  311. tf.Parse(self.terminal_statu.statu, terminal_statu)
  312. # print(terminal_statu.car_number)
  313. self.car_number_txt.setText(terminal_statu.car_number)
  314. self.car_number_txt.setStyleSheet(
  315. "border-width:1px;border-style:solid;border-color:rgb(150,150,150);color:green")
  316. else:
  317. self.car_number_txt.setText("车牌号为空!")
  318. self.car_number_txt.setStyleSheet(
  319. "border-width:1px;border-style:solid;border-color:rgb(150,150,150);color:red")
  320. # 先判断连接状态
  321. if self.dispatch_statu.timeout():
  322. self.panel_txt.ShowImg(self.images['传感器超时'])
  323. self.panel_arrow.FlashImg(self.images['传感器超时'])
  324. return
  325. if self.measure_statu.timeout():
  326. self.panel_txt.ShowImg(self.images['测绘超时'])
  327. self.panel_arrow.FlashImg(self.images['测绘超时'])
  328. return
  329. # 有车才显示
  330. dispatch_statu = message.dispatch_node_statu()
  331. tf.Parse(self.dispatch_statu.statu, dispatch_statu)
  332. measure_buffer = message.measure_buffer()
  333. measure_info = message.measure_info()
  334. tf.Parse(self.measure_statu.statu, measure_buffer)
  335. measure_info.CopyFrom(measure_buffer.measure_info_to_terminal)
  336. # 测量状态
  337. lidar_statu = measure_info.ground_status # 测量状态(正常,无数据、噪声、超界)
  338. # 传感器状态
  339. dispatch_plc_passway_status = dispatch_statu.dispatch_plc_passway_status_vector[self.import_id - 1]
  340. print(dispatch_plc_passway_status.car_height)
  341. sensor_1 = dispatch_plc_passway_status.sensor_1
  342. if lidar_statu == MeasureStatu['故障']:
  343. self.panel_txt.ShowImg(self.images['测绘超时'])
  344. self.panel_arrow.FlashImg(self.images['测绘超时'])
  345. return
  346. # 获取传感器数据
  347. # print('---------------------------------')
  348. # print('PLC数据:')
  349. # print(dispatch_plc_passway_status)
  350. # print('----------------------------------')
  351. # print('====================================')
  352. # print('雷达数据:')
  353. # print(measure_info)
  354. # print('====================================')
  355. # 关门清除上一帧数据
  356. if dispatch_plc_passway_status.outside_door_status == 2:
  357. with self.lock:
  358. self.last_moving_statu = None
  359. # 判断超界信息
  360. if (sensor_1 >> 3) & 0x01 == 0:
  361. if not self.last_back_io == "超界":
  362. self.last_back_io = "超界"
  363. self.flag = False
  364. else:
  365. if not self.last_back_io == "正常":
  366. self.last_back_io = "正常"
  367. self.flag = True
  368. if dispatch_plc_passway_status.car_height == 0:
  369. self.panel_txt.ShowImg(self.images["空闲"])
  370. self.panel_arrow.ShowImg(self.images["空闲"])
  371. return
  372. if dispatch_plc_passway_status.car_height == 4:
  373. self.panel_txt.ShowImg(self.images["超高车辆"])
  374. self.panel_arrow.ShowImg(self.images["超高车辆"])
  375. return
  376. # 以下是有车的处理
  377. # 1,显示测量数据(实时和静态)
  378. realtime_info_txt = ''
  379. static_info_txt = ''
  380. realtime_info_txt = "(实时) 中心(%.3f,%.3f) 角度:%.2f° 宽:%.3f 轴距:%.3f 前轮角:%.2f°" % \
  381. (measure_info.cx, measure_info.cy, measure_info.theta, measure_info.width,
  382. measure_info.wheelbase, measure_info.front_theta)
  383. if not self.last_moving_statu == None:
  384. static_info_txt = "(静止) 中心(%.3f,%.3f) 角度:%.2f° 宽:%.3f 轴距:%.3f 前轮角:%.2f°" % \
  385. (self.last_moving_statu.cx, self.last_moving_statu.cy,
  386. self.last_moving_statu.theta, self.last_moving_statu.width,
  387. self.last_moving_statu.wheelbase, self.last_moving_statu.front_theta)
  388. self.measure_info_txt.setText(realtime_info_txt + "\n" + static_info_txt)
  389. # 2,获取车辆运动状态(静止or动态)
  390. border_statu = measure_info.border_statu
  391. is_moving = measure_info.motion_statu == 0
  392. # 当前运动
  393. if is_moving:
  394. with self.lock:
  395. self.last_moving_statu = None
  396. else:
  397. # 当前静止
  398. if lidar_statu == MeasureStatu["ok"]:
  399. with self.lock:
  400. self.last_moving_statu = measure_info
  401. elif lidar_statu == MeasureStatu["超界"]:
  402. if not self.last_moving_statu == None:
  403. # 上一刻静止且数据正确,当前静止,不可能出现超界,将超界清除
  404. new_border = border_statu
  405. new_border = (new_border & (~(0x01 << 0)))
  406. new_border = (new_border & (~(0x01 << 1)))
  407. new_border = (new_border & (~(0x01 << 2)))
  408. new_border = (new_border & (~(0x01 << 3)))
  409. new_border = (new_border & (~(0x01 << 6)))
  410. new_border = (new_border & (~(0x01 << 7)))
  411. new_border = (new_border & (~(0x01 << 8)))
  412. new_border = (new_border & (~(0x01 << 9)))
  413. border_statu = new_border
  414. elif lidar_statu == MeasureStatu["无数据"]:
  415. # 当前静止无车,清除上一时刻数据
  416. with self.lock:
  417. self.last_moving_statu = None
  418. elif lidar_statu == MeasureStatu["噪声"]:
  419. if not self.last_moving_statu == None:
  420. # 上一时刻静止且正确,当前噪声,不显示当前数据,显示上一正确数据
  421. measure_info.CopyFrom(self.last_moving_statu)
  422. # print((sensor_1 >> 4) & 0x01)
  423. # 先判断光电
  424. if (sensor_1 >> 3) & 0x01 == 0:
  425. self.panel_txt.ShowImg(self.images["请调整"])
  426. self.panel_arrow.FlashImg(self.images["向前调整"])
  427. self.last_show = "调整"
  428. return
  429. elif (sensor_1 >> 4) & 0x01 == 0:
  430. self.panel_txt.ShowImg(self.images["请调整"])
  431. self.panel_arrow.FlashImg(self.images["向后调整"])
  432. self.last_show = "调整"
  433. # print(111)
  434. return
  435. # elif (sensor_1 >> 5) & 0x01 == 0:
  436. # self.panel_txt.ShowImg(self.images["请调整"])
  437. # self.panel_arrow.FlashImg(self.images["向右调整"])
  438. # self.last_show = "调整"
  439. # return
  440. # elif (sensor_1 >> 6) & 0x01 == 0:
  441. # self.panel_txt.ShowImg(self.images["请调整"])
  442. # self.panel_arrow.FlashImg(self.images["向左调整"])
  443. # self.last_show = "调整"
  444. # return
  445. lidar_statu = measure_info.ground_status # 测量状态(正常,无数据、噪声、超界)
  446. # 光电正常
  447. if lidar_statu == MeasureStatu["无数据"]:
  448. self.panel_txt.ShowImg(self.images["空闲"])
  449. self.panel_arrow.ShowImg(self.images["空闲"])
  450. self.last_show = "空闲"
  451. return
  452. elif lidar_statu == MeasureStatu["失去连接"]:
  453. self.panel_txt.ShowImg(self.images['测绘超时'])
  454. self.panel_arrow.FlashImg(self.images['测绘超时'])
  455. self.last_show = "超时"
  456. return
  457. elif lidar_statu == MeasureStatu["噪声"]:
  458. if self.last_moving_statu is None and self.flag is True:
  459. self.panel_txt.ShowImg(self.images['请调整'])
  460. self.panel_arrow.ShowImg(self.images["请调整"])
  461. self.last_show = "请调整"
  462. return
  463. if self.last_show == "超时":
  464. self.panel_txt.ShowImg(self.images["空闲"])
  465. self.panel_arrow.ShowImg(self.images["空闲"])
  466. self.last_show = "空闲"
  467. return
  468. elif lidar_statu == MeasureStatu["ok"]:
  469. self.panel_txt.ShowImg(self.images['正确文字'])
  470. self.panel_arrow.ShowImg(self.images['正确图片'])
  471. return
  472. # 查看是否超界
  473. elif lidar_statu == MeasureStatu["超界"]:
  474. border = border_statu & 0xf7ff
  475. if (border in ArrowType.keys()) is False:
  476. self.panel_txt.ShowImg(self.images['检查杂物'])
  477. self.panel_arrow.FlashImg(self.images['检查杂物'])
  478. self.last_show = "检查杂物"
  479. else:
  480. if ArrowType[border] == "正确图片":
  481. self.panel_arrow.ShowImg(self.images[ArrowType[border]])
  482. self.panel_txt.ShowImg(self.images['正确文字'])
  483. self.last_show = "正确"
  484. elif ArrowType[border] == "向前调整":
  485. if (measure_info.move_distance is not None):
  486. self.panel_txt.ShowTxt("请向前" + '%.2f'%(measure_info.move_distance * 100) + "厘米")
  487. else:
  488. self.panel_txt.ShowImg(self.images['请调整'])
  489. self.panel_arrow.FlashImg(self.images["向前调整"])
  490. self.last_show = "请调整"
  491. else:
  492. self.panel_arrow.FlashImg(self.images[ArrowType[border]])
  493. self.panel_txt.ShowImg(self.images['请调整'])
  494. self.last_show = "请调整"
  495. except Exception as e:
  496. print(str(e.args))
  497. logging.error(str(e.args))