|
@@ -1,129 +0,0 @@
|
|
|
-
|
|
|
-import message_pb2 as message
|
|
|
-import google.protobuf.text_format as tf
|
|
|
-from async_communication import rabbit_async_communicator as g_rabbitmq
|
|
|
-
|
|
|
-
|
|
|
-MeasureStatu={"ok":0,"无数据":1,"噪声":2,"超界":3}
|
|
|
-class CheckCommand():
|
|
|
- def check_park_command(self, msg):
|
|
|
- park = message.park_table()
|
|
|
- tf.Parse(msg, park)
|
|
|
- unit_id = park.unit_id
|
|
|
- terminal_id = park.terminal_id
|
|
|
- measure_key="statu_ex:measure_%d_statu_port"% terminal_id
|
|
|
- in_mcpu_key="statu_ex:in_mcpu_%d_statu_port"% terminal_id
|
|
|
- dispatch_key="statu_ex:dispatch_%d_statu_port"% unit_id
|
|
|
-
|
|
|
- measure_results = self.check_measure_statu(measure_key)
|
|
|
- in_mcpu_results = self.check_in_mcpu_statu(in_mcpu_key)
|
|
|
- dispatch_results = self.check_dispatch_node_statu(dispatch_key)
|
|
|
- if measure_results is True and in_mcpu_results is True and dispatch_results is True:
|
|
|
- measure_statu = message.measure_info()
|
|
|
- tf.Parse(g_rabbitmq[measure_key].statu,measure_statu)
|
|
|
- park.entrance_measure_info.CopyFrom(measure_statu)
|
|
|
- park.entrance_measure_info.height = self.get_height(in_mcpu_key)
|
|
|
- return tf.MessageToString(park, as_utf8=True)
|
|
|
- else:
|
|
|
- park.statu.execute_statu = message.eError
|
|
|
- park.statu.statu_description = ""
|
|
|
- if measure_results is not True:
|
|
|
- park.statu.statu_description = park.statu.statu_description + measure_results + " "
|
|
|
- if in_mcpu_results is not True:
|
|
|
- park.statu.statu_description = park.statu.statu_description + in_mcpu_results + " "
|
|
|
- if dispatch_results is not True:
|
|
|
- park.statu.statu_description = park.statu.statu_description + dispatch_results + " "
|
|
|
- return tf.MessageToString(park, as_utf8=True)
|
|
|
-
|
|
|
- def check_pick_command(self, msg):
|
|
|
- pick = message.park_table()
|
|
|
- tf.Parse(msg, pick)
|
|
|
- if pick.primary_key is None:
|
|
|
- pick.statu.execute_statu = message.eError
|
|
|
- pick.statu.statu_description = " 唯一码不能为空!"
|
|
|
- return tf.MessageToString(pick, as_utf8=True)
|
|
|
- return tf.MessageToString(pick, as_utf8=True)
|
|
|
-
|
|
|
- # results = self.check_dispatch_node_statu(unit_id)
|
|
|
- # if results is not True:
|
|
|
- # pick.statu.execute_statu = message.eError
|
|
|
- # pick.statu.statu_description = " 调度状态错误!"
|
|
|
- # return tf.MessageToString(pick, as_utf8=True)
|
|
|
-
|
|
|
- def check_measure_statu(self, key):
|
|
|
- if g_rabbitmq[key].statu is not None and g_rabbitmq[key].timeout() is False:
|
|
|
- # if 0.85 > self.measure_info[index].theta or self.measure_info[index].theta> 0.95:
|
|
|
- # return "角度偏差较大!"
|
|
|
-
|
|
|
- measure_info = message.measure_info()
|
|
|
- tf.Parse(g_rabbitmq[key].statu,measure_info)
|
|
|
- border_statu = measure_info.border_statu
|
|
|
- lidar_statu=measure_info.ground_status # 测量状态(正常,无数据、噪声、超界)
|
|
|
- if lidar_statu==MeasureStatu["ok"] :
|
|
|
- return True
|
|
|
- else:
|
|
|
- return "请根据提示操作!"
|
|
|
-
|
|
|
-
|
|
|
- #检测雷达超界信息
|
|
|
- # if (((border_statu >> 0) & 0x01) > 0):
|
|
|
- # results = results + "前超界!"
|
|
|
- # if (((border_statu >> 1) & 0x01) > 0):
|
|
|
- # results = results + "后超界!"
|
|
|
- # if (((border_statu >> 2) & 0x01) > 0):
|
|
|
- # results = results + "左超界!"
|
|
|
- # if (((border_statu >> 3) & 0x01) > 0):
|
|
|
- # results = results + "右超界!"
|
|
|
- # if (((border_statu >> 6) & 0x01) > 0):
|
|
|
- # results = results + "车辆超宽!"
|
|
|
- # if (((border_statu >> 7) & 0x01) > 0):
|
|
|
- # results = results + "轴距超差!"
|
|
|
- # if (((border_statu >> 8) & 0x01) > 0) or ((border_statu >> 9) & 0x01):
|
|
|
- # results = results + "方向盘未回正!"
|
|
|
- # if results == "" :
|
|
|
- # return True
|
|
|
- # else:
|
|
|
- # return results
|
|
|
- else:
|
|
|
- return "设备故障!"
|
|
|
-
|
|
|
- def check_in_mcpu_statu(self, key):
|
|
|
- if g_rabbitmq[key].statu is not None and g_rabbitmq[key].timeout() is False:
|
|
|
- im_mcpu_statu = message.in_mcpu_statu()
|
|
|
- tf.Parse(g_rabbitmq[key].statu,im_mcpu_statu)
|
|
|
- results = ""
|
|
|
- if im_mcpu_statu.back_io != 2:
|
|
|
- results = results + "车辆后超界!"
|
|
|
- if im_mcpu_statu.is_occupy != 2:
|
|
|
- results = results + "库位无车!"
|
|
|
- if im_mcpu_statu.heighth == 1:
|
|
|
- results = results + "未知车高!"
|
|
|
- if im_mcpu_statu.heighth == 5:
|
|
|
- results = results + "车辆超高!"
|
|
|
- if results == "" :
|
|
|
- return True
|
|
|
- else:
|
|
|
- return results
|
|
|
- else:
|
|
|
- return "设备故障!"
|
|
|
-
|
|
|
- def check_dispatch_node_statu(self, key):
|
|
|
- if g_rabbitmq[key].statu is not None and \
|
|
|
- g_rabbitmq[key].timeout() is False:
|
|
|
- dispatch_node_statu = message.dispatch_node_statu()
|
|
|
- tf.Parse(g_rabbitmq[key].statu,dispatch_node_statu)
|
|
|
- if dispatch_node_statu.statu != message.eFault:
|
|
|
- return True
|
|
|
- return "设备故障!"
|
|
|
- def get_height(self, in_mcpu_key):
|
|
|
- im_mcpu_statu = message.in_mcpu_statu()
|
|
|
- tf.Parse(g_rabbitmq[in_mcpu_key].statu,im_mcpu_statu)
|
|
|
- if im_mcpu_statu.heighth == 2:
|
|
|
- return 1.50
|
|
|
- elif im_mcpu_statu.heighth == 3:
|
|
|
- return 1.70
|
|
|
- elif im_mcpu_statu.heighth == 4:
|
|
|
- return 1.90
|
|
|
-
|
|
|
-
|
|
|
-check_command = CheckCommand()
|